directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1034628 - in /directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody: KdcReqBodyGrammar.java actions/StoreAddresses.java actions/StoreEncAuthorizationData.java
Date Sat, 13 Nov 2010 02:26:56 GMT
Author: elecharny
Date: Sat Nov 13 02:26:56 2010
New Revision: 1034628

URL: http://svn.apache.org/viewvc?rev=1034628&view=rev
Log:
o Added the enc-authorization-data decoding
o Added some log, removed some printStackTrace

Added:
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/StoreEncAuthorizationData.java
Modified:
    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/actions/StoreAddresses.java

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=1034628&r1=1034627&r2=1034628&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:26:56 2010
@@ -31,6 +31,7 @@ import org.apache.directory.shared.kerbe
 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.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;
@@ -310,6 +311,28 @@ public final class KdcReqBodyGrammar ext
             KdcReqBodyStatesEnum.KDC_REQ_BODY_ETYPE_STATE, KdcReqBodyStatesEnum.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[KdcReqBodyStatesEnum.KDC_REQ_BODY_ETYPE_STATE.ordinal()][KerberosConstants.KDC_REQ_BODY_ENC_AUTHZ_DATA_TAG]
= new GrammarTransition(
+            KdcReqBodyStatesEnum.KDC_REQ_BODY_ETYPE_STATE, KdcReqBodyStatesEnum.KDC_REQ_BODY_ENC_AUTH_DATA_STATE,
KerberosConstants.KDC_REQ_BODY_ENC_AUTHZ_DATA_TAG,
+            new StoreEncAuthorizationData() );
+
+    
+    
+
+        // --------------------------------------------------------------------------------------------
+        // Transition from addresses values to encAuthorizationData
+        // --------------------------------------------------------------------------------------------
+        // KDC-REQ-BODY    ::= SEQUENCE {
+        //         ...
+        //         enc-authorization-data  [10]
+        super.transitions[KdcReqBodyStatesEnum.KDC_REQ_BODY_ADDRESSES_STATE.ordinal()][KerberosConstants.KDC_REQ_BODY_ENC_AUTHZ_DATA_TAG]
= new GrammarTransition(
+            KdcReqBodyStatesEnum.KDC_REQ_BODY_ADDRESSES_STATE, KdcReqBodyStatesEnum.KDC_REQ_BODY_ENC_AUTH_DATA_STATE,
KerberosConstants.KDC_REQ_BODY_ENC_AUTHZ_DATA_TAG,
+            new StoreEncAuthorizationData() );
     }
 
 

Modified: 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=1034628&r1=1034627&r2=1034628&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/StoreAddresses.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/StoreAddresses.java
Sat Nov 13 02:26:56 2010
@@ -92,7 +92,6 @@ public class StoreAddresses extends Gram
         }
         catch ( DecoderException de )
         {
-            de.printStackTrace();
             throw de;
         }
 
@@ -102,5 +101,12 @@ public class StoreAddresses extends Gram
         
         // Update the parent
         container.setParentTLV( tlv.getParent() );
+        
+        container.setGrammarEndAllowed( true );
+        
+        if ( IS_DEBUG )
+        {
+            LOG.debug( "Addresses : {}", hostAddresses );
+        }
     }
 }

Added: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/StoreEncAuthorizationData.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/StoreEncAuthorizationData.java?rev=1034628&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/StoreEncAuthorizationData.java
(added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/StoreEncAuthorizationData.java
Sat Nov 13 02:26:56 2010
@@ -0,0 +1,112 @@
+/*
+ *  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.encryptedData.EncryptedDataContainer;
+import org.apache.directory.shared.kerberos.codec.kdcReqBody.KdcReqBodyContainer;
+import org.apache.directory.shared.kerberos.components.EncryptedData;
+import org.apache.directory.shared.kerberos.components.KdcReqBody;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store the EncAuthorizationData
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoreEncAuthorizationData extends GrammarAction
+{
+    /** The logger */
+    private static final Logger LOG = LoggerFactory.getLogger( StoreEncAuthorizationData.class
);
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
+
+
+    /**
+     * Instantiates a new StoreEncAuthorizationData action.
+     */
+    public StoreEncAuthorizationData()
+    {
+        super( "KDC-REQ-BODY enc-authorization-data" );
+    }
+
+
+    /**
+     * {@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 EncAuthorizationData
+        Asn1Decoder encryptedDataDecoder = new Asn1Decoder();
+        
+        EncryptedDataContainer encryptedDataContainer = new EncryptedDataContainer();
+        
+        // Passes the Stream to the decoder
+        encryptedDataContainer.setStream( container.getStream() );
+
+        // Decode the HostAddresses PDU
+        try
+        {
+            encryptedDataDecoder.decode( container.getStream(), encryptedDataContainer );
+        }
+        catch ( DecoderException de )
+        {
+            throw de;
+        }
+
+        // Store the encryptedData in the container
+        EncryptedData encryptedData = encryptedDataContainer.getEncryptedData();
+        kdcReqBody.setEncAuthorizationData( encryptedData );
+        
+        // Update the parent
+        container.setParentTLV( tlv.getParent() );
+        
+        container.setGrammarEndAllowed( true );
+        
+        if ( IS_DEBUG )
+        {
+            LOG.debug( "enc-authorization-data : {}", encryptedData );
+        }
+    }
+}



Mime
View raw message