directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1033798 - in /directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody: KdcReqBodyGrammar.java actions/StoreCName.java actions/StoreRealm.java
Date Thu, 11 Nov 2010 01:54:03 GMT
Author: elecharny
Date: Thu Nov 11 01:54:02 2010
New Revision: 1033798

URL: http://svn.apache.org/viewvc?rev=1033798&view=rev
Log:
Some more elements for the KRB-REQ-BODY decoder

Added:
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/StoreRealm.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/actions/StoreCName.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=1033798&r1=1033797&r2=1033798&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
Thu Nov 11 01:54:02 2010
@@ -29,6 +29,7 @@ import org.apache.directory.shared.kerbe
 import org.apache.directory.shared.kerberos.codec.kdcReqBody.actions.KdcReqBodyInit;
 import org.apache.directory.shared.kerberos.codec.kdcReqBody.actions.StoreCName;
 import org.apache.directory.shared.kerberos.codec.kdcReqBody.actions.StoreKdcOptions;
+import org.apache.directory.shared.kerberos.codec.kdcReqBody.actions.StoreRealm;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -110,6 +111,26 @@ public final class KdcReqBodyGrammar ext
         super.transitions[KdcReqBodyStatesEnum.KRB_REQ_BODY_CNAME_TAG_STATE.ordinal()][KerberosConstants.KDC_REQ_BODY_REALM_TAG]
= new GrammarTransition(
             KdcReqBodyStatesEnum.KRB_REQ_BODY_CNAME_TAG_STATE, KdcReqBodyStatesEnum.KRB_REQ_BODY_REALM_TAG_STATE,
KerberosConstants.KDC_REQ_BODY_REALM_TAG,
             new CheckNotNullLength() );
+        
+        // --------------------------------------------------------------------------------------------
+        // Transition from cname tag to realm tag
+        // --------------------------------------------------------------------------------------------
+        // KDC-REQ-BODY    ::= SEQUENCE {
+        //         ...
+        //         realm                   [2]
+        super.transitions[KdcReqBodyStatesEnum.KRB_REQ_BODY_REALM_TAG_STATE.ordinal()][KerberosConstants.KDC_REQ_BODY_REALM_TAG]
= new GrammarTransition(
+            KdcReqBodyStatesEnum.KRB_REQ_BODY_REALM_TAG_STATE, KdcReqBodyStatesEnum.KRB_REQ_BODY_REALM_STATE,
KerberosConstants.KDC_REQ_BODY_REALM_TAG,
+            new CheckNotNullLength() );
+        
+        // --------------------------------------------------------------------------------------------
+        // Transition from realm tag to realm value
+        // --------------------------------------------------------------------------------------------
+        // KDC-REQ-BODY    ::= SEQUENCE {
+        //         ...
+        //         realm                   [2] Realm
+        super.transitions[KdcReqBodyStatesEnum.KRB_REQ_BODY_REALM_STATE.ordinal()][UniversalTag.GENERAL_STRING.getValue()]
= new GrammarTransition(
+            KdcReqBodyStatesEnum.KRB_REQ_BODY_REALM_STATE, KdcReqBodyStatesEnum.KRB_REQ_BODY_SNAME_TAG_STATE,
UniversalTag.GENERAL_STRING.getValue(),
+            new StoreRealm() );
     }
 
 

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/StoreCName.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/StoreCName.java?rev=1033798&r1=1033797&r2=1033798&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/StoreCName.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/StoreCName.java
Thu Nov 11 01:54:02 2010
@@ -53,7 +53,7 @@ public class StoreCName extends GrammarA
      */
     public StoreCName()
     {
-        super( "Stores the KDCOptions" );
+        super( "Stores the CName" );
     }
 
 

Added: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/StoreRealm.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/StoreRealm.java?rev=1033798&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/StoreRealm.java
(added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/StoreRealm.java
Thu Nov 11 01:54:02 2010
@@ -0,0 +1,89 @@
+/*
+ *  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.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 Realm
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoreRealm extends GrammarAction
+{
+    /** The logger */
+    private static final Logger LOG = LoggerFactory.getLogger( StoreRealm.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
+
+
+    /**
+     * Instantiates a new StoreRealm action.
+     */
+    public StoreRealm()
+    {
+        super( "Stores the Realm" );
+    }
+
+
+    /**
+     * {@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();
+        
+        // The value is the realm
+        Value value = tlv.getValue();
+        String realm = StringTools.utf8ToString( value.getData() );
+        kdcReqBody.setRealm( realm );
+        
+        if ( IS_DEBUG )
+        {
+            LOG.debug( "Realm : {}", realm );
+        }
+    }
+}



Mime
View raw message