directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1034415 - in /directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody: KdcReqBodyGrammar.java KdcReqBodyStatesEnum.java actions/StoreNonce.java
Date Fri, 12 Nov 2010 15:06:42 GMT
Author: elecharny
Date: Fri Nov 12 15:06:42 2010
New Revision: 1034415

URL: http://svn.apache.org/viewvc?rev=1034415&view=rev
Log:
Added the till and nonce

Added:
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/StoreNonce.java
Modified:
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/KdcReqBodyGrammar.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/KdcReqBodyStatesEnum.java

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/KdcReqBodyGrammar.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/KdcReqBodyGrammar.java?rev=1034415&r1=1034414&r2=1034415&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/KdcReqBodyGrammar.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/KdcReqBodyGrammar.java
Fri Nov 12 15:06:42 2010
@@ -30,6 +30,8 @@ import org.apache.directory.shared.kerbe
 import org.apache.directory.shared.kerberos.codec.kdcReqBody.actions.StoreCName;
 import org.apache.directory.shared.kerberos.codec.kdcReqBody.actions.StoreFrom;
 import org.apache.directory.shared.kerberos.codec.kdcReqBody.actions.StoreKdcOptions;
+import org.apache.directory.shared.kerberos.codec.kdcReqBody.actions.StoreNonce;
+import org.apache.directory.shared.kerberos.codec.kdcReqBody.actions.StoreRTime;
 import org.apache.directory.shared.kerberos.codec.kdcReqBody.actions.StoreRealm;
 import org.apache.directory.shared.kerberos.codec.kdcReqBody.actions.StoreSName;
 import org.apache.directory.shared.kerberos.codec.kdcReqBody.actions.StoreTill;
@@ -214,6 +216,57 @@ public final class KdcReqBodyGrammar ext
        super.transitions[KdcReqBodyStatesEnum.KDC_REQ_BODY_TILL_STATE.ordinal()][UniversalTag.GENERALIZED_TIME.getValue()]
= new GrammarTransition(
             KdcReqBodyStatesEnum.KDC_REQ_BODY_TILL_STATE, KdcReqBodyStatesEnum.KDC_REQ_BODY_RTIME_OR_NONCE_TAG_STATE,
UniversalTag.GENERALIZED_TIME.getValue(),
             new StoreTill() );
+
+       // --------------------------------------------------------------------------------------------
+       // Transition from till value to rtime 
+       // --------------------------------------------------------------------------------------------
+       // KDC-REQ-BODY    ::= SEQUENCE {
+       //         ...
+       //         rtime                    [6] 
+      super.transitions[KdcReqBodyStatesEnum.KDC_REQ_BODY_RTIME_OR_NONCE_TAG_STATE.ordinal()][KerberosConstants.KDC_REQ_BODY_RTIME_TAG]
= new GrammarTransition(
+           KdcReqBodyStatesEnum.KDC_REQ_BODY_RTIME_OR_NONCE_TAG_STATE, KdcReqBodyStatesEnum.KDC_REQ_BODY_RTIME_STATE,
KerberosConstants.KDC_REQ_BODY_RTIME_TAG,
+           new CheckNotNullLength() );
+
+      // --------------------------------------------------------------------------------------------
+      // Transition from till value to nonce 
+      // --------------------------------------------------------------------------------------------
+      // KDC-REQ-BODY    ::= SEQUENCE {
+      //         ...
+      //         nonce                    [7]
+     super.transitions[KdcReqBodyStatesEnum.KDC_REQ_BODY_RTIME_OR_NONCE_TAG_STATE.ordinal()][KerberosConstants.KDC_REQ_BODY_NONCE_TAG]
= new GrammarTransition(
+          KdcReqBodyStatesEnum.KDC_REQ_BODY_RTIME_OR_NONCE_TAG_STATE, KdcReqBodyStatesEnum.KDC_REQ_BODY_NONCE_STATE,
KerberosConstants.KDC_REQ_BODY_NONCE_TAG,
+          new CheckNotNullLength() );
+
+     // --------------------------------------------------------------------------------------------
+     // Transition from rtime to nonce tag
+     // --------------------------------------------------------------------------------------------
+     // KDC-REQ-BODY    ::= SEQUENCE {
+     //         ...
+     //         rtime                    [6] KerberosTime
+    super.transitions[KdcReqBodyStatesEnum.KDC_REQ_BODY_RTIME_STATE.ordinal()][UniversalTag.GENERALIZED_TIME.getValue()]
= new GrammarTransition(
+         KdcReqBodyStatesEnum.KDC_REQ_BODY_RTIME_STATE, KdcReqBodyStatesEnum.KDC_REQ_BODY_NONCE_TAG_STATE,
UniversalTag.GENERALIZED_TIME.getValue(),
+         new StoreRTime() );
+
+    // --------------------------------------------------------------------------------------------
+    // Transition from nonce tag to nonce value
+    // --------------------------------------------------------------------------------------------
+    // KDC-REQ-BODY    ::= SEQUENCE {
+    //         ...
+    //         nonce                    [7] UInt32
+   super.transitions[KdcReqBodyStatesEnum.KDC_REQ_BODY_NONCE_TAG_STATE.ordinal()][KerberosConstants.KDC_REQ_BODY_NONCE_TAG]
= new GrammarTransition(
+        KdcReqBodyStatesEnum.KDC_REQ_BODY_NONCE_TAG_STATE, KdcReqBodyStatesEnum.KDC_REQ_BODY_NONCE_STATE,
KerberosConstants.KDC_REQ_BODY_NONCE_TAG,
+        new CheckNotNullLength() );
+
+    // --------------------------------------------------------------------------------------------
+    // Transition from nonce value to etype Tag
+    // --------------------------------------------------------------------------------------------
+    // KDC-REQ-BODY    ::= SEQUENCE {
+    //         ...
+    //         etype                    [8]
+   super.transitions[KdcReqBodyStatesEnum.KDC_REQ_BODY_NONCE_STATE.ordinal()][UniversalTag.INTEGER.getValue()]
= new GrammarTransition(
+        KdcReqBodyStatesEnum.KDC_REQ_BODY_NONCE_TAG_STATE, KdcReqBodyStatesEnum.KDC_REQ_BODY_ETYPE_TAG_STATE,
UniversalTag.INTEGER.getValue(),
+        new StoreNonce() );
+
 }
 
 

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/KdcReqBodyStatesEnum.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/KdcReqBodyStatesEnum.java?rev=1034415&r1=1034414&r2=1034415&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/KdcReqBodyStatesEnum.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/KdcReqBodyStatesEnum.java
Fri Nov 12 15:06:42 2010
@@ -56,10 +56,10 @@ public enum KdcReqBodyStatesEnum impleme
     KDC_REQ_BODY_TILL_STATE,                    // 11
     
     KDC_REQ_BODY_RTIME_OR_NONCE_TAG_STATE,      // 12
-    KDC_REQ_BODY_RTIME_STATE,                   // 15
+    KDC_REQ_BODY_RTIME_STATE,                   // 13
 
-    KDC_REQ_BODY_NONCE_TAG_STATE,               // 16
-    KDC_REQ_BODY_NONCE_STATE,                   // 17
+    KDC_REQ_BODY_NONCE_TAG_STATE,               // 14
+    KDC_REQ_BODY_NONCE_STATE,                   // 15
 
     KDC_REQ_BODY_ETYPE_TAG_STATE,               // 18
     KDC_REQ_BODY_ETYPE_SEQ_STATE,               // 19

Added: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/StoreNonce.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/StoreNonce.java?rev=1034415&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/StoreNonce.java
(added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/StoreNonce.java
Fri Nov 12 15:06:42 2010
@@ -0,0 +1,103 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.shared.kerberos.codec.kdcReqBody.actions;
+
+
+import org.apache.directory.shared.asn1.ber.Asn1Container;
+import org.apache.directory.shared.asn1.ber.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.codec.kdcReqBody.KdcReqBodyContainer;
+import org.apache.directory.shared.kerberos.components.KdcReqBody;
+import org.apache.directory.shared.ldap.util.StringTools;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store the Nonce
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoreNonce extends GrammarAction
+{
+    /** The logger */
+    private static final Logger LOG = LoggerFactory.getLogger( StoreNonce.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
+
+
+    /**
+     * Instantiates a new StoreNonce action.
+     */
+    public StoreNonce()
+    {
+        super( "KDC-REQ-BODY nonce" );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void action( Asn1Container container ) throws DecoderException
+    {
+        KdcReqBodyContainer kdcReqBodyContainer = ( KdcReqBodyContainer ) container;
+
+        TLV tlv = kdcReqBodyContainer.getCurrentTLV();
+
+        // The Length should not be null
+        if ( tlv.getLength() == 0 )
+        {
+            LOG.error( I18n.err( I18n.ERR_04066 ) );
+
+            // This will generate a PROTOCOL_ERROR
+            throw new DecoderException( I18n.err( I18n.ERR_04067 ) );
+        }
+        
+        KdcReqBody kdcReqBody = kdcReqBodyContainer.getKdcReqBody();
+        
+        Value value = tlv.getValue();
+        
+        try
+        {
+            int nonce = IntegerDecoder.parse( value );
+
+            kdcReqBody.setNonce( nonce );
+
+            if ( IS_DEBUG )
+            {
+                LOG.debug( "nonce : {}", nonce );
+            }
+        }
+        catch ( IntegerDecoderException ide )
+        {
+            LOG.error( I18n.err( I18n.ERR_04070, StringTools.dumpBytes( value.getData() ),
ide
+                .getLocalizedMessage() ) );
+
+            // This will generate a PROTOCOL_ERROR
+            throw new DecoderException( ide.getMessage() );
+        }
+    }
+}



Mime
View raw message