harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r441390 - in /incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth: internal/kerberos/v5/KDCReply.java internal/kerberos/v5/Ticket.java module/Krb5LoginModule.java
Date Fri, 08 Sep 2006 05:56:25 GMT
Author: smishura
Date: Thu Sep  7 22:56:24 2006
New Revision: 441390

URL: http://svn.apache.org/viewvc?view=rev&rev=441390
Log:
Prototyping Kerberos API: add stubs for KDCReply and Ticket types
(note: need regression test)

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

Added: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/KDCReply.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/KDCReply.java?view=auto&rev=441390
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/KDCReply.java
(added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/KDCReply.java
Thu Sep  7 22:56:24 2006
@@ -0,0 +1,126 @@
+/*
+ *  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.internal.kerberos.v5;
+
+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;
+import org.apache.harmony.security.asn1.ASN1SequenceOf;
+import org.apache.harmony.security.asn1.ASN1StringType;
+import org.apache.harmony.security.asn1.ASN1Type;
+import org.apache.harmony.security.asn1.BerInputStream;
+
+/**
+ * TODO comment me
+ * 
+ * @see http://www.ietf.org/rfc/rfc4120.txt
+ */
+public class KDCReply {
+
+    /**
+     * Authentication Service request message type
+     */
+    public static final int AS_REP = 11;
+
+    /**
+     * Ticket-Granting Service request message type
+     */
+    public static final int TGS_REP = 13;
+
+    // type of a protocol message: AS_REP or TGS_REP
+    private final int msgType;
+
+    private final PrincipalName cname;
+
+    private final String crealm;
+
+    private final Ticket ticket;
+
+    private KDCReply(int msgType, String crealm, PrincipalName cname,
+            Ticket ticket) {
+        this.msgType = msgType;
+        this.cname = cname;
+        this.crealm = crealm;
+        this.ticket = ticket;
+    }
+
+    public int getMsgtype() {
+        return msgType;
+    }
+
+    public String getCrealm() {
+        return crealm;
+    }
+
+    public PrincipalName getCname() {
+        return cname;
+    }
+
+    public Ticket getTicket() {
+        return ticket;
+    }
+
+    //
+    // KDC-REP         ::= SEQUENCE {
+    //    pvno            [0] INTEGER (5),
+    //    msg-type        [1] INTEGER (11 -- AS -- | 13 -- TGS --),
+    //    padata          [2] SEQUENCE OF PA-DATA OPTIONAL
+    //                            -- NOTE: not empty --,
+    //    crealm          [3] Realm,
+    //    cname           [4] PrincipalName,
+    //    ticket          [5] Ticket,
+    //    enc-part        [6] EncryptedData
+    //                            -- EncASRepPart or EncTGSRepPart,
+    //                            -- as appropriate
+    // }
+    //
+    static final ASN1Sequence KDC_REP_ASN1 = new ASN1Sequence(new ASN1Type[] {
+            new ASN1Explicit(0, ASN1Integer.getInstance()), // pvno
+            new ASN1Explicit(1, ASN1Integer.getInstance()), // msg-type
+            new ASN1Explicit(2, new ASN1SequenceOf(ASN1Any.getInstance())),
+            // TODO should we define Realm type?
+            new ASN1Explicit(3, ASN1StringType.GENERALSTRING), // crealm
+            new ASN1Explicit(4, PrincipalName.ASN1), // cname
+            new ASN1Explicit(5, Ticket.TICKET_ASN1), // ticket 
+            // FIXME ignored
+            new ASN1Explicit(6, ASN1Any.getInstance()), // enc-part 
+    }) {
+        {
+            setOptional(2); // padata
+        }
+
+        protected Object getDecodedObject(BerInputStream in) throws IOException {
+
+            Object[] values = (Object[]) in.content;
+
+            return new KDCReply(ASN1Integer.toIntValue(values[1]),
+                    (String) values[3], (PrincipalName) values[4],
+                    (Ticket) values[5]);
+        }
+
+        protected void getValues(Object object, Object[] values) {
+            throw new RuntimeException(); //FIXME message
+        }
+    };
+
+    public static final ASN1Explicit AS_REP_ASN1 = new ASN1Explicit(
+            ASN1Constants.CLASS_APPLICATION, AS_REP, KDC_REP_ASN1);
+}

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

Added: 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=auto&rev=441390
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/Ticket.java
(added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/internal/kerberos/v5/Ticket.java
Thu Sep  7 22:56:24 2006
@@ -0,0 +1,81 @@
+/*
+ *  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.internal.kerberos.v5;
+
+import java.io.IOException;
+
+import org.apache.harmony.security.asn1.ASN1Any;
+import org.apache.harmony.security.asn1.ASN1Explicit;
+import org.apache.harmony.security.asn1.ASN1Integer;
+import org.apache.harmony.security.asn1.ASN1Sequence;
+import org.apache.harmony.security.asn1.ASN1StringType;
+import org.apache.harmony.security.asn1.ASN1Type;
+import org.apache.harmony.security.asn1.BerInputStream;
+
+/**
+ * TODO comment me
+ * 
+ * @see http://www.ietf.org/rfc/rfc4120.txt
+ */
+public class Ticket {
+
+    private final PrincipalName sname;
+
+    private final String realm;
+
+    private Ticket(String realm, PrincipalName sname) {
+        this.sname = sname;
+        this.realm = realm;
+    }
+
+    public String getRealm() {
+        return realm;
+    }
+
+    public PrincipalName getSname() {
+        return sname;
+    }
+
+    //
+    // Ticket          ::= [APPLICATION 1] SEQUENCE {
+    //     tkt-vno         [0] INTEGER (5),
+    //     realm           [1] Realm,
+    //     sname           [2] PrincipalName,
+    //     enc-part        [3] EncryptedData -- EncTicketPart
+    // }
+    //
+    static final ASN1Sequence TICKET_ASN1 = new ASN1Sequence(new ASN1Type[] {
+            new ASN1Explicit(0, ASN1Integer.getInstance()), // tkt-vno
+            // TODO should we define Realm type?
+            new ASN1Explicit(1, ASN1StringType.GENERALSTRING), // realm
+            new ASN1Explicit(2, PrincipalName.ASN1), // sname
+            // FIXME ignored
+            new ASN1Explicit(3, ASN1Any.getInstance()), // ticket 
+    }) {
+
+        protected Object getDecodedObject(BerInputStream in) throws IOException {
+
+            Object[] values = (Object[]) in.content;
+
+            return new Ticket((String) values[1], (PrincipalName) values[2]);
+        }
+
+        protected void getValues(Object object, Object[] values) {
+            throw new RuntimeException(); //FIXME message
+        }
+    };
+}

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

Modified: incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/module/Krb5LoginModule.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/module/Krb5LoginModule.java?view=diff&rev=441390&r1=441389&r2=441390
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/module/Krb5LoginModule.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/auth/src/main/java/common/org/apache/harmony/auth/module/Krb5LoginModule.java
Thu Sep  7 22:56:24 2006
@@ -29,6 +29,7 @@
 import javax.security.auth.login.LoginException;
 import javax.security.auth.spi.LoginModule;
 
+import org.apache.harmony.auth.internal.kerberos.v5.KDCReply;
 import org.apache.harmony.auth.internal.kerberos.v5.KDCRequest;
 import org.apache.harmony.auth.internal.kerberos.v5.KerberosErrorMessage;
 import org.apache.harmony.auth.internal.kerberos.v5.PrincipalName;
@@ -105,7 +106,7 @@
 
             DerInputStream in = new DerInputStream(out.toByteArray());
 
-            if (in.tag == 0) { //TODO AS reply
+            if (in.tag == KDCReply.AS_REP_ASN1.constrId) { //TODO AS reply
                 throw new RuntimeException();//FIXME
             } else if (in.tag == KerberosErrorMessage.ASN1.constrId) {
                 KerberosErrorMessage errMsg = KerberosErrorMessage.decode(in);



Mime
View raw message