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/06/24 05:33:49 UTC

directory-kerby git commit: Renamed some classes

Repository: directory-kerby
Updated Branches:
  refs/heads/master 4832ef6c9 -> 38f3f11b3


Renamed some classes


Project: http://git-wip-us.apache.org/repos/asf/directory-kerby/repo
Commit: http://git-wip-us.apache.org/repos/asf/directory-kerby/commit/38f3f11b
Tree: http://git-wip-us.apache.org/repos/asf/directory-kerby/tree/38f3f11b
Diff: http://git-wip-us.apache.org/repos/asf/directory-kerby/diff/38f3f11b

Branch: refs/heads/master
Commit: 38f3f11b3a05fd17c60c7d6bf8362f674697f81d
Parents: 4832ef6
Author: Drankye <dr...@gmail.com>
Authored: Wed Jun 24 19:31:50 2015 +0800
Committer: Drankye <dr...@gmail.com>
Committed: Wed Jun 24 19:31:50 2015 +0800

----------------------------------------------------------------------
 .../kerby/kerberos/kerb/admin/AdminHelper.java  | 216 ++++++++++++++++
 .../kerby/kerberos/kerb/admin/Kadmin.java       |  24 +-
 .../kerby/kerberos/kerb/admin/KadminUtil.java   | 216 ----------------
 .../kerberos/kerb/server/GSSInteropTest.java    | 253 -------------------
 .../kerberos/kerb/server/GssInteropTest.java    | 253 +++++++++++++++++++
 5 files changed, 481 insertions(+), 481 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/38f3f11b/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/AdminHelper.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/AdminHelper.java b/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/AdminHelper.java
new file mode 100644
index 0000000..585cbe8
--- /dev/null
+++ b/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/AdminHelper.java
@@ -0,0 +1,216 @@
+/**
+ *  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.admin;
+
+import org.apache.kerby.KOptions;
+import org.apache.kerby.config.Config;
+import org.apache.kerby.kerberos.kerb.KrbException;
+import org.apache.kerby.kerberos.kerb.identity.KrbIdentity;
+import org.apache.kerby.kerberos.kerb.identity.backend.IdentityBackend;
+import org.apache.kerby.kerberos.kerb.identity.backend.MemoryIdentityBackend;
+import org.apache.kerby.kerberos.kerb.keytab.Keytab;
+import org.apache.kerby.kerberos.kerb.keytab.KeytabEntry;
+import org.apache.kerby.kerberos.kerb.server.KdcConfigKey;
+import org.apache.kerby.kerberos.kerb.spec.KerberosTime;
+import org.apache.kerby.kerberos.kerb.spec.base.EncryptionKey;
+import org.apache.kerby.kerberos.kerb.spec.base.EncryptionType;
+import org.apache.kerby.kerberos.kerb.spec.base.PrincipalName;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Kadmin utilities.
+ */
+public final class AdminHelper {
+
+    private AdminHelper() { }
+
+    /**
+     * Init the identity backend from backend configuration.
+     */
+    static IdentityBackend getBackend(Config backendConfig) throws KrbException {
+        String backendClassName = backendConfig.getString(
+            KdcConfigKey.KDC_IDENTITY_BACKEND);
+        if (backendClassName == null) {
+            backendClassName = MemoryIdentityBackend.class.getCanonicalName();
+        }
+
+        Class<?> backendClass;
+        try {
+            backendClass = Class.forName(backendClassName);
+        } catch (ClassNotFoundException e) {
+            throw new KrbException("Failed to load backend class: "
+                    + backendClassName);
+        }
+
+        IdentityBackend backend;
+        try {
+            backend = (IdentityBackend) backendClass.newInstance();
+        } catch (InstantiationException | IllegalAccessException e) {
+            throw new KrbException("Failed to create backend: "
+                    + backendClassName);
+        }
+
+        backend.setConfig(backendConfig);
+        backend.initialize();
+        return backend;
+    }
+
+
+    static void exportKeytab(File keytabFile, KrbIdentity identity)
+            throws KrbException {
+
+        Keytab keytab = createOrLoadKeytab(keytabFile);
+
+        exportToKeytab(keytab, identity);
+
+        storeKeytab(keytab, keytabFile);
+    }
+
+    static Keytab loadKeytab(File keytabFile) throws KrbException {
+        Keytab keytab;
+        try {
+            keytab = Keytab.loadKeytab(keytabFile);
+        } catch (IOException e) {
+            throw new KrbException("Failed to load keytab", e);
+        }
+
+        return keytab;
+    }
+
+    static Keytab createOrLoadKeytab(File keytabFile) throws KrbException {
+
+        Keytab keytab;
+        try {
+            if (!keytabFile.exists()) {
+                if (!keytabFile.createNewFile()) {
+                    throw new KrbException("Failed to create keytab file "
+                            + keytabFile.getAbsolutePath());
+                }
+                keytab = new Keytab();
+            } else {
+                keytab = Keytab.loadKeytab(keytabFile);
+            }
+        } catch (IOException e) {
+            throw new KrbException("Failed to load or create keytab", e);
+        }
+
+        return keytab;
+    }
+
+    static void exportToKeytab(Keytab keytab, KrbIdentity identity)
+        throws KrbException {
+
+        //Add principal to keytab.
+        PrincipalName principal = identity.getPrincipal();
+        KerberosTime timestamp = KerberosTime.now();
+        for (EncryptionType encType : identity.getKeys().keySet()) {
+            EncryptionKey ekey = identity.getKeys().get(encType);
+            int keyVersion = ekey.getKvno();
+            keytab.addEntry(new KeytabEntry(principal, timestamp, keyVersion, ekey));
+        }
+    }
+
+    static void storeKeytab(Keytab keytab, File keytabFile) throws KrbException {
+        try {
+            keytab.store(keytabFile);
+        } catch (IOException e) {
+            throw new KrbException("Failed to store keytab", e);
+        }
+    }
+
+    static void removeKeytabEntriesOf(File keytabFile,
+                                             String principalName) throws KrbException {
+        Keytab keytab = loadKeytab(keytabFile);
+
+        keytab.removeKeytabEntries(new PrincipalName(principalName));
+
+        storeKeytab(keytab, keytabFile);
+    }
+
+    static void removeKeytabEntriesOf(File keytabFile,
+                                      String principalName, int kvno) throws KrbException {
+        Keytab keytab = loadKeytab(keytabFile);
+
+        keytab.removeKeytabEntries(new PrincipalName(principalName), kvno);
+
+        storeKeytab(keytab, keytabFile);
+    }
+
+    static void removeOldKeytabEntriesOf(File keytabFile,
+                                                String principalName) throws KrbException {
+        Keytab keytab = loadKeytab(keytabFile);
+
+        List<KeytabEntry> entries = keytab.getKeytabEntries(
+                new PrincipalName(principalName));
+
+        int maxKvno = 0;
+        for (KeytabEntry entry : entries) {
+            if (maxKvno < entry.getKvno()) {
+                maxKvno = entry.getKvno();
+            }
+        }
+
+        for(KeytabEntry entry : entries) {
+            if(entry.getKvno() < maxKvno) {
+                keytab.removeKeytabEntry(entry);
+            }
+        }
+
+        storeKeytab(keytab, keytabFile);
+    }
+
+    static KrbIdentity createIdentity(String principal, KOptions kOptions)
+        throws KrbException {
+        KrbIdentity kid = new KrbIdentity(principal);
+        kid.setCreatedTime(KerberosTime.now());
+        if(kOptions.contains(KadminOption.EXPIRE)) {
+            Date date = kOptions.getDateOption(KadminOption.EXPIRE);
+            kid.setExpireTime(new KerberosTime(date.getTime()));
+        } else {
+            kid.setExpireTime(KerberosTime.NEVER);
+        }
+        if(kOptions.contains(KadminOption.KVNO)) {
+            kid.setKeyVersion(kOptions.getIntegerOption(KadminOption.KVNO));
+        } else {
+            kid.setKeyVersion(1);
+        }
+        kid.setDisabled(false);
+        kid.setLocked(false);
+
+        return kid;
+    }
+
+    static void updateIdentity(KrbIdentity identity, KOptions kOptions) {
+        if (kOptions.contains(KadminOption.EXPIRE)) {
+            Date date = kOptions.getDateOption(KadminOption.EXPIRE);
+            identity.setExpireTime(new KerberosTime(date.getTime()));
+        }
+        if (kOptions.contains(KadminOption.DISABLED)) {
+            identity.setDisabled(kOptions.getBooleanOption(KadminOption.DISABLED));
+        }
+        if (kOptions.contains(KadminOption.LOCKED)) {
+            identity.setLocked(kOptions.getBooleanOption(KadminOption.LOCKED));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/38f3f11b/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/Kadmin.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/Kadmin.java b/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/Kadmin.java
index a2a167c..64505fc 100644
--- a/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/Kadmin.java
+++ b/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/Kadmin.java
@@ -54,7 +54,7 @@ public class Kadmin {
     public Kadmin(KdcConfig kdcConfig, Config backendConfig) throws KrbException {
         this.kdcConfig = kdcConfig;
         this.backendConfig = backendConfig;
-        this.backend = KadminUtil.getBackend(backendConfig);
+        this.backend = AdminHelper.getBackend(backendConfig);
     }
 
     public Kadmin(File confDir) throws KrbException {
@@ -80,7 +80,7 @@ public class Kadmin {
             }
         }
 
-        backend = KadminUtil.getBackend(backendConfig);
+        backend = AdminHelper.getBackend(backendConfig);
     }
 
     public KdcConfig getKdcConfig() {
@@ -107,7 +107,7 @@ public class Kadmin {
     public void addPrincipal(String principal, KOptions kOptions)
         throws KrbException {
         principal = fixPrincipal(principal);
-        KrbIdentity identity = KadminUtil.createIdentity(principal, kOptions);
+        KrbIdentity identity = AdminHelper.createIdentity(principal, kOptions);
         List<EncryptionKey> keys = EncryptionUtil.generateKeys(
                 kdcConfig.getEncryptionTypes());
         identity.addKeys(keys);
@@ -123,7 +123,7 @@ public class Kadmin {
     public void addPrincipal(String principal, String password, KOptions kOptions)
         throws KrbException {
         principal = fixPrincipal(principal);
-        KrbIdentity identity = KadminUtil.createIdentity(principal, kOptions);
+        KrbIdentity identity = AdminHelper.createIdentity(principal, kOptions);
         List<EncryptionKey> keys = EncryptionUtil.generateKeys(principal, password,
             kdcConfig.getEncryptionTypes());
         identity.addKeys(keys);
@@ -147,7 +147,7 @@ public class Kadmin {
                     principal);
         }
 
-        KadminUtil.exportKeytab(keytabFile, identity);
+        AdminHelper.exportKeytab(keytabFile, identity);
     }
 
     /**
@@ -156,35 +156,35 @@ public class Kadmin {
      * @throws KrbException
      */
     public void exportKeytab(File keytabFile) throws KrbException {
-        Keytab keytab = KadminUtil.createOrLoadKeytab(keytabFile);
+        Keytab keytab = AdminHelper.createOrLoadKeytab(keytabFile);
 
         List<String> principals = backend.getIdentities();
         for (String principal : principals) {
             KrbIdentity identity = backend.getIdentity(principal);
             if (identity != null) {
-                KadminUtil.exportToKeytab(keytab, identity);
+                AdminHelper.exportToKeytab(keytab, identity);
             }
         }
 
-        KadminUtil.storeKeytab(keytab, keytabFile);
+        AdminHelper.storeKeytab(keytab, keytabFile);
     }
 
     public void removeKeytabEntriesOf(File keytabFile, String principal)
         throws KrbException {
         principal = fixPrincipal(principal);
-        KadminUtil.removeKeytabEntriesOf(keytabFile, principal);
+        AdminHelper.removeKeytabEntriesOf(keytabFile, principal);
     }
 
     public void removeKeytabEntriesOf(File keytabFile, String principal, int kvno)
         throws KrbException {
         principal = fixPrincipal(principal);
-        KadminUtil.removeKeytabEntriesOf(keytabFile, principal, kvno);
+        AdminHelper.removeKeytabEntriesOf(keytabFile, principal, kvno);
     }
 
     public void removeOldKeytabEntriesOf(File keytabFile, String principal)
         throws KrbException {
         principal = fixPrincipal(principal);
-        KadminUtil.removeOldKeytabEntriesOf(keytabFile, principal);
+        AdminHelper.removeOldKeytabEntriesOf(keytabFile, principal);
     }
 
     public void deletePrincipal(String principal) throws KrbException {
@@ -200,7 +200,7 @@ public class Kadmin {
             throw new KrbException("Principal \"" +
                 identity.getPrincipalName() + "\" does not exist.");
         }
-        KadminUtil.updateIdentity(identity, kOptions);
+        AdminHelper.updateIdentity(identity, kOptions);
         backend.updateIdentity(identity);
     }
 

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/38f3f11b/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/KadminUtil.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/KadminUtil.java b/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/KadminUtil.java
deleted file mode 100644
index 620ab0c..0000000
--- a/kerby-kerb/kerb-admin/src/main/java/org/apache/kerby/kerberos/kerb/admin/KadminUtil.java
+++ /dev/null
@@ -1,216 +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.admin;
-
-import org.apache.kerby.KOptions;
-import org.apache.kerby.config.Config;
-import org.apache.kerby.kerberos.kerb.KrbException;
-import org.apache.kerby.kerberos.kerb.identity.KrbIdentity;
-import org.apache.kerby.kerberos.kerb.identity.backend.IdentityBackend;
-import org.apache.kerby.kerberos.kerb.identity.backend.MemoryIdentityBackend;
-import org.apache.kerby.kerberos.kerb.keytab.Keytab;
-import org.apache.kerby.kerberos.kerb.keytab.KeytabEntry;
-import org.apache.kerby.kerberos.kerb.server.KdcConfigKey;
-import org.apache.kerby.kerberos.kerb.spec.KerberosTime;
-import org.apache.kerby.kerberos.kerb.spec.base.EncryptionKey;
-import org.apache.kerby.kerberos.kerb.spec.base.EncryptionType;
-import org.apache.kerby.kerberos.kerb.spec.base.PrincipalName;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Date;
-import java.util.List;
-
-/**
- * Kadmin utilities.
- */
-public final class KadminUtil {
-
-    private KadminUtil() { }
-
-    /**
-     * Init the identity backend from backend configuration.
-     */
-    static IdentityBackend getBackend(Config backendConfig) throws KrbException {
-        String backendClassName = backendConfig.getString(
-            KdcConfigKey.KDC_IDENTITY_BACKEND);
-        if (backendClassName == null) {
-            backendClassName = MemoryIdentityBackend.class.getCanonicalName();
-        }
-
-        Class<?> backendClass;
-        try {
-            backendClass = Class.forName(backendClassName);
-        } catch (ClassNotFoundException e) {
-            throw new KrbException("Failed to load backend class: "
-                    + backendClassName);
-        }
-
-        IdentityBackend backend;
-        try {
-            backend = (IdentityBackend) backendClass.newInstance();
-        } catch (InstantiationException | IllegalAccessException e) {
-            throw new KrbException("Failed to create backend: "
-                    + backendClassName);
-        }
-
-        backend.setConfig(backendConfig);
-        backend.initialize();
-        return backend;
-    }
-
-
-    static void exportKeytab(File keytabFile, KrbIdentity identity)
-            throws KrbException {
-
-        Keytab keytab = createOrLoadKeytab(keytabFile);
-
-        exportToKeytab(keytab, identity);
-
-        storeKeytab(keytab, keytabFile);
-    }
-
-    static Keytab loadKeytab(File keytabFile) throws KrbException {
-        Keytab keytab;
-        try {
-            keytab = Keytab.loadKeytab(keytabFile);
-        } catch (IOException e) {
-            throw new KrbException("Failed to load keytab", e);
-        }
-
-        return keytab;
-    }
-
-    static Keytab createOrLoadKeytab(File keytabFile) throws KrbException {
-
-        Keytab keytab;
-        try {
-            if (!keytabFile.exists()) {
-                if (!keytabFile.createNewFile()) {
-                    throw new KrbException("Failed to create keytab file "
-                            + keytabFile.getAbsolutePath());
-                }
-                keytab = new Keytab();
-            } else {
-                keytab = Keytab.loadKeytab(keytabFile);
-            }
-        } catch (IOException e) {
-            throw new KrbException("Failed to load or create keytab", e);
-        }
-
-        return keytab;
-    }
-
-    static void exportToKeytab(Keytab keytab, KrbIdentity identity)
-        throws KrbException {
-
-        //Add principal to keytab.
-        PrincipalName principal = identity.getPrincipal();
-        KerberosTime timestamp = KerberosTime.now();
-        for (EncryptionType encType : identity.getKeys().keySet()) {
-            EncryptionKey ekey = identity.getKeys().get(encType);
-            int keyVersion = ekey.getKvno();
-            keytab.addEntry(new KeytabEntry(principal, timestamp, keyVersion, ekey));
-        }
-    }
-
-    static void storeKeytab(Keytab keytab, File keytabFile) throws KrbException {
-        try {
-            keytab.store(keytabFile);
-        } catch (IOException e) {
-            throw new KrbException("Failed to store keytab", e);
-        }
-    }
-
-    static void removeKeytabEntriesOf(File keytabFile,
-                                             String principalName) throws KrbException {
-        Keytab keytab = loadKeytab(keytabFile);
-
-        keytab.removeKeytabEntries(new PrincipalName(principalName));
-
-        storeKeytab(keytab, keytabFile);
-    }
-
-    static void removeKeytabEntriesOf(File keytabFile,
-                                      String principalName, int kvno) throws KrbException {
-        Keytab keytab = loadKeytab(keytabFile);
-
-        keytab.removeKeytabEntries(new PrincipalName(principalName), kvno);
-
-        storeKeytab(keytab, keytabFile);
-    }
-
-    static void removeOldKeytabEntriesOf(File keytabFile,
-                                                String principalName) throws KrbException {
-        Keytab keytab = loadKeytab(keytabFile);
-
-        List<KeytabEntry> entries = keytab.getKeytabEntries(
-                new PrincipalName(principalName));
-
-        int maxKvno = 0;
-        for (KeytabEntry entry : entries) {
-            if (maxKvno < entry.getKvno()) {
-                maxKvno = entry.getKvno();
-            }
-        }
-
-        for(KeytabEntry entry : entries) {
-            if(entry.getKvno() < maxKvno) {
-                keytab.removeKeytabEntry(entry);
-            }
-        }
-
-        storeKeytab(keytab, keytabFile);
-    }
-
-    static KrbIdentity createIdentity(String principal, KOptions kOptions)
-        throws KrbException {
-        KrbIdentity kid = new KrbIdentity(principal);
-        kid.setCreatedTime(KerberosTime.now());
-        if(kOptions.contains(KadminOption.EXPIRE)) {
-            Date date = kOptions.getDateOption(KadminOption.EXPIRE);
-            kid.setExpireTime(new KerberosTime(date.getTime()));
-        } else {
-            kid.setExpireTime(KerberosTime.NEVER);
-        }
-        if(kOptions.contains(KadminOption.KVNO)) {
-            kid.setKeyVersion(kOptions.getIntegerOption(KadminOption.KVNO));
-        } else {
-            kid.setKeyVersion(1);
-        }
-        kid.setDisabled(false);
-        kid.setLocked(false);
-
-        return kid;
-    }
-
-    static void updateIdentity(KrbIdentity identity, KOptions kOptions) {
-        if (kOptions.contains(KadminOption.EXPIRE)) {
-            Date date = kOptions.getDateOption(KadminOption.EXPIRE);
-            identity.setExpireTime(new KerberosTime(date.getTime()));
-        }
-        if (kOptions.contains(KadminOption.DISABLED)) {
-            identity.setDisabled(kOptions.getBooleanOption(KadminOption.DISABLED));
-        }
-        if (kOptions.contains(KadminOption.LOCKED)) {
-            identity.setLocked(kOptions.getBooleanOption(KadminOption.LOCKED));
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/38f3f11b/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/GSSInteropTest.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/GSSInteropTest.java b/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/GSSInteropTest.java
deleted file mode 100644
index d248e0f..0000000
--- a/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/GSSInteropTest.java
+++ /dev/null
@@ -1,253 +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.server;
-
-import org.apache.kerby.kerberos.kerb.KrbException;
-import org.ietf.jgss.GSSContext;
-import org.ietf.jgss.GSSCredential;
-import org.ietf.jgss.GSSException;
-import org.ietf.jgss.GSSManager;
-import org.ietf.jgss.GSSName;
-import org.ietf.jgss.Oid;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-import javax.security.auth.Subject;
-import javax.security.auth.callback.Callback;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.callback.PasswordCallback;
-import javax.security.auth.callback.UnsupportedCallbackException;
-import javax.security.auth.kerberos.KerberosTicket;
-import javax.security.auth.login.LoginContext;
-import java.io.File;
-import java.io.IOException;
-import java.security.Principal;
-import java.security.PrivilegedExceptionAction;
-import java.util.Set;
-
-/**
- * This is an interop test using the Java GSS APIs against the Kerby KDC
- */
-public class GSSInteropTest extends KdcTest {
-    private String clientPrincipal;
-    private String serverPrincipal;
-
-    @Override
-    protected void setUpKdcServer() throws Exception {
-        kdcServer = new TestKdcServer();
-        prepareKdcServer();
-
-        kdcServer.init();
-
-        // Must disable pre-auth
-        kdcServer.getSetting().getKdcConfig().setBoolean(KdcConfigKey.PREAUTH_REQUIRED, false);
-
-        kdcRealm = kdcServer.getKdcRealm();
-        clientPrincipal = "drankye@" + kdcRealm;
-        setClientPrincipal(clientPrincipal);
-        serverPrincipal = "test-service/localhost@" + kdcRealm;
-        setServerPrincipal(serverPrincipal);
-    }
-
-    @Override
-    protected void createPrincipals() throws KrbException {
-        kdcServer.createTgsPrincipal();
-        kdcServer.createPrincipal(serverPrincipal, TEST_PASSWORD);
-        kdcServer.createPrincipal(clientPrincipal, TEST_PASSWORD);
-    }
-
-    @Before
-    @Override
-    public void setUp() throws Exception {
-        super.setUp();
-
-        File file1 = new File(this.getClass().getResource("/kerberos.jaas").getPath());
-        String content1 = getFileContent(file1.getPath());
-        String path1 = writeToTestDir(content1, file1.getName());
-
-        // System.setProperty("sun.security.krb5.debug", "true");
-        System.setProperty("java.security.auth.login.config", path1);
-
-        // Read in krb5.conf and substitute in the correct port
-        File file2 = new File(this.getClass().getResource("/krb5.conf").getPath());
-        String content2 = getFileContent(file2.getPath());
-        content2 = content2.replaceAll("port", "" + tcpPort);
-        String path2 = writeToTestDir(content2, file2.getName());
-
-        System.setProperty("java.security.krb5.conf", path2);
-    }
-
-    @Override
-    protected boolean allowUdp() {
-        return false;
-    }
-
-    @Test
-    public void testKdc() throws Exception {
-        kdcServer.start();
-
-        LoginContext loginContext = new LoginContext("drankye", new KerberosCallbackHandler());
-        loginContext.login();
-
-        Subject clientSubject = loginContext.getSubject();
-        Set<Principal> clientPrincipals = clientSubject.getPrincipals();
-        Assert.assertFalse(clientPrincipals.isEmpty());
-
-        // Get the TGT
-        Set<KerberosTicket> privateCredentials =
-                clientSubject.getPrivateCredentials(KerberosTicket.class);
-        Assert.assertFalse(privateCredentials.isEmpty());
-        KerberosTicket tgt = privateCredentials.iterator().next();
-        Assert.assertNotNull(tgt);
-
-        // Get the service ticket
-        KerberosClientExceptionAction action =
-                new KerberosClientExceptionAction(clientPrincipals.iterator().next(),
-                        "test-service/localhost@TEST.COM");
-
-        byte[] kerberosToken = (byte[]) Subject.doAs(clientSubject, action);
-        Assert.assertNotNull(kerberosToken);
-
-        loginContext.logout();
-
-        validateServiceTicket(kerberosToken);
-
-        kdcServer.stop();
-    }
-
-    private void validateServiceTicket(byte[] ticket) throws Exception {
-        // Get the TGT for the service
-        LoginContext loginContext = new LoginContext("test-service", new KerberosCallbackHandler());
-        loginContext.login();
-
-        Subject serviceSubject = loginContext.getSubject();
-        Set<Principal> servicePrincipals = serviceSubject.getPrincipals();
-        Assert.assertFalse(servicePrincipals.isEmpty());
-
-        // Handle the service ticket
-        KerberosServiceExceptionAction serviceAction =
-                new KerberosServiceExceptionAction(ticket, "test-service/localhost@TEST.COM");
-
-        Subject.doAs(serviceSubject, serviceAction);
-    }
-
-    private static class KerberosCallbackHandler implements CallbackHandler {
-
-        public void handle(Callback[] callbacks) throws IOException,
-                UnsupportedCallbackException {
-            for (int i = 0; i < callbacks.length; i++) {
-                if (callbacks[i] instanceof PasswordCallback) {
-                    PasswordCallback pc = (PasswordCallback) callbacks[i];
-                    if (pc.getPrompt().contains("drankye")) {
-                        pc.setPassword(TEST_PASSWORD.toCharArray());
-                        break;
-                    } else if (pc.getPrompt().contains("test-service")) {
-                        pc.setPassword(TEST_PASSWORD.toCharArray());
-                        break;
-                    }
-                }
-            }
-        }
-    }
-
-    /**
-     * This class represents a PrivilegedExceptionAction implementation to obtain a service ticket from a Kerberos
-     * Key Distribution Center.
-     */
-    private static class KerberosClientExceptionAction implements PrivilegedExceptionAction<byte[]> {
-
-        private static final String JGSS_KERBEROS_TICKET_OID = "1.2.840.113554.1.2.2";
-
-        private Principal clientPrincipal;
-        private String serviceName;
-
-        public KerberosClientExceptionAction(Principal clientPrincipal, String serviceName) {
-            this.clientPrincipal = clientPrincipal;
-            this.serviceName = serviceName;
-        }
-
-        public byte[] run() throws GSSException {
-            GSSManager gssManager = GSSManager.getInstance();
-
-            GSSName gssService = gssManager.createName(serviceName, GSSName.NT_USER_NAME);
-            Oid oid = new Oid(JGSS_KERBEROS_TICKET_OID);
-            GSSName gssClient = gssManager.createName(clientPrincipal.getName(), GSSName.NT_USER_NAME);
-            GSSCredential credentials =
-                    gssManager.createCredential(
-                            gssClient, GSSCredential.DEFAULT_LIFETIME, oid, GSSCredential.INITIATE_ONLY
-                    );
-
-            GSSContext secContext =
-                    gssManager.createContext(
-                            gssService, oid, credentials, GSSContext.DEFAULT_LIFETIME
-                    );
-
-            secContext.requestMutualAuth(false);
-            secContext.requestCredDeleg(false);
-
-            try {
-                byte[] token = new byte[0];
-                byte[] returnedToken = secContext.initSecContext(token, 0, token.length);
-
-                return returnedToken;
-            } finally {
-                secContext.dispose();
-            }
-        }
-    }
-
-    private static class KerberosServiceExceptionAction implements PrivilegedExceptionAction<byte[]> {
-
-        private static final String JGSS_KERBEROS_TICKET_OID = "1.2.840.113554.1.2.2";
-
-        private byte[] ticket;
-        private String serviceName;
-
-        public KerberosServiceExceptionAction(byte[] ticket, String serviceName) {
-            this.ticket = ticket;
-            this.serviceName = serviceName;
-        }
-
-        public byte[] run() throws GSSException {
-
-            GSSManager gssManager = GSSManager.getInstance();
-
-            GSSContext secContext = null;
-            GSSName gssService = gssManager.createName(serviceName, GSSName.NT_USER_NAME);
-
-            Oid oid = new Oid(JGSS_KERBEROS_TICKET_OID);
-            GSSCredential credentials =
-                    gssManager.createCredential(
-                            gssService, GSSCredential.DEFAULT_LIFETIME, oid, GSSCredential.ACCEPT_ONLY
-                    );
-            secContext = gssManager.createContext(credentials);
-
-            try {
-                return secContext.acceptSecContext(ticket, 0, ticket.length);
-            } finally {
-                if (null != secContext) {
-                    secContext.dispose();
-                }
-            }
-        }
-
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/38f3f11b/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/GssInteropTest.java
----------------------------------------------------------------------
diff --git a/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/GssInteropTest.java b/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/GssInteropTest.java
new file mode 100644
index 0000000..8885787
--- /dev/null
+++ b/kerby-kerb/kerb-kdc-test/src/test/java/org/apache/kerby/kerberos/kerb/server/GssInteropTest.java
@@ -0,0 +1,253 @@
+/**
+ *  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.server;
+
+import org.apache.kerby.kerberos.kerb.KrbException;
+import org.ietf.jgss.GSSContext;
+import org.ietf.jgss.GSSCredential;
+import org.ietf.jgss.GSSException;
+import org.ietf.jgss.GSSManager;
+import org.ietf.jgss.GSSName;
+import org.ietf.jgss.Oid;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.security.auth.Subject;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.security.auth.kerberos.KerberosTicket;
+import javax.security.auth.login.LoginContext;
+import java.io.File;
+import java.io.IOException;
+import java.security.Principal;
+import java.security.PrivilegedExceptionAction;
+import java.util.Set;
+
+/**
+ * This is an interop test using the Java GSS APIs against the Kerby KDC
+ */
+public class GssInteropTest extends KdcTest {
+    private String clientPrincipal;
+    private String serverPrincipal;
+
+    @Override
+    protected void setUpKdcServer() throws Exception {
+        kdcServer = new TestKdcServer();
+        prepareKdcServer();
+
+        kdcServer.init();
+
+        // Must disable pre-auth
+        kdcServer.getSetting().getKdcConfig().setBoolean(KdcConfigKey.PREAUTH_REQUIRED, false);
+
+        kdcRealm = kdcServer.getKdcRealm();
+        clientPrincipal = "drankye@" + kdcRealm;
+        setClientPrincipal(clientPrincipal);
+        serverPrincipal = "test-service/localhost@" + kdcRealm;
+        setServerPrincipal(serverPrincipal);
+    }
+
+    @Override
+    protected void createPrincipals() throws KrbException {
+        kdcServer.createTgsPrincipal();
+        kdcServer.createPrincipal(serverPrincipal, TEST_PASSWORD);
+        kdcServer.createPrincipal(clientPrincipal, TEST_PASSWORD);
+    }
+
+    @Before
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+
+        File file1 = new File(this.getClass().getResource("/kerberos.jaas").getPath());
+        String content1 = getFileContent(file1.getPath());
+        String path1 = writeToTestDir(content1, file1.getName());
+
+        // System.setProperty("sun.security.krb5.debug", "true");
+        System.setProperty("java.security.auth.login.config", path1);
+
+        // Read in krb5.conf and substitute in the correct port
+        File file2 = new File(this.getClass().getResource("/krb5.conf").getPath());
+        String content2 = getFileContent(file2.getPath());
+        content2 = content2.replaceAll("port", "" + tcpPort);
+        String path2 = writeToTestDir(content2, file2.getName());
+
+        System.setProperty("java.security.krb5.conf", path2);
+    }
+
+    @Override
+    protected boolean allowUdp() {
+        return false;
+    }
+
+    @Test
+    public void testKdc() throws Exception {
+        kdcServer.start();
+
+        LoginContext loginContext = new LoginContext("drankye", new KerberosCallbackHandler());
+        loginContext.login();
+
+        Subject clientSubject = loginContext.getSubject();
+        Set<Principal> clientPrincipals = clientSubject.getPrincipals();
+        Assert.assertFalse(clientPrincipals.isEmpty());
+
+        // Get the TGT
+        Set<KerberosTicket> privateCredentials =
+                clientSubject.getPrivateCredentials(KerberosTicket.class);
+        Assert.assertFalse(privateCredentials.isEmpty());
+        KerberosTicket tgt = privateCredentials.iterator().next();
+        Assert.assertNotNull(tgt);
+
+        // Get the service ticket
+        KerberosClientExceptionAction action =
+                new KerberosClientExceptionAction(clientPrincipals.iterator().next(),
+                        "test-service/localhost@TEST.COM");
+
+        byte[] kerberosToken = (byte[]) Subject.doAs(clientSubject, action);
+        Assert.assertNotNull(kerberosToken);
+
+        loginContext.logout();
+
+        validateServiceTicket(kerberosToken);
+
+        kdcServer.stop();
+    }
+
+    private void validateServiceTicket(byte[] ticket) throws Exception {
+        // Get the TGT for the service
+        LoginContext loginContext = new LoginContext("test-service", new KerberosCallbackHandler());
+        loginContext.login();
+
+        Subject serviceSubject = loginContext.getSubject();
+        Set<Principal> servicePrincipals = serviceSubject.getPrincipals();
+        Assert.assertFalse(servicePrincipals.isEmpty());
+
+        // Handle the service ticket
+        KerberosServiceExceptionAction serviceAction =
+                new KerberosServiceExceptionAction(ticket, "test-service/localhost@TEST.COM");
+
+        Subject.doAs(serviceSubject, serviceAction);
+    }
+
+    private static class KerberosCallbackHandler implements CallbackHandler {
+
+        public void handle(Callback[] callbacks) throws IOException,
+                UnsupportedCallbackException {
+            for (int i = 0; i < callbacks.length; i++) {
+                if (callbacks[i] instanceof PasswordCallback) {
+                    PasswordCallback pc = (PasswordCallback) callbacks[i];
+                    if (pc.getPrompt().contains("drankye")) {
+                        pc.setPassword(TEST_PASSWORD.toCharArray());
+                        break;
+                    } else if (pc.getPrompt().contains("test-service")) {
+                        pc.setPassword(TEST_PASSWORD.toCharArray());
+                        break;
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * This class represents a PrivilegedExceptionAction implementation to obtain a service ticket from a Kerberos
+     * Key Distribution Center.
+     */
+    private static class KerberosClientExceptionAction implements PrivilegedExceptionAction<byte[]> {
+
+        private static final String JGSS_KERBEROS_TICKET_OID = "1.2.840.113554.1.2.2";
+
+        private Principal clientPrincipal;
+        private String serviceName;
+
+        public KerberosClientExceptionAction(Principal clientPrincipal, String serviceName) {
+            this.clientPrincipal = clientPrincipal;
+            this.serviceName = serviceName;
+        }
+
+        public byte[] run() throws GSSException {
+            GSSManager gssManager = GSSManager.getInstance();
+
+            GSSName gssService = gssManager.createName(serviceName, GSSName.NT_USER_NAME);
+            Oid oid = new Oid(JGSS_KERBEROS_TICKET_OID);
+            GSSName gssClient = gssManager.createName(clientPrincipal.getName(), GSSName.NT_USER_NAME);
+            GSSCredential credentials =
+                    gssManager.createCredential(
+                            gssClient, GSSCredential.DEFAULT_LIFETIME, oid, GSSCredential.INITIATE_ONLY
+                    );
+
+            GSSContext secContext =
+                    gssManager.createContext(
+                            gssService, oid, credentials, GSSContext.DEFAULT_LIFETIME
+                    );
+
+            secContext.requestMutualAuth(false);
+            secContext.requestCredDeleg(false);
+
+            try {
+                byte[] token = new byte[0];
+                byte[] returnedToken = secContext.initSecContext(token, 0, token.length);
+
+                return returnedToken;
+            } finally {
+                secContext.dispose();
+            }
+        }
+    }
+
+    private static class KerberosServiceExceptionAction implements PrivilegedExceptionAction<byte[]> {
+
+        private static final String JGSS_KERBEROS_TICKET_OID = "1.2.840.113554.1.2.2";
+
+        private byte[] ticket;
+        private String serviceName;
+
+        public KerberosServiceExceptionAction(byte[] ticket, String serviceName) {
+            this.ticket = ticket;
+            this.serviceName = serviceName;
+        }
+
+        public byte[] run() throws GSSException {
+
+            GSSManager gssManager = GSSManager.getInstance();
+
+            GSSContext secContext = null;
+            GSSName gssService = gssManager.createName(serviceName, GSSName.NT_USER_NAME);
+
+            Oid oid = new Oid(JGSS_KERBEROS_TICKET_OID);
+            GSSCredential credentials =
+                    gssManager.createCredential(
+                            gssService, GSSCredential.DEFAULT_LIFETIME, oid, GSSCredential.ACCEPT_ONLY
+                    );
+            secContext = gssManager.createContext(credentials);
+
+            try {
+                return secContext.acceptSecContext(ticket, 0, ticket.length);
+            } finally {
+                if (null != secContext) {
+                    secContext.dispose();
+                }
+            }
+        }
+
+    }
+}
\ No newline at end of file