Return-Path: Delivered-To: apmail-incubator-harmony-commits-archive@www.apache.org Received: (qmail 28122 invoked from network); 8 Sep 2006 05:56:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 8 Sep 2006 05:56:47 -0000 Received: (qmail 9518 invoked by uid 500); 8 Sep 2006 05:56:47 -0000 Delivered-To: apmail-incubator-harmony-commits-archive@incubator.apache.org Received: (qmail 9489 invoked by uid 500); 8 Sep 2006 05:56:47 -0000 Mailing-List: contact harmony-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: harmony-dev@incubator.apache.org Delivered-To: mailing list harmony-commits@incubator.apache.org Received: (qmail 9478 invoked by uid 99); 8 Sep 2006 05:56:47 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Sep 2006 22:56:47 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Sep 2006 22:56:46 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id EBCA41A981A; Thu, 7 Sep 2006 22:56:25 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: harmony-commits@incubator.apache.org From: smishura@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20060908055625.EBCA41A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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);