directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1039696 - in /directory/apacheds/trunk/kerberos-codec/src: main/java/org/apache/directory/shared/kerberos/codec/actions/ main/java/org/apache/directory/shared/kerberos/codec/apReq/actions/ main/java/org/apache/directory/shared/kerberos/cod...
Date Sat, 27 Nov 2010 15:18:05 GMT
Author: elecharny
Date: Sat Nov 27 15:17:57 2010
New Revision: 1039696

URL: http://svn.apache.org/viewvc?rev=1039696&view=rev
Log:
o Used the AbstractReadEncPart everywhere it's useful
o Fixed the logger

Modified:
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/actions/AbstractReadEncryptedPart.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/actions/StoreAuthenticator.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/StoreEncAuthorizationData.java
    directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/TicketDecoderTest.java

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/actions/AbstractReadEncryptedPart.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/actions/AbstractReadEncryptedPart.java?rev=1039696&r1=1039695&r2=1039696&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/actions/AbstractReadEncryptedPart.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/actions/AbstractReadEncryptedPart.java
Sat Nov 27 15:17:57 2010
@@ -26,7 +26,6 @@ import org.apache.directory.shared.asn1.
 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.KerberosMessageGrammar;
 import org.apache.directory.shared.kerberos.codec.encryptedData.EncryptedDataContainer;
 import org.apache.directory.shared.kerberos.components.EncryptedData;
 import org.slf4j.Logger;
@@ -41,7 +40,7 @@ import org.slf4j.LoggerFactory;
 public abstract class AbstractReadEncryptedPart extends GrammarAction
 {
     /** The logger */
-    private static final Logger LOG = LoggerFactory.getLogger( KerberosMessageGrammar.class
);
+    private static final Logger LOG = LoggerFactory.getLogger( "ASN1-DECODER" );
 
     /** Speedup for logs */
     private static final boolean IS_DEBUG = LOG.isDebugEnabled();

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/actions/StoreAuthenticator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/actions/StoreAuthenticator.java?rev=1039696&r1=1039695&r2=1039696&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/actions/StoreAuthenticator.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/actions/StoreAuthenticator.java
Sat Nov 27 15:17:57 2010
@@ -21,19 +21,9 @@ package org.apache.directory.shared.kerb
 
 
 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.KerberosMessageGrammar;
+import org.apache.directory.shared.kerberos.codec.actions.AbstractReadEncryptedPart;
 import org.apache.directory.shared.kerberos.codec.apReq.ApReqContainer;
-import org.apache.directory.shared.kerberos.codec.encryptedData.EncryptedDataContainer;
 import org.apache.directory.shared.kerberos.components.EncryptedData;
-import org.apache.directory.shared.kerberos.messages.ApReq;
-import org.apache.directory.shared.ldap.util.StringTools;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -41,72 +31,25 @@ import org.slf4j.LoggerFactory;
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class StoreAuthenticator extends GrammarAction
+public class StoreAuthenticator extends AbstractReadEncryptedPart
 {
-    /** 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 StoreAuthenticator action.
      */
     public StoreAuthenticator()
     {
-        super( "Authenticator" );
+        super( "Encrypted Authenticator" );
     }
 
 
     /**
      * {@inheritDoc}
      */
-    public void action( Asn1Container container ) throws DecoderException
+    @Override
+    protected void setEncryptedData( EncryptedData encryptedData, Asn1Container container
)
     {
         ApReqContainer apReqContainer = ( ApReqContainer ) container;
-
-        TLV tlv = apReqContainer.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 ) );
-        }
-        
-        // Now, let's decode the Authenticator
-        Asn1Decoder encryptedDataDecoder = new Asn1Decoder();
-        
-        EncryptedDataContainer encryptedDataContainer = new EncryptedDataContainer();
-        encryptedDataContainer.setStream( container.getStream() );
-
-        // Decode the Authenticator PDU
-        try
-        {
-            encryptedDataDecoder.decode( container.getStream(), encryptedDataContainer );
-        }
-        catch ( DecoderException de )
-        {
-            throw de;
-        }
-
-        EncryptedData encryptedData = encryptedDataContainer.getEncryptedData();
-        ApReq apReq = apReqContainer.getApReq();
-        apReq.setAuthenticator( encryptedData );
-
-        if ( IS_DEBUG )
-        {
-            LOG.debug( "Authenticator : {}", StringTools.dumpBytes( encryptedData.getCipher()
) );
-        }
-
-        // Update the TLV
-        tlv.setExpectedLength( tlv.getExpectedLength() - tlv.getLength() );
-
-        // Update the parent
-        container.updateParent();
+        apReqContainer.getApReq().setAuthenticator( encryptedData );
 
         container.setGrammarEndAllowed( true );
     }

Modified: 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=1039696&r1=1039695&r2=1039696&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/StoreEncAuthorizationData.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/StoreEncAuthorizationData.java
Sat Nov 27 15:17:57 2010
@@ -21,17 +21,9 @@ package org.apache.directory.shared.kerb
 
 
 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.actions.AbstractReadEncryptedPart;
 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;
 
 
 /**
@@ -39,15 +31,8 @@ import org.slf4j.LoggerFactory;
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class StoreEncAuthorizationData extends GrammarAction
+public class StoreEncAuthorizationData extends AbstractReadEncryptedPart
 {
-    /** 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.
      */
@@ -60,56 +45,12 @@ public class StoreEncAuthorizationData e
     /**
      * {@inheritDoc}
      */
-    public void action( Asn1Container container ) throws DecoderException
+    @Override
+    protected void setEncryptedData( EncryptedData encryptedData, Asn1Container container
)
     {
         KdcReqBodyContainer kdcReqBodyContainer = ( KdcReqBodyContainer ) container;
+        kdcReqBodyContainer.getKdcReqBody().setEncAuthorizationData( encryptedData );
 
-        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 expected length for the current TLV
-        tlv.setExpectedLength( tlv.getExpectedLength() - tlv.getLength() );
-
-        // Update the parent
-        container.updateParent();
-        
         container.setGrammarEndAllowed( true );
-        
-        if ( IS_DEBUG )
-        {
-            LOG.debug( "enc-authorization-data : {}", encryptedData );
-        }
     }
 }

Modified: directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/TicketDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/TicketDecoderTest.java?rev=1039696&r1=1039695&r2=1039696&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/TicketDecoderTest.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/TicketDecoderTest.java
Sat Nov 27 15:17:57 2010
@@ -56,7 +56,7 @@ public class TicketDecoderTest
      * Test the decoding of a Ticket message
      */
     @Test
-    public void testDecodeTicket()
+    public void testDecodeFullTicket()
     {
         Asn1Decoder kerberosDecoder = new Asn1Decoder();
 



Mime
View raw message