directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1039811 - 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/checksum/actions/ main/java/org/apache/director...
Date Sun, 28 Nov 2010 02:08:36 GMT
Author: elecharny
Date: Sun Nov 28 02:08:35 2010
New Revision: 1039811

URL: http://svn.apache.org/viewvc?rev=1039811&view=rev
Log:
Used the AbstractReadOctetString all over the codec code

Added:
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/padata/actions/StorePaDataValue.java
      - copied, changed from r1039697, directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/padata/actions/StoreValue.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/typedData/actions/StoreDataValue.java
      - copied, changed from r1039697, directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/typedData/actions/StoreTdData.java
Removed:
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/padata/actions/StoreValue.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/typedData/actions/StoreTdData.java
Modified:
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/authorizationData/actions/StoreAdData.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/checksum/actions/StoreChecksum.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encKrbPrivPart/actions/StoreUserData.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encryptionKey/actions/StoreKeyValue.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/etypeInfo2Entry/actions/StoreS2KParams.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/etypeInfoEntry/actions/StoreSalt.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/main/java/org/apache/directory/shared/kerberos/codec/krbError/actions/StoreEData.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/krbSafeBody/actions/StoreUserData.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/padata/PaDataGrammar.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/transitedEncoding/actions/StoreContents.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/typedData/TypedDataGrammar.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/typedData/actions/StoreTdType.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/TypedData.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/KrbError.java
    directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/TypedDataDecoderTest.java

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/authorizationData/actions/StoreAdData.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/authorizationData/actions/StoreAdData.java?rev=1039811&r1=1039810&r2=1039811&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/authorizationData/actions/StoreAdData.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/authorizationData/actions/StoreAdData.java Sun Nov 28 02:08:35 2010
@@ -21,16 +21,8 @@ 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.i18n.I18n;
+import org.apache.directory.shared.asn1.codec.actions.AbstractReadOctetString;
 import org.apache.directory.shared.kerberos.codec.authorizationData.AuthorizationDataContainer;
-import org.apache.directory.shared.kerberos.components.AuthorizationData;
-import org.apache.directory.shared.ldap.util.StringTools;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -38,15 +30,8 @@ import org.slf4j.LoggerFactory;
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class StoreAdData extends GrammarAction
+public class StoreAdData extends AbstractReadOctetString
 {
-    /** The logger */
-    private static final Logger LOG = LoggerFactory.getLogger( StoreAdData.class );
-
-    /** Speedup for logs */
-    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
-
-
     /**
      * Instantiates a new AuthorizationDataAdData action.
      */
@@ -59,40 +44,11 @@ public class StoreAdData extends Grammar
     /**
      * {@inheritDoc}
      */
-    public void action( Asn1Container container ) throws DecoderException
+    @Override
+    protected void setOctetString( byte[] data, Asn1Container container )
     {
         AuthorizationDataContainer authDataContainer = ( AuthorizationDataContainer ) container;
-
-        TLV tlv = authDataContainer.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 ) );
-        }
-        
-        Value value = tlv.getValue();
-        
-        // The encrypted data should not be null
-        if ( value.getData() == null ) 
-        {
-            LOG.error( I18n.err( I18n.ERR_04066 ) );
-
-            // This will generate a PROTOCOL_ERROR
-            throw new DecoderException( I18n.err( I18n.ERR_04067 ) );
-        }
-        
-        AuthorizationData authData = authDataContainer.getAuthorizationData();
-        authData.setCurrentAdData( value.getData() );
-        
-        if ( IS_DEBUG )
-        {
-            LOG.debug( "ad-data : {}", StringTools.dumpBytes( value.getData() ) );
-        }
-        
-        authDataContainer.setGrammarEndAllowed( true );
+        authDataContainer.getAuthorizationData().setCurrentAdData( data );
+        container.setGrammarEndAllowed( true );
     }
 }

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/checksum/actions/StoreChecksum.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/checksum/actions/StoreChecksum.java?rev=1039811&r1=1039810&r2=1039811&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/checksum/actions/StoreChecksum.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/checksum/actions/StoreChecksum.java Sun Nov 28 02:08:35 2010
@@ -21,16 +21,8 @@ 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.i18n.I18n;
+import org.apache.directory.shared.asn1.codec.actions.AbstractReadOctetString;
 import org.apache.directory.shared.kerberos.codec.checksum.ChecksumContainer;
-import org.apache.directory.shared.kerberos.components.Checksum;
-import org.apache.directory.shared.ldap.util.StringTools;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -38,15 +30,8 @@ import org.slf4j.LoggerFactory;
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class StoreChecksum extends GrammarAction
+public class StoreChecksum extends AbstractReadOctetString
 {
-    /** The logger */
-    private static final Logger LOG = LoggerFactory.getLogger( StoreChecksum.class );
-
-    /** Speedup for logs */
-    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
-
-
     /**
      * Instantiates a new ChecksumData action.
      */
@@ -59,40 +44,11 @@ public class StoreChecksum extends Gramm
     /**
      * {@inheritDoc}
      */
-    public void action( Asn1Container container ) throws DecoderException
+    @Override
+    protected void setOctetString( byte[] data, Asn1Container container )
     {
         ChecksumContainer checksumContainer = ( ChecksumContainer ) container;
-
-        TLV tlv = checksumContainer.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 ) );
-        }
-        
-        Value value = tlv.getValue();
-        
-        // The encrypted data should not be null
-        if ( value.getData() == null ) 
-        {
-            LOG.error( I18n.err( I18n.ERR_04066 ) );
-
-            // This will generate a PROTOCOL_ERROR
-            throw new DecoderException( I18n.err( I18n.ERR_04067 ) );
-        }
-        
-        Checksum checksum = checksumContainer.getChecksum();
-        checksum.setChecksumValue( value.getData() );
-        
-        if ( IS_DEBUG )
-        {
-            LOG.debug( "checksum value : {}", StringTools.dumpBytes( value.getData() ) );
-        }
-        
-        checksumContainer.setGrammarEndAllowed( true );
+        checksumContainer.getChecksum().setChecksumValue( data );
+        container.setGrammarEndAllowed( true );
     }
 }

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encKrbPrivPart/actions/StoreUserData.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encKrbPrivPart/actions/StoreUserData.java?rev=1039811&r1=1039810&r2=1039811&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encKrbPrivPart/actions/StoreUserData.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encKrbPrivPart/actions/StoreUserData.java Sun Nov 28 02:08:35 2010
@@ -21,16 +21,8 @@ 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.i18n.I18n;
+import org.apache.directory.shared.asn1.codec.actions.AbstractReadOctetString;
 import org.apache.directory.shared.kerberos.codec.encKrbPrivPart.EncKrbPrivPartContainer;
-import org.apache.directory.shared.kerberos.components.EncKrbPrivPart;
-import org.apache.directory.shared.ldap.util.StringTools;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -38,51 +30,24 @@ import org.slf4j.LoggerFactory;
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class StoreUserData extends GrammarAction
+public class StoreUserData extends AbstractReadOctetString
 {
-    /** The logger */
-    private static final Logger LOG = LoggerFactory.getLogger( StoreUserData.class );
-
-    /** Speedup for logs */
-    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
-
-
     /**
      * Instantiates a new StoreUserData action.
      */
     public StoreUserData()
     {
-        super( "EncKrbPrivPart user-data" );
+        super( "EncKrbPrivPart user-data", true );
     }
 
 
     /**
      * {@inheritDoc}
      */
-    public final void action( Asn1Container container ) throws DecoderException
+    @Override
+    protected void setOctetString( byte[] data, Asn1Container container )
     {
         EncKrbPrivPartContainer encKrbPrivPartContainer = ( EncKrbPrivPartContainer ) container;
-        
-        TLV tlv = encKrbPrivPartContainer.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 ) );
-        }
-        
-        // The value is the realm
-        Value value = tlv.getValue();
-
-        EncKrbPrivPart encKrbPrivPart = encKrbPrivPartContainer.getEncKrbPrivPart();
-        encKrbPrivPart.setUserData( value.getData() );
-        
-        if ( IS_DEBUG )
-        {
-            LOG.debug( "user-data: " + StringTools.dumpBytes( value.getData() ) );
-        }
+        encKrbPrivPartContainer.getEncKrbPrivPart().setUserData( data );
     }
 }

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encryptionKey/actions/StoreKeyValue.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encryptionKey/actions/StoreKeyValue.java?rev=1039811&r1=1039810&r2=1039811&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encryptionKey/actions/StoreKeyValue.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/encryptionKey/actions/StoreKeyValue.java Sun Nov 28 02:08:35 2010
@@ -21,16 +21,8 @@ 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.i18n.I18n;
+import org.apache.directory.shared.asn1.codec.actions.AbstractReadOctetString;
 import org.apache.directory.shared.kerberos.codec.encryptionKey.EncryptionKeyContainer;
-import org.apache.directory.shared.kerberos.components.EncryptionKey;
-import org.apache.directory.shared.ldap.util.StringTools;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -38,15 +30,8 @@ import org.slf4j.LoggerFactory;
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class StoreKeyValue extends GrammarAction
+public class StoreKeyValue extends AbstractReadOctetString
 {
-    /** The logger */
-    private static final Logger LOG = LoggerFactory.getLogger( StoreKeyValue.class );
-
-    /** Speedup for logs */
-    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
-
-
     /**
      * Instantiates a new EncryptionKeyKeyValue action.
      */
@@ -59,40 +44,11 @@ public class StoreKeyValue extends Gramm
     /**
      * {@inheritDoc}
      */
-    public void action( Asn1Container container ) throws DecoderException
+    @Override
+    protected void setOctetString( byte[] data, 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 ) );
-        }
-        
-        Value value = tlv.getValue();
-        
-        // The encrypted data should not be null
-        if ( value.getData() == null ) 
-        {
-            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();
-        encKey.setKeyValue( value.getData() );
-        
-        if ( IS_DEBUG )
-        {
-            LOG.debug( "keyvalue : {}", StringTools.dumpBytes( value.getData() ) );
-        }
-        
-        encKeyContainer.setGrammarEndAllowed( true );
+        encKeyContainer.getEncryptionKey().setKeyValue( data );
+        container.setGrammarEndAllowed( true );
     }
 }

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/etypeInfo2Entry/actions/StoreS2KParams.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/etypeInfo2Entry/actions/StoreS2KParams.java?rev=1039811&r1=1039810&r2=1039811&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/etypeInfo2Entry/actions/StoreS2KParams.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/etypeInfo2Entry/actions/StoreS2KParams.java Sun Nov 28 02:08:35 2010
@@ -21,68 +21,34 @@ 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.codec.actions.AbstractReadOctetString;
 import org.apache.directory.shared.kerberos.codec.etypeInfo2Entry.ETypeInfo2EntryContainer;
-import org.apache.directory.shared.kerberos.components.ETypeInfo2Entry;
-import org.apache.directory.shared.ldap.util.StringTools;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
- * The action used to store the ETYPE-INFO2-ENTRY cipher
+ * The action used to store the ETYPE-INFO2-ENTRY s2kparams
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class StoreS2KParams extends GrammarAction
+public class StoreS2KParams extends AbstractReadOctetString
 {
-    /** The logger */
-    private static final Logger LOG = LoggerFactory.getLogger( StoreS2KParams.class );
-
-    /** Speedup for logs */
-    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
-
-
     /**
-     * Instantiates a new StoreS2Params action.
+     * Instantiates a new StoreS2KParams action.
      */
     public StoreS2KParams()
     {
-        super( "ETYPE-INFO2-ENTRY s2kparams" );
+        super( "ETYPE-INFO2-ENTRY s2kparams", true );
     }
 
 
     /**
      * {@inheritDoc}
      */
-    public void action( Asn1Container container ) throws DecoderException
+    @Override
+    protected void setOctetString( byte[] data, Asn1Container container )
     {
         ETypeInfo2EntryContainer etypeInfo2EntryContainer = ( ETypeInfo2EntryContainer ) container;
-
-        TLV tlv = etypeInfo2EntryContainer.getCurrentTLV();
-        ETypeInfo2Entry etypeInfo2Entry = etypeInfo2EntryContainer.getETypeInfo2Entry();
-
-        // The Length may be null
-        if ( tlv.getLength() != 0 ) 
-        {
-            Value value = tlv.getValue();
-            
-            // The encrypted data may be null
-            if ( value.getData() != null ) 
-            {
-                etypeInfo2Entry.setS2kparams( value.getData() );
-            }
-        }
-        
-        if ( IS_DEBUG )
-        {
-            LOG.debug( "salt : {}", StringTools.dumpBytes( etypeInfo2Entry.getS2kparams() ) );
-        }
-        
-        // We can end here
+        etypeInfo2EntryContainer.getETypeInfo2Entry().setS2kparams( data );
         etypeInfo2EntryContainer.setGrammarEndAllowed( true );
     }
 }

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/etypeInfoEntry/actions/StoreSalt.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/etypeInfoEntry/actions/StoreSalt.java?rev=1039811&r1=1039810&r2=1039811&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/etypeInfoEntry/actions/StoreSalt.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/etypeInfoEntry/actions/StoreSalt.java Sun Nov 28 02:08:35 2010
@@ -21,15 +21,8 @@ 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.codec.actions.AbstractReadOctetString;
 import org.apache.directory.shared.kerberos.codec.etypeInfoEntry.ETypeInfoEntryContainer;
-import org.apache.directory.shared.kerberos.components.ETypeInfoEntry;
-import org.apache.directory.shared.ldap.util.StringTools;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -37,52 +30,25 @@ import org.slf4j.LoggerFactory;
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class StoreSalt extends GrammarAction
+public class StoreSalt extends AbstractReadOctetString
 {
-    /** The logger */
-    private static final Logger LOG = LoggerFactory.getLogger( StoreSalt.class );
-
-    /** Speedup for logs */
-    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
-
-
     /**
      * Instantiates a new StoreSalt action.
      */
     public StoreSalt()
     {
-        super( "ETYPE-INFO-ENTRY salt" );
+        super( "ETYPE-INFO-ENTRY salt", true );
     }
 
 
     /**
      * {@inheritDoc}
      */
-    public void action( Asn1Container container ) throws DecoderException
+    @Override
+    protected void setOctetString( byte[] data, Asn1Container container )
     {
         ETypeInfoEntryContainer etypeInfoEntryContainer = ( ETypeInfoEntryContainer ) container;
-
-        TLV tlv = etypeInfoEntryContainer.getCurrentTLV();
-        ETypeInfoEntry etypeInfoEntry = etypeInfoEntryContainer.getETypeInfoEntry();
-
-        // The Length may be null
-        if ( tlv.getLength() != 0 ) 
-        {
-            Value value = tlv.getValue();
-            
-            // The encrypted data may be null
-            if ( value.getData() != null ) 
-            {
-                etypeInfoEntry.setSalt( value.getData() );
-            }
-        }
-        
-        if ( IS_DEBUG )
-        {
-            LOG.debug( "salt : {}", StringTools.dumpBytes( etypeInfoEntry.getSalt() ) );
-        }
-        
-        // We can end here
+        etypeInfoEntryContainer.getETypeInfoEntry().setSalt( data );
         etypeInfoEntryContainer.setGrammarEndAllowed( true );
     }
 }

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=1039811&r1=1039810&r2=1039811&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 Sun Nov 28 02:08:35 2010
@@ -21,17 +21,8 @@ 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.i18n.I18n;
-import org.apache.directory.shared.kerberos.codec.KerberosMessageGrammar;
+import org.apache.directory.shared.asn1.codec.actions.AbstractReadOctetString;
 import org.apache.directory.shared.kerberos.codec.hostAddress.HostAddressContainer;
-import org.apache.directory.shared.kerberos.components.HostAddress;
-import org.apache.directory.shared.ldap.util.StringTools;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -39,15 +30,8 @@ import org.slf4j.LoggerFactory;
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class StoreAddress extends GrammarAction
+public class StoreAddress extends AbstractReadOctetString
 {
-    /** The logger */
-    private static final Logger LOG = LoggerFactory.getLogger( KerberosMessageGrammar.class );
-
-    /** Speedup for logs */
-    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
-
-
     /**
      * Instantiates a new HostAddressAddress action.
      */
@@ -60,32 +44,11 @@ public class StoreAddress extends Gramma
     /**
      * {@inheritDoc}
      */
-    public void action( Asn1Container container ) throws DecoderException
+    @Override
+    protected void setOctetString( byte[] data, Asn1Container container )
     {
         HostAddressContainer hostAddressContainer = ( HostAddressContainer ) container;
-
-        TLV tlv = hostAddressContainer.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 ) );
-        }
-        
-        // Get the address value now
-        Value value = tlv.getValue();
-        
-        HostAddress hostAddressData = hostAddressContainer.getHostAddress();
-        
-        hostAddressData.setAddress( value.getData() );
-        hostAddressContainer.setGrammarEndAllowed( true );
-
-        if ( IS_DEBUG )
-        {
-            LOG.debug( "address : {}" + StringTools.dumpBytes( value.getData() ) );
-        }
+        hostAddressContainer.getHostAddress().setAddress( data );
+        container.setGrammarEndAllowed( true );
     }
 }

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/krbError/actions/StoreEData.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/krbError/actions/StoreEData.java?rev=1039811&r1=1039810&r2=1039811&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/krbError/actions/StoreEData.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/krbError/actions/StoreEData.java Sun Nov 28 02:08:35 2010
@@ -21,16 +21,8 @@ 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.i18n.I18n;
+import org.apache.directory.shared.asn1.codec.actions.AbstractReadOctetString;
 import org.apache.directory.shared.kerberos.codec.krbError.KrbErrorContainer;
-import org.apache.directory.shared.kerberos.messages.KrbError;
-import org.apache.directory.shared.ldap.util.StringTools;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -38,53 +30,25 @@ import org.slf4j.LoggerFactory;
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class StoreEData extends GrammarAction
+public class StoreEData extends AbstractReadOctetString
 {
-    /** The logger */
-    private static final Logger LOG = LoggerFactory.getLogger( StoreEData.class );
-
-    /** Speedup for logs */
-    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
-
-
     /**
      * Instantiates a new AbstractReadRealm action.
      */
     public StoreEData()
     {
-        super( "KRB-ERROR edata" );
+        super( "KRB-ERROR edata", true );
     }
 
 
     /**
      * {@inheritDoc}
      */
-    public final void action( Asn1Container container ) throws DecoderException
+    @Override
+    protected void setOctetString( byte[] data, Asn1Container container )
     {
         KrbErrorContainer krbErrContainer = ( KrbErrorContainer ) container;
-        
-        TLV tlv = krbErrContainer.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 ) );
-        }
-        
-        // The value is the realm
-        Value value = tlv.getValue();
-
-        KrbError krbError = krbErrContainer.getKrbError();
-        krbError.seteData( value.getData() );
-        
-        if ( IS_DEBUG )
-        {
-            LOG.debug( "eData: " + StringTools.dumpBytes( value.getData() ) );
-        }
-        
+        krbErrContainer.getKrbError().setEData( data );
         container.setGrammarEndAllowed( true );
     }
 }

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/krbSafeBody/actions/StoreUserData.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/krbSafeBody/actions/StoreUserData.java?rev=1039811&r1=1039810&r2=1039811&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/krbSafeBody/actions/StoreUserData.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/krbSafeBody/actions/StoreUserData.java Sun Nov 28 02:08:35 2010
@@ -21,16 +21,8 @@ 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.i18n.I18n;
+import org.apache.directory.shared.asn1.codec.actions.AbstractReadOctetString;
 import org.apache.directory.shared.kerberos.codec.krbSafeBody.KrbSafeBodyContainer;
-import org.apache.directory.shared.kerberos.components.KrbSafeBody;
-import org.apache.directory.shared.ldap.util.StringTools;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -38,51 +30,24 @@ import org.slf4j.LoggerFactory;
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class StoreUserData extends GrammarAction
+public class StoreUserData extends AbstractReadOctetString
 {
-    /** The logger */
-    private static final Logger LOG = LoggerFactory.getLogger( StoreUserData.class );
-
-    /** Speedup for logs */
-    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
-
-
     /**
      * Instantiates a new StoreUserData action.
      */
     public StoreUserData()
     {
-        super( "KRB-SAFE-BODY user-data" );
+        super( "KRB-SAFE-BODY user-data", true );
     }
 
 
     /**
      * {@inheritDoc}
      */
-    public final void action( Asn1Container container ) throws DecoderException
+    @Override
+    protected void setOctetString( byte[] data, Asn1Container container )
     {
         KrbSafeBodyContainer krbSafeBodyContainer = ( KrbSafeBodyContainer ) container;
-        
-        TLV tlv = krbSafeBodyContainer.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 ) );
-        }
-        
-        // The value is the realm
-        Value value = tlv.getValue();
-
-        KrbSafeBody krbSafeBody = krbSafeBodyContainer.getKrbSafeBody();
-        krbSafeBody.setUserData( value.getData() );
-        
-        if ( IS_DEBUG )
-        {
-            LOG.debug( "user-data: " + StringTools.dumpBytes( value.getData() ) );
-        }
+        krbSafeBodyContainer.getKrbSafeBody().setUserData( data );
     }
 }

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/padata/PaDataGrammar.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/padata/PaDataGrammar.java?rev=1039811&r1=1039810&r2=1039811&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/padata/PaDataGrammar.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/padata/PaDataGrammar.java Sun Nov 28 02:08:35 2010
@@ -28,7 +28,7 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.kerberos.KerberosConstants;
 import org.apache.directory.shared.kerberos.codec.padata.actions.PaDataInit;
 import org.apache.directory.shared.kerberos.codec.padata.actions.StoreDataType;
-import org.apache.directory.shared.kerberos.codec.padata.actions.StoreValue;
+import org.apache.directory.shared.kerberos.codec.padata.actions.StorePaDataValue;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -107,7 +107,7 @@ public final class PaDataGrammar extends
         //          padata-value    [2] OCTET STRING
         super.transitions[PaDataStatesEnum.PADATA_VALUE_TAG_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
             PaDataStatesEnum.PADATA_VALUE_TAG_STATE, PaDataStatesEnum.PADATA_VALUE_STATE, UniversalTag.OCTET_STRING.getValue(),
-            new StoreValue() );
+            new StorePaDataValue() );
     }
 
 

Copied: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/padata/actions/StorePaDataValue.java (from r1039697, directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/padata/actions/StoreValue.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/padata/actions/StorePaDataValue.java?p2=directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/padata/actions/StorePaDataValue.java&p1=directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/padata/actions/StoreValue.java&r1=1039697&r2=1039811&rev=1039811&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/padata/actions/StoreValue.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/padata/actions/StorePaDataValue.java Sun Nov 28 02:08:35 2010
@@ -21,16 +21,8 @@ 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.i18n.I18n;
+import org.apache.directory.shared.asn1.codec.actions.AbstractReadOctetString;
 import org.apache.directory.shared.kerberos.codec.padata.PaDataContainer;
-import org.apache.directory.shared.kerberos.components.PaData;
-import org.apache.directory.shared.ldap.util.StringTools;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -38,19 +30,12 @@ import org.slf4j.LoggerFactory;
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class StoreValue extends GrammarAction
+public class StorePaDataValue extends AbstractReadOctetString
 {
-    /** The logger */
-    private static final Logger LOG = LoggerFactory.getLogger( StoreValue.class );
-
-    /** Speedup for logs */
-    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
-
-
     /**
      * Instantiates a new PaDataValue action.
      */
-    public StoreValue()
+    public StorePaDataValue()
     {
         super( "PaData's padata-value" );
     }
@@ -59,40 +44,11 @@ public class StoreValue extends GrammarA
     /**
      * {@inheritDoc}
      */
-    public void action( Asn1Container container ) throws DecoderException
+    @Override
+    protected void setOctetString( byte[] data, Asn1Container container )
     {
         PaDataContainer paDataContainer = ( PaDataContainer ) container;
-
-        TLV tlv = paDataContainer.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 ) );
-        }
-        
-        Value value = tlv.getValue();
-        
-        // The encrypted data should not be null
-        if ( value.getData() == null ) 
-        {
-            LOG.error( I18n.err( I18n.ERR_04066 ) );
-
-            // This will generate a PROTOCOL_ERROR
-            throw new DecoderException( I18n.err( I18n.ERR_04067 ) );
-        }
-        
-        PaData paData = paDataContainer.getPaData();
-        paData.setPaDataValue( value.getData() );
-        
-        if ( IS_DEBUG )
-        {
-            LOG.debug( "padata value : {}", StringTools.dumpBytes( value.getData() ) );
-        }
-        
-        paDataContainer.setGrammarEndAllowed( true );
+        paDataContainer.getPaData().setPaDataValue( data );
+        container.setGrammarEndAllowed( true );
     }
 }

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/transitedEncoding/actions/StoreContents.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/transitedEncoding/actions/StoreContents.java?rev=1039811&r1=1039810&r2=1039811&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/transitedEncoding/actions/StoreContents.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/transitedEncoding/actions/StoreContents.java Sun Nov 28 02:08:35 2010
@@ -21,70 +21,34 @@ 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.i18n.I18n;
+import org.apache.directory.shared.asn1.codec.actions.AbstractReadOctetString;
 import org.apache.directory.shared.kerberos.codec.transitedEncoding.TransitedEncodingContainer;
-import org.apache.directory.shared.kerberos.components.TransitedEncoding;
-import org.apache.directory.shared.ldap.util.StringTools;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
- * The action used to read the TransitedEncoding etext
+ * The action used to read the TransitedEncoding contents
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class StoreContents extends GrammarAction
+public class StoreContents extends AbstractReadOctetString
 {
-    /** The logger */
-    private static final Logger LOG = LoggerFactory.getLogger( StoreContents.class );
-
-    /** Speedup for logs */
-    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
-
-
     /**
      * Instantiates a new StoreContents action.
      */
     public StoreContents()
     {
-        super( "TransitedEncoding etext" );
+        super( "TransitedEncoding contents", true );
     }
 
 
     /**
      * {@inheritDoc}
      */
-    public final void action( Asn1Container container ) throws DecoderException
+    @Override
+    protected void setOctetString( byte[] data, Asn1Container container )
     {
         TransitedEncodingContainer transitedEncodingContainer = ( TransitedEncodingContainer ) container;
-        
-        TLV tlv = transitedEncodingContainer.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 ) );
-        }
-        
-        // The value is the realm
-        Value value = tlv.getValue();
-
-        TransitedEncoding transitedEncoding = transitedEncodingContainer.getTransitedEncoding();
-        transitedEncoding.setContents( value.getData() );
-        
-        if ( IS_DEBUG )
-        {
-            LOG.debug( "Contents: " + StringTools.dumpBytes( value.getData() ) );
-        }
-        
+        transitedEncodingContainer.getTransitedEncoding().setContents( data );
         container.setGrammarEndAllowed( true );
     }
 }

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/typedData/TypedDataGrammar.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/typedData/TypedDataGrammar.java?rev=1039811&r1=1039810&r2=1039811&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/typedData/TypedDataGrammar.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/typedData/TypedDataGrammar.java Sun Nov 28 02:08:35 2010
@@ -26,7 +26,7 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.ber.tlv.UniversalTag;
 import org.apache.directory.shared.asn1.codec.actions.CheckNotNullLength;
 import org.apache.directory.shared.kerberos.KerberosConstants;
-import org.apache.directory.shared.kerberos.codec.typedData.actions.StoreTdData;
+import org.apache.directory.shared.kerberos.codec.typedData.actions.StoreDataValue;
 import org.apache.directory.shared.kerberos.codec.typedData.actions.StoreTdType;
 import org.apache.directory.shared.kerberos.codec.typedData.actions.TypedDataInit;
 import org.slf4j.Logger;
@@ -117,7 +117,7 @@ public final class TypedDataGrammar exte
         //         data-value     [1] (OCTET STRING)
         super.transitions[TypedDataStatesEnum.TYPED_DATA_TDDATA_TAG_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()] = new GrammarTransition(
             TypedDataStatesEnum.TYPED_DATA_TDDATA_TAG_STATE, TypedDataStatesEnum.TYPED_DATA_TDDATA_STATE, UniversalTag.OCTET_STRING.getValue(),
-            new StoreTdData() );
+            new StoreDataValue() );
         
         // --------------------------------------------------------------------------------------------
         // Transition from ad-data value to SEQUENCE

Copied: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/typedData/actions/StoreDataValue.java (from r1039697, directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/typedData/actions/StoreTdData.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/typedData/actions/StoreDataValue.java?p2=directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/typedData/actions/StoreDataValue.java&p1=directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/typedData/actions/StoreTdData.java&r1=1039697&r2=1039811&rev=1039811&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/typedData/actions/StoreTdData.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/typedData/actions/StoreDataValue.java Sun Nov 28 02:08:35 2010
@@ -21,15 +21,8 @@ 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.i18n.I18n;
+import org.apache.directory.shared.asn1.codec.actions.AbstractReadOctetString;
 import org.apache.directory.shared.kerberos.codec.typedData.TypedDataContainer;
-import org.apache.directory.shared.ldap.util.StringTools;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -37,20 +30,12 @@ import org.slf4j.LoggerFactory;
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class StoreTdData extends GrammarAction
+public class StoreDataValue extends AbstractReadOctetString
 {
-
-    /** The logger */
-    private static final Logger LOG = LoggerFactory.getLogger( StoreTdData.class );
-
-    /** Speedup for logs */
-    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
-
-
     /**
      * Instantiates a new StoreTdData action.
      */
-    public StoreTdData()
+    public StoreDataValue()
     {
         super( "TypedData data-value" );
     }
@@ -59,40 +44,11 @@ public class StoreTdData extends Grammar
     /**
      * {@inheritDoc}
      */
-    public void action( Asn1Container container ) throws DecoderException
+    @Override
+    protected void setOctetString( byte[] data, Asn1Container container )
     {
-        TypedDataContainer tdContainer = ( TypedDataContainer ) container;
-
-        TLV tlv = tdContainer.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 ) );
-        }
-
-        Value value = tlv.getValue();
-
-        //        // The encrypted data should not be null
-        //        if ( value.getData() == null ) 
-        //        {
-        //            LOG.error( I18n.err( I18n.ERR_04066 ) );
-        //
-        //            // This will generate a PROTOCOL_ERROR
-        //            throw new DecoderException( I18n.err( I18n.ERR_04067 ) );
-        //        }
-
-        tdContainer.getTypedData().setCurrentTdData( value.getData() );
-
-        if ( IS_DEBUG )
-        {
-            LOG.debug( "data-value : {}", StringTools.dumpBytes( value.getData() ) );
-        }
-
-        container.setGrammarEndAllowed( true );
+        TypedDataContainer typedDataContainer = ( TypedDataContainer ) container;
+        typedDataContainer.getTypedData().setCurrentDataValue( data );
+        typedDataContainer.setGrammarEndAllowed( true );
     }
-
 }

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/typedData/actions/StoreTdType.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/typedData/actions/StoreTdType.java?rev=1039811&r1=1039810&r2=1039811&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/typedData/actions/StoreTdType.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/typedData/actions/StoreTdType.java Sun Nov 28 02:08:35 2010
@@ -52,7 +52,7 @@ public class StoreTdType extends Abstrac
         
         TypedData typedData = typedDataContainer.getTypedData();
         typedData.createNewTD();
-        typedData.setCurrentTdType( value );
+        typedData.setCurrentDataType( value );
         
         container.setGrammarEndAllowed( true );
     }

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/TypedData.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/TypedData.java?rev=1039811&r1=1039810&r2=1039811&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/TypedData.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/TypedData.java Sun Nov 28 02:08:35 2010
@@ -53,27 +53,27 @@ public class TypedData extends AbstractA
     public class TD
     {
         /** the type of TypedData */
-        private int tdType;
+        private int dataType;
 
         /** the TypedData data */
-        private byte[] tdData;
+        private byte[] dataValue;
 
 
         /**
          * @return the TD type
          */
-        public int getTdType()
+        public int getDataType()
         {
-            return tdType;
+            return dataType;
         }
 
 
         /**
          * @return the TD data
          */
-        public byte[] getTdData()
+        public byte[] getDataValue()
         {
-            return tdData;
+            return dataValue;
         }
     }
 
@@ -90,10 +90,74 @@ public class TypedData extends AbstractA
     private static final boolean IS_DEBUG = LOG.isDebugEnabled();
 
     // Storage for computed lengths
-    private transient int tdTypeTagLen[];
-    private transient int tdDataTagLen[];
-    private transient int typedDataSeqLen[];
-    private transient int typedDataSeqSeqLen;
+    private transient int dataTypeTagLength[];
+    private transient int dataValueTagLength[];
+    private transient int typedDataSeqLength[];
+    private transient int typedDataSeqSeqLength;
+
+
+    /**
+     * @return the currentTD type
+     */
+    public int getCurrentDataType()
+    {
+        return currentTD.dataType;
+    }
+
+
+    /**
+     * Set the current TD type
+     */
+    public void setCurrentDataType( int tdType )
+    {
+        currentTD.dataType = tdType;
+    }
+
+
+    /**
+     * @return the currentTD data
+     */
+    public byte[] getCurrentDataValue()
+    {
+        return currentTD.dataValue;
+    }
+
+
+    /**
+     * Set the current TD data
+     */
+    public void setCurrentDataValue( byte[] tdData )
+    {
+        currentTD.dataValue = tdData;
+    }
+
+
+    /**
+     * @return the currentTD
+     */
+    public TD getCurrentTD()
+    {
+        return currentTD;
+    }
+
+
+    /**
+     * Create a new currentTD
+     */
+    public void createNewTD()
+    {
+        currentTD = new TD();
+        typedDataList.add( currentTD );
+    }
+
+
+    /**
+     * @return the TypedData
+     */
+    public List<TD> getTypedData()
+    {
+        return typedDataList;
+    }
 
 
     /**
@@ -116,27 +180,27 @@ public class TypedData extends AbstractA
     public int computeLength()
     {
         int i = 0;
-        typedDataSeqLen = new int[typedDataList.size()];
-        tdTypeTagLen = new int[typedDataList.size()];
-        tdDataTagLen = new int[typedDataList.size()];
+        typedDataSeqLength = new int[typedDataList.size()];
+        dataTypeTagLength = new int[typedDataList.size()];
+        dataValueTagLength = new int[typedDataList.size()];
 
         for ( TD td : typedDataList )
         {
-            int adTypeLen = Value.getNbBytes( td.tdType );
-            tdTypeTagLen[i] = 1 + TLV.getNbBytes( adTypeLen ) + adTypeLen;
-            typedDataSeqLen[i] = 1 + TLV.getNbBytes( tdTypeTagLen[i] ) + tdTypeTagLen[i];
+            int adTypeLen = Value.getNbBytes( td.dataType );
+            dataTypeTagLength[i] = 1 + TLV.getNbBytes( adTypeLen ) + adTypeLen;
+            typedDataSeqLength[i] = 1 + TLV.getNbBytes( dataTypeTagLength[i] ) + dataTypeTagLength[i];
             
-            if ( td.tdData != null )
+            if ( td.dataValue != null )
             {
-                tdDataTagLen[i] = 1 + TLV.getNbBytes( td.tdData.length ) + td.tdData.length;
-                typedDataSeqLen[i] += 1 + TLV.getNbBytes( tdDataTagLen[i] ) + tdDataTagLen[i];
+                dataValueTagLength[i] = 1 + TLV.getNbBytes( td.dataValue.length ) + td.dataValue.length;
+                typedDataSeqLength[i] += 1 + TLV.getNbBytes( dataValueTagLength[i] ) + dataValueTagLength[i];
             }
 
-            typedDataSeqSeqLen += 1 + TLV.getNbBytes( typedDataSeqLen[i] ) + typedDataSeqLen[i];
+            typedDataSeqSeqLength += 1 + TLV.getNbBytes( typedDataSeqLength[i] ) + typedDataSeqLength[i];
             i++;
         }
 
-        return 1 + TLV.getNbBytes( typedDataSeqSeqLen ) + typedDataSeqSeqLen;
+        return 1 + TLV.getNbBytes( typedDataSeqSeqLength ) + typedDataSeqSeqLength;
     }
 
 
@@ -155,25 +219,25 @@ public class TypedData extends AbstractA
         {
             // The AuthorizationData SEQ OF Tag
             buffer.put( UniversalTag.SEQUENCE.getValue() );
-            buffer.put( TLV.getBytes( typedDataSeqSeqLen ) );
+            buffer.put( TLV.getBytes( typedDataSeqSeqLength ) );
 
             int i = 0;
             for ( TD td : typedDataList )
             {
                 buffer.put( UniversalTag.SEQUENCE.getValue() );
-                buffer.put( TLV.getBytes( typedDataSeqLen[i] ) );
+                buffer.put( TLV.getBytes( typedDataSeqLength[i] ) );
 
                 // the tdType
                 buffer.put( ( byte ) KerberosConstants.TYPED_DATA_TDTYPE_TAG );
-                buffer.put( TLV.getBytes( tdTypeTagLen[i] ) );
-                Value.encode( buffer, td.tdType );
+                buffer.put( TLV.getBytes( dataTypeTagLength[i] ) );
+                Value.encode( buffer, td.dataType );
 
-                if ( td.tdData != null )
+                if ( td.dataValue != null )
                 {
                     // the tdData
                     buffer.put( ( byte ) KerberosConstants.TYPED_DATA_TDDATA_TAG );
-                    buffer.put( TLV.getBytes( tdDataTagLen[i] ) );
-                    Value.encode( buffer, td.tdData );
+                    buffer.put( TLV.getBytes( dataValueTagLength[i] ) );
+                    Value.encode( buffer, td.dataValue );
                 }
                 
                 i++;
@@ -181,8 +245,8 @@ public class TypedData extends AbstractA
         }
         catch ( BufferOverflowException boe )
         {
-            LOG.error( I18n.err( I18n.ERR_743_CANNOT_ENCODE_TYPED_DATA, 1 + TLV.getNbBytes( typedDataSeqSeqLen )
-                + typedDataSeqSeqLen, buffer.capacity() ) );
+            LOG.error( I18n.err( I18n.ERR_743_CANNOT_ENCODE_TYPED_DATA, 1 + TLV.getNbBytes( typedDataSeqSeqLength )
+                + typedDataSeqSeqLength, buffer.capacity() ) );
             throw new EncoderException( I18n.err( I18n.ERR_138 ) );
         }
 
@@ -197,70 +261,6 @@ public class TypedData extends AbstractA
 
 
     /**
-     * @return the currentTD type
-     */
-    public int getCurrentTdType()
-    {
-        return currentTD.tdType;
-    }
-
-
-    /**
-     * Set the current TD type
-     */
-    public void setCurrentTdType( int tdType )
-    {
-        currentTD.tdType = tdType;
-    }
-
-
-    /**
-     * @return the currentTD data
-     */
-    public byte[] getCurrentTdData()
-    {
-        return currentTD.tdData;
-    }
-
-
-    /**
-     * Set the current TD data
-     */
-    public void setCurrentTdData( byte[] tdData )
-    {
-        currentTD.tdData = tdData;
-    }
-
-
-    /**
-     * @return the currentTD
-     */
-    public TD getCurrentTD()
-    {
-        return currentTD;
-    }
-
-
-    /**
-     * Create a new currentTD
-     */
-    public void createNewTD()
-    {
-        currentTD = new TD();
-        typedDataList.add( currentTD );
-    }
-
-
-    /**
-     * @return the TypedData
-     */
-    public List<TD> getTypedData()
-    {
-        return typedDataList;
-    }
-
-
-    /**
      * @see Object#toString()
      */
     public String toString()
@@ -281,15 +281,14 @@ public class TypedData extends AbstractA
         for ( TD td : typedDataList )
         {
             sb.append( tabs ).append( "    {\n" );
-            sb.append( tabs ).append( "        tdType: " ).append( td.tdType ).append( '\n' );
-            if ( td.tdData != null )
+            sb.append( tabs ).append( "        tdType: " ).append( td.dataType ).append( '\n' );
+            if ( td.dataValue != null )
             {
-                sb.append( tabs ).append( "        tdData: " ).append( StringTools.dumpBytes( td.tdData ) ).append( '\n' );
+                sb.append( tabs ).append( "        tdData: " ).append( StringTools.dumpBytes( td.dataValue ) ).append( '\n' );
             }
             sb.append( tabs ).append( "    }\n" );
         }
 
         return sb.toString();
     }
-
 }

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/KrbError.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/KrbError.java?rev=1039811&r1=1039810&r2=1039811&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/KrbError.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/messages/KrbError.java Sun Nov 28 02:08:35 2010
@@ -329,7 +329,7 @@ public class KrbError extends KerberosMe
     /**
      * @param eData the eData to set
      */
-    public void seteData( byte[] eData )
+    public void setEData( byte[] eData )
     {
         this.eData = eData;
     }

Modified: directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/TypedDataDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/TypedDataDecoderTest.java?rev=1039811&r1=1039810&r2=1039811&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/TypedDataDecoderTest.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/TypedDataDecoderTest.java Sun Nov 28 02:08:35 2010
@@ -91,8 +91,8 @@ public class TypedDataDecoderTest
         
         for ( TypedData.TD td : typedData.getTypedData() )
         {
-            assertEquals( 2, td.getTdType() );
-            assertTrue( Arrays.equals( StringTools.getBytesUtf8( expected[i++] ), td.getTdData() ) );
+            assertEquals( 2, td.getDataType() );
+            assertTrue( Arrays.equals( StringTools.getBytesUtf8( expected[i++] ), td.getDataValue() ) );
         }
 
         // Check the encoding
@@ -162,7 +162,7 @@ public class TypedDataDecoderTest
         
         assertNotNull( typedData.getTypedData() );
         assertEquals( 1, typedData.getTypedData().size() );
-        assertEquals( 2, typedData.getCurrentTD().getTdType() );
+        assertEquals( 2, typedData.getCurrentTD().getDataType() );
     }
 
     



Mime
View raw message