directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1036480 - in /directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec: actions/ kdcRep/ kdcRep/actions/ kdcReq/ kdcReq/actions/
Date Thu, 18 Nov 2010 15:12:55 GMT
Author: kayyagari
Date: Thu Nov 18 15:12:54 2010
New Revision: 1036480

URL: http://svn.apache.org/viewvc?rev=1036480&view=rev
Log:
o resurrected the deletec CheckMsgType class from kdcRep package
o renamed the common CheckMesgType to AbstractReadMsgType
o fixed the grammar classes

Added:
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/actions/AbstractReadMsgType.java
      - copied, changed from r1036435, directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/actions/CheckMsgType.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcRep/actions/CheckMsgType.java
  (contents, props changed)
      - copied, changed from r1036391, directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcRep/actions/CheckMsgType.java
Removed:
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/actions/CheckMsgType.java
Modified:
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcRep/KdcRepGrammar.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReq/KdcReqGrammar.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReq/actions/CheckMsgType.java

Copied: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/actions/AbstractReadMsgType.java
(from r1036435, directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/actions/CheckMsgType.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/actions/AbstractReadMsgType.java?p2=directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/actions/AbstractReadMsgType.java&p1=directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/actions/CheckMsgType.java&r1=1036435&r2=1036480&rev=1036480&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/actions/CheckMsgType.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/actions/AbstractReadMsgType.java
Thu Nov 18 15:12:54 2010
@@ -20,8 +20,6 @@
 package org.apache.directory.shared.kerberos.codec.actions;
 
 
-import java.util.Arrays;
-
 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;
@@ -41,28 +39,33 @@ import org.slf4j.LoggerFactory;
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class CheckMsgType extends GrammarAction
+public abstract class AbstractReadMsgType extends GrammarAction
 {
     /** The logger */
-    private static final Logger LOG = LoggerFactory.getLogger( CheckMsgType.class );
+    private static final Logger LOG = LoggerFactory.getLogger( AbstractReadMsgType.class
);
 
     /** Speedup for logs */
     private static final boolean IS_DEBUG = LOG.isDebugEnabled();
 
-    /** an array of allowed message types */
-    private KerberosMessageType[] validMsgTypes;
-
-
     /**
      * Instantiates a new StoreMsgType action.
      */
-    public CheckMsgType( String name, KerberosMessageType... validMsgTypes )
+    public AbstractReadMsgType( String name )
     {
         super( name );
-        this.validMsgTypes = validMsgTypes;
     }
 
+    
+    /**
+     * verifies whether the given message type is acceptable for the ASN.1 object type
+     * present in the container
+     * 
+     * @param krbMsgType the message type
+     * @throws DecoderException if the message type is not acceptable for the ASN.1 object
present in the container
+     */
+    protected abstract void verifyMsgType( KerberosMessageType krbMsgType, Asn1Container
container ) throws DecoderException;
 
+    
     /**
      * {@inheritDoc}
      */
@@ -86,31 +89,12 @@ public class CheckMsgType extends Gramma
             int msgType = IntegerDecoder.parse( value );
             KerberosMessageType krbMsgType = KerberosMessageType.getTypeByOrdinal( msgType
);
 
-            boolean found = false;
-
-            for ( KerberosMessageType kbt : validMsgTypes )
-            {
-                if ( krbMsgType == kbt )
-                {
-                    found = true;
-                    break;
-                }
-            }
-
-            // The message type must be the expected one
-            if ( !found )
-            {
-                String msg = "The acceptable msg-types for the grammar action '" + name +
"' are " + Arrays.asList( validMsgTypes );
-                LOG.error( I18n.err( I18n.ERR_04070, StringTools.dumpBytes( value.getData()
), msg ) );
-
-                // This will generate a PROTOCOL_ERROR
-                throw new DecoderException( msg );
-            }
-
             if ( IS_DEBUG )
             {
                 LOG.debug( "msg-type : {}", krbMsgType );
             }
+            
+            verifyMsgType( krbMsgType, container );
         }
         catch ( IntegerDecoderException ide )
         {

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcRep/KdcRepGrammar.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcRep/KdcRepGrammar.java?rev=1036480&r1=1036479&r2=1036480&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcRep/KdcRepGrammar.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcRep/KdcRepGrammar.java
Thu Nov 18 15:12:54 2010
@@ -25,10 +25,9 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.ber.grammar.GrammarTransition;
 import org.apache.directory.shared.asn1.ber.tlv.UniversalTag;
 import org.apache.directory.shared.kerberos.KerberosConstants;
-import org.apache.directory.shared.kerberos.KerberosMessageType;
-import org.apache.directory.shared.kerberos.codec.actions.CheckMsgType;
 import org.apache.directory.shared.kerberos.codec.actions.CheckNotNullLength;
 import org.apache.directory.shared.kerberos.codec.kdcRep.actions.AddPaData;
+import org.apache.directory.shared.kerberos.codec.kdcRep.actions.CheckMsgType;
 import org.apache.directory.shared.kerberos.codec.kdcRep.actions.StoreCName;
 import org.apache.directory.shared.kerberos.codec.kdcRep.actions.StoreCRealm;
 import org.apache.directory.shared.kerberos.codec.kdcRep.actions.StoreEncPart;
@@ -114,7 +113,7 @@ public final class KdcRepGrammar extends
         //         msg-type        [1] INTEGER (11 -- AS -- | 13 -- TGS --),
         super.transitions[KdcRepStatesEnum.KDC_REP_MSG_TYPE_TAG_STATE.ordinal()][UniversalTag.INTEGER.getValue()]
= new GrammarTransition(
             KdcRepStatesEnum.KDC_REP_MSG_TYPE_TAG_STATE, KdcRepStatesEnum.KDC_REP_MSG_TYPE_STATE,
UniversalTag.INTEGER.getValue(),
-            new CheckMsgType( "KDC-REP msg-type", KerberosMessageType.AS_REP, KerberosMessageType.TGS_REP
) );
+            new CheckMsgType() );
         
         // --------------------------------------------------------------------------------------------
         // Transition from msg-type value pa-data tag

Copied: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcRep/actions/CheckMsgType.java
(from r1036391, directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcRep/actions/CheckMsgType.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcRep/actions/CheckMsgType.java?p2=directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcRep/actions/CheckMsgType.java&p1=directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcRep/actions/CheckMsgType.java&r1=1036391&r2=1036480&rev=1036480&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcRep/actions/CheckMsgType.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcRep/actions/CheckMsgType.java
Thu Nov 18 15:12:54 2010
@@ -21,17 +21,12 @@ 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.kerberos.KerberosMessageType;
+import org.apache.directory.shared.kerberos.codec.actions.AbstractReadMsgType;
 import org.apache.directory.shared.kerberos.codec.kdcRep.KdcRepContainer;
 import org.apache.directory.shared.kerberos.components.KdcRep;
-import org.apache.directory.shared.ldap.util.StringTools;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -41,15 +36,11 @@ import org.slf4j.LoggerFactory;
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class CheckMsgType extends GrammarAction
+public class CheckMsgType extends AbstractReadMsgType
 {
     /** The logger */
     private static final Logger LOG = LoggerFactory.getLogger( CheckMsgType.class );
 
-    /** Speedup for logs */
-    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
-
-
     /**
      * Instantiates a new StoreMsgType action.
      */
@@ -62,51 +53,19 @@ public class CheckMsgType extends Gramma
     /**
      * {@inheritDoc}
      */
-    public void action( Asn1Container container ) throws DecoderException
+    @Override
+    protected void verifyMsgType( KerberosMessageType krbMsgType, Asn1Container container
) throws DecoderException
     {
         KdcRepContainer kdcRepContainer = ( KdcRepContainer ) container;
-
-        TLV tlv = kdcRepContainer.getCurrentTLV();
-
-        // The Length should not be null and should be 1
-        if ( tlv.getLength() != 1 )
-        {
-            LOG.error( I18n.err( I18n.ERR_04066 ) );
-
-            // This will generate a PROTOCOL_ERROR
-            throw new DecoderException( I18n.err( I18n.ERR_04067 ) );
-        }
-        
         KdcRep kdcRep = kdcRepContainer.getKdcRep();
-        
-        Value value = tlv.getValue();
-        
-        try
-        {
-            int msgType = IntegerDecoder.parse( value );
-            KerberosMessageType krbMsgType = KerberosMessageType.getTypeByOrdinal( msgType
);
-            
-            // The message type must be the expected one
-            if ( krbMsgType != kdcRep.getMsgType() )
-            {
-                LOG.error( I18n.err( I18n.ERR_04070, StringTools.dumpBytes( value.getData()
), "The msg-type should be AS-REQ or TGS-REQ" ) );
-
-                // This will generate a PROTOCOL_ERROR
-                throw new DecoderException( "The msg-type should be AS-REQ or TGS-REQ" );
-            }
-
-            if ( IS_DEBUG )
-            {
-                LOG.debug( "msg-type : {}", krbMsgType );
-            }
-        }
-        catch ( IntegerDecoderException ide )
+
+        // The message type must be the expected one
+        if ( krbMsgType != kdcRep.getMsgType() )
         {
-            LOG.error( I18n.err( I18n.ERR_04070, StringTools.dumpBytes( value.getData() ),
ide
-                .getLocalizedMessage() ) );
+            LOG.error( I18n.err( I18n.ERR_04070, krbMsgType, "The msg-type should be AS-REQ
or TGS-REQ" ) );
 
             // This will generate a PROTOCOL_ERROR
-            throw new DecoderException( ide.getMessage() );
+            throw new DecoderException( "The msg-type should be AS-REQ or TGS-REQ" );
         }
     }
 }

Propchange: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcRep/actions/CheckMsgType.java
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Thu Nov 18 15:12:54 2010
@@ -0,0 +1,6 @@
+/directory/apacheds/branches/apacheds-codec-merge/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcRep/actions/CheckMsgType.java:982369-987590
+/directory/apacheds/branches/apacheds-config/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcRep/actions/CheckMsgType.java:1023442-1029077
+/directory/apacheds/branches/apacheds-replication/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcRep/actions/CheckMsgType.java:749790-764110
+/directory/apacheds/branches/apacheds-schema/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcRep/actions/CheckMsgType.java:806623-896441
+/directory/apacheds/branches/apacheds-subtree/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcRep/actions/CheckMsgType.java:965203-965686
+/directory/apacheds/branches/xdbm-refactoring/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcRep/actions/CheckMsgType.java:945827-946347

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReq/KdcReqGrammar.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReq/KdcReqGrammar.java?rev=1036480&r1=1036479&r2=1036480&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReq/KdcReqGrammar.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReq/KdcReqGrammar.java
Thu Nov 18 15:12:54 2010
@@ -25,10 +25,9 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.ber.grammar.GrammarTransition;
 import org.apache.directory.shared.asn1.ber.tlv.UniversalTag;
 import org.apache.directory.shared.kerberos.KerberosConstants;
-import org.apache.directory.shared.kerberos.KerberosMessageType;
-import org.apache.directory.shared.kerberos.codec.actions.CheckMsgType;
 import org.apache.directory.shared.kerberos.codec.actions.CheckNotNullLength;
 import org.apache.directory.shared.kerberos.codec.kdcReq.actions.AddPaData;
+import org.apache.directory.shared.kerberos.codec.kdcReq.actions.CheckMsgType;
 import org.apache.directory.shared.kerberos.codec.kdcReq.actions.StoreKdcReqBody;
 import org.apache.directory.shared.kerberos.codec.kdcReq.actions.StorePvno;
 import org.slf4j.Logger;
@@ -111,7 +110,7 @@ public final class KdcReqGrammar extends
         //         msg-type        [2] INTEGER (10 -- AS -- | 12 -- TGS --),
         super.transitions[KdcReqStatesEnum.KDC_REQ_MSG_TYPE_TAG_STATE.ordinal()][UniversalTag.INTEGER.getValue()]
= new GrammarTransition(
             KdcReqStatesEnum.KDC_REQ_MSG_TYPE_TAG_STATE, KdcReqStatesEnum.KDC_REQ_MSG_TYPE_STATE,
UniversalTag.INTEGER.getValue(),
-            new CheckMsgType( "KDC-REQ msg-type", KerberosMessageType.AS_REQ, KerberosMessageType.TGS_REQ
) );
+            new CheckMsgType() );
         
         // --------------------------------------------------------------------------------------------
         // Transition from msg-type value to padata tag

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReq/actions/CheckMsgType.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReq/actions/CheckMsgType.java?rev=1036480&r1=1036479&r2=1036480&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReq/actions/CheckMsgType.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReq/actions/CheckMsgType.java
Thu Nov 18 15:12:54 2010
@@ -21,17 +21,12 @@ 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.kerberos.KerberosMessageType;
+import org.apache.directory.shared.kerberos.codec.actions.AbstractReadMsgType;
 import org.apache.directory.shared.kerberos.codec.kdcReq.KdcReqContainer;
 import org.apache.directory.shared.kerberos.components.KdcReq;
-import org.apache.directory.shared.ldap.util.StringTools;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -41,14 +36,11 @@ import org.slf4j.LoggerFactory;
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class CheckMsgType extends GrammarAction
+public class CheckMsgType extends AbstractReadMsgType
 {
     /** The logger */
     private static final Logger LOG = LoggerFactory.getLogger( CheckMsgType.class );
 
-    /** Speedup for logs */
-    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
-
 
     /**
      * Instantiates a new StoreMsgType action.
@@ -62,51 +54,20 @@ public class CheckMsgType extends Gramma
     /**
      * {@inheritDoc}
      */
-    public void action( Asn1Container container ) throws DecoderException
+    @Override
+    protected void verifyMsgType( KerberosMessageType krbMsgType, Asn1Container container
) throws DecoderException
     {
         KdcReqContainer kdcReqContainer = ( KdcReqContainer ) container;
 
-        TLV tlv = kdcReqContainer.getCurrentTLV();
-
-        // The Length should not be null and should be 1
-        if ( tlv.getLength() != 1 )
-        {
-            LOG.error( I18n.err( I18n.ERR_04066 ) );
-
-            // This will generate a PROTOCOL_ERROR
-            throw new DecoderException( I18n.err( I18n.ERR_04067 ) );
-        }
-        
         KdcReq kdcReq = kdcReqContainer.getKdcReq();
-        
-        Value value = tlv.getValue();
-        
-        try
-        {
-            int msgType = IntegerDecoder.parse( value );
-            KerberosMessageType krbMsgType = KerberosMessageType.getTypeByOrdinal( msgType
);
-            
-            // The message type must be the expected one
-            if ( krbMsgType != kdcReq.getMsgType() )
-            {
-                LOG.error( I18n.err( I18n.ERR_04070, StringTools.dumpBytes( value.getData()
), "The msg-type should be AS-REQ or TGS-REQ" ) );
-
-                // This will generate a PROTOCOL_ERROR
-                throw new DecoderException( "The msg-type should be AS-REQ or TGS-REQ" );
-            }
-
-            if ( IS_DEBUG )
-            {
-                LOG.debug( "msg-type : {}", krbMsgType );
-            }
-        }
-        catch ( IntegerDecoderException ide )
+
+        // The message type must be the expected one
+        if ( krbMsgType != kdcReq.getMsgType() )
         {
-            LOG.error( I18n.err( I18n.ERR_04070, StringTools.dumpBytes( value.getData() ),
ide
-                .getLocalizedMessage() ) );
+            LOG.error( I18n.err( I18n.ERR_04070, krbMsgType, "The msg-type should be AS-REQ
or TGS-REQ" ) );
 
             // This will generate a PROTOCOL_ERROR
-            throw new DecoderException( ide.getMessage() );
+            throw new DecoderException( "The msg-type should be AS-REQ or TGS-REQ" );
         }
     }
 }



Mime
View raw message