directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1040152 - in /directory/apacheds/trunk/kerberos-codec/src: main/java/org/apache/directory/shared/kerberos/codec/authorizationData/actions/ main/java/org/apache/directory/shared/kerberos/codec/encryptedData/actions/ main/java/org/apache/dir...
Date Mon, 29 Nov 2010 15:35:37 GMT
Author: elecharny
Date: Mon Nov 29 15:35:36 2010
New Revision: 1040152

URL: http://svn.apache.org/viewvc?rev=1040152&view=rev
Log:
o Reviewed the EncryptionType class, tests, etc
o Added some logs

Modified:
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/authorizationData/actions/StoreAdType.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encryptedData/actions/StoreEType.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encryptionKey/EncryptionKeyContainer.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encryptionKey/EncryptionKeyGrammar.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encryptionKey/EncryptionKeyStatesEnum.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encryptionKey/actions/EncryptionKeyInit.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encryptionKey/actions/StoreKeyType.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/hostAddress/actions/StoreAddress.java
    directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/EncryptionKeyDecoderTest.java

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/authorizationData/actions/StoreAdType.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/authorizationData/actions/StoreAdType.java?rev=1040152&r1=1040151&r2=1040152&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/authorizationData/actions/StoreAdType.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/authorizationData/actions/StoreAdType.java
Mon Nov 29 15:35:36 2010
@@ -23,8 +23,11 @@ package org.apache.directory.shared.kerb
 import org.apache.directory.shared.asn1.ber.Asn1Container;
 import org.apache.directory.shared.asn1.codec.actions.AbstractReadInteger;
 import org.apache.directory.shared.kerberos.codec.authorizationData.AuthorizationDataContainer;
+import org.apache.directory.shared.kerberos.codec.encryptedData.actions.StoreEType;
 import org.apache.directory.shared.kerberos.codec.types.AuthorizationType;
 import org.apache.directory.shared.kerberos.components.AuthorizationData;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 /**
@@ -34,6 +37,12 @@ import org.apache.directory.shared.kerbe
  */
 public class StoreAdType extends AbstractReadInteger
 {
+    /** The logger */
+    private static final Logger LOG = LoggerFactory.getLogger( StoreEType.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
+
     /**
      * Instantiates a new AuthorizationDataAdType action.
      */
@@ -56,5 +65,10 @@ public class StoreAdType extends Abstrac
         AuthorizationData authorizationData = authDataContainer.getAuthorizationData();
         authorizationData.createNewAD();
         authorizationData.setCurrentAdType( authType );
+        
+        if ( IS_DEBUG )
+        {
+            LOG.debug( "zdType : {}", authType );
+        }
     }
 }

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encryptedData/actions/StoreEType.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encryptedData/actions/StoreEType.java?rev=1040152&r1=1040151&r2=1040152&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encryptedData/actions/StoreEType.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encryptedData/actions/StoreEType.java
Mon Nov 29 15:35:36 2010
@@ -25,6 +25,8 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.kerberos.codec.encryptedData.EncryptedDataContainer;
 import org.apache.directory.shared.kerberos.codec.types.EncryptionType;
 import org.apache.directory.shared.kerberos.components.EncryptedData;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 /**
@@ -34,6 +36,12 @@ import org.apache.directory.shared.kerbe
  */
 public class StoreEType extends AbstractReadInteger
 {
+    /** The logger */
+    private static final Logger LOG = LoggerFactory.getLogger( StoreEType.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
+
     /**
      * Instantiates a new EncryptedPartEType action.
      */
@@ -55,5 +63,10 @@ public class StoreEType extends Abstract
         
         EncryptedData encryptedData = encryptedDataContainer.getEncryptedData();
         encryptedData.setEType( encryptionType );
+        
+        if ( IS_DEBUG )
+        {
+            LOG.debug( "e-type : {}", encryptionType );
+        }
     }
 }

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encryptionKey/EncryptionKeyContainer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encryptionKey/EncryptionKeyContainer.java?rev=1040152&r1=1040151&r2=1040152&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encryptionKey/EncryptionKeyContainer.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encryptionKey/EncryptionKeyContainer.java
Mon Nov 29 15:35:36 2010
@@ -31,7 +31,7 @@ import org.apache.directory.shared.kerbe
 public class EncryptionKeyContainer extends AbstractContainer
 {
     /** holds EncryptionKey */
-    private EncryptionKey encKey;
+    private EncryptionKey encryptionKey;
 
     /**
      * Creates a new EncryptionKeyContainer object.
@@ -50,17 +50,17 @@ public class EncryptionKeyContainer exte
      */
     public EncryptionKey getEncryptionKey()
     {
-        return encKey;
+        return encryptionKey;
     }
 
     
     /**
      * Set a EncryptionKey Object into the container
      * 
-     * @param encKey The EncryptionKey to set.
+     * @param encryptionKey The EncryptionKey to set.
      */
-    public void setEncryptionKey( EncryptionKey encKey )
+    public void setEncryptionKey( EncryptionKey encryptionKey )
     {
-        this.encKey = encKey;
+        this.encryptionKey = encryptionKey;
     }
 }

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encryptionKey/EncryptionKeyGrammar.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encryptionKey/EncryptionKeyGrammar.java?rev=1040152&r1=1040151&r2=1040152&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encryptionKey/EncryptionKeyGrammar.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encryptionKey/EncryptionKeyGrammar.java
Mon Nov 29 15:35:36 2010
@@ -60,7 +60,7 @@ public final class EncryptionKeyGrammar 
         setName( EncryptionKeyGrammar.class.getName() );
 
         // Create the transitions table
-        super.transitions = new GrammarTransition[EncryptionKeyStatesEnum.LAST_ENCKEY_STATE.ordinal()][256];
+        super.transitions = new GrammarTransition[EncryptionKeyStatesEnum.LAST_ENCRYPTION_KEY_STATE.ordinal()][256];
 
         // ============================================================================================
         // EncryptionKey 
@@ -70,7 +70,7 @@ public final class EncryptionKeyGrammar 
         // --------------------------------------------------------------------------------------------
         // EncryptionKey         ::= SEQUENCE {
         super.transitions[EncryptionKeyStatesEnum.START_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()]
= new GrammarTransition(
-            EncryptionKeyStatesEnum.START_STATE, EncryptionKeyStatesEnum.ENCKEY_SEQ_STATE,
UniversalTag.SEQUENCE.getValue(),
+            EncryptionKeyStatesEnum.START_STATE, EncryptionKeyStatesEnum.ENCRYPTION_KEY_SEQ_STATE,
UniversalTag.SEQUENCE.getValue(),
             new EncryptionKeyInit() );
         
         // --------------------------------------------------------------------------------------------
@@ -78,8 +78,8 @@ public final class EncryptionKeyGrammar 
         // --------------------------------------------------------------------------------------------
         // EncryptionKey         ::= SEQUENCE {
         //       keytype     [0]
-        super.transitions[EncryptionKeyStatesEnum.ENCKEY_SEQ_STATE.ordinal()][KerberosConstants.ENCRYPTION_KEY_TYPE_TAG]
= new GrammarTransition(
-            EncryptionKeyStatesEnum.ENCKEY_SEQ_STATE, EncryptionKeyStatesEnum.ENCKEY_TYPE_TAG_STATE,
KerberosConstants.ENCRYPTION_KEY_TYPE_TAG,
+        super.transitions[EncryptionKeyStatesEnum.ENCRYPTION_KEY_SEQ_STATE.ordinal()][KerberosConstants.ENCRYPTION_KEY_TYPE_TAG]
= new GrammarTransition(
+            EncryptionKeyStatesEnum.ENCRYPTION_KEY_SEQ_STATE, EncryptionKeyStatesEnum.ENCRYPTION_KEY_TYPE_TAG_STATE,
KerberosConstants.ENCRYPTION_KEY_TYPE_TAG,
             new CheckNotNullLength() );
         
         // --------------------------------------------------------------------------------------------
@@ -87,8 +87,8 @@ public final class EncryptionKeyGrammar 
         // --------------------------------------------------------------------------------------------
         // EncryptionKey         ::= SEQUENCE {
         //       keytype     [0] Int32
-        super.transitions[EncryptionKeyStatesEnum.ENCKEY_TYPE_TAG_STATE.ordinal()][UniversalTag.INTEGER.getValue()]
= new GrammarTransition(
-            EncryptionKeyStatesEnum.ENCKEY_TYPE_TAG_STATE, EncryptionKeyStatesEnum.ENCKEY_TYPE_STATE,
UniversalTag.INTEGER.getValue(),
+        super.transitions[EncryptionKeyStatesEnum.ENCRYPTION_KEY_TYPE_TAG_STATE.ordinal()][UniversalTag.INTEGER.getValue()]
= new GrammarTransition(
+            EncryptionKeyStatesEnum.ENCRYPTION_KEY_TYPE_TAG_STATE, EncryptionKeyStatesEnum.ENCRYPTION_KEY_TYPE_STATE,
UniversalTag.INTEGER.getValue(),
             new StoreKeyType() );
         
         // --------------------------------------------------------------------------------------------
@@ -97,8 +97,8 @@ public final class EncryptionKeyGrammar 
         // EncryptionKey         ::= SEQUENCE {
         //          ...
         //          keyvalue    [2]
-        super.transitions[EncryptionKeyStatesEnum.ENCKEY_TYPE_STATE.ordinal()][KerberosConstants.ENCRYPTION_KEY_VALUE_TAG]
= new GrammarTransition(
-            EncryptionKeyStatesEnum.ENCKEY_TYPE_STATE, EncryptionKeyStatesEnum.ENCKEY_VALUE_TAG_STATE,
KerberosConstants.ENCRYPTION_KEY_VALUE_TAG,
+        super.transitions[EncryptionKeyStatesEnum.ENCRYPTION_KEY_TYPE_STATE.ordinal()][KerberosConstants.ENCRYPTION_KEY_VALUE_TAG]
= new GrammarTransition(
+            EncryptionKeyStatesEnum.ENCRYPTION_KEY_TYPE_STATE, EncryptionKeyStatesEnum.ENCRYPTION_KEY_VALUE_TAG_STATE,
KerberosConstants.ENCRYPTION_KEY_VALUE_TAG,
             new CheckNotNullLength() );
         
         // --------------------------------------------------------------------------------------------
@@ -106,8 +106,8 @@ public final class EncryptionKeyGrammar 
         // --------------------------------------------------------------------------------------------
         // EncryptionKey         ::= SEQUENCE {
         //          keyvalue    [2] OCTET STRING
-        super.transitions[EncryptionKeyStatesEnum.ENCKEY_VALUE_TAG_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()]
= new GrammarTransition(
-            EncryptionKeyStatesEnum.ENCKEY_VALUE_TAG_STATE, EncryptionKeyStatesEnum.ENCKEY_VALUE_STATE,
UniversalTag.OCTET_STRING.getValue(),
+        super.transitions[EncryptionKeyStatesEnum.ENCRYPTION_KEY_VALUE_TAG_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()]
= new GrammarTransition(
+            EncryptionKeyStatesEnum.ENCRYPTION_KEY_VALUE_TAG_STATE, EncryptionKeyStatesEnum.ENCRYPTION_KEY_VALUE_STATE,
UniversalTag.OCTET_STRING.getValue(),
             new StoreKeyValue() );
     }
 

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encryptionKey/EncryptionKeyStatesEnum.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encryptionKey/EncryptionKeyStatesEnum.java?rev=1040152&r1=1040151&r2=1040152&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encryptionKey/EncryptionKeyStatesEnum.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encryptionKey/EncryptionKeyStatesEnum.java
Mon Nov 29 15:35:36 2010
@@ -34,20 +34,20 @@ import org.apache.directory.shared.kerbe
 public enum EncryptionKeyStatesEnum implements States
 {
     // Start
-    START_STATE,             // 0
+    START_STATE,                     // 0
     
-    ENCKEY_SEQ_STATE,        // 1
+    ENCRYPTION_KEY_SEQ_STATE,        // 1
     
-    ENCKEY_TYPE_TAG_STATE,   // 2
+    ENCRYPTION_KEY_TYPE_TAG_STATE,   // 2
     
-    ENCKEY_TYPE_STATE,       // 3
+    ENCRYPTION_KEY_TYPE_STATE,       // 3
     
-    ENCKEY_VALUE_TAG_STATE,  // 4
+    ENCRYPTION_KEY_VALUE_TAG_STATE,  // 4
     
-    ENCKEY_VALUE_STATE,      // 5
+    ENCRYPTION_KEY_VALUE_STATE,      // 5
     
     // End
-    LAST_ENCKEY_STATE;       // 6
+    LAST_ENCRYPTION_KEY_STATE;       // 6
 
     
     /**
@@ -58,7 +58,7 @@ public enum EncryptionKeyStatesEnum impl
      */
     public String getGrammarName( int grammar )
     {
-        return "ENCRYPTIONKEY_GRAMMAR";
+        return "ENCRYPTION_KEY_GRAMMAR";
     }
 
 
@@ -72,7 +72,7 @@ public enum EncryptionKeyStatesEnum impl
     {
         if ( grammar instanceof KerberosMessageGrammar )
         {
-            return "ENCRYPTIONKEY_GRAMMAR";
+            return "ENCRYPTION_KEY_GRAMMAR";
         }
         else
         {
@@ -89,7 +89,7 @@ public enum EncryptionKeyStatesEnum impl
      */
     public String getState( int state )
     {
-        return ( ( state == LAST_ENCKEY_STATE.ordinal() ) ? "LAST_ENCKEY_STATE" : name()
);
+        return ( ( state == LAST_ENCRYPTION_KEY_STATE.ordinal() ) ? "LAST_ENCRYPTION_KEY_STATE"
: name() );
     }
 
     
@@ -98,7 +98,7 @@ public enum EncryptionKeyStatesEnum impl
      */
     public boolean isEndState()
     {
-        return this == LAST_ENCKEY_STATE;
+        return this == LAST_ENCRYPTION_KEY_STATE;
     }
     
     

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encryptionKey/actions/EncryptionKeyInit.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encryptionKey/actions/EncryptionKeyInit.java?rev=1040152&r1=1040151&r2=1040152&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encryptionKey/actions/EncryptionKeyInit.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encryptionKey/actions/EncryptionKeyInit.java
Mon Nov 29 15:35:36 2010
@@ -20,11 +20,11 @@
 package org.apache.directory.shared.kerberos.codec.encryptionKey.actions;
 
 
+import org.apache.directory.server.i18n.I18n;
 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.encryptionKey.EncryptionKeyContainer;
 import org.apache.directory.shared.kerberos.components.EncryptionKey;
 import org.slf4j.Logger;
@@ -66,10 +66,10 @@ public class EncryptionKeyInit extends G
         // The Length should not be null
         if ( tlv.getLength() == 0 )
         {
-            LOG.error( I18n.err( I18n.ERR_04066 ) );
+            LOG.error( I18n.err( I18n.ERR_744_NULL_PDU_LENGTH ) );
 
             // This will generate a PROTOCOL_ERROR
-            throw new DecoderException( I18n.err( I18n.ERR_04067 ) );
+            throw new DecoderException( I18n.err( I18n.ERR_744_NULL_PDU_LENGTH ) );
         }
         
         EncryptionKey encKey = new EncryptionKey();

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encryptionKey/actions/StoreKeyType.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encryptionKey/actions/StoreKeyType.java?rev=1040152&r1=1040151&r2=1040152&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encryptionKey/actions/StoreKeyType.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encryptionKey/actions/StoreKeyType.java
Mon Nov 29 15:35:36 2010
@@ -22,17 +22,10 @@ package org.apache.directory.shared.kerb
 
 
 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.ber.tlv.Value;
-import org.apache.directory.shared.asn1.codec.DecoderException;
-import org.apache.directory.shared.asn1.util.IntegerDecoder;
-import org.apache.directory.shared.asn1.util.IntegerDecoderException;
-import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.asn1.codec.actions.AbstractReadInteger;
 import org.apache.directory.shared.kerberos.codec.encryptionKey.EncryptionKeyContainer;
 import org.apache.directory.shared.kerberos.codec.types.EncryptionType;
 import org.apache.directory.shared.kerberos.components.EncryptionKey;
-import org.apache.directory.shared.ldap.util.StringTools;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -42,7 +35,7 @@ import org.slf4j.LoggerFactory;
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class StoreKeyType extends GrammarAction
+public class StoreKeyType extends AbstractReadInteger
 {
     /** The logger */
     private static final Logger LOG = LoggerFactory.getLogger( StoreKeyType.class );
@@ -50,7 +43,6 @@ public class StoreKeyType extends Gramma
     /** Speedup for logs */
     private static final boolean IS_DEBUG = LOG.isDebugEnabled();
 
-
     /**
      * Creates a new instance of EncryptionKeyKeyType.
      */
@@ -63,44 +55,19 @@ public class StoreKeyType extends Gramma
     /**
      * {@inheritDoc}
      */
-    public void action( Asn1Container container ) throws DecoderException
+    @Override
+    protected void setIntegerValue( int value, Asn1Container container )
     {
         EncryptionKeyContainer encKeyContainer = ( EncryptionKeyContainer ) container;
-
-        TLV tlv = encKeyContainer.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 ) );
-        }
-
         EncryptionKey encKey = encKeyContainer.getEncryptionKey();
         
-        // The Key type is an integer
-        Value value = tlv.getValue();
-
-        try
-        {
-            int encKeyType = IntegerDecoder.parse( value );
-
-            encKey.setKeyType( EncryptionType.getTypeByValue( encKeyType ) );
+        EncryptionType encryptionType = EncryptionType.getTypeByValue( value );
+        
+        encKey.setKeyType( encryptionType );
 
-            if ( IS_DEBUG )
-            {
-                LOG.debug( "keytype : " + encKeyType );
-            }
-        }
-        catch ( IntegerDecoderException ide )
+        if ( IS_DEBUG )
         {
-            LOG.error( I18n.err( I18n.ERR_04070, StringTools.dumpBytes( value.getData() ),
ide
-                .getLocalizedMessage() ) );
-
-            // This will generate a PROTOCOL_ERROR
-            throw new DecoderException( ide.getMessage() );
+            LOG.debug( "keytype : {}", encryptionType );
         }
     }
 }

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/hostAddress/actions/StoreAddress.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/hostAddress/actions/StoreAddress.java?rev=1040152&r1=1040151&r2=1040152&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/hostAddress/actions/StoreAddress.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/hostAddress/actions/StoreAddress.java
Mon Nov 29 15:35:36 2010
@@ -23,6 +23,9 @@ package org.apache.directory.shared.kerb
 import org.apache.directory.shared.asn1.ber.Asn1Container;
 import org.apache.directory.shared.asn1.codec.actions.AbstractReadOctetString;
 import org.apache.directory.shared.kerberos.codec.hostAddress.HostAddressContainer;
+import org.apache.directory.shared.ldap.util.StringTools;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 /**
@@ -32,6 +35,12 @@ import org.apache.directory.shared.kerbe
  */
 public class StoreAddress extends AbstractReadOctetString
 {
+    /** The logger */
+    private static final Logger LOG = LoggerFactory.getLogger( StoreAddress.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
+
     /**
      * Instantiates a new HostAddressAddress action.
      */
@@ -50,5 +59,10 @@ public class StoreAddress extends Abstra
         HostAddressContainer hostAddressContainer = ( HostAddressContainer ) container;
         hostAddressContainer.getHostAddress().setAddress( data );
         container.setGrammarEndAllowed( true );
+        
+        if ( IS_DEBUG )
+        {
+            LOG.debug( "Address : {}", StringTools.utf8ToString( data ) );
+        }
     }
 }

Modified: directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/EncryptionKeyDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/EncryptionKeyDecoderTest.java?rev=1040152&r1=1040151&r2=1040152&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/EncryptionKeyDecoderTest.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/EncryptionKeyDecoderTest.java
Mon Nov 29 15:35:36 2010
@@ -44,7 +44,7 @@ import org.junit.Test;
 public class EncryptionKeyDecoderTest
 {
     @Test
-    public void testDecodeEncryptionKey()
+    public void testDecodeFullEncryptionKey()
     {
         Asn1Decoder krbDecoder = new Asn1Decoder();
         
@@ -101,15 +101,81 @@ public class EncryptionKeyDecoderTest
     
     
     @Test( expected = DecoderException.class )
+    public void testDecodeEncryptionKeyWithEmptySeq() throws DecoderException
+    {
+        Asn1Decoder krbDecoder = new Asn1Decoder();
+        
+        ByteBuffer stream = ByteBuffer.allocate( 0x02 );
+
+        stream.put( new byte[]
+            { 
+                0x30, 0x00
+            } );
+        
+        stream.flip();
+
+        EncryptionKeyContainer container = new EncryptionKeyContainer();
+        
+        krbDecoder.decode( stream, container );
+        fail();
+    }
+    
+    
+    @Test( expected = DecoderException.class )
+    public void testDecodeEncryptionKeyEmptyKeyTypeTag() throws DecoderException
+    {
+        Asn1Decoder krbDecoder = new Asn1Decoder();
+        
+        ByteBuffer stream = ByteBuffer.allocate( 0x04 );
+
+        stream.put( new byte[]
+            { 
+                0x30, 0x02,
+                  (byte)0xA0, 0x00
+            } );
+        
+        stream.flip();
+
+        EncryptionKeyContainer container = new EncryptionKeyContainer();
+        
+        krbDecoder.decode( stream, container );
+        fail();
+    }
+    
+    
+    @Test( expected = DecoderException.class )
+    public void testDecodeEncryptionKeyEmptyKeyTypeValue() throws DecoderException
+    {
+        Asn1Decoder krbDecoder = new Asn1Decoder();
+        
+        ByteBuffer stream = ByteBuffer.allocate( 0x06 );
+
+        stream.put( new byte[]
+            { 
+                0x30, 0x04,
+                  (byte)0xA0, 0x02,
+                    0x02, 0x00
+            } );
+        
+        stream.flip();
+
+        EncryptionKeyContainer container = new EncryptionKeyContainer();
+        
+        krbDecoder.decode( stream, container );
+        fail();
+    }
+    
+    
+    @Test( expected = DecoderException.class )
     public void testDecodeEncryptionKeyWithoutType() throws DecoderException
     {
         Asn1Decoder krbDecoder = new Asn1Decoder();
         
-        ByteBuffer stream = ByteBuffer.allocate( 0xC );
+        ByteBuffer stream = ByteBuffer.allocate( 0x0C );
 
         stream.put( new byte[]
             { 
-                0x30, 0xA,
+                0x30, 0x0A,
                   (byte)0xA1, 0x08,                 // keyvalue
                       0x04, 0x06, 'k', 'e', 'y', 'v', 'a', 'l'
             } );
@@ -147,15 +213,18 @@ public class EncryptionKeyDecoderTest
     
     
     @Test( expected = DecoderException.class )
-    public void testDecodeEncryptionKeyWithEmptySeq() throws DecoderException
+    public void testDecodeChecksumWitEmptyEncryptionKeyTag() throws DecoderException
     {
         Asn1Decoder krbDecoder = new Asn1Decoder();
         
-        ByteBuffer stream = ByteBuffer.allocate( 2 );
+        ByteBuffer stream = ByteBuffer.allocate( 0x09 );
 
         stream.put( new byte[]
             { 
-                0x30, 0x0
+                0x30, 0x07,
+                  (byte)0xA0, 0x03,                 // keytype
+                    0x02, 0x01, 0x02,
+                  (byte)0xA1, 0x00
             } );
         
         stream.flip();
@@ -165,5 +234,29 @@ public class EncryptionKeyDecoderTest
         krbDecoder.decode( stream, container );
         fail();
     }
+    
+    
+    @Test( expected = DecoderException.class )
+    public void testDecodeChecksumWitEmptyEncryptionKeyValue() throws DecoderException
+    {
+        Asn1Decoder krbDecoder = new Asn1Decoder();
+        
+        ByteBuffer stream = ByteBuffer.allocate( 0x0B );
 
+        stream.put( new byte[]
+            { 
+                0x30, 0x09,
+                  (byte)0xA0, 0x03,                 // keytype
+                    0x02, 0x01, 0x02,
+                  (byte)0xA1, 0x02,
+                    0x04, 0x00
+            } );
+        
+        stream.flip();
+
+        EncryptionKeyContainer container = new EncryptionKeyContainer();
+        
+        krbDecoder.decode( stream, container );
+        fail();
+    }
 }



Mime
View raw message