directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From plusplusjia...@apache.org
Subject [01/27] directory-kerby git commit: Adding @Ignore'd GSS interop testcase
Date Thu, 07 Jul 2016 06:41:46 GMT
Repository: directory-kerby
Updated Branches:
  refs/heads/kpasswd 70fd3d0c5 -> dcbfcbe2d


Adding @Ignore'd GSS interop testcase


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

Branch: refs/heads/kpasswd
Commit: 1bce738d298cd706bc7d62d25287cc04163cbfcf
Parents: 79d4a58
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Tue Jun 28 14:57:23 2016 +0100
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Tue Jun 28 14:57:23 2016 +0100

----------------------------------------------------------------------
 .../kerberos/kerb/server/GssInteropTest.java    | 52 +++++++++++++++++---
 1 file changed, 46 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/directory-kerby/blob/1bce738d/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
index 832d59d..7e0d269 100644
--- 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
@@ -19,6 +19,20 @@
  */
 package org.apache.kerby.kerberos.kerb.server;
 
+import java.io.ByteArrayOutputStream;
+import java.security.Principal;
+import java.security.PrivilegedExceptionAction;
+import java.util.Set;
+
+import javax.security.auth.Subject;
+import javax.security.auth.kerberos.KerberosTicket;
+
+import org.apache.kerby.kerberos.kerb.ccache.CredCacheOutputStream;
+import org.apache.kerby.kerberos.kerb.ccache.Credential;
+import org.apache.kerby.kerberos.kerb.ccache.CredentialCache;
+import org.apache.kerby.kerberos.kerb.client.KrbClient;
+import org.apache.kerby.kerberos.kerb.type.ticket.SgtTicket;
+import org.apache.kerby.kerberos.kerb.type.ticket.TgtTicket;
 import org.ietf.jgss.GSSContext;
 import org.ietf.jgss.GSSCredential;
 import org.ietf.jgss.GSSException;
@@ -28,12 +42,6 @@ import org.ietf.jgss.Oid;
 import org.junit.Assert;
 import org.junit.Test;
 
-import javax.security.auth.Subject;
-import javax.security.auth.kerberos.KerberosTicket;
-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
  */
@@ -62,6 +70,38 @@ public class GssInteropTest extends LoginTestBase {
 
         validateServiceTicket(kerberosToken);
     }
+    
+    @Test
+    @org.junit.Ignore
+    public void testKerbyClientAndGssService() throws Exception {
+        KrbClient client = getKrbClient();
+        client.init();
+
+        try {
+            // Get a service ticket using Kerby APIs
+            TgtTicket tgt = client.requestTgt(getClientPrincipal(), getClientPassword());
+            Assert.assertTrue(tgt != null);
+
+            SgtTicket tkt = client.requestSgt(tgt, getServerPrincipal());
+            Assert.assertTrue(tkt != null);
+            
+            Credential credential = new Credential(tkt, tgt.getClientPrincipal());
+            CredentialCache cCache = new CredentialCache();
+            cCache.addCredential(credential);
+            cCache.setPrimaryPrincipal(tgt.getClientPrincipal());
+            
+            ByteArrayOutputStream bout = new ByteArrayOutputStream();
+            CredCacheOutputStream os = new CredCacheOutputStream(bout);
+            cCache.store(bout);
+            os.close();
+            
+            // Now validate the ticket using GSS
+            validateServiceTicket(bout.toByteArray());
+        } catch (Exception e) {
+            e.printStackTrace();
+            Assert.fail();
+        }
+    }
 
     private void validateServiceTicket(byte[] ticket) throws Exception {
         Subject serviceSubject = loginServiceUsingKeytab();


Mime
View raw message