harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r441459 - in /incubator/harmony/enhanced/classlib/trunk/modules/auth/src: main/java/common/org/apache/harmony/auth/internal/kerberos/v5/Ticket.java test/java/common/org/apache/harmony/auth/tests/internal/kerberos/v5/KDCReplyTest.java
Date Fri, 08 Sep 2006 09:44:58 GMT
Author: smishura
Date: Fri Sep  8 02:44:57 2006
New Revision: 441459

URL: http://svn.apache.org/viewvc?view=rev&rev=441459
Log:
Regression test for KDCReply + minor fix for Ticket

Added:
    incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/org/apache/harmony/auth/tests/internal/kerberos/v5/KDCReplyTest.java
  (with props)
Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/Ticket.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/Ticket.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/Ticket.java?view=diff&rev=441459&r1=441458&r2=441459
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/Ticket.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/Ticket.java
Fri Sep  8 02:44:57 2006
@@ -19,6 +19,7 @@
 import java.io.IOException;
 
 import org.apache.harmony.security.asn1.ASN1Any;
+import org.apache.harmony.security.asn1.ASN1Constants;
 import org.apache.harmony.security.asn1.ASN1Explicit;
 import org.apache.harmony.security.asn1.ASN1Integer;
 import org.apache.harmony.security.asn1.ASN1Sequence;
@@ -58,7 +59,7 @@
     //     enc-part        [3] EncryptedData -- EncTicketPart
     // }
     //
-    static final ASN1Sequence TICKET_ASN1 = new ASN1Sequence(new ASN1Type[] {
+    static final ASN1Sequence ASN1 = new ASN1Sequence(new ASN1Type[] {
             new ASN1Explicit(0, ASN1Integer.getInstance()), // tkt-vno
             // TODO should we define Realm type?
             new ASN1Explicit(1, ASN1StringType.GENERALSTRING), // realm
@@ -78,4 +79,7 @@
             throw new RuntimeException(); //FIXME message
         }
     };
+
+    public static final ASN1Explicit TICKET_ASN1 = new ASN1Explicit(
+            ASN1Constants.CLASS_APPLICATION, 1, ASN1);
 }

Added: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/org/apache/harmony/auth/tests/internal/kerberos/v5/KDCReplyTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/org/apache/harmony/auth/tests/internal/kerberos/v5/KDCReplyTest.java?view=auto&rev=441459
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/org/apache/harmony/auth/tests/internal/kerberos/v5/KDCReplyTest.java
(added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/org/apache/harmony/auth/tests/internal/kerberos/v5/KDCReplyTest.java
Fri Sep  8 02:44:57 2006
@@ -0,0 +1,135 @@
+/*
+ *  Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed 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.harmony.auth.tests.internal.kerberos.v5;
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.apache.harmony.auth.internal.kerberos.v5.KDCReply;
+import org.apache.harmony.auth.internal.kerberos.v5.PrincipalName;
+import org.apache.harmony.auth.internal.kerberos.v5.Ticket;
+
+public class KDCReplyTest extends TestCase {
+
+    public void test_Ctor() throws IOException {
+
+        KDCReply reply = (KDCReply) KDCReply.AS_REP_ASN1.decode(enc);
+
+        assertEquals("msg-type", KDCReply.AS_REP, reply.getMsgtype());
+        assertEquals("crealm", "MY.REALM", reply.getCrealm());
+        assertEquals("cname", new PrincipalName(1, new String[] { "me" }),
+                reply.getCname());
+
+        Ticket ticket = reply.getTicket();
+        assertEquals("ticket's realm", "MY.REALM", ticket.getRealm());
+        assertEquals("ticket's sname", new PrincipalName(0, new String[] {
+                "krbtgt", "MY.REALM" }), ticket.getSname());
+    }
+
+    // testing array was created by hands according to RFC4120
+    public static byte[] enc = new byte[] {
+            // [APPLICATION 11] KDC-REP
+            (byte) 0x6b,
+            (byte) 0x67,
+            // KDC-REP ::= SEQUENCE 
+            (byte) 0x30,
+            (byte) 0x65,
+            // pvno [0] INTEGER (5)
+            (byte) 0xa0,
+            (byte) 0x03,
+            (byte) 0x02,
+            (byte) 0x01,
+            (byte) 0x05,
+            // msg-type [1] INTEGER 
+            (byte) 0xa1,
+            (byte) 0x03,
+            (byte) 0x02,
+            (byte) 0x01,
+            (byte) 0x0b,
+            // padata [2] SEQUENCE OF PA-DATA OPTIONAL: missed for a while
+            // crealm [3] Realm
+            (byte) 0xa3,
+            (byte) 0x0a,
+            (byte) 0x1b,
+            (byte) 0x08,
+            (byte) 0x4d,
+            (byte) 0x59,
+            (byte) 0x2e,
+            (byte) 0x52,
+            (byte) 0x45,
+            (byte) 0x41,
+            (byte) 0x4c,
+            (byte) 0x4d,
+            // cname [4] PrincipalName
+            (byte) 0xa4,
+            (byte) 0x0f,
+            (byte) 0x30,
+            (byte) 0x0d,
+            (byte) 0xa0,
+            (byte) 0x03,
+            (byte) 0x02,
+            (byte) 0x01,
+            (byte) 0x01,
+            (byte) 0xa1,
+            (byte) 0x06,
+            (byte) 0x30,
+            (byte) 0x04,
+            (byte) 0x1b,
+            (byte) 0x02,
+            (byte) 0x6d,
+            (byte) 0x65,
+
+            // ticket [5] Ticket
+            (byte) 0xa5,
+            (byte) 0x38,
+            // [APPLICATION 1]
+            (byte) 0x61,
+            (byte) 0x36,
+            // SEQUENCE 
+            (byte) 0x30,
+            (byte) 0x34,
+            // tkt-vno [0] INTEGER (5)
+            (byte) 0xa0,
+            (byte) 0x03,
+            (byte) 0x02,
+            (byte) 0x01,
+            (byte) 0x05,
+            // realm [1] Realm
+            (byte) 0xa1, (byte) 0x0a, (byte) 0x1b, (byte) 0x08, (byte) 0x4d,
+            (byte) 0x59,
+            (byte) 0x2e,
+            (byte) 0x52,
+            (byte) 0x45,
+            (byte) 0x41,
+            (byte) 0x4c,
+            (byte) 0x4d,
+            // sname [2] PrincipalName
+            (byte) 0xa2, (byte) 0x1d, (byte) 0x30, (byte) 0x1b, (byte) 0xa0,
+            (byte) 0x03, (byte) 0x02, (byte) 0x01, (byte) 0x00, (byte) 0xa1,
+            (byte) 0x14, (byte) 0x30, (byte) 0x12, (byte) 0x1b, (byte) 0x06,
+            (byte) 0x6b, (byte) 0x72, (byte) 0x62, (byte) 0x74, (byte) 0x67,
+            (byte) 0x74, (byte) 0x1b, (byte) 0x08, (byte) 0x4d, (byte) 0x59,
+            (byte) 0x2e, (byte) 0x52, (byte) 0x45, (byte) 0x41, (byte) 0x4c,
+            (byte) 0x4d,
+            // enc-part [3] EncryptedData: empty for a while 
+            (byte) 0xa3, (byte) 0x02, (byte) 0x00, (byte) 0x00,
+
+            // enc-part [6] EncryptedData: empty for a while
+            (byte) 0xa6, (byte) 0x02, (byte) 0x00, (byte) 0x00, };
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/test/java/common/org/apache/harmony/auth/tests/internal/kerberos/v5/KDCReplyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message