directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1035038 - in /directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec: kdcReq/ kdcReq/actions/ kdcReqBody/
Date Sun, 14 Nov 2010 18:17:17 GMT
Author: elecharny
Date: Sun Nov 14 18:17:16 2010
New Revision: 1035038

URL: http://svn.apache.org/viewvc?rev=1035038&view=rev
Log:
First drop of the KdcReq codec (the grammar is not completed)

Added:
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReq/
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReq/KdcReqContainer.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReq/KdcReqGrammar.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReq/KdcReqStatesEnum.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReq/actions/
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReq/actions/KdcReqInit.java
Modified:
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/KdcReqBodyContainer.java

Added: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReq/KdcReqContainer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReq/KdcReqContainer.java?rev=1035038&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReq/KdcReqContainer.java
(added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReq/KdcReqContainer.java
Sun Nov 14 18:17:16 2010
@@ -0,0 +1,67 @@
+/*
+ *  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.directory.shared.kerberos.codec.kdcReq;
+
+import org.apache.directory.shared.asn1.ber.AbstractContainer;
+import org.apache.directory.shared.kerberos.components.KdcReq;
+
+
+/**
+ * The KdcReq container stores the KDC-REQ decoded by the Asn1Decoder.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class KdcReqContainer extends AbstractContainer
+{
+    /** An KDC-REQ container */
+    private KdcReq kdcReq;
+    
+    /**
+     * Creates a new KdcReqContainer object.
+     */
+    public KdcReqContainer()
+    {
+        super();
+        this.stateStack = new int[1];
+        this.grammar = KdcReqGrammar.getInstance();
+        setTransition( KdcReqStatesEnum.START_STATE );
+    }
+
+
+    /**
+     * @return Returns the KdcReq.
+     */
+    public KdcReq getKdcReq()
+    {
+        return kdcReq;
+    }
+
+    
+    /**
+     * Set a KdcReq Object into the container. It will be completed by the
+     * KerberosDecoder.
+     * 
+     * @param kdcReq The KdcReq to set.
+     */
+    public void setKdcReq( KdcReq kdcReq )
+    {
+        this.kdcReq = kdcReq;
+    }
+}

Added: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReq/KdcReqGrammar.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReq/KdcReqGrammar.java?rev=1035038&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReq/KdcReqGrammar.java
(added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReq/KdcReqGrammar.java
Sun Nov 14 18:17:16 2010
@@ -0,0 +1,412 @@
+/*
+ *  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.directory.shared.kerberos.codec.kdcReq;
+
+
+import org.apache.directory.shared.asn1.ber.grammar.AbstractGrammar;
+import org.apache.directory.shared.asn1.ber.grammar.Grammar;
+import org.apache.directory.shared.asn1.ber.grammar.GrammarTransition;
+import org.apache.directory.shared.asn1.ber.tlv.UniversalTag;
+import org.apache.directory.shared.kerberos.KerberosConstants;
+import org.apache.directory.shared.kerberos.codec.actions.CheckNotNullLength;
+import org.apache.directory.shared.kerberos.codec.kdcReq.actions.KdcReqInit;
+import org.apache.directory.shared.kerberos.codec.kdcReqBody.actions.AddEType;
+import org.apache.directory.shared.kerberos.codec.kdcReqBody.actions.AddTicket;
+import org.apache.directory.shared.kerberos.codec.kdcReqBody.actions.ETypeSequence;
+import org.apache.directory.shared.kerberos.codec.kdcReqBody.actions.StoreAddresses;
+import org.apache.directory.shared.kerberos.codec.kdcReqBody.actions.StoreCName;
+import org.apache.directory.shared.kerberos.codec.kdcReqBody.actions.StoreEncAuthorizationData;
+import org.apache.directory.shared.kerberos.codec.kdcReqBody.actions.StoreFrom;
+import org.apache.directory.shared.kerberos.codec.kdcReqBody.actions.StoreKdcOptions;
+import org.apache.directory.shared.kerberos.codec.kdcReqBody.actions.StoreNonce;
+import org.apache.directory.shared.kerberos.codec.kdcReqBody.actions.StoreRTime;
+import org.apache.directory.shared.kerberos.codec.kdcReqBody.actions.StoreRealm;
+import org.apache.directory.shared.kerberos.codec.kdcReqBody.actions.StoreSName;
+import org.apache.directory.shared.kerberos.codec.kdcReqBody.actions.StoreTill;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * This class implements the KdcReq structure. All the actions are declared
+ * in this class. As it is a singleton, these declaration are only done once. If
+ * an action is to be added or modified, this is where the work is to be done !
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public final class KdcReqGrammar extends AbstractGrammar
+{
+    /** The logger */
+    static final Logger LOG = LoggerFactory.getLogger( KdcReqGrammar.class );
+
+    /** A speedup for logger */
+    static final boolean IS_DEBUG = LOG.isDebugEnabled();
+
+    /** The instance of grammar. KdcReqGrammar is a singleton */
+    private static Grammar instance = new KdcReqGrammar();
+
+
+    /**
+     * Creates a new KdcReqGrammar object.
+     */
+    private KdcReqGrammar()
+    {
+        setName( KdcReqGrammar.class.getName() );
+
+        // Create the transitions table
+        super.transitions = new GrammarTransition[KdcReqStatesEnum.LAST_KDC_REQ_STATE.ordinal()][256];
+
+        // ============================================================================================
+        // KdcReq 
+        // ============================================================================================
+        // --------------------------------------------------------------------------------------------
+        // Transition from KdcReq init to KdcReq SEQ
+        // --------------------------------------------------------------------------------------------
+        // KDC-REQ-BODY    ::= SEQUENCE {
+        super.transitions[KdcReqStatesEnum.START_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()]
= new GrammarTransition(
+            KdcReqStatesEnum.START_STATE, KdcReqStatesEnum.KDC_REQ_PVNO_TAG_STATE, UniversalTag.SEQUENCE.getValue(),
+            new KdcReqInit() );
+        
+        // --------------------------------------------------------------------------------------------
+        // Transition from KdcReqBody SEQ to kdc-options tag
+        // --------------------------------------------------------------------------------------------
+        // KDC-REQ-BODY    ::= SEQUENCE {
+        //         kdc-options             [0]
+        super.transitions[KdcReqStatesEnum.KDC_REQ_BODY_KDC_OPTIONS_TAG_STATE.ordinal()][KerberosConstants.KDC_REQ_BODY_KDC_OPTIONS_TAG]
= new GrammarTransition(
+            KdcReqStatesEnum.KDC_REQ_BODY_KDC_OPTIONS_TAG_STATE, KdcReqStatesEnum.KDC_REQ_BODY_KDC_OPTIONS_STATE,
KerberosConstants.KDC_REQ_BODY_KDC_OPTIONS_TAG,
+            new CheckNotNullLength() );
+        
+        // --------------------------------------------------------------------------------------------
+        // Transition from kdc-options tag to kdc-options value
+        // --------------------------------------------------------------------------------------------
+        // KDC-REQ-BODY    ::= SEQUENCE {
+        //         kdc-options             [0] KDCOptions
+        super.transitions[KdcReqStatesEnum.KDC_REQ_BODY_KDC_OPTIONS_STATE.ordinal()][UniversalTag.BIT_STRING.getValue()]
= new GrammarTransition(
+            KdcReqStatesEnum.KDC_REQ_BODY_KDC_OPTIONS_STATE, KdcReqStatesEnum.KDC_REQ_BODY_CNAME_OR_REALM_TAG_STATE,
UniversalTag.BIT_STRING.getValue(),
+            new StoreKdcOptions() );
+        
+        // --------------------------------------------------------------------------------------------
+        // Transition from kdc-options value to cname tag
+        // --------------------------------------------------------------------------------------------
+        // KDC-REQ-BODY    ::= SEQUENCE {
+        //         ...
+        //         cname                   [1]
+        super.transitions[KdcReqStatesEnum.KDC_REQ_BODY_CNAME_OR_REALM_TAG_STATE.ordinal()][KerberosConstants.KDC_REQ_BODY_CNAME_TAG]
= new GrammarTransition(
+            KdcReqStatesEnum.KDC_REQ_BODY_CNAME_OR_REALM_TAG_STATE, KdcReqStatesEnum.KDC_REQ_BODY_CNAME_STATE,
KerberosConstants.KDC_REQ_BODY_CNAME_TAG,
+            new StoreCName() );
+        
+        // --------------------------------------------------------------------------------------------
+        // Transition from kdc-options value to realm tag (cname is empty)
+        // --------------------------------------------------------------------------------------------
+        // KDC-REQ-BODY    ::= SEQUENCE {
+        //         ...
+        //         realm                   [2]
+        super.transitions[KdcReqStatesEnum.KDC_REQ_BODY_CNAME_OR_REALM_TAG_STATE.ordinal()][KerberosConstants.KDC_REQ_BODY_REALM_TAG]
= new GrammarTransition(
+            KdcReqStatesEnum.KDC_REQ_BODY_CNAME_OR_REALM_TAG_STATE, KdcReqStatesEnum.KDC_REQ_BODY_REALM_TAG_STATE,
KerberosConstants.KDC_REQ_BODY_REALM_TAG,
+            new CheckNotNullLength() );
+        
+        // --------------------------------------------------------------------------------------------
+        // Transition from cname tag to realm tag
+        // --------------------------------------------------------------------------------------------
+        // KDC-REQ-BODY    ::= SEQUENCE {
+        //         ...
+        //         realm                   [2]
+        super.transitions[KdcReqStatesEnum.KDC_REQ_BODY_CNAME_STATE.ordinal()][KerberosConstants.KDC_REQ_BODY_REALM_TAG]
= new GrammarTransition(
+            KdcReqStatesEnum.KDC_REQ_BODY_CNAME_STATE, KdcReqStatesEnum.KDC_REQ_BODY_REALM_TAG_STATE,
KerberosConstants.KDC_REQ_BODY_REALM_TAG,
+            new CheckNotNullLength() );
+        
+        // --------------------------------------------------------------------------------------------
+        // Transition from realm tag to realm value
+        // --------------------------------------------------------------------------------------------
+        // KDC-REQ-BODY    ::= SEQUENCE {
+        //         ...
+        //         realm                   [2] Realm
+        super.transitions[KdcReqStatesEnum.KDC_REQ_BODY_REALM_TAG_STATE.ordinal()][UniversalTag.GENERAL_STRING.getValue()]
= new GrammarTransition(
+            KdcReqStatesEnum.KDC_REQ_BODY_REALM_TAG_STATE, KdcReqStatesEnum.KDC_REQ_BODY_SNAME_OR_FROM_OR_TILL_TAG_STATE,
UniversalTag.GENERAL_STRING.getValue(),
+            new StoreRealm() );
+        
+        // --------------------------------------------------------------------------------------------
+        // Transition from realm value to sname tag
+        // --------------------------------------------------------------------------------------------
+        // KDC-REQ-BODY    ::= SEQUENCE {
+        //         ...
+        //         sname                   [3]
+        super.transitions[KdcReqStatesEnum.KDC_REQ_BODY_SNAME_OR_FROM_OR_TILL_TAG_STATE.ordinal()][KerberosConstants.KDC_REQ_BODY_SNAME_TAG]
= new GrammarTransition(
+            KdcReqStatesEnum.KDC_REQ_BODY_SNAME_OR_FROM_OR_TILL_TAG_STATE, KdcReqStatesEnum.KDC_REQ_BODY_SNAME_STATE,
KerberosConstants.KDC_REQ_BODY_SNAME_TAG,
+            new StoreSName() );
+        
+        // --------------------------------------------------------------------------------------------
+        // Transition from realm value to from tag (sname is empty)
+        // --------------------------------------------------------------------------------------------
+        // KDC-REQ-BODY    ::= SEQUENCE {
+        //         ...
+        //         from                    [4]
+        super.transitions[KdcReqStatesEnum.KDC_REQ_BODY_SNAME_OR_FROM_OR_TILL_TAG_STATE.ordinal()][KerberosConstants.KDC_REQ_BODY_FROM_TAG]
= new GrammarTransition(
+            KdcReqStatesEnum.KDC_REQ_BODY_SNAME_OR_FROM_OR_TILL_TAG_STATE, KdcReqStatesEnum.KDC_REQ_BODY_FROM_STATE,
KerberosConstants.KDC_REQ_BODY_FROM_TAG,
+            new CheckNotNullLength() );
+
+        // --------------------------------------------------------------------------------------------
+        // Transition from realm value to till tag (sname and from are empty)
+        // --------------------------------------------------------------------------------------------
+        // KDC-REQ-BODY    ::= SEQUENCE {
+        //         ...
+        //         till                    [5]
+        super.transitions[KdcReqStatesEnum.KDC_REQ_BODY_SNAME_OR_FROM_OR_TILL_TAG_STATE.ordinal()][KerberosConstants.KDC_REQ_BODY_TILL_TAG]
= new GrammarTransition(
+            KdcReqStatesEnum.KDC_REQ_BODY_SNAME_OR_FROM_OR_TILL_TAG_STATE, KdcReqStatesEnum.KDC_REQ_BODY_TILL_STATE,
KerberosConstants.KDC_REQ_BODY_TILL_TAG,
+            new CheckNotNullLength() );
+
+        // --------------------------------------------------------------------------------------------
+        // Transition from sname tag to from tag
+        // --------------------------------------------------------------------------------------------
+        // KDC-REQ-BODY    ::= SEQUENCE {
+        //         ...
+        //         from                    [4]
+       super.transitions[KdcReqStatesEnum.KDC_REQ_BODY_SNAME_STATE.ordinal()][KerberosConstants.KDC_REQ_BODY_FROM_TAG]
= new GrammarTransition(
+            KdcReqStatesEnum.KDC_REQ_BODY_SNAME_STATE, KdcReqStatesEnum.KDC_REQ_BODY_FROM_STATE,
KerberosConstants.KDC_REQ_BODY_FROM_TAG,
+            new CheckNotNullLength() );
+        
+        // --------------------------------------------------------------------------------------------
+        // Transition from sname tag to till tag (from is empty)
+        // --------------------------------------------------------------------------------------------
+        // KDC-REQ-BODY    ::= SEQUENCE {
+        //         ...
+        //         till                    [5]
+       super.transitions[KdcReqStatesEnum.KDC_REQ_BODY_SNAME_STATE.ordinal()][KerberosConstants.KDC_REQ_BODY_TILL_TAG]
= new GrammarTransition(
+            KdcReqStatesEnum.KDC_REQ_BODY_SNAME_STATE, KdcReqStatesEnum.KDC_REQ_BODY_TILL_STATE,
KerberosConstants.KDC_REQ_BODY_TILL_TAG,
+            new CheckNotNullLength() );
+        
+        // --------------------------------------------------------------------------------------------
+        // Transition from from tag to from value
+        // --------------------------------------------------------------------------------------------
+        // KDC-REQ-BODY    ::= SEQUENCE {
+        //         ...
+        //         from                    [4] KerberosTime
+       super.transitions[KdcReqStatesEnum.KDC_REQ_BODY_FROM_STATE.ordinal()][UniversalTag.GENERALIZED_TIME.getValue()]
= new GrammarTransition(
+            KdcReqStatesEnum.KDC_REQ_BODY_FROM_STATE, KdcReqStatesEnum.KDC_REQ_BODY_TILL_TAG_STATE,
UniversalTag.GENERALIZED_TIME.getValue(),
+            new StoreFrom() );
+
+        // --------------------------------------------------------------------------------------------
+        // Transition from till tag to till value
+        // --------------------------------------------------------------------------------------------
+        // KDC-REQ-BODY    ::= SEQUENCE {
+        //         ...
+        //         till                    [5]
+       super.transitions[KdcReqStatesEnum.KDC_REQ_BODY_TILL_TAG_STATE.ordinal()][KerberosConstants.KDC_REQ_BODY_TILL_TAG]
= new GrammarTransition(
+            KdcReqStatesEnum.KDC_REQ_BODY_TILL_TAG_STATE, KdcReqStatesEnum.KDC_REQ_BODY_TILL_STATE,
KerberosConstants.KDC_REQ_BODY_TILL_TAG,
+            new CheckNotNullLength() );
+
+        // --------------------------------------------------------------------------------------------
+        // Transition from till tag to till value
+        // --------------------------------------------------------------------------------------------
+        // KDC-REQ-BODY    ::= SEQUENCE {
+        //         ...
+        //         till                    [5] KerberosTime
+        super.transitions[KdcReqStatesEnum.KDC_REQ_BODY_TILL_STATE.ordinal()][UniversalTag.GENERALIZED_TIME.getValue()]
= new GrammarTransition(
+            KdcReqStatesEnum.KDC_REQ_BODY_TILL_STATE, KdcReqStatesEnum.KDC_REQ_BODY_RTIME_OR_NONCE_TAG_STATE,
UniversalTag.GENERALIZED_TIME.getValue(),
+            new StoreTill() );
+
+        // --------------------------------------------------------------------------------------------
+        // Transition from till value to rtime 
+        // --------------------------------------------------------------------------------------------
+        // KDC-REQ-BODY    ::= SEQUENCE {
+        //         ...
+        //         rtime                    [6] 
+        super.transitions[KdcReqStatesEnum.KDC_REQ_BODY_RTIME_OR_NONCE_TAG_STATE.ordinal()][KerberosConstants.KDC_REQ_BODY_RTIME_TAG]
= new GrammarTransition(
+            KdcReqStatesEnum.KDC_REQ_BODY_RTIME_OR_NONCE_TAG_STATE, KdcReqStatesEnum.KDC_REQ_BODY_RTIME_STATE,
KerberosConstants.KDC_REQ_BODY_RTIME_TAG,
+           new CheckNotNullLength() );
+
+        // --------------------------------------------------------------------------------------------
+        // Transition from till value to nonce 
+        // --------------------------------------------------------------------------------------------
+        // KDC-REQ-BODY    ::= SEQUENCE {
+        //         ...
+        //         nonce                    [7]
+        super.transitions[KdcReqStatesEnum.KDC_REQ_BODY_RTIME_OR_NONCE_TAG_STATE.ordinal()][KerberosConstants.KDC_REQ_BODY_NONCE_TAG]
= new GrammarTransition(
+            KdcReqStatesEnum.KDC_REQ_BODY_RTIME_OR_NONCE_TAG_STATE, KdcReqStatesEnum.KDC_REQ_BODY_NONCE_STATE,
KerberosConstants.KDC_REQ_BODY_NONCE_TAG,
+            new CheckNotNullLength() );
+
+        // --------------------------------------------------------------------------------------------
+        // Transition from rtime to nonce tag
+        // --------------------------------------------------------------------------------------------
+        // KDC-REQ-BODY    ::= SEQUENCE {
+        //         ...
+        //         rtime                    [6] KerberosTime
+        super.transitions[KdcReqStatesEnum.KDC_REQ_BODY_RTIME_STATE.ordinal()][UniversalTag.GENERALIZED_TIME.getValue()]
= new GrammarTransition(
+            KdcReqStatesEnum.KDC_REQ_BODY_RTIME_STATE, KdcReqStatesEnum.KDC_REQ_BODY_NONCE_TAG_STATE,
UniversalTag.GENERALIZED_TIME.getValue(),
+            new StoreRTime() );
+
+        // --------------------------------------------------------------------------------------------
+        // Transition from nonce tag to nonce value
+        // --------------------------------------------------------------------------------------------
+        // KDC-REQ-BODY    ::= SEQUENCE {
+        //         ...
+        //         nonce                    [7] UInt32
+       super.transitions[KdcReqStatesEnum.KDC_REQ_BODY_NONCE_TAG_STATE.ordinal()][KerberosConstants.KDC_REQ_BODY_NONCE_TAG]
= new GrammarTransition(
+           KdcReqStatesEnum.KDC_REQ_BODY_NONCE_TAG_STATE, KdcReqStatesEnum.KDC_REQ_BODY_NONCE_STATE,
KerberosConstants.KDC_REQ_BODY_NONCE_TAG,
+           new CheckNotNullLength() );
+
+        // --------------------------------------------------------------------------------------------
+        // Transition from nonce value to etype Tag
+        // --------------------------------------------------------------------------------------------
+        // KDC-REQ-BODY    ::= SEQUENCE {
+        //         ...
+        //         etype                    [8]
+        super.transitions[KdcReqStatesEnum.KDC_REQ_BODY_NONCE_STATE.ordinal()][UniversalTag.INTEGER.getValue()]
= new GrammarTransition(
+            KdcReqStatesEnum.KDC_REQ_BODY_NONCE_TAG_STATE, KdcReqStatesEnum.KDC_REQ_BODY_ETYPE_TAG_STATE,
UniversalTag.INTEGER.getValue(),
+            new StoreNonce() );
+
+        // --------------------------------------------------------------------------------------------
+        // Transition from etype Tag to etype Tag
+        // --------------------------------------------------------------------------------------------
+        // KDC-REQ-BODY    ::= SEQUENCE {
+        //         ...
+        //         etype                    [8] 
+        super.transitions[KdcReqStatesEnum.KDC_REQ_BODY_ETYPE_TAG_STATE.ordinal()][KerberosConstants.KDC_REQ_BODY_ETYPE_TAG]
= new GrammarTransition(
+            KdcReqStatesEnum.KDC_REQ_BODY_ETYPE_TAG_STATE, KdcReqStatesEnum.KDC_REQ_BODY_ETYPE_SEQ_STATE,
KerberosConstants.KDC_REQ_BODY_ETYPE_TAG,
+            new CheckNotNullLength() );
+
+        // --------------------------------------------------------------------------------------------
+        // Transition from etype Tag to etype SEQ
+        // --------------------------------------------------------------------------------------------
+        // KDC-REQ-BODY    ::= SEQUENCE {
+        //         ...
+        //         etype                    [8] SEQUENCE OF 
+        super.transitions[KdcReqStatesEnum.KDC_REQ_BODY_ETYPE_SEQ_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()]
= new GrammarTransition(
+            KdcReqStatesEnum.KDC_REQ_BODY_ETYPE_SEQ_STATE, KdcReqStatesEnum.KDC_REQ_BODY_ETYPE_STATE,
UniversalTag.SEQUENCE.getValue(),
+            new ETypeSequence() );
+
+        // --------------------------------------------------------------------------------------------
+        // Transition from etype SEQ to EType values
+        // --------------------------------------------------------------------------------------------
+        // KDC-REQ-BODY    ::= SEQUENCE {
+        //         ...
+        //         etype                    [8] SEQUENCE OF Int32
+        super.transitions[KdcReqStatesEnum.KDC_REQ_BODY_ETYPE_STATE.ordinal()][UniversalTag.INTEGER.getValue()]
= new GrammarTransition(
+            KdcReqStatesEnum.KDC_REQ_BODY_ETYPE_STATE, KdcReqStatesEnum.KDC_REQ_BODY_ETYPE_STATE,
UniversalTag.INTEGER.getValue(),
+            new AddEType() );
+
+        // --------------------------------------------------------------------------------------------
+        // Transition from EType values to addresses
+        // --------------------------------------------------------------------------------------------
+        // KDC-REQ-BODY    ::= SEQUENCE {
+        //         ...
+        //         addresses               [9]
+        super.transitions[KdcReqStatesEnum.KDC_REQ_BODY_ETYPE_STATE.ordinal()][KerberosConstants.KDC_REQ_BODY_ADDRESSES_TAG]
= new GrammarTransition(
+            KdcReqStatesEnum.KDC_REQ_BODY_ETYPE_STATE, KdcReqStatesEnum.KDC_REQ_BODY_ADDRESSES_STATE,
KerberosConstants.KDC_REQ_BODY_ADDRESSES_TAG,
+            new StoreAddresses() );
+
+        // --------------------------------------------------------------------------------------------
+        // Transition from EType values to encAuthorizationData (addresses is empty)
+        // --------------------------------------------------------------------------------------------
+        // KDC-REQ-BODY    ::= SEQUENCE {
+        //         ...
+        //         enc-authorization-data  [10]
+        super.transitions[KdcReqStatesEnum.KDC_REQ_BODY_ETYPE_STATE.ordinal()][KerberosConstants.KDC_REQ_BODY_ENC_AUTHZ_DATA_TAG]
= new GrammarTransition(
+            KdcReqStatesEnum.KDC_REQ_BODY_ETYPE_STATE, KdcReqStatesEnum.KDC_REQ_BODY_ENC_AUTH_DATA_STATE,
KerberosConstants.KDC_REQ_BODY_ENC_AUTHZ_DATA_TAG,
+            new StoreEncAuthorizationData() );
+
+        // --------------------------------------------------------------------------------------------
+        // Transition from EType values to additionalTickets tag (addresses and enc-authorization
data
+        // are empty)
+        // --------------------------------------------------------------------------------------------
+        // KDC-REQ-BODY    ::= SEQUENCE {
+        //         ...
+        //         additional-tickets      [11]
+        super.transitions[KdcReqStatesEnum.KDC_REQ_BODY_ETYPE_STATE.ordinal()][KerberosConstants.KDC_REQ_BODY_ADDITIONAL_TICKETS_TAG]
= new GrammarTransition(
+            KdcReqStatesEnum.KDC_REQ_BODY_ETYPE_STATE, KdcReqStatesEnum.KDC_REQ_BODY_ADDITIONAL_TICKETS_TAG_STATE,
KerberosConstants.KDC_REQ_BODY_ADDITIONAL_TICKETS_TAG,
+            new CheckNotNullLength() );
+    
+    
+
+        // --------------------------------------------------------------------------------------------
+        // Transition from addresses values to encAuthorizationData
+        // --------------------------------------------------------------------------------------------
+        // KDC-REQ-BODY    ::= SEQUENCE {
+        //         ...
+        //         enc-authorization-data  [10]
+        super.transitions[KdcReqStatesEnum.KDC_REQ_BODY_ADDRESSES_STATE.ordinal()][KerberosConstants.KDC_REQ_BODY_ENC_AUTHZ_DATA_TAG]
= new GrammarTransition(
+            KdcReqStatesEnum.KDC_REQ_BODY_ADDRESSES_STATE, KdcReqStatesEnum.KDC_REQ_BODY_ENC_AUTH_DATA_STATE,
KerberosConstants.KDC_REQ_BODY_ENC_AUTHZ_DATA_TAG,
+            new StoreEncAuthorizationData() );
+
+        // --------------------------------------------------------------------------------------------
+        // Transition from addresses values to additional-tickets tag
+        // --------------------------------------------------------------------------------------------
+        // KDC-REQ-BODY    ::= SEQUENCE {
+        //         ...
+        //         additional-tickets      [11]
+        super.transitions[KdcReqStatesEnum.KDC_REQ_BODY_ADDRESSES_STATE.ordinal()][KerberosConstants.KDC_REQ_BODY_ADDITIONAL_TICKETS_TAG]
= new GrammarTransition(
+            KdcReqStatesEnum.KDC_REQ_BODY_ADDRESSES_STATE, KdcReqStatesEnum.KDC_REQ_BODY_ADDITIONAL_TICKETS_TAG_STATE,
KerberosConstants.KDC_REQ_BODY_ADDITIONAL_TICKETS_TAG,
+            new CheckNotNullLength() );
+
+
+        
+        // --------------------------------------------------------------------------------------------
+        // Transition from encAuthorizationData to additional-tickets tag
+        // --------------------------------------------------------------------------------------------
+        // KDC-REQ-BODY    ::= SEQUENCE {
+        //         ...
+        //         additional-tickets      [11]
+        super.transitions[KdcReqStatesEnum.KDC_REQ_BODY_ENC_AUTH_DATA_STATE.ordinal()][KerberosConstants.KDC_REQ_BODY_ADDITIONAL_TICKETS_TAG]
= new GrammarTransition(
+            KdcReqStatesEnum.KDC_REQ_BODY_ENC_AUTH_DATA_STATE, KdcReqStatesEnum.KDC_REQ_BODY_ADDITIONAL_TICKETS_TAG_STATE,
KerberosConstants.KDC_REQ_BODY_ADDITIONAL_TICKETS_TAG,
+            new CheckNotNullLength() );
+
+    
+    
+        // --------------------------------------------------------------------------------------------
+        // Transition from additional-tickets tag to Ticket SEQUENCE
+        // --------------------------------------------------------------------------------------------
+        // KDC-REQ-BODY    ::= SEQUENCE {
+        //         ...
+        //         additional-tickets      [11] SEQUENCE OF
+        super.transitions[KdcReqStatesEnum.KDC_REQ_BODY_ADDITIONAL_TICKETS_TAG_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()]
= new GrammarTransition(
+            KdcReqStatesEnum.KDC_REQ_BODY_ADDITIONAL_TICKETS_TAG_STATE, KdcReqStatesEnum.KDC_REQ_BODY_ADDITIONAL_TICKETS_SEQ_STATE,
UniversalTag.SEQUENCE.getValue(),
+            new CheckNotNullLength() );
+
+        // --------------------------------------------------------------------------------------------
+        // Transition from Ticket SEQUENCE to Ticket
+        // --------------------------------------------------------------------------------------------
+        // KDC-REQ-BODY    ::= SEQUENCE {
+        //         ...
+        //         additional-tickets      [11] SEQUENCE OF Ticket
+        super.transitions[KdcReqStatesEnum.KDC_REQ_BODY_ADDITIONAL_TICKETS_SEQ_STATE.ordinal()][KerberosConstants.TICKET_TAG]
= new GrammarTransition(
+            KdcReqStatesEnum.KDC_REQ_BODY_ADDITIONAL_TICKETS_SEQ_STATE, KdcReqStatesEnum.KDC_REQ_BODY_ADDITIONAL_TICKETS_STATE,
KerberosConstants.TICKET_TAG,
+            new AddTicket() );
+        
+        // --------------------------------------------------------------------------------------------
+        // Transition from Ticket to Ticket
+        // --------------------------------------------------------------------------------------------
+        // KDC-REQ-BODY    ::= SEQUENCE {
+        //         ...
+        //         additional-tickets      [11] SEQUENCE OF Ticket
+        super.transitions[KdcReqStatesEnum.KDC_REQ_BODY_ADDITIONAL_TICKETS_STATE.ordinal()][KerberosConstants.TICKET_TAG]
= new GrammarTransition(
+            KdcReqStatesEnum.KDC_REQ_BODY_ADDITIONAL_TICKETS_STATE, KdcReqStatesEnum.KDC_REQ_BODY_ADDITIONAL_TICKETS_STATE,
KerberosConstants.TICKET_TAG,
+            new AddTicket() );
+    }
+
+    /**
+     * Get the instance of this grammar
+     * 
+     * @return An instance on the KDC-REQ-BODY Grammar
+     */
+    public static Grammar getInstance()
+    {
+        return instance;
+    }
+}

Added: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReq/KdcReqStatesEnum.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReq/KdcReqStatesEnum.java?rev=1035038&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReq/KdcReqStatesEnum.java
(added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReq/KdcReqStatesEnum.java
Sun Nov 14 18:17:16 2010
@@ -0,0 +1,117 @@
+/*
+ *  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.directory.shared.kerberos.codec.kdcReq;
+
+
+import org.apache.directory.shared.asn1.ber.grammar.Grammar;
+import org.apache.directory.shared.asn1.ber.grammar.States;
+import org.apache.directory.shared.kerberos.codec.KerberosMessageGrammar;
+
+
+/**
+ * This class store the KDC-REQ grammar's constants. It is also used for debugging
+ * purpose
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public enum KdcReqStatesEnum implements States
+{
+    // Start
+    START_STATE,                           // 0
+    
+    // ----- KDC-REQ component --------------------------------------
+    KDC_REQ_SEQ_STATE,                     // 1
+    
+    KDC_REQ_PVNO_TAG_STATE,                // 2
+    KDC_REQ_PVNO_STATE,                    // 3
+    
+    KDC_REQ_MSG_TYPE_TAG_STATE,            // 4
+    KDC_REQ_MSG_TYPE_STATE,                // 5
+
+    KDC_REQ_PA_DATA_TAG_STATE,             // 6
+    KDC_REQ_PA_DATA_SEQ_STATE,             // 7
+    KDC_REQ_PA_DATA_STATE,                 // 8
+
+    KDC_REQ_KDC_REQ_BODY_STATE,            // 9
+
+    // End
+    LAST_KDC_REQ_STATE;                    // 10
+
+    
+    /**
+     * Get the grammar name
+     * 
+     * @param grammar The grammar code
+     * @return The grammar name
+     */
+    public String getGrammarName( int grammar )
+    {
+        return "KDC_REQ_GRAMMAR";
+    }
+
+
+    /**
+     * Get the grammar name
+     * 
+     * @param grammar The grammar class
+     * @return The grammar name
+     */
+    public String getGrammarName( Grammar grammar )
+    {
+        if ( grammar instanceof KerberosMessageGrammar )
+        {
+            return "KDC_REQ_GRAMMAR";
+        }
+        else
+        {
+            return "UNKNOWN GRAMMAR";
+        }
+    }
+
+
+    /**
+     * Get the string representing the state
+     * 
+     * @param state The state number
+     * @return The String representing the state
+     */
+    public String getState( int state )
+    {
+        return ( ( state == LAST_KDC_REQ_STATE.ordinal() ) ? "KDC_REQ_END_STATE" : name()
);
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEndState()
+    {
+        return this == LAST_KDC_REQ_STATE;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public KdcReqStatesEnum getStartState()
+    {
+        return START_STATE;
+    }
+}

Added: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReq/actions/KdcReqInit.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReq/actions/KdcReqInit.java?rev=1035038&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReq/actions/KdcReqInit.java
(added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReq/actions/KdcReqInit.java
Sun Nov 14 18:17:16 2010
@@ -0,0 +1,83 @@
+/*
+ *  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.directory.shared.kerberos.codec.kdcReq.actions;
+
+
+import org.apache.directory.shared.asn1.ber.Asn1Container;
+import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.asn1.codec.DecoderException;
+import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.kerberos.codec.kdcReq.KdcReqContainer;
+import org.apache.directory.shared.kerberos.components.KdcReq;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to initialize the KDC-REQ object
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class KdcReqInit extends GrammarAction
+{
+    /** The logger */
+    private static final Logger LOG = LoggerFactory.getLogger( KdcReqInit.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
+
+
+    /**
+     * Instantiates a new KdcReqInit action.
+     */
+    public KdcReqInit()
+    {
+        super( "Creates a KdcReq instance" );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void action( Asn1Container container ) throws DecoderException
+    {
+        KdcReqContainer kdcReqContainer = ( KdcReqContainer ) container;
+
+        TLV tlv = kdcReqContainer.getCurrentTLV();
+
+        // The Length should not be null
+        if ( tlv.getLength() == 0 )
+        {
+            LOG.error( I18n.err( I18n.ERR_04066 ) );
+
+            // This will generate a PROTOCOL_ERROR
+            throw new DecoderException( I18n.err( I18n.ERR_04067 ) );
+        }
+        
+        KdcReq kdcReq = new KdcReq();
+        kdcReqContainer.setKdcReq( kdcReq );
+        
+        if ( IS_DEBUG )
+        {
+            LOG.debug( "KdcReq created" );
+        }
+    }
+}

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/KdcReqBodyContainer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/KdcReqBodyContainer.java?rev=1035038&r1=1035037&r2=1035038&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/KdcReqBodyContainer.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/KdcReqBodyContainer.java
Sun Nov 14 18:17:16 2010
@@ -24,13 +24,13 @@ import org.apache.directory.shared.kerbe
 
 
 /**
- * The KdcReqBody container stores the KRB-REQ-BODY decoded by the Asn1Decoder.
+ * The KdcReqBody container stores the KDC-REQ-BODY decoded by the Asn1Decoder.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
 public class KdcReqBodyContainer extends AbstractContainer
 {
-    /** An KRB-REQ-BODY container */
+    /** An KDC-REQ-BODY container */
     private KdcReqBody kdcReqBody;
     
     /**



Mime
View raw message