directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1039333 - in /directory/apacheds/trunk/kerberos-codec/src: main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/ main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/actions/ main/java/org/apache/directory/shared/...
Date Fri, 26 Nov 2010 12:44:56 GMT
Author: elecharny
Date: Fri Nov 26 12:44:56 2010
New Revision: 1039333

URL: http://svn.apache.org/viewvc?rev=1039333&view=rev
Log:
Added the EncApRepPart grammar and tests

Added:
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/EncApRepPartContainer.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/EncApRepPartGrammar.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/EncApRepPartStatesEnum.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/actions/
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/actions/EncApRepPartInit.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/actions/StoreCTime.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/actions/StoreCusec.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/actions/StoreSeqNumber.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/actions/StoreSubKey.java
    directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/EncApRepPartDecoderTest.java
Modified:
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/EncApRepPart.java

Added: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/EncApRepPartContainer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/EncApRepPartContainer.java?rev=1039333&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/EncApRepPartContainer.java (added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/EncApRepPartContainer.java Fri Nov 26 12:44:56 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.encApRepPart;
+
+import org.apache.directory.shared.kerberos.codec.kdcReq.KdcReqContainer;
+import org.apache.directory.shared.kerberos.messages.EncApRepPart;
+
+
+/**
+ * The EncApRepPart container stores the EncApRepPart decoded by the Asn1Decoder.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class EncApRepPartContainer extends KdcReqContainer
+{
+    /** An EncApRepPart container */
+    private EncApRepPart encApRepPart = new EncApRepPart();
+
+    /**
+     * Creates a new EncApRepPartContainer object.
+     */
+    public EncApRepPartContainer()
+    {
+        super();
+        this.stateStack = new int[1];
+        this.grammar = EncApRepPartGrammar.getInstance();
+        setTransition( EncApRepPartStatesEnum.START_STATE );
+    }
+
+
+    /**
+     * @return Returns the EncApRepPart.
+     */
+    public EncApRepPart getEncApRepPart()
+    {
+        return encApRepPart;
+    }
+
+    
+    /**
+     * Set an EncApRepPart Object into the container. It will be completed by the
+     * KerberosDecoder.
+     * 
+     * @param encApRepPart The EncApRepPart to set.
+     */
+    public void setEncApRepPart( EncApRepPart encApRepPart )
+    {
+        this.encApRepPart = encApRepPart;
+    }
+}

Added: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/EncApRepPartGrammar.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/EncApRepPartGrammar.java?rev=1039333&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/EncApRepPartGrammar.java (added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/EncApRepPartGrammar.java Fri Nov 26 12:44:56 2010
@@ -0,0 +1,176 @@
+/*
+ *  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.encApRepPart;
+
+
+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.encApRepPart.actions.EncApRepPartInit;
+import org.apache.directory.shared.kerberos.codec.encApRepPart.actions.StoreCTime;
+import org.apache.directory.shared.kerberos.codec.encApRepPart.actions.StoreCusec;
+import org.apache.directory.shared.kerberos.codec.encApRepPart.actions.StoreSeqNumber;
+import org.apache.directory.shared.kerberos.codec.encApRepPart.actions.StoreSubKey;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * This class implements the EncApRepPart 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 EncApRepPartGrammar extends AbstractGrammar
+{
+    /** The logger */
+    static final Logger LOG = LoggerFactory.getLogger( EncApRepPartGrammar.class );
+
+    /** A speedup for logger */
+    static final boolean IS_DEBUG = LOG.isDebugEnabled();
+
+    /** The instance of grammar. EncApRepPartGrammar is a singleton */
+    private static Grammar instance = new EncApRepPartGrammar();
+
+
+    /**
+     * Creates a new EncApRepPartGrammar object.
+     */
+    private EncApRepPartGrammar()
+    {
+        setName( EncApRepPartGrammar.class.getName() );
+
+        // Create the transitions table
+        super.transitions = new GrammarTransition[EncApRepPartStatesEnum.LAST_ENC_AP_REP_PART_STATE.ordinal()][256];
+
+        // ============================================================================================
+        // EncApRepPart 
+        // ============================================================================================
+        // --------------------------------------------------------------------------------------------
+        // Transition from EncApRepPart init to APPLICATION tag
+        // --------------------------------------------------------------------------------------------
+        // EncAPRepPart    ::= [APPLICATION 27]
+        super.transitions[EncApRepPartStatesEnum.START_STATE.ordinal()][KerberosConstants.ENC_AP_REP_PART_TAG] = new GrammarTransition(
+            EncApRepPartStatesEnum.START_STATE, EncApRepPartStatesEnum.ENC_AP_REP_PART_STATE, KerberosConstants.ENC_AP_REP_PART_TAG,
+            new EncApRepPartInit() );
+        
+        // --------------------------------------------------------------------------------------------
+        // Transition from EncApRepPart APPLICATION to EncApRepPart SEQ
+        // --------------------------------------------------------------------------------------------
+        // EncAPRepPart    ::= [APPLICATION 27] SEQUENCE {
+        super.transitions[EncApRepPartStatesEnum.ENC_AP_REP_PART_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
+            EncApRepPartStatesEnum.ENC_AP_REP_PART_STATE, EncApRepPartStatesEnum.ENC_AP_REP_PART_SEQ_STATE, UniversalTag.SEQUENCE.getValue(),
+            new CheckNotNullLength() );
+        
+        // --------------------------------------------------------------------------------------------
+        // Transition from EncApRepPart SEQ to ctime tag
+        // --------------------------------------------------------------------------------------------
+        // EncAPRepPart    ::= [APPLICATION 27] SEQUENCE {
+        //         ctime           [0]
+        super.transitions[EncApRepPartStatesEnum.ENC_AP_REP_PART_SEQ_STATE.ordinal()][KerberosConstants.ENC_AP_REP_PART_CTIME_TAG] = new GrammarTransition(
+            EncApRepPartStatesEnum.ENC_AP_REP_PART_SEQ_STATE, EncApRepPartStatesEnum.ENC_AP_REP_PART_CTIME_TAG_STATE, KerberosConstants.ENC_AP_REP_PART_CTIME_TAG,
+            new CheckNotNullLength() );
+        
+        // --------------------------------------------------------------------------------------------
+        // Transition from ctime tag to ctime value
+        // --------------------------------------------------------------------------------------------
+        // EncAPRepPart    ::= [APPLICATION 27] SEQUENCE {
+        //         ctime           [0] KerberosTime,
+        super.transitions[EncApRepPartStatesEnum.ENC_AP_REP_PART_CTIME_TAG_STATE.ordinal()][UniversalTag.GENERALIZED_TIME.getValue()] = new GrammarTransition(
+            EncApRepPartStatesEnum.ENC_AP_REP_PART_CTIME_TAG_STATE, EncApRepPartStatesEnum.ENC_AP_REP_PART_CTIME_STATE, UniversalTag.GENERALIZED_TIME.getValue(),
+            new StoreCTime() );
+        
+        // --------------------------------------------------------------------------------------------
+        // Transition from ctime value to cusec tag
+        // --------------------------------------------------------------------------------------------
+        // EncAPRepPart    ::= [APPLICATION 27] SEQUENCE {
+        //         ...
+        //         cusec           [1]
+        super.transitions[EncApRepPartStatesEnum.ENC_AP_REP_PART_CTIME_STATE.ordinal()][KerberosConstants.ENC_AP_REP_PART_CUSEC_TAG] = new GrammarTransition(
+            EncApRepPartStatesEnum.ENC_AP_REP_PART_CTIME_STATE, EncApRepPartStatesEnum.ENC_AP_REP_PART_CUSEC_TAG_STATE, KerberosConstants.ENC_AP_REP_PART_CUSEC_TAG,
+            new CheckNotNullLength() );
+        
+        // --------------------------------------------------------------------------------------------
+        // Transition from cusec tag to cusec value
+        // --------------------------------------------------------------------------------------------
+        // EncAPRepPart    ::= [APPLICATION 27] SEQUENCE {
+        //         ...
+        //         cusec           [1] Microseconds,
+        super.transitions[EncApRepPartStatesEnum.ENC_AP_REP_PART_CUSEC_TAG_STATE.ordinal()][UniversalTag.INTEGER.getValue()] = new GrammarTransition(
+            EncApRepPartStatesEnum.ENC_AP_REP_PART_CUSEC_TAG_STATE, EncApRepPartStatesEnum.ENC_AP_REP_PART_CUSEC_STATE, UniversalTag.INTEGER.getValue(),
+            new StoreCusec() );
+        
+        // --------------------------------------------------------------------------------------------
+        // Transition from cusec value to subkey
+        // --------------------------------------------------------------------------------------------
+        // EncAPRepPart    ::= [APPLICATION 27] SEQUENCE {
+        //         ...
+        //         subkey          [2] <EncryptionKey> OPTIONAL,
+        super.transitions[EncApRepPartStatesEnum.ENC_AP_REP_PART_CUSEC_STATE.ordinal()][KerberosConstants.ENC_AP_REP_PART_SUB_KEY_TAG] = new GrammarTransition(
+            EncApRepPartStatesEnum.ENC_AP_REP_PART_CUSEC_STATE, EncApRepPartStatesEnum.ENC_AP_REP_PART_SUBKEY_STATE, KerberosConstants.ENC_AP_REP_PART_SUB_KEY_TAG,
+            new StoreSubKey() );
+        
+        // --------------------------------------------------------------------------------------------
+        // Transition from cusec value to seq-number tag
+        // --------------------------------------------------------------------------------------------
+        // EncAPRepPart    ::= [APPLICATION 27] SEQUENCE {
+        //         ...
+        //         seq-number      [3] UInt32 OPTIONAL
+        super.transitions[EncApRepPartStatesEnum.ENC_AP_REP_PART_CUSEC_STATE.ordinal()][KerberosConstants.ENC_AP_REP_PART_SEQ_NUMBER_TAG] = new GrammarTransition(
+            EncApRepPartStatesEnum.ENC_AP_REP_PART_CUSEC_STATE, EncApRepPartStatesEnum.ENC_AP_REP_PART_SEQ_NUMBER_TAG_STATE, KerberosConstants.ENC_AP_REP_PART_SEQ_NUMBER_TAG,
+            new CheckNotNullLength() );
+        
+        // --------------------------------------------------------------------------------------------
+        // Transition from subkey to seq-number tag
+        // --------------------------------------------------------------------------------------------
+        // EncAPRepPart    ::= [APPLICATION 27] SEQUENCE {
+        //         ...
+        //         seq-number      [3] UInt32 OPTIONAL
+        super.transitions[EncApRepPartStatesEnum.ENC_AP_REP_PART_SUBKEY_STATE.ordinal()][KerberosConstants.ENC_AP_REP_PART_SEQ_NUMBER_TAG] = new GrammarTransition(
+            EncApRepPartStatesEnum.ENC_AP_REP_PART_SUBKEY_STATE, EncApRepPartStatesEnum.ENC_AP_REP_PART_SEQ_NUMBER_TAG_STATE, KerberosConstants.ENC_AP_REP_PART_SEQ_NUMBER_TAG,
+            new CheckNotNullLength() );
+
+        // --------------------------------------------------------------------------------------------
+        // Transition from seq-number tag to seq-number value
+        // --------------------------------------------------------------------------------------------
+        // EncAPRepPart    ::= [APPLICATION 27] SEQUENCE {
+        //         ...
+        //         seq-number      [3] UInt32 OPTIONAL
+        // }
+        super.transitions[EncApRepPartStatesEnum.ENC_AP_REP_PART_SEQ_NUMBER_TAG_STATE.ordinal()][UniversalTag.INTEGER.getValue()] = new GrammarTransition(
+            EncApRepPartStatesEnum.ENC_AP_REP_PART_SEQ_NUMBER_TAG_STATE, EncApRepPartStatesEnum.ENC_AP_REP_PART_SEQ_NUMBER_STATE, UniversalTag.INTEGER.getValue(),
+            new StoreSeqNumber() );
+    }
+
+
+    /**
+     * Get the instance of this grammar
+     * 
+     * @return An instance on the EncApRepPart Grammar
+     */
+    public static Grammar getInstance()
+    {
+        return instance;
+    }
+}

Added: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/EncApRepPartStatesEnum.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/EncApRepPartStatesEnum.java?rev=1039333&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/EncApRepPartStatesEnum.java (added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/EncApRepPartStatesEnum.java Fri Nov 26 12:44:56 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.encApRepPart;
+
+
+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 EncApRepPart grammar's constants. It is also used for debugging
+ * purpose
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public enum EncApRepPartStatesEnum implements States
+{
+    // Start
+    START_STATE,                            // 0
+    
+    // ----- EncApRepPart message --------------------------------------
+    ENC_AP_REP_PART_STATE,                  // 1
+    ENC_AP_REP_PART_SEQ_STATE,              // 2
+    
+    ENC_AP_REP_PART_CTIME_TAG_STATE,        // 3
+    ENC_AP_REP_PART_CTIME_STATE,            // 4
+    
+    ENC_AP_REP_PART_CUSEC_TAG_STATE,        // 5
+    ENC_AP_REP_PART_CUSEC_STATE,            // 6
+    
+    ENC_AP_REP_PART_SUBKEY_STATE,           // 7
+
+    ENC_AP_REP_PART_SEQ_NUMBER_TAG_STATE,   // 8
+    ENC_AP_REP_PART_SEQ_NUMBER_STATE,       // 9
+
+    // End
+    LAST_ENC_AP_REP_PART_STATE;             // 10
+
+    
+    /**
+     * Get the grammar name
+     * 
+     * @param grammar The grammar code
+     * @return The grammar name
+     */
+    public String getGrammarName( int grammar )
+    {
+        return "ENC_AP_REP_PART_GRAMMAR";
+    }
+
+
+    /**
+     * Get the grammar name
+     * 
+     * @param grammar The grammar class
+     * @return The grammar name
+     */
+    public String getGrammarName( Grammar grammar )
+    {
+        if ( grammar instanceof KerberosMessageGrammar )
+        {
+            return "ENC_AP_REP_PART_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_ENC_AP_REP_PART_STATE.ordinal() ) ? "ENC_AP_REP_PART_END_STATE" : name() );
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEndState()
+    {
+        return this == LAST_ENC_AP_REP_PART_STATE;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public EncApRepPartStatesEnum getStartState()
+    {
+        return START_STATE;
+    }
+}

Added: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/actions/EncApRepPartInit.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/actions/EncApRepPartInit.java?rev=1039333&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/actions/EncApRepPartInit.java (added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/actions/EncApRepPartInit.java Fri Nov 26 12:44:56 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.encApRepPart.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.encApRepPart.EncApRepPartContainer;
+import org.apache.directory.shared.kerberos.messages.EncApRepPart;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to initialize the EncApRepPart object
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class EncApRepPartInit extends GrammarAction
+{
+    /** The logger */
+    private static final Logger LOG = LoggerFactory.getLogger( EncApRepPartInit.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
+
+
+    /**
+     * Instantiates a new EncApRepPartInit action.
+     */
+    public EncApRepPartInit()
+    {
+        super( "Creates an EncApRepPart instance" );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void action( Asn1Container container ) throws DecoderException
+    {
+        EncApRepPartContainer encApRepPartContainer = ( EncApRepPartContainer ) container;
+
+        TLV tlv = encApRepPartContainer.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 ) );
+        }
+        
+        EncApRepPart encApRepPart = new EncApRepPart();
+        encApRepPartContainer.setEncApRepPart( encApRepPart );
+        
+        if ( IS_DEBUG )
+        {
+            LOG.debug( "EncApRepPart created" );
+        }
+    }
+}

Added: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/actions/StoreCTime.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/actions/StoreCTime.java?rev=1039333&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/actions/StoreCTime.java (added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/actions/StoreCTime.java Fri Nov 26 12:44:56 2010
@@ -0,0 +1,55 @@
+/*
+ *  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.encApRepPart.actions;
+
+
+import org.apache.directory.shared.asn1.ber.Asn1Container;
+import org.apache.directory.shared.kerberos.KerberosTime;
+import org.apache.directory.shared.kerberos.codec.actions.AbstractReadKerberosTime;
+import org.apache.directory.shared.kerberos.codec.encApRepPart.EncApRepPartContainer;
+
+
+/**
+ * The action used to store the ctime KerberosTime
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoreCTime extends AbstractReadKerberosTime
+{
+
+    /**
+     * Instantiates a new StoreCTime action.
+     */
+    public StoreCTime()
+    {
+        super( "Stores the CTime" );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected void setKerberosTime( KerberosTime krbtime, Asn1Container container )
+    {
+        EncApRepPartContainer encApRepPart = ( EncApRepPartContainer ) container;
+        encApRepPart.getEncApRepPart().setCTime( krbtime );
+    }
+}

Added: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/actions/StoreCusec.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/actions/StoreCusec.java?rev=1039333&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/actions/StoreCusec.java (added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/actions/StoreCusec.java Fri Nov 26 12:44:56 2010
@@ -0,0 +1,55 @@
+/*
+ *  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.encApRepPart.actions;
+
+
+import org.apache.directory.shared.asn1.ber.Asn1Container;
+import org.apache.directory.shared.kerberos.codec.actions.AbstractReadInteger;
+import org.apache.directory.shared.kerberos.codec.encApRepPart.EncApRepPartContainer;
+
+
+/**
+ * The action used to store the cusec
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoreCusec extends AbstractReadInteger
+{
+
+    /**
+     * Instantiates a new StoreCusec action.
+     */
+    public StoreCusec()
+    {
+        super( "EncApRepPart cusec" );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected void setIntegerValue( int value, Asn1Container container )
+    {
+        EncApRepPartContainer encApRepPartContainer = ( EncApRepPartContainer ) container;
+        encApRepPartContainer.getEncApRepPart().setCusec( value );
+        encApRepPartContainer.setGrammarEndAllowed( true );
+    }
+}

Added: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/actions/StoreSeqNumber.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/actions/StoreSeqNumber.java?rev=1039333&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/actions/StoreSeqNumber.java (added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/actions/StoreSeqNumber.java Fri Nov 26 12:44:56 2010
@@ -0,0 +1,55 @@
+/*
+ *  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.encApRepPart.actions;
+
+
+import org.apache.directory.shared.asn1.ber.Asn1Container;
+import org.apache.directory.shared.kerberos.codec.actions.AbstractReadInteger;
+import org.apache.directory.shared.kerberos.codec.encApRepPart.EncApRepPartContainer;
+
+
+/**
+ * The action used to store the seq-number
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoreSeqNumber extends AbstractReadInteger
+{
+
+    /**
+     * Instantiates a new StoreSeqNumber action.
+     */
+    public StoreSeqNumber()
+    {
+        super( "EncApRepPart seq-number" );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected void setIntegerValue( int value, Asn1Container container )
+    {
+        EncApRepPartContainer encApRepPartContainer = ( EncApRepPartContainer ) container;
+        encApRepPartContainer.getEncApRepPart().setSeqNumber( value );
+        encApRepPartContainer.setGrammarEndAllowed( true );
+    }
+}

Added: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/actions/StoreSubKey.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/actions/StoreSubKey.java?rev=1039333&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/actions/StoreSubKey.java (added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encApRepPart/actions/StoreSubKey.java Fri Nov 26 12:44:56 2010
@@ -0,0 +1,56 @@
+/*
+ *  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.encApRepPart.actions;
+
+
+import org.apache.directory.shared.asn1.ber.Asn1Container;
+import org.apache.directory.shared.kerberos.codec.actions.AbstractReadEncryptionKey;
+import org.apache.directory.shared.kerberos.codec.encApRepPart.EncApRepPartContainer;
+import org.apache.directory.shared.kerberos.components.EncryptionKey;
+
+
+/**
+ * The action used to set the EncApRepPart subkey
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoreSubKey extends AbstractReadEncryptionKey
+{
+
+    /**
+     * Instantiates a new StoreEncryptionKey action.
+     */
+    public StoreSubKey()
+    {
+        super( "EncApRepPart subkey" );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected void setEncryptionKey( EncryptionKey encryptionKey, Asn1Container container )
+    {
+        EncApRepPartContainer encApRepPartContainer = ( EncApRepPartContainer ) container;
+        encApRepPartContainer.getEncApRepPart().setSubkey( encryptionKey );
+        encApRepPartContainer.setGrammarEndAllowed( true );
+    }
+}

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/EncApRepPart.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/EncApRepPart.java?rev=1039333&r1=1039332&r2=1039333&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/EncApRepPart.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/EncApRepPart.java Fri Nov 26 12:44:56 2010
@@ -75,6 +75,7 @@ public class EncApRepPart extends Kerber
     private transient int cusecLength;
     private transient int subKeyLength;
     private transient int seqNumberLength;
+    private transient int encApRepPartSeqLength;
     private transient int encApRepPartLength;
 
     /**
@@ -167,19 +168,21 @@ public class EncApRepPart extends Kerber
      * 
      * 0x7B L1 EncApRepPart [APPLICATION 27]
      *  |
-     *  +--> 0xA0 11 ctime tag
-     *  |     |
-     *  |     +--> 0x18 0x0F ttt ctime (KerberosTime)
-     *  |
-     *  +--> 0xA1 L2 cusec tag
-     *  |     |
-     *  |     +--> 0x02 L2-1 cusec (INTEGER)
-     *  |
-     *  +--> 0xA2 L3 subkey (EncryptionKey)
-     *  |
-     *  +--> 0xA3 L4 seq-number tag
+     *  +--> 0x30 L2 SEQ
+     *        |
+     *        +--> 0xA0 11 ctime tag
+     *        |     |
+     *        |     +--> 0x18 0x0F ttt ctime (KerberosTime)
+     *        |
+     *        +--> 0xA1 L3 cusec tag
+     *        |     |
+     *        |     +--> 0x02 L3-1 cusec (INTEGER)
      *        |
-     *        +--> 0x02 L4-1 NN seq-number (INTEGER)
+     *        +--> 0xA2 L4 subkey (EncryptionKey)
+     *        |
+     *        +--> 0xA3 L5 seq-number tag
+     *              |
+     *              +--> 0x02 L5-1 NN seq-number (INTEGER)
      * </pre>
      */
     @Override
@@ -187,27 +190,28 @@ public class EncApRepPart extends Kerber
     {
         // Compute the ctime length.
         ctimeLength = 1 + 1 + 0x0F;
-        encApRepPartLength = 1 + TLV.getNbBytes( ctimeLength ) + ctimeLength;
+        encApRepPartSeqLength = 1 + TLV.getNbBytes( ctimeLength ) + ctimeLength;
 
         // Compute the cusec length
         cusecLength = 1 + 1 + Value.getNbBytes( cusec );
-        encApRepPartLength += 1 + TLV.getNbBytes( cusecLength ) + cusecLength;
+        encApRepPartSeqLength += 1 + TLV.getNbBytes( cusecLength ) + cusecLength;
         
         // Compute the subkey length, if any
         if ( subkey != null )
         {
             subKeyLength = subkey.computeLength();
-            encApRepPartLength += 1 + TLV.getNbBytes( subKeyLength ) + subKeyLength;
+            encApRepPartSeqLength += 1 + TLV.getNbBytes( subKeyLength ) + subKeyLength;
         }
         
         // Compute the sequence size, if any
         if ( seqNumber != null )
         {
             seqNumberLength = 1 + 1 + Value.getNbBytes( seqNumber );
-            encApRepPartLength += 1 + TLV.getNbBytes( seqNumberLength ) + seqNumberLength;
+            encApRepPartSeqLength += 1 + TLV.getNbBytes( seqNumberLength ) + seqNumberLength;
         }
         
-        
+        encApRepPartLength = 1 + TLV.getNbBytes( encApRepPartSeqLength ) + encApRepPartSeqLength;
+            
         return 1 + TLV.getNbBytes( encApRepPartLength ) + encApRepPartLength;
     }
 
@@ -218,14 +222,15 @@ public class EncApRepPart extends Kerber
      * EncApRepPart :
      * 
      * 0x7B LL
-     *   0xA0 0x11 
-     *     0x18 0x0F ttt ctime 
-     *   0xA1 LL 
-     *     0x02 LL NN cusec
-     *  [0xA2 LL
-     *     0x30 LL abcd] subkey
-     *  [0xA3 LL
-     *     0x02 LL NN] seq-number
+     *   0x30 LL
+     *     0xA0 0x11 
+     *       0x18 0x0F ttt ctime 
+     *     0xA1 LL 
+     *       0x02 LL NN cusec
+     *    [0xA2 LL
+     *       0x30 LL abcd] subkey
+     *    [0xA3 LL
+     *       0x02 LL NN] seq-number
      * </pre>
      * @return The constructed PDU.
      */
@@ -243,6 +248,10 @@ public class EncApRepPart extends Kerber
             buffer.put( (byte)KerberosConstants.ENC_AP_REP_PART_TAG );
             buffer.put( TLV.getBytes( encApRepPartLength ) );
 
+            // The EncApRepPart SEQ Tag
+            buffer.put( (byte)UniversalTag.SEQUENCE.getValue() );
+            buffer.put( TLV.getBytes( encApRepPartSeqLength ) );
+
             // The ctime ------------------------------------------------------
             // The tag
             buffer.put( (byte)KerberosConstants.ENC_AP_REP_PART_CTIME_TAG );
@@ -273,12 +282,15 @@ public class EncApRepPart extends Kerber
             }
             
             // The seq-number, if any -----------------------------------------
-            // The tag
-            buffer.put( (byte)KerberosConstants.ENC_AP_REP_PART_SEQ_NUMBER_TAG );
-            buffer.put( TLV.getBytes( seqNumberLength ) );
-            
-            // The value
-            Value.encode( buffer, seqNumber );
+            if ( seqNumber != null )
+            {
+                // The tag
+                buffer.put( (byte)KerberosConstants.ENC_AP_REP_PART_SEQ_NUMBER_TAG );
+                buffer.put( TLV.getBytes( seqNumberLength ) );
+                
+                // The value
+                Value.encode( buffer, seqNumber );
+            }
             
         }
         catch ( BufferOverflowException boe )

Added: directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/EncApRepPartDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/EncApRepPartDecoderTest.java?rev=1039333&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/EncApRepPartDecoderTest.java (added)
+++ directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/EncApRepPartDecoderTest.java Fri Nov 26 12:44:56 2010
@@ -0,0 +1,477 @@
+/*
+ *  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;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.nio.ByteBuffer;
+
+import org.apache.directory.junit.tools.Concurrent;
+import org.apache.directory.junit.tools.ConcurrentJunitRunner;
+import org.apache.directory.shared.asn1.ber.Asn1Container;
+import org.apache.directory.shared.asn1.ber.Asn1Decoder;
+import org.apache.directory.shared.asn1.codec.DecoderException;
+import org.apache.directory.shared.asn1.codec.EncoderException;
+import org.apache.directory.shared.kerberos.codec.encApRepPart.EncApRepPartContainer;
+import org.apache.directory.shared.kerberos.messages.EncApRepPart;
+import org.apache.directory.shared.ldap.util.StringTools;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+/**
+ * Test the decoder for a EncApRepPart message
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@RunWith(ConcurrentJunitRunner.class)
+@Concurrent()
+public class EncApRepPartDecoderTest
+{
+    /**
+     * Test the decoding of a EncApRepPart message
+     */
+    @Test
+    public void testDecodeFullEncApRepPart() throws Exception
+    {
+        Asn1Decoder kerberosDecoder = new Asn1Decoder();
+
+        ByteBuffer stream = ByteBuffer.allocate( 0x33 );
+        
+        stream.put( new byte[]
+        {
+          0x7B, 0x31,
+            0x30, 0x2F,
+              (byte)0xA0, 0x11,         // ctime 
+                0x18, 0x0F, 
+                  '2', '0', '1', '0', '1', '1', '1', '0', '1', '5', '4', '5', '2', '5', 'Z',
+              (byte)0xA1, 0x03,         // cusec
+                0x02, 0x01, 0x7F, 
+              (byte)0xA2, 0x0F,         // subkey
+                0x30, 0x0D,
+                  (byte)0xA0, 0x03,
+                    0x02, 0x01, 0x01,
+                  (byte)0xA1, 0x06,
+                    0x04, 0x04, 'A', 'B', 'C', 'D',
+              (byte)0xA3, 0x04,         // seq-number
+                0x02, 0x02, 
+                  0x30, 0x39, 
+        });
+
+        String decodedPdu = StringTools.dumpBytes( stream.array() );
+        stream.flip();
+
+        // Allocate a EncApRepPart Container
+        Asn1Container encApRepPartContainer = new EncApRepPartContainer();
+        encApRepPartContainer.setStream( stream );
+        
+        // Decode the EncApRepPart PDU
+        try
+        {
+            kerberosDecoder.decode( stream, encApRepPartContainer );
+        }
+        catch ( DecoderException de )
+        {
+            fail( de.getMessage() );
+        }
+
+        EncApRepPart encApRepPart = ((EncApRepPartContainer)encApRepPartContainer).getEncApRepPart();
+        
+        // Check the encoding
+        int length = encApRepPart.computeLength();
+
+        // Check the length
+        assertEquals( 0x33, length );
+        
+        // Check the encoding
+        ByteBuffer encodedPdu = ByteBuffer.allocate( length );
+        
+        try
+        {
+            encodedPdu = encApRepPart.encode( encodedPdu );
+            
+            // Check the length
+            assertEquals( 0x33, encodedPdu.limit() );
+            assertEquals( decodedPdu, StringTools.dumpBytes( encodedPdu.array() ) );
+        }
+        catch ( EncoderException ee )
+        {
+            fail();
+        }
+    }
+    
+    
+    /**
+     * Test the decoding of a EncApRepPart with nothing in it
+     */
+    @Test( expected = DecoderException.class)
+    public void testAuthenticatorEmpty() throws DecoderException
+    {
+        Asn1Decoder kerberosDecoder = new Asn1Decoder();
+
+        ByteBuffer stream = ByteBuffer.allocate( 0x02 );
+        
+        stream.put( new byte[]
+            { 0x7B, 0x00 } );
+
+        stream.flip();
+
+        // Allocate a EncApRepPart Container
+        Asn1Container encApRepPartContainer = new EncApRepPartContainer();
+
+        // Decode the EncApRepPart PDU
+        kerberosDecoder.decode( stream, encApRepPartContainer );
+        fail();
+    }
+    
+    
+    /**
+     * Test the decoding of a EncApRepPart with empty sequence
+     */
+    @Test( expected = DecoderException.class)
+    public void testEncApRepPartEmptySequence() throws DecoderException
+    {
+        Asn1Decoder kerberosDecoder = new Asn1Decoder();
+
+        ByteBuffer stream = ByteBuffer.allocate( 0x04 );
+        
+        stream.put( new byte[]
+            { 
+                0x7B, 0x02,
+                  0x30, 0x00
+            } );
+
+        stream.flip();
+
+        // Allocate a EncApRepPart Container
+        Asn1Container encApRepPartContainer = new EncApRepPartContainer();
+
+        // Decode the EncApRepPart PDU
+        kerberosDecoder.decode( stream, encApRepPartContainer );
+        fail();
+    }
+    
+    
+    /**
+     * Test the decoding of a EncApRepPart with empty ctime tag
+     */
+    @Test( expected = DecoderException.class)
+    public void testEncApRepPartEmptyCTimeg() throws DecoderException
+    {
+        Asn1Decoder kerberosDecoder = new Asn1Decoder();
+
+        ByteBuffer stream = ByteBuffer.allocate( 0x06 );
+        
+        stream.put( new byte[]
+            { 
+                0x7B, 0x04,
+                  0x30, 0x02,
+                    (byte)0xA0, 0x00
+            } );
+
+        stream.flip();
+
+        // Allocate a EncApRepPart Container
+        Asn1Container encApRepPartContainer = new EncApRepPartContainer();
+
+        // Decode the EncApRepPart PDU
+        kerberosDecoder.decode( stream, encApRepPartContainer );
+        fail();
+    }
+    
+    
+    /**
+     * Test the decoding of a EncApRepPart with no CTime
+     */
+    @Test( expected = DecoderException.class)
+    public void testEncApRepPartNoCtime() throws DecoderException
+    {
+        Asn1Decoder kerberosDecoder = new Asn1Decoder();
+
+        ByteBuffer stream = ByteBuffer.allocate( 0x20 );
+        
+        stream.put( new byte[]
+            { 
+              0x7B, 0x1E,
+                0x30, 0x1C,
+                  (byte)0xA1, 0x03,         // cusec
+                    0x02, 0x01, 0x7F, 
+                  (byte)0xA2, 0x0F,         // subkey
+                    0x30, 0x0D,
+                      (byte)0xA0, 0x03,
+                        0x02, 0x01, 0x01,
+                      (byte)0xA1, 0x06,
+                        0x04, 0x04, 'A', 'B', 'C', 'D',
+                  (byte)0xA3, 0x04,         // seq-number
+                    0x02, 0x02, 
+                      0x30, 0x39, 
+            } );
+
+        stream.flip();
+
+        // Allocate a EncApRepPart Container
+        Asn1Container encApRepPartContainer = new EncApRepPartContainer();
+
+        // Decode the EncApRepPart PDU
+        kerberosDecoder.decode( stream, encApRepPartContainer );
+        fail();
+    }
+    
+    
+    /**
+     * Test the decoding of a EncApRepPart with no cusec
+     */
+    @Test( expected = DecoderException.class)
+    public void testEncApRepPartNoCusec() throws DecoderException
+    {
+        Asn1Decoder kerberosDecoder = new Asn1Decoder();
+
+        ByteBuffer stream = ByteBuffer.allocate( 0x2F );
+        
+        stream.put( new byte[]
+            { 
+              0x7B, 0x2C,
+                0x30, 0x2A,
+                  (byte)0xA0, 0x11,         // ctime 
+                    0x18, 0x0F, 
+                      '2', '0', '1', '0', '1', '1', '1', '0', '1', '5', '4', '5', '2', '5', 'Z',
+                  (byte)0xA2, 0x0F,         // subkey
+                    0x30, 0x0D,
+                      (byte)0xA0, 0x03,
+                        0x02, 0x01, 0x01,
+                      (byte)0xA1, 0x06,
+                        0x04, 0x04, 'A', 'B', 'C', 'D',
+                  (byte)0xA3, 0x04,         // seq-number
+                    0x02, 0x02, 
+                      0x30, 0x39, 
+            } );
+
+        stream.flip();
+
+        // Allocate a EncApRepPart Container
+        Asn1Container encApRepPartContainer = new EncApRepPartContainer();
+
+        // Decode the EncApRepPart PDU
+        kerberosDecoder.decode( stream, encApRepPartContainer );
+        fail();
+    }
+
+
+    /**
+     * Test the decoding of a EncApRepPart message with no subKey
+     */
+    @Test
+    public void testDecodeEncApRepPartNoSubKey() throws Exception
+    {
+        Asn1Decoder kerberosDecoder = new Asn1Decoder();
+
+        ByteBuffer stream = ByteBuffer.allocate( 0x22 );
+        
+        stream.put( new byte[]
+        {
+          0x7B, 0x20,
+            0x30, 0x1E,
+              (byte)0xA0, 0x11,         // ctime 
+                0x18, 0x0F, 
+                  '2', '0', '1', '0', '1', '1', '1', '0', '1', '5', '4', '5', '2', '5', 'Z',
+              (byte)0xA1, 0x03,         // cusec
+                0x02, 0x01, 0x7F, 
+              (byte)0xA3, 0x04,         // seq-number
+                0x02, 0x02, 
+                  0x30, 0x39, 
+        });
+
+        String decodedPdu = StringTools.dumpBytes( stream.array() );
+        stream.flip();
+
+        // Allocate a EncApRepPart Container
+        Asn1Container encApRepPartContainer = new EncApRepPartContainer();
+        encApRepPartContainer.setStream( stream );
+        
+        // Decode the EncApRepPart PDU
+        try
+        {
+            kerberosDecoder.decode( stream, encApRepPartContainer );
+        }
+        catch ( DecoderException de )
+        {
+            fail( de.getMessage() );
+        }
+
+        EncApRepPart encApRepPart = ((EncApRepPartContainer)encApRepPartContainer).getEncApRepPart();
+        
+        // Check the encoding
+        int length = encApRepPart.computeLength();
+
+        // Check the length
+        assertEquals( 0x22, length );
+        
+        // Check the encoding
+        ByteBuffer encodedPdu = ByteBuffer.allocate( length );
+        
+        try
+        {
+            encodedPdu = encApRepPart.encode( encodedPdu );
+            
+            // Check the length
+            assertEquals( 0x22, encodedPdu.limit() );
+            assertEquals( decodedPdu, StringTools.dumpBytes( encodedPdu.array() ) );
+        }
+        catch ( EncoderException ee )
+        {
+            fail();
+        }
+    }
+    
+    
+    /**
+     * Test the decoding of a EncApRepPart message with no seq-number
+     */
+    @Test
+    public void testDecodeEncApRepPartNoSeqNumber() throws Exception
+    {
+        Asn1Decoder kerberosDecoder = new Asn1Decoder();
+
+        ByteBuffer stream = ByteBuffer.allocate( 0x2D );
+        
+        stream.put( new byte[]
+        {
+          0x7B, 0x2B,
+            0x30, 0x29,
+              (byte)0xA0, 0x11,         // ctime 
+                0x18, 0x0F, 
+                  '2', '0', '1', '0', '1', '1', '1', '0', '1', '5', '4', '5', '2', '5', 'Z',
+              (byte)0xA1, 0x03,         // cusec
+                0x02, 0x01, 0x7F, 
+              (byte)0xA2, 0x0F,         // subkey
+                0x30, 0x0D,
+                  (byte)0xA0, 0x03,
+                    0x02, 0x01, 0x01,
+                  (byte)0xA1, 0x06,
+                    0x04, 0x04, 'A', 'B', 'C', 'D',
+        });
+
+        String decodedPdu = StringTools.dumpBytes( stream.array() );
+        stream.flip();
+
+        // Allocate a EncApRepPart Container
+        Asn1Container encApRepPartContainer = new EncApRepPartContainer();
+        encApRepPartContainer.setStream( stream );
+        
+        // Decode the EncApRepPart PDU
+        try
+        {
+            kerberosDecoder.decode( stream, encApRepPartContainer );
+        }
+        catch ( DecoderException de )
+        {
+            fail( de.getMessage() );
+        }
+
+        EncApRepPart encApRepPart = ((EncApRepPartContainer)encApRepPartContainer).getEncApRepPart();
+        
+        // Check the encoding
+        int length = encApRepPart.computeLength();
+
+        // Check the length
+        assertEquals( 0x2D, length );
+        
+        // Check the encoding
+        ByteBuffer encodedPdu = ByteBuffer.allocate( length );
+        
+        try
+        {
+            encodedPdu = encApRepPart.encode( encodedPdu );
+            
+            // Check the length
+            assertEquals( 0x2D, encodedPdu.limit() );
+            assertEquals( decodedPdu, StringTools.dumpBytes( encodedPdu.array() ) );
+        }
+        catch ( EncoderException ee )
+        {
+            fail();
+        }
+    }
+    
+    
+    /**
+     * Test the decoding of a EncApRepPart message with no subKey nor seq-number
+     */
+    @Test
+    public void testDecodeEncApRepPartNoSubKeyNoSeqNumber() throws Exception
+    {
+        Asn1Decoder kerberosDecoder = new Asn1Decoder();
+
+        ByteBuffer stream = ByteBuffer.allocate( 0x1C );
+        
+        stream.put( new byte[]
+        {
+          0x7B, 0x1A,
+            0x30, 0x18,
+              (byte)0xA0, 0x11,         // ctime 
+                0x18, 0x0F, 
+                  '2', '0', '1', '0', '1', '1', '1', '0', '1', '5', '4', '5', '2', '5', 'Z',
+              (byte)0xA1, 0x03,         // cusec
+                0x02, 0x01, 0x7F, 
+        });
+
+        String decodedPdu = StringTools.dumpBytes( stream.array() );
+        stream.flip();
+
+        // Allocate a EncApRepPart Container
+        Asn1Container encApRepPartContainer = new EncApRepPartContainer();
+        encApRepPartContainer.setStream( stream );
+        
+        // Decode the EncApRepPart PDU
+        try
+        {
+            kerberosDecoder.decode( stream, encApRepPartContainer );
+        }
+        catch ( DecoderException de )
+        {
+            fail( de.getMessage() );
+        }
+
+        EncApRepPart encApRepPart = ((EncApRepPartContainer)encApRepPartContainer).getEncApRepPart();
+        
+        // Check the encoding
+        int length = encApRepPart.computeLength();
+
+        // Check the length
+        assertEquals( 0x1C, length );
+        
+        // Check the encoding
+        ByteBuffer encodedPdu = ByteBuffer.allocate( length );
+        
+        try
+        {
+            encodedPdu = encApRepPart.encode( encodedPdu );
+            
+            // Check the length
+            assertEquals( 0x1C, encodedPdu.limit() );
+            assertEquals( decodedPdu, StringTools.dumpBytes( encodedPdu.array() ) );
+        }
+        catch ( EncoderException ee )
+        {
+            fail();
+        }
+    }
+}



Mime
View raw message