You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2010/11/11 02:01:58 UTC
svn commit: r1033791 - in
/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos:
./ codec/kdcReqBody/ codec/kdcReqBody/actions/ codec/principalName/actions/
codec/types/ components/
Author: elecharny
Date: Thu Nov 11 01:01:57 2010
New Revision: 1033791
URL: http://svn.apache.org/viewvc?rev=1033791&view=rev
Log:
o Rename the getordinal() method to getValue()
o Added the first part of the KRB-REQ-BODY decoder
Added:
directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/
directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/KdcReqBodyContainer.java
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
directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/
directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/KdcReqBodyInit.java
directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/StoreCName.java
directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/StoreKdcOptions.java
Modified:
directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/KerberosUtils.java
directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/principalName/actions/PrincipalNameNameType.java
directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/EncryptionType.java
directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/HostAddrType.java
directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/PrincipalNameType.java
directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/EncryptedData.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/PrincipalName.java
Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/KerberosUtils.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/KerberosUtils.java?rev=1033791&r1=1033790&r2=1033791&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/KerberosUtils.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/KerberosUtils.java Thu Nov 11 01:01:57 2010
@@ -221,7 +221,7 @@ public class KerberosUtils
name += '@' + realm;
}
- return new KerberosPrincipal( name, principal.getNameType().getOrdinal() );
+ return new KerberosPrincipal( name, principal.getNameType().getValue() );
}
Added: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/KdcReqBodyContainer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/KdcReqBodyContainer.java?rev=1033791&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/KdcReqBodyContainer.java (added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/KdcReqBodyContainer.java Thu Nov 11 01:01:57 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.kdcReqBody;
+
+import org.apache.directory.shared.asn1.ber.AbstractContainer;
+import org.apache.directory.shared.kerberos.components.KdcReqBody;
+
+
+/**
+ * The KdcReqBody container stores the KRB-REQ-BODY decoded by the Asn1Decoder.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class KdcReqBodyContainer extends AbstractContainer
+{
+ /** An KRB-REQ-BODY container */
+ private KdcReqBody kdcReqBody;
+
+ /**
+ * Creates a new KdcReqBodyContainer object.
+ */
+ public KdcReqBodyContainer()
+ {
+ super();
+ this.stateStack = new int[1];
+ this.grammar = KdcReqBodyGrammar.getInstance();
+ setTransition( KdcReqBodyStatesEnum.START_STATE );
+ }
+
+
+ /**
+ * @return Returns the KdcReqBody.
+ */
+ public KdcReqBody getKdcReqBody()
+ {
+ return kdcReqBody;
+ }
+
+
+ /**
+ * Set a KdcReqBody Object into the container. It will be completed by the
+ * KerberosDecoder.
+ *
+ * @param kdcReqBody The KdcReqBody to set.
+ */
+ public void setKdcReqBody( KdcReqBody kdcReqBody )
+ {
+ this.kdcReqBody = kdcReqBody;
+ }
+}
Added: 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=1033791&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/KdcReqBodyGrammar.java (added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/KdcReqBodyGrammar.java Thu Nov 11 01:01:57 2010
@@ -0,0 +1,128 @@
+/*
+ * 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;
+
+
+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.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.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * This class implements the KdcReqBody 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 KdcReqBodyGrammar extends AbstractGrammar
+{
+ /** The logger */
+ static final Logger LOG = LoggerFactory.getLogger( KdcReqBodyGrammar.class );
+
+ /** A speedup for logger */
+ static final boolean IS_DEBUG = LOG.isDebugEnabled();
+
+ /** The instance of grammar. KdcReqBodyGrammar is a singleton */
+ private static Grammar instance = new KdcReqBodyGrammar();
+
+
+ /**
+ * Creates a new KdcReqBodyGrammar object.
+ */
+ private KdcReqBodyGrammar()
+ {
+ setName( KdcReqBodyGrammar.class.getName() );
+
+ // Create the transitions table
+ super.transitions = new GrammarTransition[KdcReqBodyStatesEnum.LAST_KRB_REQ_BODY_STATE.ordinal()][256];
+
+ // ============================================================================================
+ // KdcReqBody
+ // ============================================================================================
+ // --------------------------------------------------------------------------------------------
+ // Transition from KdcReqBody init to KdcReqBody SEQ
+ // --------------------------------------------------------------------------------------------
+ // KDC-REQ-BODY ::= SEQUENCE {
+ super.transitions[KdcReqBodyStatesEnum.START_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
+ KdcReqBodyStatesEnum.START_STATE, KdcReqBodyStatesEnum.KRB_REQ_BODY_KDC_OPTIONS_TAG_STATE, UniversalTag.SEQUENCE.getValue(),
+ new KdcReqBodyInit() );
+
+ // --------------------------------------------------------------------------------------------
+ // Transition from KdcReqBody SEQ to kdc-options tag
+ // --------------------------------------------------------------------------------------------
+ // KDC-REQ-BODY ::= SEQUENCE {
+ // kdc-options [0]
+ super.transitions[KdcReqBodyStatesEnum.KRB_REQ_BODY_KDC_OPTIONS_TAG_STATE.ordinal()][KerberosConstants.KDC_REQ_BODY_KDC_OPTIONS_TAG] = new GrammarTransition(
+ KdcReqBodyStatesEnum.KRB_REQ_BODY_KDC_OPTIONS_TAG_STATE, KdcReqBodyStatesEnum.KRB_REQ_BODY_KDC_OPTIONS_STATE, KerberosConstants.KDC_REQ_BODY_KDC_OPTIONS_TAG,
+ new CheckNotNullLength() );
+
+ // --------------------------------------------------------------------------------------------
+ // Transition from kdc-options tag to kdc-options value
+ // --------------------------------------------------------------------------------------------
+ // KDC-REQ-BODY ::= SEQUENCE {
+ // kdc-options [0] KDCOptions
+ super.transitions[KdcReqBodyStatesEnum.KRB_REQ_BODY_KDC_OPTIONS_STATE.ordinal()][UniversalTag.BIT_STRING.getValue()] = new GrammarTransition(
+ KdcReqBodyStatesEnum.KRB_REQ_BODY_KDC_OPTIONS_STATE, KdcReqBodyStatesEnum.KRB_REQ_BODY_CNAME_TAG_STATE, UniversalTag.BIT_STRING.getValue(),
+ new StoreKdcOptions() );
+
+ // --------------------------------------------------------------------------------------------
+ // Transition from kdc-options value to cname tag
+ // --------------------------------------------------------------------------------------------
+ // KDC-REQ-BODY ::= SEQUENCE {
+ // ...
+ // cname [1]
+ super.transitions[KdcReqBodyStatesEnum.KRB_REQ_BODY_CNAME_TAG_STATE.ordinal()][KerberosConstants.KDC_REQ_BODY_CNAME_TAG] = new GrammarTransition(
+ KdcReqBodyStatesEnum.KRB_REQ_BODY_CNAME_TAG_STATE, KdcReqBodyStatesEnum.KRB_REQ_BODY_REALM_TAG_STATE, KerberosConstants.KDC_REQ_BODY_CNAME_TAG,
+ new StoreCName() );
+
+ // --------------------------------------------------------------------------------------------
+ // Transition from kdc-options value to realm tag (cname is empty)
+ // --------------------------------------------------------------------------------------------
+ // KDC-REQ-BODY ::= SEQUENCE {
+ // ...
+ // realm [2]
+ 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() );
+ }
+
+
+ // ~ Methods
+ // ------------------------------------------------------------------------------------
+
+ /**
+ * Get the instance of this grammar
+ *
+ * @return An instance on the KDC-REQ-BODY Grammar
+ */
+ public static Grammar getInstance()
+ {
+ return instance;
+ }
+}
Added: 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=1033791&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/KdcReqBodyStatesEnum.java (added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/KdcReqBodyStatesEnum.java Thu Nov 11 01:01:57 2010
@@ -0,0 +1,142 @@
+/*
+ * 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;
+
+
+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 KDC-REQ-BODY grammar's constants. It is also used for debugging
+ * purpose
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public enum KdcReqBodyStatesEnum implements States
+{
+ // Start
+ START_STATE, // 0
+
+ // ----- KDC-REQ-BODY message --------------------------------------
+ KRB_REQ_BODY_SEQ_STATE, // 1
+
+ KRB_REQ_BODY_KDC_OPTIONS_TAG_STATE, // 2
+ KRB_REQ_BODY_KDC_OPTIONS_STATE, // 3
+
+ KRB_REQ_BODY_CNAME_TAG_STATE, // 4
+ KRB_REQ_BODY_CNAME_STATE, // 5
+
+ KRB_REQ_BODY_REALM_TAG_STATE, // 6
+ KRB_REQ_BODY_REALM_STATE, // 7
+
+ KRB_REQ_BODY_SNAME_TAG_STATE, // 8
+ KRB_REQ_BODY_SNAME_STATE, // 9
+
+ KRB_REQ_BODY_FROM_TAG_STATE, // 10
+ KRB_REQ_BODY_FROM_STATE, // 11
+
+ KRB_REQ_BODY_TILL_TAG_STATE, // 12
+ KRB_REQ_BODY_TILL_STATE, // 13
+
+ KRB_REQ_BODY_RTIME_TAG_STATE, // 14
+ KRB_REQ_BODY_RTIME_STATE, // 15
+
+ KRB_REQ_BODY_NONCE_TAG_STATE, // 16
+ KRB_REQ_BODY_NONCE_STATE, // 17
+
+ KRB_REQ_BODY_ETYPE_TAG_STATE, // 18
+ KRB_REQ_BODY_ETYPE_SEQ_STATE, // 19
+ KRB_REQ_BODY_ETYPE_STATE, // 20
+
+ KRB_REQ_BODY_ADDRESSES_TAG_STATE, // 21
+ KRB_REQ_BODY_ADDRESSES_STATE, // 22
+
+ KRB_REQ_BODY_ENC_AUTH_DATA_TAG_STATE, // 2
+ KRB_REQ_BODY_ENC_AUTH_DATA_STATE, // 2
+
+ KRB_REQ_BODY_ADDITIONAL_TICKETS_TAG_STATE, // 2
+ KRB_REQ_BODY_ADDITIONAL_TICKETS_STATE, // 2
+
+ // End
+ LAST_KRB_REQ_BODY_STATE; // 8
+
+
+ /**
+ * Get the grammar name
+ *
+ * @param grammar The grammar code
+ * @return The grammar name
+ */
+ public String getGrammarName( int grammar )
+ {
+ return "KRB_REQ_BODY_GRAMMAR";
+ }
+
+
+ /**
+ * Get the grammar name
+ *
+ * @param grammar The grammar class
+ * @return The grammar name
+ */
+ public String getGrammarName( Grammar grammar )
+ {
+ if ( grammar instanceof KerberosMessageGrammar )
+ {
+ return "KRB_REQ_BODY_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_KRB_REQ_BODY_STATE.ordinal() ) ? "KRB_REQ_BODY_END_STATE" : name() );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isEndState()
+ {
+ return this == LAST_KRB_REQ_BODY_STATE;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public KdcReqBodyStatesEnum getStartState()
+ {
+ return START_STATE;
+ }
+}
Added: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/KdcReqBodyInit.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/KdcReqBodyInit.java?rev=1033791&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/KdcReqBodyInit.java (added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/KdcReqBodyInit.java Thu Nov 11 01:01:57 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.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.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.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to initialize the KDC-REQ-BODY object
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class KdcReqBodyInit extends GrammarAction
+{
+ /** The logger */
+ private static final Logger LOG = LoggerFactory.getLogger( KdcReqBodyInit.class );
+
+ /** Speedup for logs */
+ private static final boolean IS_DEBUG = LOG.isDebugEnabled();
+
+
+ /**
+ * Instantiates a new KdcReqBodyInit action.
+ */
+ public KdcReqBodyInit()
+ {
+ super( "Creates a KdcReqBody instance" );
+ }
+
+
+ /**
+ * {@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 = new KdcReqBody();
+ kdcReqBodyContainer.setKdcReqBody( kdcReqBody );
+
+ if ( IS_DEBUG )
+ {
+ LOG.debug( "KdcReqBody created" );
+ }
+ }
+}
Added: 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=1033791&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/StoreCName.java (added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/StoreCName.java Thu Nov 11 01:01:57 2010
@@ -0,0 +1,106 @@
+/*
+ * 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.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.kdcReqBody.KdcReqBodyContainer;
+import org.apache.directory.shared.kerberos.codec.principalName.PrincipalNameContainer;
+import org.apache.directory.shared.kerberos.components.KdcReqBody;
+import org.apache.directory.shared.kerberos.components.PrincipalName;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store the KDCOptions
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoreCName extends GrammarAction
+{
+ /** The logger */
+ private static final Logger LOG = LoggerFactory.getLogger( StoreCName.class );
+
+ /** Speedup for logs */
+ private static final boolean IS_DEBUG = LOG.isDebugEnabled();
+
+
+ /**
+ * Instantiates a new StoreKdcOptions action.
+ */
+ public StoreCName()
+ {
+ super( "Stores the KDCOptions" );
+ }
+
+
+ /**
+ * {@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 ) );
+ }
+
+ // Now, let's decode the PrincipalName
+ Asn1Decoder principalNameDecoder = new Asn1Decoder();
+
+ PrincipalNameContainer principalNameContainer = new PrincipalNameContainer();
+
+ // Decode the Ticket PDU
+ try
+ {
+ principalNameDecoder.decode( container.getStream(), principalNameContainer );
+ }
+ catch ( DecoderException de )
+ {
+ throw de;
+ }
+
+ // Store the Principal name in the container
+ PrincipalName principalName = principalNameContainer.getPrincipalName();
+ KdcReqBody kdcReqBody = kdcReqBodyContainer.getKdcReqBody();
+ kdcReqBody.setCName( principalName );
+
+ // Update the parent
+ container.setParentTLV( tlv.getParent() );
+
+ if ( IS_DEBUG )
+ {
+ LOG.debug( "CName : {}", principalName );
+ }
+ }
+}
Added: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/StoreKdcOptions.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/StoreKdcOptions.java?rev=1033791&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/StoreKdcOptions.java (added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/kdcReqBody/actions/StoreKdcOptions.java Thu Nov 11 01:01:57 2010
@@ -0,0 +1,87 @@
+/*
+ * 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.codec.DecoderException;
+import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.kerberos.codec.kdcReqBody.KdcReqBodyContainer;
+import org.apache.directory.shared.kerberos.codec.options.KdcOptions;
+import org.apache.directory.shared.kerberos.components.KdcReqBody;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store the KDCOptions
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoreKdcOptions extends GrammarAction
+{
+ /** The logger */
+ private static final Logger LOG = LoggerFactory.getLogger( StoreKdcOptions.class );
+
+ /** Speedup for logs */
+ private static final boolean IS_DEBUG = LOG.isDebugEnabled();
+
+
+ /**
+ * Instantiates a new StoreKdcOptions action.
+ */
+ public StoreKdcOptions()
+ {
+ super( "Stores the KDCOptions" );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void action( Asn1Container container ) throws DecoderException
+ {
+ KdcReqBodyContainer kdcReqBodyContainer = ( KdcReqBodyContainer ) container;
+
+ TLV tlv = kdcReqBodyContainer.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 ) );
+ }
+
+ KdcReqBody kdcReqBody = kdcReqBodyContainer.getKdcReqBody();
+ KdcOptions kdcOptions = new KdcOptions( tlv.getValue().getData() );
+
+ kdcReqBody.setKdcOptions( kdcOptions );
+ System.out.println( kdcOptions );
+
+ if ( IS_DEBUG )
+ {
+ LOG.debug( "KDCOptions : {}", kdcOptions );
+ }
+ }
+}
Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/principalName/actions/PrincipalNameNameType.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/principalName/actions/PrincipalNameNameType.java?rev=1033791&r1=1033790&r2=1033791&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/principalName/actions/PrincipalNameNameType.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/principalName/actions/PrincipalNameNameType.java Thu Nov 11 01:01:57 2010
@@ -86,7 +86,7 @@ public class PrincipalNameNameType exten
try
{
- int nameType = IntegerDecoder.parse( value, PrincipalNameType.FIRST_NAME_TYPE.ordinal(), PrincipalNameType.LAST_NAME_TYPE.ordinal() );
+ int nameType = IntegerDecoder.parse( value, PrincipalNameType.FIRST_NAME_TYPE.getValue(), PrincipalNameType.LAST_NAME_TYPE.getValue() );
principalNameType = PrincipalNameType.getTypeByOrdinal( nameType );
principalName.setNameType( principalNameType );
Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/EncryptionType.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/EncryptionType.java?rev=1033791&r1=1033790&r2=1033791&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/EncryptionType.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/EncryptionType.java Thu Nov 11 01:01:57 2010
@@ -159,7 +159,7 @@ public enum EncryptionType
/**
* The value/code for the encryption type.
*/
- private final int ordinal;
+ private final int value;
/**
* The name
@@ -178,7 +178,7 @@ public enum EncryptionType
for ( EncryptionType type : EncryptionType.values() )
{
encryptionTypesByName.put( type.getName().toLowerCase(), type );
- encryptionTypesByOrdinal.put( type.getOrdinal(), type );
+ encryptionTypesByOrdinal.put( type.getValue(), type );
}
}
@@ -186,9 +186,9 @@ public enum EncryptionType
/**
* Private constructor prevents construction outside of this class.
*/
- private EncryptionType( int ordinal, String name )
+ private EncryptionType( int value, String name )
{
- this.ordinal = ordinal;
+ this.value = value;
this.name = name;
}
@@ -204,7 +204,7 @@ public enum EncryptionType
}
/**
- * Returns the encryption type when specified by its ordinal.
+ * Returns the encryption type when specified by its value.
*
* @param type
* @return The encryption type.
@@ -227,9 +227,9 @@ public enum EncryptionType
*
* @return The encryption type number.
*/
- public int getOrdinal()
+ public int getValue()
{
- return ordinal;
+ return value;
}
@@ -273,6 +273,6 @@ public enum EncryptionType
*/
public String toString()
{
- return getName() + " (" + ordinal + ")";
+ return getName() + " (" + value + ")";
}
}
Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/HostAddrType.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/HostAddrType.java?rev=1033791&r1=1033790&r2=1033791&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/HostAddrType.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/HostAddrType.java Thu Nov 11 01:01:57 2010
@@ -201,15 +201,15 @@ public enum HostAddrType
/**
* The value/code for the host address type.
*/
- private final int ordinal;
+ private final int value;
/**
* Private constructor prevents construction outside of this class.
*/
- private HostAddrType( int ordinal )
+ private HostAddrType( int value )
{
- this.ordinal = ordinal;
+ this.value = value;
}
@@ -256,9 +256,9 @@ public enum HostAddrType
*
* @return The host address type ordinal.
*/
- public int getOrdinal()
+ public int getValue()
{
- return ordinal;
+ return value;
}
/**
@@ -266,31 +266,31 @@ public enum HostAddrType
*/
public String toString()
{
- switch ( ordinal )
+ switch ( value )
{
- //case 1 : return "Unix" + "(" + ordinal + ")" ;
- case 2 : return "Internet" + "(" + ordinal + ")" ;
- case 3 : return "Arpanet" + "(" + ordinal + ")" ;
- //case 4 : return "PUP" + "(" + ordinal + ")" ;
- case 5 : return "CHAOS" + "(" + ordinal + ")" ;
- case 6 : return "XEROX Network Services" + "(" + ordinal + ")" ;
- case 7 : return "OSI" + "(" + ordinal + ")" ;
- //case 8 : return "European Computer Manufacturers" + "(" + ordinal + ")" ;
- //case 9 : return "Datakit" + "(" + ordinal + ")" ;
- //case 10 : return "CCITT" + "(" + ordinal + ")" ;
- //case 11 : return "SNA" + "(" + ordinal + ")" ;
- case 12 : return "DECnet" + "(" + ordinal + ")" ;
- //case 13 : return "Direct Data Link Interface" + "(" + ordinal + ")" ;
- //case 14 : return "LAT" + "(" + ordinal + ")" ;
- //case 15 : return "NSC Hyperchannel" + "(" + ordinal + ")" ;
- //case 16 : return "AppleTalk" + "(" + ordinal + ")" ;
- //case 18 : return "VoiceView" + "(" + ordinal + ")" ;
- //case 19 : return "Firefox" + "(" + ordinal + ")" ;
- case 20 : return "NetBios" + "(" + ordinal + ")" ;
- //case 21 : return "Banyan" + "(" + ordinal + ")" ;
- //case 22 : return "ATM" + "(" + ordinal + ")" ;
- case 24 : return "Internet Protocol V6" + "(" + ordinal + ")" ;
- default : return "null" + "(" + ordinal + ")" ;
+ //case 1 : return "Unix" + "(" + value + ")" ;
+ case 2 : return "Internet" + "(" + value + ")" ;
+ case 3 : return "Arpanet" + "(" + value + ")" ;
+ //case 4 : return "PUP" + "(" + value + ")" ;
+ case 5 : return "CHAOS" + "(" + value + ")" ;
+ case 6 : return "XEROX Network Services" + "(" + value + ")" ;
+ case 7 : return "OSI" + "(" + value + ")" ;
+ //case 8 : return "European Computer Manufacturers" + "(" + value + ")" ;
+ //case 9 : return "Datakit" + "(" + value + ")" ;
+ //case 10 : return "CCITT" + "(" + value + ")" ;
+ //case 11 : return "SNA" + "(" + value + ")" ;
+ case 12 : return "DECnet" + "(" + value + ")" ;
+ //case 13 : return "Direct Data Link Interface" + "(" + value + ")" ;
+ //case 14 : return "LAT" + "(" + value + ")" ;
+ //case 15 : return "NSC Hyperchannel" + "(" + value + ")" ;
+ //case 16 : return "AppleTalk" + "(" + value + ")" ;
+ //case 18 : return "VoiceView" + "(" + value + ")" ;
+ //case 19 : return "Firefox" + "(" + value + ")" ;
+ case 20 : return "NetBios" + "(" + value + ")" ;
+ //case 21 : return "Banyan" + "(" + value + ")" ;
+ //case 22 : return "ATM" + "(" + value + ")" ;
+ case 24 : return "Internet Protocol V6" + "(" + value + ")" ;
+ default : return "null" + "(" + value + ")" ;
}
}
}
Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/PrincipalNameType.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/PrincipalNameType.java?rev=1033791&r1=1033790&r2=1033791&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/PrincipalNameType.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/PrincipalNameType.java Thu Nov 11 01:01:57 2010
@@ -78,15 +78,15 @@ public enum PrincipalNameType
/**
* The value/code for the principal name type.
*/
- private final int ordinal;
+ private final int value;
/**
* Private constructor prevents construction outside of this class.
*/
- private PrincipalNameType( int ordinal )
+ private PrincipalNameType( int value )
{
- this.ordinal = ordinal;
+ this.value = value;
}
@@ -119,9 +119,9 @@ public enum PrincipalNameType
*
* @return The principal name type ordinal.
*/
- public int getOrdinal()
+ public int getValue()
{
- return ordinal;
+ return value;
}
/**
@@ -132,34 +132,34 @@ public enum PrincipalNameType
switch ( this )
{
case KRB_NT_UNKNOWN :
- return "Name type not known" + "(" + ordinal + ")";
+ return "Name type not known" + "(" + value + ")";
case KRB_NT_PRINCIPAL :
- return "Just the name of the principal as in DCE, or for users" + "(" + ordinal + ")";
+ return "Just the name of the principal as in DCE, or for users" + "(" + value + ")";
case KRB_NT_SRV_INST :
- return "Service and other unique instance (krbtgt)" + "(" + ordinal + ")";
+ return "Service and other unique instance (krbtgt)" + "(" + value + ")";
case KRB_NT_SRV_HST :
- return "Service with host name as instance (telnet, rcommands)" + "(" + ordinal + ")";
+ return "Service with host name as instance (telnet, rcommands)" + "(" + value + ")";
case KRB_NT_SRV_XHST :
- return "Service with host as remaining components" + "(" + ordinal + ")";
+ return "Service with host as remaining components" + "(" + value + ")";
case KRB_NT_UID :
- return "Unique ID" + "(" + ordinal + ")";
+ return "Unique ID" + "(" + value + ")";
case KRB_NT_X500_PRINCIPAL :
- return "Encoded X.509 Distinguished name [RFC2253]" + "(" + ordinal + ")";
+ return "Encoded X.509 Distinguished name [RFC2253]" + "(" + value + ")";
case KRB_NT_SMTP_NAME :
- return "Name in form of SMTP email name (e.g., user@example.com)" + "(" + ordinal + ")";
+ return "Name in form of SMTP email name (e.g., user@example.com)" + "(" + value + ")";
case KRB_NT_ENTERPRISE :
- return "Enterprise name; may be mapped to principal name" + "(" + ordinal + ")";
+ return "Enterprise name; may be mapped to principal name" + "(" + value + ")";
default :
- return "unknown name type" + "(" + ordinal + ")";
+ return "unknown name type" + "(" + value + ")";
}
}
}
Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/EncryptedData.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/EncryptedData.java?rev=1033791&r1=1033790&r2=1033791&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/EncryptedData.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/EncryptedData.java Thu Nov 11 01:01:57 2010
@@ -210,7 +210,7 @@ public class EncryptedData extends Abstr
encryptedDataSeqLength = 0;
// Compute the encryption Type length
- int eTypeLength = Value.getNbBytes( eType.getOrdinal() );
+ int eTypeLength = Value.getNbBytes( eType.getValue() );
eTypeTagLength = 1 + TLV.getNbBytes( eTypeLength ) + eTypeLength;
encryptedDataSeqLength = 1 + TLV.getNbBytes( eTypeTagLength ) + eTypeTagLength;
@@ -278,7 +278,7 @@ public class EncryptedData extends Abstr
buffer.put( ( byte ) 0xA0 );
buffer.put( TLV.getBytes( eTypeTagLength ) );
- Value.encode( buffer, eType.getOrdinal() );
+ Value.encode( buffer, eType.getValue() );
// The kvno, if any, first the tag, then the value
if ( hasKvno )
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=1033791&r1=1033790&r2=1033791&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 Thu Nov 11 01:01:57 2010
@@ -228,7 +228,7 @@ public class HostAddress extends Abstrac
public int computeLength()
{
// Compute the keyType. The Length will always be contained in 1 byte
- addrTypeLength = 1 + 1 + Value.getNbBytes( addrType.getOrdinal() );
+ addrTypeLength = 1 + 1 + Value.getNbBytes( addrType.getValue() );
hostAddressLength = 1 + TLV.getNbBytes( addrTypeLength ) + addrTypeLength;
// Compute the keyValue
@@ -281,7 +281,7 @@ public class HostAddress extends Abstrac
// The addr-type, first the tag, then the value
buffer.put( ( byte ) 0xA0 );
buffer.put( TLV.getBytes( addrTypeLength ) );
- Value.encode( buffer, addrType.getOrdinal() );
+ Value.encode( buffer, addrType.getValue() );
// The address, first the tag, then the value
buffer.put( ( byte ) 0xA1 );
Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/PrincipalName.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/PrincipalName.java?rev=1033791&r1=1033790&r2=1033791&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/PrincipalName.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/PrincipalName.java Thu Nov 11 01:01:57 2010
@@ -311,7 +311,7 @@ public class PrincipalName extends Abstr
public int computeLength()
{
// The principalName can't be empty.
- principalTypeLength = Value.getNbBytes( nameType.getOrdinal() );
+ principalTypeLength = Value.getNbBytes( nameType.getValue() );
principalTypeTagLength = 1 + 1 + principalTypeLength;
principalNameSeqLength = 1 + TLV.getNbBytes( principalTypeTagLength ) + principalTypeTagLength;
@@ -385,7 +385,7 @@ public class PrincipalName extends Abstr
// The name-type, first the tag, then the value
buffer.put( ( byte ) 0xA0 );
buffer.put( TLV.getBytes( principalTypeTagLength ) );
- Value.encode( buffer, nameType.getOrdinal() );
+ Value.encode( buffer, nameType.getValue() );
// The name-string tag
buffer.put( ( byte ) 0xA1 );