directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1036492 - in /directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec: apReq/ apReq/actions/ kdcRep/actions/
Date Thu, 18 Nov 2010 15:33:15 GMT
Author: elecharny
Date: Thu Nov 18 15:33:15 2010
New Revision: 1036492

URL: http://svn.apache.org/viewvc?rev=1036492&view=rev
Log:
Added the AP-REQ grammar

Added:
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/ApReqContainer.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/ApReqGrammar.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/ApReqStatesEnum.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/actions/
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/actions/CheckMsgType.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/actions/StoreApOptions.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/apReq/actions/StorePvno.java
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/actions/StoreTicket.java
Modified:
    directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcRep/actions/CheckMsgType.java

Added: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/ApReqContainer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/ApReqContainer.java?rev=1036492&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/ApReqContainer.java
(added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/ApReqContainer.java
Thu Nov 18 15:33:15 2010
@@ -0,0 +1,67 @@
+/*
+ *  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.apReq;
+
+import org.apache.directory.shared.kerberos.codec.kdcReq.KdcReqContainer;
+import org.apache.directory.shared.kerberos.messages.ApReq;
+
+
+/**
+ * The AP-REQ container.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ApReqContainer extends KdcReqContainer
+{
+    /** An AP-REQ container */
+    private ApReq apReq;
+
+    /**
+     * Creates a new ApReqContainer object.
+     */
+    public ApReqContainer()
+    {
+        super();
+        this.stateStack = new int[1];
+        this.grammar = ApReqGrammar.getInstance();
+        setTransition( ApReqStatesEnum.START_STATE );
+    }
+
+
+    /**
+     * @return Returns the ApReq.
+     */
+    public ApReq getApReq()
+    {
+        return apReq;
+    }
+
+    
+    /**
+     * Set an ApReq Object into the container. It will be completed by the
+     * KerberosDecoder.
+     * 
+     * @param apReq The ApReq to set.
+     */
+    public void setApReq( ApReq apReq )
+    {
+        this.apReq = apReq;
+    }
+}

Added: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/ApReqGrammar.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/ApReqGrammar.java?rev=1036492&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/ApReqGrammar.java
(added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/ApReqGrammar.java
Thu Nov 18 15:33:15 2010
@@ -0,0 +1,176 @@
+/*
+ *  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.apReq;
+
+
+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.apReq.actions.CheckMsgType;
+import org.apache.directory.shared.kerberos.codec.apReq.actions.StoreApOptions;
+import org.apache.directory.shared.kerberos.codec.apReq.actions.StoreAuthenticator;
+import org.apache.directory.shared.kerberos.codec.apReq.actions.StorePvno;
+import org.apache.directory.shared.kerberos.codec.apReq.actions.StoreTicket;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * This class implements the AP-REQ 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 ApReqGrammar extends AbstractGrammar
+{
+    /** The logger */
+    static final Logger LOG = LoggerFactory.getLogger( ApReqGrammar.class );
+
+    /** A speedup for logger */
+    static final boolean IS_DEBUG = LOG.isDebugEnabled();
+
+    /** The instance of grammar. ApReqGrammar is a singleton */
+    private static Grammar instance = new ApReqGrammar();
+
+
+    /**
+     * Creates a new ApReqGrammar object.
+     */
+    private ApReqGrammar()
+    {
+        setName( ApReqGrammar.class.getName() );
+
+        // Create the transitions table
+        super.transitions = new GrammarTransition[ApReqStatesEnum.LAST_AP_REQ_STATE.ordinal()][256];
+
+        // ============================================================================================
+        // AP-REQ 
+        // ============================================================================================
+        // --------------------------------------------------------------------------------------------
+        // Transition from AP-REQ init to AP-REQ tag
+        // --------------------------------------------------------------------------------------------
+        // AP-REQ          ::= [APPLICATION 14]
+        super.transitions[ApReqStatesEnum.START_STATE.ordinal()][KerberosConstants.AP_REQ_TAG]
= new GrammarTransition(
+            ApReqStatesEnum.START_STATE, ApReqStatesEnum.AP_REQ_STATE, KerberosConstants.AP_REQ_TAG,
+            new CheckNotNullLength() );
+
+        // --------------------------------------------------------------------------------------------
+        // Transition from AP-REQ tag to AP-REQ SEQ {
+        // --------------------------------------------------------------------------------------------
+        // AP-REQ          ::= [APPLICATION 14] SEQUENCE
+        super.transitions[ApReqStatesEnum.AP_REQ_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()]
= new GrammarTransition(
+            ApReqStatesEnum.AP_REQ_STATE, ApReqStatesEnum.AP_REQ_SEQ_STATE, UniversalTag.SEQUENCE.getValue(),
+            new CheckNotNullLength() );
+        
+        // --------------------------------------------------------------------------------------------
+        // Transition from AP-REQ SEQ to PVNO tag
+        // --------------------------------------------------------------------------------------------
+        // AP-REQ          ::= [APPLICATION 14] SEQUENCE
+        //         pvno            [0]
+        super.transitions[ApReqStatesEnum.AP_REQ_SEQ_STATE.ordinal()][KerberosConstants.AP_REQ_PVNO_TAG]
= new GrammarTransition(
+            ApReqStatesEnum.AP_REQ_SEQ_STATE, ApReqStatesEnum.AP_REQ_PVNO_TAG_STATE, KerberosConstants.AP_REQ_PVNO_TAG,
+            new CheckNotNullLength() );
+        
+        // --------------------------------------------------------------------------------------------
+        // Transition from PVNO tag to PVNO value
+        // --------------------------------------------------------------------------------------------
+        // AP-REQ          ::= [APPLICATION 14] SEQUENCE
+        //         pvno            [0] INTEGER (5),
+        super.transitions[ApReqStatesEnum.AP_REQ_PVNO_TAG_STATE.ordinal()][UniversalTag.INTEGER.getValue()]
= new GrammarTransition(
+            ApReqStatesEnum.AP_REQ_PVNO_TAG_STATE, ApReqStatesEnum.AP_REQ_PVNO_STATE, UniversalTag.INTEGER.getValue(),
+            new StorePvno() );
+        
+        // --------------------------------------------------------------------------------------------
+        // Transition from PVNO value to msg-type tag
+        // --------------------------------------------------------------------------------------------
+        // AP-REQ          ::= [APPLICATION 14] SEQUENCE
+        //         ...
+        //         msg-type        [1]
+        super.transitions[ApReqStatesEnum.AP_REQ_PVNO_STATE.ordinal()][KerberosConstants.AP_REQ_MSG_TYPE_TAG]
= new GrammarTransition(
+            ApReqStatesEnum.AP_REQ_PVNO_STATE, ApReqStatesEnum.AP_REQ_MSG_TYPE_TAG_STATE,
KerberosConstants.AP_REQ_MSG_TYPE_TAG,
+            new CheckNotNullLength() );
+        
+        // --------------------------------------------------------------------------------------------
+        // Transition from msg-type tag to msg-type value
+        // --------------------------------------------------------------------------------------------
+        // AP-REQ          ::= [APPLICATION 14] SEQUENCE
+        //         ...
+        //         msg-type        [1] INTEGER (14),
+        super.transitions[ApReqStatesEnum.AP_REQ_MSG_TYPE_TAG_STATE.ordinal()][UniversalTag.INTEGER.getValue()]
= new GrammarTransition(
+            ApReqStatesEnum.AP_REQ_MSG_TYPE_TAG_STATE, ApReqStatesEnum.AP_REQ_MSG_TYPE_STATE,
UniversalTag.INTEGER.getValue(),
+            new CheckMsgType() );
+        
+        // --------------------------------------------------------------------------------------------
+        // Transition from msg-type value to ap-options tag
+        // --------------------------------------------------------------------------------------------
+        // AP-REQ          ::= [APPLICATION 14] SEQUENCE
+        //         ...
+        //         ap-options      [2]
+        super.transitions[ApReqStatesEnum.AP_REQ_MSG_TYPE_STATE.ordinal()][KerberosConstants.AP_REQ_AP_OPTIONS_TAG]
= new GrammarTransition(
+            ApReqStatesEnum.AP_REQ_MSG_TYPE_STATE, ApReqStatesEnum.AP_REQ_AP_OPTIONS_TAG_STATE,
KerberosConstants.AP_REQ_AP_OPTIONS_TAG,
+            new CheckNotNullLength() );
+        
+        // --------------------------------------------------------------------------------------------
+        // Transition from ap-options tag to ap-options value
+        // --------------------------------------------------------------------------------------------
+        // AP-REQ          ::= [APPLICATION 14] SEQUENCE
+        //         ...
+        //         ap-options      [2] APOptions,
+        super.transitions[ApReqStatesEnum.AP_REQ_AP_OPTIONS_TAG_STATE.ordinal()][UniversalTag.BIT_STRING.getValue()]
= new GrammarTransition(
+            ApReqStatesEnum.AP_REQ_AP_OPTIONS_TAG_STATE, ApReqStatesEnum.AP_REQ_AP_OPTIONS_STATE,
UniversalTag.BIT_STRING.getValue(),
+            new StoreApOptions() );
+        
+        // --------------------------------------------------------------------------------------------
+        // Transition from ap-options value to ticket
+        // --------------------------------------------------------------------------------------------
+        // AP-REQ          ::= [APPLICATION 14] SEQUENCE
+        //         ...
+        //         ticket          [3] Ticket,
+        super.transitions[ApReqStatesEnum.AP_REQ_AP_OPTIONS_STATE.ordinal()][KerberosConstants.AP_REQ_TICKET_TAG]
= new GrammarTransition(
+            ApReqStatesEnum.AP_REQ_AP_OPTIONS_STATE, ApReqStatesEnum.AP_REQ_TICKET_STATE,
KerberosConstants.AP_REQ_TICKET_TAG,
+            new StoreTicket() );
+        
+        // --------------------------------------------------------------------------------------------
+        // Transition from ticket to authenticator
+        // --------------------------------------------------------------------------------------------
+        // AP-REQ          ::= [APPLICATION 14] SEQUENCE
+        //         ...
+        //         authenticator   [4] <EncryptedData> -- Authenticator
+        // }
+        super.transitions[ApReqStatesEnum.AP_REQ_TICKET_STATE.ordinal()][KerberosConstants.AP_REQ_AUTHENTICATOR_TAG]
= new GrammarTransition(
+            ApReqStatesEnum.AP_REQ_TICKET_STATE, ApReqStatesEnum.LAST_AP_REQ_STATE, KerberosConstants.AP_REQ_AUTHENTICATOR_TAG,
+            new StoreAuthenticator() );
+    }
+
+
+    /**
+     * Get the instance of this grammar
+     * 
+     * @return An instance on the AP-REQ Grammar
+     */
+    public static Grammar getInstance()
+    {
+        return instance;
+    }
+}

Added: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/ApReqStatesEnum.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/ApReqStatesEnum.java?rev=1036492&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/ApReqStatesEnum.java
(added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/ApReqStatesEnum.java
Thu Nov 18 15:33:15 2010
@@ -0,0 +1,119 @@
+/*
+ *  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.apReq;
+
+
+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 AP-REQ grammar's constants. It is also used for debugging
+ * purpose
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public enum ApReqStatesEnum implements States
+{
+    // Start
+    START_STATE,                            // 0
+    
+    // ----- AS-REQ message --------------------------------------
+    AP_REQ_STATE,                           // 1
+    AP_REQ_SEQ_STATE,                       // 2
+    
+    AP_REQ_PVNO_TAG_STATE,                  // 3
+    AP_REQ_PVNO_STATE,                      // 4
+    
+    AP_REQ_MSG_TYPE_TAG_STATE,              // 5
+    AP_REQ_MSG_TYPE_STATE,                  // 6
+    
+    AP_REQ_AP_OPTIONS_TAG_STATE,            // 7
+    AP_REQ_AP_OPTIONS_STATE,                // 8
+
+    AP_REQ_TICKET_STATE,                    // 9
+
+    AP_REQ_AUTHENTICATOR_STATE,             // 10
+    
+    // End
+    LAST_AP_REQ_STATE;                      // 11
+
+    
+    /**
+     * Get the grammar name
+     * 
+     * @param grammar The grammar code
+     * @return The grammar name
+     */
+    public String getGrammarName( int grammar )
+    {
+        return "AP_REQ_GRAMMAR";
+    }
+
+
+    /**
+     * Get the grammar name
+     * 
+     * @param grammar The grammar class
+     * @return The grammar name
+     */
+    public String getGrammarName( Grammar grammar )
+    {
+        if ( grammar instanceof KerberosMessageGrammar )
+        {
+            return "AP_REQ_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_AP_REQ_STATE.ordinal() ) ? "AP_REQ_END_STATE" : name() );
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isEndState()
+    {
+        return this == LAST_AP_REQ_STATE;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public ApReqStatesEnum getStartState()
+    {
+        return START_STATE;
+    }
+}

Added: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/actions/CheckMsgType.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/actions/CheckMsgType.java?rev=1036492&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/actions/CheckMsgType.java
(added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/actions/CheckMsgType.java
Thu Nov 18 15:33:15 2010
@@ -0,0 +1,71 @@
+/*
+ *  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.apReq.actions;
+
+
+import org.apache.directory.shared.asn1.ber.Asn1Container;
+import org.apache.directory.shared.asn1.codec.DecoderException;
+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.apReq.ApReqContainer;
+import org.apache.directory.shared.kerberos.messages.ApReq;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store the msg-type
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class CheckMsgType extends AbstractReadMsgType
+{
+    /** The logger */
+    private static final Logger LOG = LoggerFactory.getLogger( CheckMsgType.class );
+
+    /**
+     * Instantiates a new CheckMsgType action.
+     */
+    public CheckMsgType()
+    {
+        super( "AP-REQ msg-type" );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected void verifyMsgType( KerberosMessageType krbMsgType, Asn1Container container
) throws DecoderException
+    {
+        ApReqContainer apReqContainer = ( ApReqContainer ) container;
+        ApReq apReq = apReqContainer.getApReq();
+
+        // The message type must be the expected one
+        if ( krbMsgType != apReq.getMessageType() )
+        {
+            LOG.error( I18n.err( I18n.ERR_04070, krbMsgType, "The msg-type should be AP-REQ"
) );
+
+            // This will generate a PROTOCOL_ERROR
+            throw new DecoderException( "The msg-type should be AP-REQ" );
+        }
+    }
+}

Added: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/actions/StoreApOptions.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/actions/StoreApOptions.java?rev=1036492&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/actions/StoreApOptions.java
(added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/actions/StoreApOptions.java
Thu Nov 18 15:33:15 2010
@@ -0,0 +1,86 @@
+/*
+ *  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.apReq.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.apReq.ApReqContainer;
+import org.apache.directory.shared.kerberos.codec.options.ApOptions;
+import org.apache.directory.shared.kerberos.messages.ApReq;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store the ApOptions
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoreApOptions extends GrammarAction
+{
+    /** The logger */
+    private static final Logger LOG = LoggerFactory.getLogger( StoreApOptions.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
+
+
+    /**
+     * Instantiates a new StoreApOptions action.
+     */
+    public StoreApOptions()
+    {
+        super( "Stores the ApOptions" );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void action( Asn1Container container ) throws DecoderException
+    {
+        ApReqContainer apReqContainer = ( ApReqContainer ) container;
+
+        TLV tlv = apReqContainer.getCurrentTLV();
+
+        // The Length should not be null, and should be 5
+        if ( tlv.getLength() != 5 )
+        {
+            LOG.error( I18n.err( I18n.ERR_04066 ) );
+
+            // This will generate a PROTOCOL_ERROR
+            throw new DecoderException( I18n.err( I18n.ERR_04067 ) );
+        }
+        
+        ApReq apReq = apReqContainer.getApReq();
+        ApOptions apOptions = new ApOptions( tlv.getValue().getData() );
+        
+        apReq.setApOptions( apOptions );
+        
+        if ( IS_DEBUG )
+        {
+            LOG.debug( "APOptions : {}", apOptions );
+        }
+    }
+}

Added: 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=1036492&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/actions/StoreAuthenticator.java
(added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/actions/StoreAuthenticator.java
Thu Nov 18 15:33:15 2010
@@ -0,0 +1,113 @@
+/*
+ *  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.apReq.actions;
+
+
+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.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;
+
+
+/**
+ * The action used to set the AP-REQ authenticator
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoreAuthenticator extends GrammarAction
+{
+    /** 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" );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void action( Asn1Container container ) throws DecoderException
+    {
+        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();
+
+        container.setGrammarEndAllowed( true );
+    }
+}

Added: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/actions/StorePvno.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/actions/StorePvno.java?rev=1036492&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/actions/StorePvno.java
(added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/actions/StorePvno.java
Thu Nov 18 15:33:15 2010
@@ -0,0 +1,104 @@
+/*
+ *  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.apReq.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.KerberosMessageGrammar;
+import org.apache.directory.shared.kerberos.codec.apReq.ApReqContainer;
+import org.apache.directory.shared.kerberos.messages.ApReq;
+import org.apache.directory.shared.ldap.util.StringTools;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to set the AP-REQ VNO
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StorePvno extends GrammarAction
+{
+    /** 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 StorePvno action.
+     */
+    public StorePvno()
+    {
+        super( "StorePvno value" );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void action( Asn1Container container ) throws DecoderException
+    {
+        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 ) );
+        }
+        
+        // The value should be an integer an equal to 5
+        Value value = tlv.getValue();
+        ApReq apReq = apReqContainer.getApReq();
+
+        try
+        {
+            int pvno = IntegerDecoder.parse( value, 5, 5 );
+
+            apReq.setProtocolVersionNumber( pvno );
+
+            if ( IS_DEBUG )
+            {
+                LOG.debug( "Pvno : " + pvno );
+            }
+        }
+        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/apReq/actions/StoreTicket.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/actions/StoreTicket.java?rev=1036492&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/actions/StoreTicket.java
(added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/apReq/actions/StoreTicket.java
Thu Nov 18 15:33:15 2010
@@ -0,0 +1,109 @@
+/*
+ *  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.apReq.actions;
+
+
+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.apReq.ApReqContainer;
+import org.apache.directory.shared.kerberos.codec.ticket.TicketContainer;
+import org.apache.directory.shared.kerberos.messages.ApReq;
+import org.apache.directory.shared.kerberos.messages.Ticket;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store the Ticket
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoreTicket extends GrammarAction
+{
+    /** The logger */
+    private static final Logger LOG = LoggerFactory.getLogger( StoreTicket.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
+
+    /**
+     * Instantiates a new StoreTicket action.
+     */
+    public StoreTicket()
+    {
+        super( "AP-REQ Store Ticket" );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void action( Asn1Container container ) throws DecoderException
+    {
+        ApReqContainer apReqContainer = ( ApReqContainer ) container;
+
+        TLV tlv = apReqContainer.getCurrentTLV();
+
+        // The Length can't 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 Ticket
+        Asn1Decoder ticketDecoder = new Asn1Decoder();
+        
+        TicketContainer ticketContainer = new TicketContainer();
+        ticketContainer.setStream( container.getStream() );
+
+        // Decode the Ticket PDU
+        try
+        {
+            ticketDecoder.decode( container.getStream(), ticketContainer );
+        }
+        catch ( DecoderException de )
+        {
+            throw de;
+        }
+        
+        // Update the expected length for the current TLV
+        tlv.setExpectedLength( tlv.getExpectedLength() - tlv.getLength() );
+
+        // Update the parent
+        container.updateParent();
+
+        // Store the Ticket in the container
+        Ticket ticket = ticketContainer.getTicket();
+        ApReq apReq = apReqContainer.getApReq();
+        apReq.setTicket( ticket );
+        
+        if ( IS_DEBUG )
+        {
+            LOG.debug( "Stored ticket:  {}", ticket );
+        }
+    }
+}

Modified: 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?rev=1036492&r1=1036491&r2=1036492&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:33:15 2010
@@ -42,7 +42,7 @@ public class CheckMsgType extends Abstra
     private static final Logger LOG = LoggerFactory.getLogger( CheckMsgType.class );
 
     /**
-     * Instantiates a new StoreMsgType action.
+     * Instantiates a new CheckMsgType action.
      */
     public CheckMsgType()
     {



Mime
View raw message