directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1037160 - in /directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos: ./ codec/etypeInfoEntry/ codec/etypeInfoEntry/actions/ components/
Date Sat, 20 Nov 2010 10:45:39 GMT
Author: elecharny
Date: Sat Nov 20 10:45:38 2010
New Revision: 1037160

URL: http://svn.apache.org/viewvc?rev=1037160&view=rev
Log:
o Added the ETYPE-INFO-ENTRY grammar
o Fixed some Javadoc typoes

Added:
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/etypeInfoEntry/
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/etypeInfoEntry/ETypeInfoEntryContainer.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/etypeInfoEntry/ETypeInfoEntryGrammar.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/etypeInfoEntry/ETypeInfoEntryStatesEnum.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/etypeInfoEntry/actions/
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/etypeInfoEntry/actions/ETypeInfoEntryInit.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/etypeInfoEntry/actions/StoreEType.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/components/ETypeInfoEntry.java
Modified:
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/KerberosConstants.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/HostAddress.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/PaData.java

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/KerberosConstants.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/KerberosConstants.java?rev=1037160&r1=1037159&r2=1037160&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/KerberosConstants.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/KerberosConstants.java
Sat Nov 20 10:45:38 2010
@@ -112,6 +112,11 @@ public class KerberosConstants
     /** EncryptionKey tags */
     public static final int ENCRYPTION_KEY_TYPE_TAG = 0xA0;
     public static final int ENCRYPTION_KEY_VALUE_TAG = 0xA1;
+    
+    /** ETYPE-INFO-ENTRY tags */
+    public static final int ETYPE_INFO_ENTRY_ETYPE_TAG = 0xA0;
+    public static final int ETYPE_INFO_ENTRY_SALT_TAG = 0xA1;
+    
 
     /** HostAddress' tags */
     public static final int HOST_ADDRESS_ADDR_TYPE_TAG = 0xA0;

Added: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/etypeInfoEntry/ETypeInfoEntryContainer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/etypeInfoEntry/ETypeInfoEntryContainer.java?rev=1037160&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/etypeInfoEntry/ETypeInfoEntryContainer.java
(added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/etypeInfoEntry/ETypeInfoEntryContainer.java
Sat Nov 20 10:45:38 2010
@@ -0,0 +1,66 @@
+/*
+ *  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.etypeInfoEntry;
+
+import org.apache.directory.shared.asn1.ber.AbstractContainer;
+import org.apache.directory.shared.kerberos.components.ETypeInfoEntry;
+
+
+/**
+ * The ETypeInfoEntry container stores the ETYPE-INFO-ENTRY decoded by the Asn1Decoder.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ETypeInfoEntryContainer extends AbstractContainer
+{
+    /** holds ETypeInfoEntry */
+    private ETypeInfoEntry etypeInfoEntry;
+
+    /**
+     * Creates a new ETypeInfoEntryContainer object.
+     */
+    public ETypeInfoEntryContainer()
+    {
+        super();
+        this.stateStack = new int[1];
+        this.grammar = ETypeInfoEntryGrammar.getInstance();
+        setTransition( ETypeInfoEntryStatesEnum.START_STATE );
+    }
+
+
+    /**
+     * @return Returns the ETypeInfoEntry.
+     */
+    public ETypeInfoEntry getETypeInfoEntry()
+    {
+        return etypeInfoEntry;
+    }
+
+    
+    /**
+     * Set a ETypeInfoEntry Object into the container
+     * 
+     * @param etypeInfoEntry The ETypeInfoEntry to set.
+     */
+    public void setETypeInfoEntry( ETypeInfoEntry etypeInfoEntry )
+    {
+        this.etypeInfoEntry = etypeInfoEntry;
+    }
+}

Added: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/etypeInfoEntry/ETypeInfoEntryGrammar.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/etypeInfoEntry/ETypeInfoEntryGrammar.java?rev=1037160&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/etypeInfoEntry/ETypeInfoEntryGrammar.java
(added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/etypeInfoEntry/ETypeInfoEntryGrammar.java
Sat Nov 20 10:45:38 2010
@@ -0,0 +1,125 @@
+/*
+ *  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.etypeInfoEntry;
+
+
+import org.apache.directory.shared.asn1.ber.grammar.AbstractGrammar;
+import org.apache.directory.shared.asn1.ber.grammar.Grammar;
+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.codec.actions.CheckNotNullLength;
+import org.apache.directory.shared.kerberos.codec.etypeInfoEntry.actions.ETypeInfoEntryInit;
+import org.apache.directory.shared.kerberos.codec.etypeInfoEntry.actions.StoreEType;
+import org.apache.directory.shared.kerberos.codec.etypeInfoEntry.actions.StoreSalt;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * This class implements the ETYPE-INFO-ENTRY structure. All the actions are declared
+ * in this class. As it is a singleton, these declaration are only done once. If
+ * an action is to be added or modified, this is where the work is to be done !
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public final class ETypeInfoEntryGrammar extends AbstractGrammar
+{
+    /** The logger */
+    static final Logger LOG = LoggerFactory.getLogger( ETypeInfoEntryGrammar.class );
+
+    /** A speedup for logger */
+    static final boolean IS_DEBUG = LOG.isDebugEnabled();
+
+    /** The instance of grammar. ETypeInfoEntryGrammar is a singleton */
+    private static Grammar instance = new ETypeInfoEntryGrammar();
+
+
+    /**
+     * Creates a new ETypeInfoEntryGrammar object.
+     */
+    private ETypeInfoEntryGrammar()
+    {
+        setName( ETypeInfoEntryGrammar.class.getName() );
+
+        // Create the transitions table
+        super.transitions = new GrammarTransition[ETypeInfoEntryStatesEnum.LAST_ETYPE_INFO_ENTRY_STATE.ordinal()][256];
+
+        // ============================================================================================
+        // ETYPE-INFO-ENTRY 
+        // ============================================================================================
+        // --------------------------------------------------------------------------------------------
+        // Transition from ETYPE-INFO-ENTRY init to ETYPE-INFO-ENTRY SEQ
+        // --------------------------------------------------------------------------------------------
+        // ETYPE-INFO-ENTRY         ::= SEQUENCE {
+        super.transitions[ETypeInfoEntryStatesEnum.START_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()]
= new GrammarTransition(
+            ETypeInfoEntryStatesEnum.START_STATE, ETypeInfoEntryStatesEnum.ETYPE_INFO_ENTRY_SEQ_STATE,
UniversalTag.SEQUENCE.getValue(),
+            new ETypeInfoEntryInit() );
+        
+        // --------------------------------------------------------------------------------------------
+        // Transition from ETYPE-INFO-ENTRY SEQ to etype tag
+        // --------------------------------------------------------------------------------------------
+        // ETYPE-INFO-ENTRY         ::= SEQUENCE {
+        //         etype           [0]
+        super.transitions[ETypeInfoEntryStatesEnum.ETYPE_INFO_ENTRY_SEQ_STATE.ordinal()][KerberosConstants.TRANSITED_ENCODING_TR_TYPE_TAG]
= new GrammarTransition(
+            ETypeInfoEntryStatesEnum.ETYPE_INFO_ENTRY_SEQ_STATE, ETypeInfoEntryStatesEnum.ETYPE_INFO_ENTRY_ETYPE_TAG_STATE,
KerberosConstants.TRANSITED_ENCODING_TR_TYPE_TAG,
+            new CheckNotNullLength() );
+        
+        // --------------------------------------------------------------------------------------------
+        // Transition from etype tag to etype value
+        // --------------------------------------------------------------------------------------------
+        // ETYPE-INFO-ENTRY         ::= SEQUENCE {
+        //         etype           [0] Int32,
+        super.transitions[ETypeInfoEntryStatesEnum.ETYPE_INFO_ENTRY_ETYPE_TAG_STATE.ordinal()][UniversalTag.INTEGER.getValue()]
= new GrammarTransition(
+            ETypeInfoEntryStatesEnum.ETYPE_INFO_ENTRY_ETYPE_TAG_STATE, ETypeInfoEntryStatesEnum.ETYPE_INFO_ENTRY_ETYPE_STATE,
UniversalTag.INTEGER.getValue(),
+            new StoreEType() );
+        
+        // --------------------------------------------------------------------------------------------
+        // Transition from etype value to salt tag
+        // --------------------------------------------------------------------------------------------
+        // ETYPE-INFO-ENTRY         ::= SEQUENCE {
+        //         ...
+        //         salt            [1]
+        super.transitions[ETypeInfoEntryStatesEnum.ETYPE_INFO_ENTRY_ETYPE_STATE.ordinal()][KerberosConstants.TRANSITED_ENCODING_CONTENTS_TAG]
= new GrammarTransition(
+            ETypeInfoEntryStatesEnum.ETYPE_INFO_ENTRY_ETYPE_STATE, ETypeInfoEntryStatesEnum.ETYPE_INFO_ENTRY_SALT_TAG_STATE,
KerberosConstants.TRANSITED_ENCODING_CONTENTS_TAG,
+            new CheckNotNullLength() );
+        
+        // --------------------------------------------------------------------------------------------
+        // Transition from salt tag to salt value
+        // --------------------------------------------------------------------------------------------
+        // ETYPE-INFO-ENTRY         ::= SEQUENCE {
+        //         ...
+        //         salt            [1] OCTET STRING OPTIONAL
+        super.transitions[ETypeInfoEntryStatesEnum.ETYPE_INFO_ENTRY_SALT_TAG_STATE.ordinal()][UniversalTag.OCTET_STRING.getValue()]
= new GrammarTransition(
+            ETypeInfoEntryStatesEnum.ETYPE_INFO_ENTRY_SALT_TAG_STATE, ETypeInfoEntryStatesEnum.ETYPE_INFO_ENTRY_SALT_STATE,
UniversalTag.OCTET_STRING.getValue(),
+            new StoreSalt() );
+    }
+
+
+    /**
+     * Get the instance of this grammar
+     * 
+     * @return An instance on the ETYPE-INFO-ENTRY Grammar
+     */
+    public static Grammar getInstance()
+    {
+        return instance;
+    }
+}

Added: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/etypeInfoEntry/ETypeInfoEntryStatesEnum.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/etypeInfoEntry/ETypeInfoEntryStatesEnum.java?rev=1037160&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/etypeInfoEntry/ETypeInfoEntryStatesEnum.java
(added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/etypeInfoEntry/ETypeInfoEntryStatesEnum.java
Sat Nov 20 10:45:38 2010
@@ -0,0 +1,112 @@
+/*
+ *  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.etypeInfoEntry;
+
+
+import org.apache.directory.shared.asn1.ber.grammar.Grammar;
+import org.apache.directory.shared.asn1.ber.grammar.States;
+import org.apache.directory.shared.kerberos.codec.KerberosMessageGrammar;
+
+
+/**
+ * This class store the ETYPE-INFO-ENTRY grammar's constants. It is also used for debugging
+ * purpose
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public enum ETypeInfoEntryStatesEnum implements States
+{
+    // Start
+    START_STATE,                        // 0
+    
+    ETYPE_INFO_ENTRY_SEQ_STATE,         // 1
+    
+    ETYPE_INFO_ENTRY_ETYPE_TAG_STATE,   // 2
+    
+    ETYPE_INFO_ENTRY_ETYPE_STATE,       // 3
+    
+    ETYPE_INFO_ENTRY_SALT_TAG_STATE,    // 4
+    
+    ETYPE_INFO_ENTRY_SALT_STATE,        // 5
+    
+    // End
+    LAST_ETYPE_INFO_ENTRY_STATE;        // 6
+
+    
+    /**
+     * Get the grammar name
+     * 
+     * @param grammar The grammar code
+     * @return The grammar name
+     */
+    public String getGrammarName( int grammar )
+    {
+        return "ETYPE_INFO_ENTRY_GRAMMAR";
+    }
+
+
+    /**
+     * Get the grammar name
+     * 
+     * @param grammar The grammar class
+     * @return The grammar name
+     */
+    public String getGrammarName( Grammar grammar )
+    {
+        if ( grammar instanceof KerberosMessageGrammar )
+        {
+            return "ETYPE_INFO_ENTRY_GRAMMAR";
+        }
+        else
+        {
+            return "UNKNOWN GRAMMAR";
+        }
+    }
+
+
+    /**
+     * Get the string representing the state
+     * 
+     * @param state The state number
+     * @return The String representing the state
+     */
+    public String getState( int state )
+    {
+        return ( ( state == LAST_ETYPE_INFO_ENTRY_STATE.ordinal() ) ? "LAST_ETYPE_INFO_ENTRY_STATE"
: name() );
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEndState()
+    {
+        return this == LAST_ETYPE_INFO_ENTRY_STATE;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public ETypeInfoEntryStatesEnum getStartState()
+    {
+        return START_STATE;
+    }
+}

Added: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/etypeInfoEntry/actions/ETypeInfoEntryInit.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/etypeInfoEntry/actions/ETypeInfoEntryInit.java?rev=1037160&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/etypeInfoEntry/actions/ETypeInfoEntryInit.java
(added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/etypeInfoEntry/actions/ETypeInfoEntryInit.java
Sat Nov 20 10:45:38 2010
@@ -0,0 +1,83 @@
+/*
+ *  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.etypeInfoEntry.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.codec.DecoderException;
+import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.kerberos.codec.etypeInfoEntry.ETypeInfoEntryContainer;
+import org.apache.directory.shared.kerberos.components.ETypeInfoEntry;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to initialize the ETYPE-INFO-ENTRY object
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ETypeInfoEntryInit extends GrammarAction
+{
+    /** The logger */
+    private static final Logger LOG = LoggerFactory.getLogger( ETypeInfoEntryInit.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
+
+
+    /**
+     * Instantiates a new ETypeInfoEntryInit action.
+     */
+    public ETypeInfoEntryInit()
+    {
+        super( "Creates a ETYPE-INFO-ENTRY instance" );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void action( Asn1Container container ) throws DecoderException
+    {
+        ETypeInfoEntryContainer etypeInfoEntryContainer = ( ETypeInfoEntryContainer ) container;
+
+        TLV tlv = etypeInfoEntryContainer.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 ) );
+        }
+        
+        ETypeInfoEntry etypeInfoEntry = new ETypeInfoEntry();
+        etypeInfoEntryContainer.setETypeInfoEntry( etypeInfoEntry );
+        
+        if ( IS_DEBUG )
+        {
+            LOG.debug( "ETYPE-INFO-ENTRY created" );
+        }
+    }
+}

Added: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/etypeInfoEntry/actions/StoreEType.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/etypeInfoEntry/actions/StoreEType.java?rev=1037160&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/etypeInfoEntry/actions/StoreEType.java
(added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/etypeInfoEntry/actions/StoreEType.java
Sat Nov 20 10:45:38 2010
@@ -0,0 +1,110 @@
+/*
+ *  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.etypeInfoEntry.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.etypeInfoEntry.ETypeInfoEntryContainer;
+import org.apache.directory.shared.kerberos.codec.types.EncryptionType;
+import org.apache.directory.shared.kerberos.components.ETypeInfoEntry;
+import org.apache.directory.shared.ldap.util.StringTools;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store the ETYPE-INFO-ENTRY etype
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoreEType extends GrammarAction
+{
+    /** The logger */
+    private static final Logger LOG = LoggerFactory.getLogger( StoreEType.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
+
+
+    /**
+     * Instantiates a new StoreEType action.
+     */
+    public StoreEType()
+    {
+        super( "ETYPE-INFO-ENTRY etype" );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void action( Asn1Container container ) throws DecoderException
+    {
+        ETypeInfoEntryContainer etypeInfoEntryContainer = ( ETypeInfoEntryContainer ) container;
+
+        TLV tlv = etypeInfoEntryContainer.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 etype is an integer
+        Value value = tlv.getValue();
+        
+        EncryptionType etype = null;
+        ETypeInfoEntry etypeInfoEntry = etypeInfoEntryContainer.getETypeInfoEntry();
+        
+        try
+        {
+            int eType = IntegerDecoder.parse( value );
+            etype = EncryptionType.getTypeByValue( eType );
+
+            etypeInfoEntry.setEType( etype );
+
+            if ( IS_DEBUG )
+            {
+                LOG.debug( "etype : " + etype );
+            }
+
+            // The next tag is optional, we can end here
+            etypeInfoEntryContainer.setGrammarEndAllowed( true );
+        }
+        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() );
+        }
+    }
+}

Added: 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=1037160&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/etypeInfoEntry/actions/StoreSalt.java
(added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/etypeInfoEntry/actions/StoreSalt.java
Sat Nov 20 10:45:38 2010
@@ -0,0 +1,88 @@
+/*
+ *  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.etypeInfoEntry.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.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;
+
+
+/**
+ * The action used to store the ETYPE-INFO-ENTRY cipher
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoreSalt extends GrammarAction
+{
+    /** 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" );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void action( Asn1Container container ) throws DecoderException
+    {
+        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.setGrammarEndAllowed( true );
+    }
+}

Added: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/ETypeInfoEntry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/ETypeInfoEntry.java?rev=1037160&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/ETypeInfoEntry.java
(added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/ETypeInfoEntry.java
Sat Nov 20 10:45:38 2010
@@ -0,0 +1,232 @@
+/*
+ *  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.components;
+
+
+import java.nio.BufferOverflowException;
+import java.nio.ByteBuffer;
+
+import org.apache.directory.server.i18n.I18n;
+import org.apache.directory.shared.asn1.AbstractAsn1Object;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.asn1.ber.tlv.UniversalTag;
+import org.apache.directory.shared.asn1.ber.tlv.Value;
+import org.apache.directory.shared.asn1.codec.EncoderException;
+import org.apache.directory.shared.kerberos.KerberosConstants;
+import org.apache.directory.shared.kerberos.codec.types.EncryptionType;
+import org.apache.directory.shared.ldap.util.StringTools;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Provides encryption info information sent to the client.
+ * 
+ * The ASN.1 grammar for this structure is :
+ * <pre>
+ * ETYPE-INFO-ENTRY        ::= SEQUENCE {
+ *            etype           [0] Int32,
+ *            salt            [1] OCTET STRING OPTIONAL
+ *    }
+ * </pre>
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ETypeInfoEntry extends AbstractAsn1Object
+{
+    /** The logger */
+    private static final Logger LOG = LoggerFactory.getLogger( ETypeInfoEntry.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
+
+    /** The encryption type */
+    private EncryptionType etype;
+    
+    /** The salt */
+    private byte[] salt;
+
+    // Storage for computed lengths
+    private transient int etypeTagLength;
+    private transient int saltTagLength;
+    private transient int etypeInfoEntrySeqLength;
+
+    /**
+     * Creates a new instance of ETypeInfoEntry.
+     */
+    public ETypeInfoEntry()
+    {
+    }
+
+
+    /**
+     * Returns the salt.
+     *
+     * @return The salt.
+     */
+    public byte[] getSalt()
+    {
+        return salt;
+    }
+
+
+    /**
+     * @param salt the salt to set
+     */
+    public void setSalt( byte[] salt )
+    {
+        this.salt = salt;
+    }
+
+    
+    /**
+     * Returns the {@link EncryptionType}.
+     *
+     * @return The {@link EncryptionType}.
+     */
+    public EncryptionType getEType()
+    {
+        return etype;
+    }
+
+
+    /**
+     * @param encryptionType the encryptionType to set
+     */
+    public void setEType( EncryptionType etype )
+    {
+        this.etype = etype;
+    }
+
+
+    /**
+     * Compute the ETYPE-INFO-ENTRY length
+     * <pre>
+     * ETYPE-INFO-ENTRY :
+     * 
+     * 0x30 L1 ETYPE-INFO-ENTRY sequence
+     *  |
+     *  +--> 0xA0 L2 etype tag
+     *  |     |
+     *  |     +--> 0x02 L2-1etype (int)
+     *  |
+     *  +--> 0xA1 L3 salt tag
+     *        |
+     *        +--> 0x04 L3-1 salt (OCTET STRING)
+     *        
+     *  where L1 = L2 + lenght(0xA0) + length(L2) +
+     *             L3 + lenght(0xA1) + length(L3) 
+     *  and
+     *  L2 = L2-1 + length(0x02) + length( L2-1) 
+     *  L3 = L3-1 + length(0x04) + length( L3-1) 
+     *  </pre>
+     */
+    public int computeLength()
+    {
+        // Compute the etype. The Length will always be contained in 1 byte
+        int etypeLength = Value.getNbBytes( etype.getValue() );
+        etypeTagLength = 1 + TLV.getNbBytes( etypeLength ) + etypeLength;
+        etypeInfoEntrySeqLength = 1 + TLV.getNbBytes( etypeTagLength ) + etypeTagLength;
+
+        // Compute the salt
+        if ( salt != null )
+        {
+            saltTagLength = 1 + TLV.getNbBytes( salt.length ) + salt.length;
+            etypeInfoEntrySeqLength += 1 + TLV.getNbBytes( saltTagLength ) + saltTagLength;
+        }
+
+        return 1 + TLV.getNbBytes( etypeInfoEntrySeqLength ) + etypeInfoEntrySeqLength;
+    }
+
+
+    /**
+     * Encode the ETYPE-INFO-ENTRY message to a PDU. 
+     * <pre>
+     * ETYPE-INFO-ENTRY :
+     * 
+     * 0x30 LL
+     *   0xA1 LL 
+     *     0x02 0x01 etype
+     *   0xA2 LL 
+     *     0x04 LL salt
+     * </pre>
+     * @param buffer The buffer where to put the PDU. It should have been allocated
+     * before, with the right size.
+     * @return The constructed PDU.
+     */
+    public ByteBuffer encode( ByteBuffer buffer ) throws EncoderException
+    {
+        if ( buffer == null )
+        {
+            throw new EncoderException( I18n.err( I18n.ERR_148 ) );
+        }
+
+        try
+        {
+            // The ETYPE-INFO-ENTRY SEQ Tag
+            buffer.put( UniversalTag.SEQUENCE.getValue() );
+            buffer.put( TLV.getBytes( etypeInfoEntrySeqLength ) );
+
+            // The etype, first the tag, then the value
+            buffer.put( ( byte ) KerberosConstants.ETYPE_INFO_ENTRY_ETYPE_TAG );
+            buffer.put( TLV.getBytes( etypeTagLength ) );
+            Value.encode( buffer, etype.getValue() );
+
+            // The salt, first the tag, then the value
+            buffer.put( ( byte ) KerberosConstants.ETYPE_INFO_ENTRY_SALT_TAG );
+            buffer.put( TLV.getBytes( saltTagLength ) );
+            Value.encode( buffer, salt );
+        }
+        catch ( BufferOverflowException boe )
+        {
+            LOG.error( I18n.err( I18n.ERR_145, 1 + TLV.getNbBytes( etypeInfoEntrySeqLength
)
+                + etypeInfoEntrySeqLength, buffer.capacity() ) );
+            throw new EncoderException( I18n.err( I18n.ERR_138 ) );
+        }
+
+        if ( IS_DEBUG )
+        {
+            LOG.debug( "ETYPE-INFO-ENTRY encoding : {}", StringTools.dumpBytes( buffer.array()
) );
+            LOG.debug( "ETYPE-INFO-ENTRY initial value : {}", toString() );
+        }
+
+        return buffer;
+    }
+
+    
+    /**
+     * @see Object#toString()
+     */
+    public String toString( String tabs )
+    {
+        StringBuilder sb = new StringBuilder();
+
+        sb.append( tabs ).append( "ETYPE-INFO-ENTRY : {\n" );
+        sb.append( tabs ).append( "    etype: " ).append( etype ).append( '\n' );
+
+        if ( salt != null )
+        {
+            sb.append( tabs + "    salt:" ).append( StringTools.dumpBytes( salt ) ).append(
'\n' );
+        }
+
+        sb.append( tabs + "}\n" );
+
+        return sb.toString();
+    }
+}

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/HostAddress.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/HostAddress.java?rev=1037160&r1=1037159&r2=1037160&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/HostAddress.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/HostAddress.java
Sat Nov 20 10:45:38 2010
@@ -41,7 +41,7 @@ import org.slf4j.LoggerFactory;
 /**
  * Provides host address information.
  * 
- * The ASN.1 grammaor for this structure is :
+ * The ASN.1 grammar for this structure is :
  * <pre>
  * HostAddress     ::= SEQUENCE  {
  *        addr-type       [0] Int32,

Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/PaData.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/PaData.java?rev=1037160&r1=1037159&r2=1037160&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/PaData.java
(original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/PaData.java
Sat Nov 20 10:45:38 2010
@@ -214,16 +214,16 @@ public class PaData extends AbstractAsn1
 
         try
         {
-            // The Checksum SEQ Tag
+            // The PreAuthenticationData SEQ Tag
             buffer.put( UniversalTag.SEQUENCE.getValue() );
             buffer.put( TLV.getBytes( preAuthenticationDataSeqLength ) );
 
-            // The cksumtype, first the tag, then the value
+            // The PaDataType, first the tag, then the value
             buffer.put( ( byte ) KerberosConstants.PADATA_TYPE_TAG );
             buffer.put( TLV.getBytes( paDataTypeTagLength ) );
             Value.encode( buffer, paDataType.getValue() );
 
-            // The checksum, first the tag, then the value
+            // The PaDataValue, first the tag, then the value
             buffer.put( ( byte ) KerberosConstants.PADATA_VALUE_TAG );
             buffer.put( TLV.getBytes( paDataValueTagLength ) );
             Value.encode( buffer, paDataValue );
@@ -243,6 +243,7 @@ public class PaData extends AbstractAsn1
 
         return buffer;
     }
+    
 
     /**
      * @see Object#toString()



Mime
View raw message