directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1034626 - in /directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec: hostAddresses/actions/ kdcReqBody/ kdcReqBody/actions/
Date Sat, 13 Nov 2010 02:12:20 GMT
Author: elecharny
Date: Sat Nov 13 02:12:20 2010
New Revision: 1034626

URL: http://svn.apache.org/viewvc?rev=1034626&view=rev
Log:
o Added the Adresses processing for KDC-REQ-BODY
o Fixed the way it's processed, by adding an atrocious hack to get the decoder called inside
the decoder called from the external decoder does not fail due to a bad expectedLength. Not
proud of it :/

Added:
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/StoreAddresses.java
Modified:
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/hostAddresses/actions/AddHostAddress.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/KdcReqBodyGrammar.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/KdcReqBodyStatesEnum.java

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/hostAddresses/actions/AddHostAddress.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/hostAddresses/actions/AddHostAddress.java?rev=1034626&r1=1034625&r2=1034626&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/hostAddresses/actions/AddHostAddress.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/hostAddresses/actions/AddHostAddress.java
Sat Nov 13 02:12:20 2010
@@ -79,27 +79,33 @@ public class AddHostAddress extends Gram
         Asn1Decoder hostAddressDecoder = new Asn1Decoder();
         
         HostAddressContainer hostAddressContainer = new HostAddressContainer();
+        hostAddressContainer.setStream( container.getStream() );
+        
+        // Compute the start position in the stream for the HostAdress to decode : 
+        // We have to move back to the HostAddress tag
+        int start = container.getStream().position() - 1 - tlv.getLengthNbBytes();
+        container.getStream().position( start );
 
         // Decode the HostAddress PDU
         try
         {
-            // We have to move back the Stream 
-            int moveBack = 1 + TLV.getNbBytes( tlv.getLength() );
-            container.getStream().position( container.getStream().position() - moveBack );
-            
             hostAddressDecoder.decode( container.getStream(), hostAddressContainer );
         }
         catch ( DecoderException de )
         {
             throw de;
         }
+        
+        // Update the expected length for the current TLV
+        tlv.setExpectedLength( tlv.getExpectedLength() - tlv.getLength() );
+
+        // Update the parent
+        container.setParentTLV( tlv.getParent() );
 
         // Store the hostAddress in the container
         HostAddress hostAddress = hostAddressContainer.getHostAddress();
         hostAddressesContainer.addHostAddress( hostAddress );
         
-        // Update the parent
-        container.setParentTLV( tlv.getParent() );
 
         if ( IS_DEBUG )
         {

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/KdcReqBodyGrammar.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/KdcReqBodyGrammar.java?rev=1034626&r1=1034625&r2=1034626&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/KdcReqBodyGrammar.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/KdcReqBodyGrammar.java
Sat Nov 13 02:12:20 2010
@@ -29,6 +29,7 @@ import org.apache.directory.shared.kerbe
 import org.apache.directory.shared.kerberos.codec.kdcReqBody.actions.AddEType;
 import org.apache.directory.shared.kerberos.codec.kdcReqBody.actions.ETypeSequence;
 import org.apache.directory.shared.kerberos.codec.kdcReqBody.actions.KdcReqBodyInit;
+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.StoreFrom;
 import org.apache.directory.shared.kerberos.codec.kdcReqBody.actions.StoreKdcOptions;
@@ -215,92 +216,101 @@ public final class KdcReqBodyGrammar ext
         // KDC-REQ-BODY    ::= SEQUENCE {
         //         ...
         //         till                    [5] KerberosTime
-       super.transitions[KdcReqBodyStatesEnum.KDC_REQ_BODY_TILL_STATE.ordinal()][UniversalTag.GENERALIZED_TIME.getValue()]
= new GrammarTransition(
+        super.transitions[KdcReqBodyStatesEnum.KDC_REQ_BODY_TILL_STATE.ordinal()][UniversalTag.GENERALIZED_TIME.getValue()]
= new GrammarTransition(
             KdcReqBodyStatesEnum.KDC_REQ_BODY_TILL_STATE, KdcReqBodyStatesEnum.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[KdcReqBodyStatesEnum.KDC_REQ_BODY_RTIME_OR_NONCE_TAG_STATE.ordinal()][KerberosConstants.KDC_REQ_BODY_RTIME_TAG]
= new GrammarTransition(
-           KdcReqBodyStatesEnum.KDC_REQ_BODY_RTIME_OR_NONCE_TAG_STATE, KdcReqBodyStatesEnum.KDC_REQ_BODY_RTIME_STATE,
KerberosConstants.KDC_REQ_BODY_RTIME_TAG,
+        // --------------------------------------------------------------------------------------------
+        // Transition from till value to rtime 
+        // --------------------------------------------------------------------------------------------
+        // KDC-REQ-BODY    ::= SEQUENCE {
+        //         ...
+        //         rtime                    [6] 
+        super.transitions[KdcReqBodyStatesEnum.KDC_REQ_BODY_RTIME_OR_NONCE_TAG_STATE.ordinal()][KerberosConstants.KDC_REQ_BODY_RTIME_TAG]
= new GrammarTransition(
+            KdcReqBodyStatesEnum.KDC_REQ_BODY_RTIME_OR_NONCE_TAG_STATE, KdcReqBodyStatesEnum.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[KdcReqBodyStatesEnum.KDC_REQ_BODY_RTIME_OR_NONCE_TAG_STATE.ordinal()][KerberosConstants.KDC_REQ_BODY_NONCE_TAG]
= new GrammarTransition(
-          KdcReqBodyStatesEnum.KDC_REQ_BODY_RTIME_OR_NONCE_TAG_STATE, KdcReqBodyStatesEnum.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[KdcReqBodyStatesEnum.KDC_REQ_BODY_RTIME_STATE.ordinal()][UniversalTag.GENERALIZED_TIME.getValue()]
= new GrammarTransition(
-         KdcReqBodyStatesEnum.KDC_REQ_BODY_RTIME_STATE, KdcReqBodyStatesEnum.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[KdcReqBodyStatesEnum.KDC_REQ_BODY_NONCE_TAG_STATE.ordinal()][KerberosConstants.KDC_REQ_BODY_NONCE_TAG]
= new GrammarTransition(
-        KdcReqBodyStatesEnum.KDC_REQ_BODY_NONCE_TAG_STATE, KdcReqBodyStatesEnum.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[KdcReqBodyStatesEnum.KDC_REQ_BODY_NONCE_STATE.ordinal()][UniversalTag.INTEGER.getValue()]
= new GrammarTransition(
-        KdcReqBodyStatesEnum.KDC_REQ_BODY_NONCE_TAG_STATE, KdcReqBodyStatesEnum.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[KdcReqBodyStatesEnum.KDC_REQ_BODY_ETYPE_TAG_STATE.ordinal()][KerberosConstants.KDC_REQ_BODY_ETYPE_TAG]
= new GrammarTransition(
-       KdcReqBodyStatesEnum.KDC_REQ_BODY_ETYPE_TAG_STATE, KdcReqBodyStatesEnum.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[KdcReqBodyStatesEnum.KDC_REQ_BODY_ETYPE_SEQ_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()]
= new GrammarTransition(
-       KdcReqBodyStatesEnum.KDC_REQ_BODY_ETYPE_SEQ_STATE, KdcReqBodyStatesEnum.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[KdcReqBodyStatesEnum.KDC_REQ_BODY_ETYPE_STATE.ordinal()][UniversalTag.INTEGER.getValue()]
= new GrammarTransition(
-      KdcReqBodyStatesEnum.KDC_REQ_BODY_ETYPE_STATE, KdcReqBodyStatesEnum.KDC_REQ_BODY_ETYPE_STATE,
UniversalTag.INTEGER.getValue(),
-      new AddEType() );
+        // --------------------------------------------------------------------------------------------
+        // Transition from till value to nonce 
+        // --------------------------------------------------------------------------------------------
+        // KDC-REQ-BODY    ::= SEQUENCE {
+        //         ...
+        //         nonce                    [7]
+        super.transitions[KdcReqBodyStatesEnum.KDC_REQ_BODY_RTIME_OR_NONCE_TAG_STATE.ordinal()][KerberosConstants.KDC_REQ_BODY_NONCE_TAG]
= new GrammarTransition(
+            KdcReqBodyStatesEnum.KDC_REQ_BODY_RTIME_OR_NONCE_TAG_STATE, KdcReqBodyStatesEnum.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[KdcReqBodyStatesEnum.KDC_REQ_BODY_RTIME_STATE.ordinal()][UniversalTag.GENERALIZED_TIME.getValue()]
= new GrammarTransition(
+            KdcReqBodyStatesEnum.KDC_REQ_BODY_RTIME_STATE, KdcReqBodyStatesEnum.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[KdcReqBodyStatesEnum.KDC_REQ_BODY_NONCE_TAG_STATE.ordinal()][KerberosConstants.KDC_REQ_BODY_NONCE_TAG]
= new GrammarTransition(
+           KdcReqBodyStatesEnum.KDC_REQ_BODY_NONCE_TAG_STATE, KdcReqBodyStatesEnum.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[KdcReqBodyStatesEnum.KDC_REQ_BODY_NONCE_STATE.ordinal()][UniversalTag.INTEGER.getValue()]
= new GrammarTransition(
+            KdcReqBodyStatesEnum.KDC_REQ_BODY_NONCE_TAG_STATE, KdcReqBodyStatesEnum.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[KdcReqBodyStatesEnum.KDC_REQ_BODY_ETYPE_TAG_STATE.ordinal()][KerberosConstants.KDC_REQ_BODY_ETYPE_TAG]
= new GrammarTransition(
+            KdcReqBodyStatesEnum.KDC_REQ_BODY_ETYPE_TAG_STATE, KdcReqBodyStatesEnum.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[KdcReqBodyStatesEnum.KDC_REQ_BODY_ETYPE_SEQ_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()]
= new GrammarTransition(
+            KdcReqBodyStatesEnum.KDC_REQ_BODY_ETYPE_SEQ_STATE, KdcReqBodyStatesEnum.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[KdcReqBodyStatesEnum.KDC_REQ_BODY_ETYPE_STATE.ordinal()][UniversalTag.INTEGER.getValue()]
= new GrammarTransition(
+            KdcReqBodyStatesEnum.KDC_REQ_BODY_ETYPE_STATE, KdcReqBodyStatesEnum.KDC_REQ_BODY_ETYPE_STATE,
UniversalTag.INTEGER.getValue(),
+            new AddEType() );
+
+        // --------------------------------------------------------------------------------------------
+        // Transition from EType values to addresses
+        // --------------------------------------------------------------------------------------------
+        // KDC-REQ-BODY    ::= SEQUENCE {
+        //         ...
+        //         addresses               [9]
+        super.transitions[KdcReqBodyStatesEnum.KDC_REQ_BODY_ETYPE_STATE.ordinal()][KerberosConstants.KDC_REQ_BODY_ADDRESSES_TAG]
= new GrammarTransition(
+            KdcReqBodyStatesEnum.KDC_REQ_BODY_ETYPE_STATE, KdcReqBodyStatesEnum.KDC_REQ_BODY_ADDRESSES_STATE,
KerberosConstants.KDC_REQ_BODY_ADDRESSES_TAG,
+            new StoreAddresses() );
+
+    }
 
 
     // ~ Methods

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/KdcReqBodyStatesEnum.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/KdcReqBodyStatesEnum.java?rev=1034626&r1=1034625&r2=1034626&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/KdcReqBodyStatesEnum.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/KdcReqBodyStatesEnum.java
Sat Nov 13 02:12:20 2010
@@ -65,17 +65,16 @@ public enum KdcReqBodyStatesEnum impleme
     KDC_REQ_BODY_ETYPE_SEQ_STATE,               // 17
     KDC_REQ_BODY_ETYPE_STATE,                   // 18
 
-    KDC_REQ_BODY_ADDRESSES_TAG_STATE,           // 21
-    KDC_REQ_BODY_ADDRESSES_STATE,               // 22
+    KDC_REQ_BODY_ADDRESSES_STATE,               // 19
 
-    KDC_REQ_BODY_ENC_AUTH_DATA_TAG_STATE,       // 2
-    KDC_REQ_BODY_ENC_AUTH_DATA_STATE,           // 2
+    KDC_REQ_BODY_ENC_AUTH_DATA_STATE,           // 20
 
-    KDC_REQ_BODY_ADDITIONAL_TICKETS_TAG_STATE,  // 2
-    KDC_REQ_BODY_ADDITIONAL_TICKETS_STATE,      // 2
+    KDC_REQ_BODY_ADDITIONAL_TICKETS_TAG_STATE,  // 21
+    KDC_REQ_BODY_ADDITIONAL_TICKETS_SEQ_STATE,  // 22
+    KDC_REQ_BODY_ADDITIONAL_TICKETS_STATE,      // 23
 
     // End
-    LAST_KDC_REQ_BODY_STATE;              // 8
+    LAST_KDC_REQ_BODY_STATE;                    // 24
 
     
     /**

Added: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/StoreAddresses.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/StoreAddresses.java?rev=1034626&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/StoreAddresses.java
(added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/StoreAddresses.java
Sat Nov 13 02:12:20 2010
@@ -0,0 +1,106 @@
+/*
+ *  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.kdcReqBody.actions;
+
+
+import org.apache.directory.shared.asn1.ber.Asn1Container;
+import org.apache.directory.shared.asn1.ber.Asn1Decoder;
+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.hostAddresses.HostAddressesContainer;
+import org.apache.directory.shared.kerberos.codec.kdcReqBody.KdcReqBodyContainer;
+import org.apache.directory.shared.kerberos.components.HostAddresses;
+import org.apache.directory.shared.kerberos.components.KdcReqBody;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store the Addresses
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoreAddresses extends GrammarAction
+{
+    /** The logger */
+    private static final Logger LOG = LoggerFactory.getLogger( StoreAddresses.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
+
+
+    /**
+     * Instantiates a new StoreAddresses action.
+     */
+    public StoreAddresses()
+    {
+        super( "KDC-REQ-BODY addresses" );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void action( Asn1Container container ) throws DecoderException
+    {
+        KdcReqBodyContainer kdcReqBodyContainer = ( KdcReqBodyContainer ) container;
+
+        TLV tlv = kdcReqBodyContainer.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 ) );
+        }
+        
+        KdcReqBody kdcReqBody = kdcReqBodyContainer.getKdcReqBody();
+        
+        // Now, let's decode the HostAddresses
+        Asn1Decoder hostAddressesDecoder = new Asn1Decoder();
+        
+        HostAddressesContainer hostAddressesContainer = new HostAddressesContainer();
+        
+        // Passes the Stream to the decoder
+        hostAddressesContainer.setStream( container.getStream() );
+
+        // Decode the HostAddresses PDU
+        try
+        {
+            hostAddressesDecoder.decode( container.getStream(), hostAddressesContainer );
+        }
+        catch ( DecoderException de )
+        {
+            de.printStackTrace();
+            throw de;
+        }
+
+        // Store the HostAddresses in the container
+        HostAddresses hostAddresses = hostAddressesContainer.getHostAddresses();
+        kdcReqBody.setAddresses( hostAddresses );
+        
+        // Update the parent
+        container.setParentTLV( tlv.getParent() );
+    }
+}



Mime
View raw message