You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by dr...@apache.org on 2015/11/21 04:23:32 UTC
directory-kerby git commit: DIRKRB-467 Allow to kdc_port to be set
for both tcp and udp ports
Repository: directory-kerby
Updated Branches:
refs/heads/master 63d7ff1a8 -> fe97606f6
DIRKRB-467 Allow to kdc_port to be set for both tcp and udp ports
Project: http://git-wip-us.apache.org/repos/asf/directory-kerby/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-kerby/commit/fe97606f
Tree: http://git-wip-us.apache.org/repos/asf/directory-kerby/tree/fe97606f
Diff: http://git-wip-us.apache.org/repos/asf/directory-kerby/diff/fe97606f
Branch: refs/heads/master
Commit: fe97606f65358e22814c69db28c13184f5c23144
Parents: 63d7ff1
Author: Drankye <dr...@gmail.com>
Authored: Sun Nov 22 11:23:30 2015 +0800
Committer: Drankye <dr...@gmail.com>
Committed: Sun Nov 22 11:23:30 2015 +0800
----------------------------------------------------------------------
.../kerby/kerberos/kerb/client/KrbConfig.java | 10 ++--
.../kerby/kerberos/kerb/client/KrbSetting.java | 4 +-
.../kerb/client/KrbClientSettingTest.java | 28 ++++++++---
.../client/TestKrbConfigLoadForSpecials.java | 51 ++++++++++++++++++++
.../TestKrbConfigLoadWithDefaultRealm.java | 45 -----------------
.../src/test/resources/krb5-kdcrealm.conf | 19 --------
.../src/test/resources/krb5-specials.conf | 20 ++++++++
.../kerby/kerberos/kerb/server/KdcConfig.java | 6 ++-
8 files changed, 104 insertions(+), 79 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/fe97606f/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/KrbConfig.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/KrbConfig.java b/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/KrbConfig.java
index 5d2d2fc..eeb5a1d 100644
--- a/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/KrbConfig.java
+++ b/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/KrbConfig.java
@@ -75,9 +75,10 @@ public class KrbConfig extends Krb5Conf {
*
* @return true to allow UDP, false otherwise
*/
- public boolean allowKdcUdp() {
+ public boolean allowUdp() {
return getBoolean(KrbConfigKey.KDC_ALLOW_UDP, true, LIBDEFAULT)
- || getInt(KrbConfigKey.KDC_UDP_PORT, true, LIBDEFAULT) != null;
+ || getInt(KrbConfigKey.KDC_UDP_PORT, true, LIBDEFAULT) != null
+ || getInt(KrbConfigKey.KDC_PORT, false, LIBDEFAULT) != null;
}
/**
@@ -85,9 +86,10 @@ public class KrbConfig extends Krb5Conf {
*
* @return true to allow TCP, false otherwise
*/
- public boolean allowKdcTcp() {
+ public boolean allowTcp() {
return getBoolean(KrbConfigKey.KDC_ALLOW_TCP, true, LIBDEFAULT)
- || getInt(KrbConfigKey.KDC_TCP_PORT, true, LIBDEFAULT) != null;
+ || getInt(KrbConfigKey.KDC_TCP_PORT, true, LIBDEFAULT) != null
+ || getInt(KrbConfigKey.KDC_PORT, false, LIBDEFAULT) != null;
}
/**
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/fe97606f/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/KrbSetting.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/KrbSetting.java b/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/KrbSetting.java
index 167f977..ce0216b 100644
--- a/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/KrbSetting.java
+++ b/kerby-kerb/kerb-client/src/main/java/org/apache/kerby/kerberos/kerb/client/KrbSetting.java
@@ -101,13 +101,13 @@ public class KrbSetting {
public boolean allowUdp() {
Boolean allowUdp = commonOptions.getBooleanOption(
- KrbOption.ALLOW_UDP, krbConfig.allowKdcUdp());
+ KrbOption.ALLOW_UDP, krbConfig.allowUdp());
return allowUdp;
}
public boolean allowTcp() {
Boolean allowTcp = commonOptions.getBooleanOption(
- KrbOption.ALLOW_TCP, krbConfig.allowKdcTcp());
+ KrbOption.ALLOW_TCP, krbConfig.allowTcp());
return allowTcp;
}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/fe97606f/kerby-kerb/kerb-client/src/test/java/org/apache/kerby/kerberos/kerb/client/KrbClientSettingTest.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-client/src/test/java/org/apache/kerby/kerberos/kerb/client/KrbClientSettingTest.java b/kerby-kerb/kerb-client/src/test/java/org/apache/kerby/kerberos/kerb/client/KrbClientSettingTest.java
index c864099..36eeaa2 100644
--- a/kerby-kerb/kerb-client/src/test/java/org/apache/kerby/kerberos/kerb/client/KrbClientSettingTest.java
+++ b/kerby-kerb/kerb-client/src/test/java/org/apache/kerby/kerberos/kerb/client/KrbClientSettingTest.java
@@ -19,27 +19,41 @@
*/
package org.apache.kerby.kerberos.kerb.client;
-import org.apache.kerby.kerberos.kerb.KrbException;
import org.junit.Test;
+import java.io.File;
+import java.net.URL;
+
import static org.assertj.core.api.Assertions.assertThat;
public class KrbClientSettingTest {
@Test
- public void testKdcServerMannualSetting() throws KrbException {
- KrbClient krbClient = new KrbClient(new KrbConfig());
+ public void testKdcServerMannualSetting() throws Exception {
+ URL confFileUrl = TestKrbConfigLoadForSpecials.class.getResource(
+ "/krb5-specials.conf");
+ File confFile = new File(confFileUrl.toURI());
+
+ KrbConfig conf = new KrbConfig();
+ conf.addIniConfig(confFile);
+ KrbClient krbClient = new KrbClient(conf);
+
+ KrbSetting krbSetting = krbClient.getSetting();
+
+ assertThat(krbSetting.getKdcRealm()).isEqualTo("KRB.COM");
+ assertThat(krbSetting.allowUdp()).isEqualTo(true);
+ assertThat(krbSetting.allowTcp()).isEqualTo(true);
+ assertThat(krbSetting.getKdcTcpPort()).isEqualTo(88);
+ assertThat(krbSetting.getKdcUdpPort()).isEqualTo(88);
+
krbClient.setKdcHost("localhost");
krbClient.setKdcRealm("TEST2.COM");
krbClient.setKdcTcpPort(12345);
- KrbSetting krbSetting = krbClient.getSetting();
+
assertThat(krbSetting.getKdcHost()).isEqualTo("localhost");
- assertThat(krbSetting.allowTcp()).isEqualTo(true);
assertThat(krbSetting.getKdcTcpPort()).isEqualTo(12345);
- assertThat(krbSetting.allowUdp()).isEqualTo(false);
- assertThat(krbSetting.getKdcUdpPort()).isEqualTo(-1);
assertThat(krbSetting.getKdcRealm()).isEqualTo("TEST2.COM");
}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/fe97606f/kerby-kerb/kerb-client/src/test/java/org/apache/kerby/kerberos/kerb/client/TestKrbConfigLoadForSpecials.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-client/src/test/java/org/apache/kerby/kerberos/kerb/client/TestKrbConfigLoadForSpecials.java b/kerby-kerb/kerb-client/src/test/java/org/apache/kerby/kerberos/kerb/client/TestKrbConfigLoadForSpecials.java
new file mode 100644
index 0000000..320a8bd
--- /dev/null
+++ b/kerby-kerb/kerb-client/src/test/java/org/apache/kerby/kerberos/kerb/client/TestKrbConfigLoadForSpecials.java
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.kerby.kerberos.kerb.client;
+
+import org.junit.Test;
+
+import java.io.File;
+import java.net.URL;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/**
+ * Test for loading configurations form krb5.conf with default kdc realm.
+ * krb5.conf is the configuration file in MIT Kerberos.
+ */
+public class TestKrbConfigLoadForSpecials {
+
+ @Test
+ public void test() throws Exception {
+ URL confFileUrl = TestKrbConfigLoadForSpecials.class.getResource(
+ "/krb5-specials.conf");
+ File confFile = new File(confFileUrl.toURI());
+
+ KrbConfig krbConfig = new KrbConfig();
+ krbConfig.addIniConfig(confFile);
+ assertThat(krbConfig.getKdcRealm()).isEqualTo("KRB.COM");
+ assertThat(krbConfig.getKdcPort()).isEqualTo(88);
+
+ assertThat(krbConfig.allowUdp()).isEqualTo(true);
+ assertThat(krbConfig.allowTcp()).isEqualTo(true);
+ assertThat(krbConfig.getKdcTcpPort()).isEqualTo(88);
+ assertThat(krbConfig.getKdcUdpPort()).isEqualTo(88);
+ }
+}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/fe97606f/kerby-kerb/kerb-client/src/test/java/org/apache/kerby/kerberos/kerb/client/TestKrbConfigLoadWithDefaultRealm.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-client/src/test/java/org/apache/kerby/kerberos/kerb/client/TestKrbConfigLoadWithDefaultRealm.java b/kerby-kerb/kerb-client/src/test/java/org/apache/kerby/kerberos/kerb/client/TestKrbConfigLoadWithDefaultRealm.java
deleted file mode 100644
index 3835de4..0000000
--- a/kerby-kerb/kerb-client/src/test/java/org/apache/kerby/kerberos/kerb/client/TestKrbConfigLoadWithDefaultRealm.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
- */
-package org.apache.kerby.kerberos.kerb.client;
-
-import org.junit.Test;
-
-import java.io.File;
-import java.net.URL;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-/**
- * Test for loading configurations form krb5.conf with default kdc realm.
- * krb5.conf is the configuration file in MIT Kerberos.
- */
-public class TestKrbConfigLoadWithDefaultRealm {
-
- @Test
- public void test() throws Exception {
- URL confFileUrl = TestKrbConfigLoadWithDefaultRealm.class.getResource(
- "/krb5-kdcrealm.conf");
- File confFile = new File(confFileUrl.toURI());
-
- KrbConfig krbConfig = new KrbConfig();
- krbConfig.addIniConfig(confFile);
- assertThat(krbConfig.getKdcRealm()).isEqualTo("KRB.COM");
- }
-}
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/fe97606f/kerby-kerb/kerb-client/src/test/resources/krb5-kdcrealm.conf
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-client/src/test/resources/krb5-kdcrealm.conf b/kerby-kerb/kerb-client/src/test/resources/krb5-kdcrealm.conf
deleted file mode 100644
index 43e68a5..0000000
--- a/kerby-kerb/kerb-client/src/test/resources/krb5-kdcrealm.conf
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-[libdefaults]
- default_realm = KRB.COM
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/fe97606f/kerby-kerb/kerb-client/src/test/resources/krb5-specials.conf
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-client/src/test/resources/krb5-specials.conf b/kerby-kerb/kerb-client/src/test/resources/krb5-specials.conf
new file mode 100644
index 0000000..7068fba
--- /dev/null
+++ b/kerby-kerb/kerb-client/src/test/resources/krb5-specials.conf
@@ -0,0 +1,20 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+[libdefaults]
+ default_realm = KRB.COM
+ kdc_port = 88
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/fe97606f/kerby-kerb/kerb-server/src/main/java/org/apache/kerby/kerberos/kerb/server/KdcConfig.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-server/src/main/java/org/apache/kerby/kerberos/kerb/server/KdcConfig.java b/kerby-kerb/kerb-server/src/main/java/org/apache/kerby/kerberos/kerb/server/KdcConfig.java
index a22411c..0eb476e 100644
--- a/kerby-kerb/kerb-server/src/main/java/org/apache/kerby/kerberos/kerb/server/KdcConfig.java
+++ b/kerby-kerb/kerb-server/src/main/java/org/apache/kerby/kerberos/kerb/server/KdcConfig.java
@@ -65,7 +65,8 @@ public class KdcConfig extends Krb5Conf {
*/
public Boolean allowTcp() {
return getBoolean(KdcConfigKey.KDC_ALLOW_TCP, true, KDCDEFAULT)
- || getInt(KdcConfigKey.KDC_TCP_PORT, true, KDCDEFAULT) != null;
+ || getInt(KdcConfigKey.KDC_TCP_PORT, true, KDCDEFAULT) != null
+ || getInt(KdcConfigKey.KDC_PORT, false, KDCDEFAULT) != null;
}
/**
@@ -74,7 +75,8 @@ public class KdcConfig extends Krb5Conf {
*/
public Boolean allowUdp() {
return getBoolean(KdcConfigKey.KDC_ALLOW_UDP, true, KDCDEFAULT)
- || getInt(KdcConfigKey.KDC_UDP_PORT, true, KDCDEFAULT) != null;
+ || getInt(KdcConfigKey.KDC_UDP_PORT, true, KDCDEFAULT) != null
+ || getInt(KdcConfigKey.KDC_PORT, false, KDCDEFAULT) != null;
}
public int getKdcUdpPort() {