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/06 02:38:16 UTC
svn commit: r1031917 - in /directory/apacheds/trunk/kerberos-codec: ./
src/main/java/org/apache/directory/shared/kerberos/
src/main/java/org/apache/directory/shared/kerberos/codec/
src/main/java/org/apache/directory/shared/kerberos/codec/actions/ src/m...
Author: elecharny
Date: Sat Nov 6 01:38:16 2010
New Revision: 1031917
URL: http://svn.apache.org/viewvc?rev=1031917&view=rev
Log:
o Reorganized the project
o Added a test for the PrincipalName element only
Added:
directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/actions/
directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/actions/CheckNotNullLength.java
directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/principalName/
directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/principalName/PrincipalNameContainer.java
directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/principalName/PrincipalNameGrammar.java
directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/principalName/PrincipalNameStatesEnum.java
directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/principalName/actions/
directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/principalName/actions/CheckNotNullLength.java
directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/principalName/actions/PrincipalNameInit.java
directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/principalName/actions/PrincipalNameNameString.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/test/java/org/apache/directory/shared/kerberos/codec/PrincipalNameDecoderTest.java
Modified:
directory/apacheds/trunk/kerberos-codec/.classpath
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/codec/KerberosMessageContainer.java
directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/KerberosMessageGrammar.java
directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/KerberosStatesEnum.java
directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/PrincipalName.java
directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/PrincipalNameType.java
Modified: directory/apacheds/trunk/kerberos-codec/.classpath
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/.classpath?rev=1031917&r1=1031916&r2=1031917&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/.classpath (original)
+++ directory/apacheds/trunk/kerberos-codec/.classpath Sat Nov 6 01:38:16 2010
@@ -1,57 +1,56 @@
-<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry excluding="**/*.java" kind="src" path="target/maven-shared-archive-resources"/>
- <classpathentry kind="src" path="src/main/java"/>
- <classpathentry kind="src" path="src/test/java"/>
- <classpathentry kind="var" path="M2_REPO/findbugs/annotations/1.0.0/annotations-1.0.0.jar"/>
- <classpathentry kind="var" path="M2_REPO/antlr/antlr/2.7.7/antlr-2.7.7.jar"/>
- <classpathentry kind="src" path="/apacheds-core-api"/>
- <classpathentry kind="src" path="/apacheds-core-constants"/>
- <classpathentry kind="src" path="/apacheds-i18n"/>
- <classpathentry kind="src" path="/apacheds-protocol-shared"/>
- <classpathentry kind="var" path="M2_REPO/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar" sourcepath="M2_REPO/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1-sources.jar">
- <attributes>
- <attribute name="javadoc_location" value="jar:file:/Users/elecharny/.m2/repository/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1-javadoc.jar!/"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="var" path="M2_REPO/commons-io/commons-io/1.4/commons-io-1.4.jar" sourcepath="M2_REPO/commons-io/commons-io/1.4/commons-io-1.4-sources.jar">
- <attributes>
- <attribute name="javadoc_location" value="jar:file:/Users/elecharny/.m2/repository/commons-io/commons-io/1.4/commons-io-1.4-javadoc.jar!/"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="var" path="M2_REPO/commons-lang/commons-lang/2.5/commons-lang-2.5.jar" sourcepath="M2_REPO/commons-lang/commons-lang/2.5/commons-lang-2.5-sources.jar">
- <attributes>
- <attribute name="javadoc_location" value="jar:file:/Users/elecharny/.m2/repository/commons-lang/commons-lang/2.5/commons-lang-2.5-javadoc.jar!/"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="var" path="M2_REPO/commons-pool/commons-pool/1.5.4/commons-pool-1.5.4.jar" sourcepath="M2_REPO/commons-pool/commons-pool/1.5.4/commons-pool-1.5.4-sources.jar">
- <attributes>
- <attribute name="javadoc_location" value="jar:file:/Users/elecharny/.m2/repository/commons-pool/commons-pool/1.5.4/commons-pool-1.5.4-javadoc.jar!/"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="var" path="M2_REPO/net/sf/ehcache/ehcache-core/2.2.0/ehcache-core-2.2.0.jar" sourcepath="M2_REPO/net/sf/ehcache/ehcache-core/2.2.0/ehcache-core-2.2.0-sources.jar">
- <attributes>
- <attribute name="javadoc_location" value="jar:file:/Users/elecharny/.m2/repository/net/sf/ehcache/ehcache-core/2.2.0/ehcache-core-2.2.0-javadoc.jar!/"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="var" path="M2_REPO/junit/junit/4.8.1/junit-4.8.1.jar" sourcepath="M2_REPO/junit/junit/4.8.1/junit-4.8.1-sources.jar"/>
- <classpathentry kind="src" path="/junit-addons"/>
- <classpathentry kind="src" path="/ldap-client-api"/>
- <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.16/log4j-1.2.16.jar" sourcepath="M2_REPO/log4j/log4j/1.2.16/log4j-1.2.16-sources.jar">
- <attributes>
- <attribute name="javadoc_location" value="jar:file:/Users/elecharny/.m2/repository/log4j/log4j/1.2.16/log4j-1.2.16-javadoc.jar!/"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="var" path="M2_REPO/org/apache/mina/mina-core/2.0.1/mina-core-2.0.1.jar" sourcepath="M2_REPO/org/apache/mina/mina-core/2.0.1/mina-core-2.0.1-sources.jar">
- <attributes>
- <attribute name="javadoc_location" value="jar:file:/Users/elecharny/.m2/repository/org/apache/mina/mina-core/2.0.1/mina-core-2.0.1-javadoc.jar!/"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="src" path="/shared-i18n"/>
- <classpathentry kind="src" path="/shared-ldap"/>
- <classpathentry kind="src" path="/shared-ldap-schema"/>
- <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.5.11/slf4j-api-1.5.11.jar" sourcepath="M2_REPO/org/slf4j/slf4j-api/1.5.11/slf4j-api-1.5.11-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-log4j12/1.5.11/slf4j-log4j12-1.5.11.jar" sourcepath="M2_REPO/org/slf4j/slf4j-log4j12/1.5.11/slf4j-log4j12-1.5.11-sources.jar"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="output" path="target/classes"/>
-</classpath>
+ <classpathentry kind="src" path="src/test/java" output="target/test-classes" including="**/*.java"/>
+ <classpathentry kind="src" path="src/main/java" including="**/*.java"/>
+ <classpathentry kind="src" path="target/maven-shared-archive-resources" excluding="**/*.java"/>
+ <classpathentry kind="output" path="target/classes"/>
+ <classpathentry kind="var" path="M2_REPO/findbugs/annotations/1.0.0/annotations-1.0.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/antlr/antlr/2.7.7/antlr-2.7.7.jar"/>
+ <classpathentry kind="src" path="/apacheds-core-api"/>
+ <classpathentry kind="src" path="/apacheds-core-constants"/>
+ <classpathentry kind="src" path="/apacheds-i18n"/>
+ <classpathentry kind="src" path="/apacheds-protocol-shared"/>
+ <classpathentry kind="var" path="M2_REPO/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar" sourcepath="M2_REPO/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1-sources.jar">
+ <attributes>
+ <attribute value="jar:file:/Users/elecharny/.m2/repository/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1-javadoc.jar!/" name="javadoc_location"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="var" path="M2_REPO/commons-io/commons-io/1.4/commons-io-1.4.jar" sourcepath="M2_REPO/commons-io/commons-io/1.4/commons-io-1.4-sources.jar">
+ <attributes>
+ <attribute value="jar:file:/Users/elecharny/.m2/repository/commons-io/commons-io/1.4/commons-io-1.4-javadoc.jar!/" name="javadoc_location"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="var" path="M2_REPO/commons-lang/commons-lang/2.5/commons-lang-2.5.jar" sourcepath="M2_REPO/commons-lang/commons-lang/2.5/commons-lang-2.5-sources.jar">
+ <attributes>
+ <attribute value="jar:file:/Users/elecharny/.m2/repository/commons-lang/commons-lang/2.5/commons-lang-2.5-javadoc.jar!/" name="javadoc_location"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="var" path="M2_REPO/commons-pool/commons-pool/1.5.4/commons-pool-1.5.4.jar" sourcepath="M2_REPO/commons-pool/commons-pool/1.5.4/commons-pool-1.5.4-sources.jar">
+ <attributes>
+ <attribute value="jar:file:/Users/elecharny/.m2/repository/commons-pool/commons-pool/1.5.4/commons-pool-1.5.4-javadoc.jar!/" name="javadoc_location"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="var" path="M2_REPO/net/sf/ehcache/ehcache-core/2.2.0/ehcache-core-2.2.0.jar" sourcepath="M2_REPO/net/sf/ehcache/ehcache-core/2.2.0/ehcache-core-2.2.0-sources.jar">
+ <attributes>
+ <attribute value="jar:file:/Users/elecharny/.m2/repository/net/sf/ehcache/ehcache-core/2.2.0/ehcache-core-2.2.0-javadoc.jar!/" name="javadoc_location"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="var" path="M2_REPO/junit/junit/4.8.1/junit-4.8.1.jar" sourcepath="M2_REPO/junit/junit/4.8.1/junit-4.8.1-sources.jar"/>
+ <classpathentry kind="src" path="/junit-addons"/>
+ <classpathentry kind="src" path="/ldap-client-api"/>
+ <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.16/log4j-1.2.16.jar" sourcepath="M2_REPO/log4j/log4j/1.2.16/log4j-1.2.16-sources.jar">
+ <attributes>
+ <attribute value="jar:file:/Users/elecharny/.m2/repository/log4j/log4j/1.2.16/log4j-1.2.16-javadoc.jar!/" name="javadoc_location"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="var" path="M2_REPO/org/apache/mina/mina-core/2.0.1/mina-core-2.0.1.jar" sourcepath="M2_REPO/org/apache/mina/mina-core/2.0.1/mina-core-2.0.1-sources.jar">
+ <attributes>
+ <attribute value="jar:file:/Users/elecharny/.m2/repository/org/apache/mina/mina-core/2.0.1/mina-core-2.0.1-javadoc.jar!/" name="javadoc_location"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" path="/shared-i18n"/>
+ <classpathentry kind="src" path="/shared-ldap"/>
+ <classpathentry kind="src" path="/shared-ldap-schema"/>
+ <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.5.11/slf4j-api-1.5.11.jar" sourcepath="M2_REPO/org/slf4j/slf4j-api/1.5.11/slf4j-api-1.5.11-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-log4j12/1.5.11/slf4j-log4j12-1.5.11.jar" sourcepath="M2_REPO/org/slf4j/slf4j-log4j12/1.5.11/slf4j-log4j12-1.5.11-sources.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+</classpath>
\ No newline at end of file
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=1031917&r1=1031916&r2=1031917&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 6 01:38:16 2010
@@ -35,4 +35,8 @@ public class KerberosConstants
public static final int TICKET_REALM_TAG = 0xA1;
public static final int TICKET_SNAME_TAG = 0xA2;
public static final int TICKET_ENC_PART_TAG = 0xA3;
+
+ /** PrincipalName's tag */
+ public static final int PRINCIPAL_NAME_NAME_TYPE_TAG = 0xA0;
+ public static final int PRINCIPAL_NAME_NAME_STRING_TAG = 0xA1;
}
Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/KerberosMessageContainer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/KerberosMessageContainer.java?rev=1031917&r1=1031916&r2=1031917&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/KerberosMessageContainer.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/KerberosMessageContainer.java Sat Nov 6 01:38:16 2010
@@ -20,6 +20,7 @@
package org.apache.directory.shared.kerberos.codec;
import org.apache.directory.shared.asn1.ber.AbstractContainer;
+import org.apache.directory.shared.kerberos.components.PrincipalName;
import org.apache.directory.shared.kerberos.messages.KerberosMessage;
import org.apache.directory.shared.kerberos.messages.Ticket;
import org.apache.directory.shared.ldap.codec.LdapStatesEnum;
@@ -36,6 +37,9 @@ public class KerberosMessageContainer ex
{
/** The internal kerberos message */
private KerberosMessage message;
+
+ /** A PrincipalName container */
+ private PrincipalName principalName;
/**
* Creates a new KerberosMessageContainer object. We will store ten grammars,
@@ -58,24 +62,45 @@ public class KerberosMessageContainer ex
return message;
}
+
+ /**
+ * Set a Message Object into the container. It will be completed by the
+ * KerberosDecoder.
+ *
+ * @param message The message to set.
+ */
+ public void setMessage( KerberosMessage message )
+ {
+ this.message = message;
+ }
+
/**
- * @return Returns the Ticket.
+ * @return Returns the Ticket if the interned message is a Ticket.
*/
public Ticket getTicket()
{
return (Ticket)message;
}
+
+ /**
+ * @return Returns the PrincipalName.
+ */
+ public PrincipalName getPrincipalName()
+ {
+ return principalName;
+ }
+
/**
- * Set a Message Object into the container. It will be completed by the
+ * Set a PrincipalName Object into the container. It will be completed by the
* KerberosDecoder.
*
- * @param message The message to set.
+ * @param principalName The principalName to set.
*/
- public void setMessage( KerberosMessage message )
+ public void setPrincipalName( PrincipalName principalName )
{
- this.message = message;
+ this.principalName = principalName;
}
}
Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/KerberosMessageGrammar.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/KerberosMessageGrammar.java?rev=1031917&r1=1031916&r2=1031917&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/KerberosMessageGrammar.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/KerberosMessageGrammar.java Sat Nov 6 01:38:16 2010
@@ -33,6 +33,10 @@ import org.apache.directory.shared.asn1.
import org.apache.directory.shared.asn1.util.IntegerDecoderException;
import org.apache.directory.shared.i18n.I18n;
import org.apache.directory.shared.kerberos.KerberosConstants;
+import org.apache.directory.shared.kerberos.codec.actions.CheckNotNullLength;
+import org.apache.directory.shared.kerberos.codec.principalName.actions.PrincipalNameInit;
+import org.apache.directory.shared.kerberos.codec.principalName.actions.PrincipalNameNameString;
+import org.apache.directory.shared.kerberos.codec.principalName.actions.PrincipalNameNameType;
import org.apache.directory.shared.kerberos.messages.Ticket;
import org.apache.directory.shared.ldap.util.StringTools;
import org.slf4j.Logger;
@@ -69,8 +73,11 @@ public final class KerberosMessageGramma
super.transitions = new GrammarTransition[KerberosStatesEnum.LAST_KERBEROS_STATE.ordinal()][256];
// ============================================================================================
- // Transition from START to Ticket
+ // Ticket
// ============================================================================================
+ // --------------------------------------------------------------------------------------------
+ // Transition from START to Ticket
+ // --------------------------------------------------------------------------------------------
// This is the starting state :
// Ticket ::= [APPLICATION 1] ...
super.transitions[KerberosStatesEnum.START_STATE.ordinal()][KerberosConstants.TICKET_TAG] = new GrammarTransition(
@@ -99,60 +106,26 @@ public final class KerberosMessageGramma
}
} );
- // ============================================================================================
+ // --------------------------------------------------------------------------------------------
// Transition from Ticket to Ticket-SEQ
- // ============================================================================================
+ // --------------------------------------------------------------------------------------------
// Ticket ::= [APPLICATION 1] SEQUENCE {
super.transitions[KerberosStatesEnum.TICKET_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
KerberosStatesEnum.TICKET_STATE, KerberosStatesEnum.TICKET_SEQ_STATE, UniversalTag.SEQUENCE.getValue(),
- new GrammarAction( "Kerberos Ticket sequence" )
- {
- public void action( Asn1Container container ) throws DecoderException
- {
- KerberosMessageContainer kerberosMessageContainer = ( KerberosMessageContainer ) container;
+ new CheckNotNullLength() );
- TLV tlv = kerberosMessageContainer.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 ) );
- }
- }
- } );
-
- // ============================================================================================
+ // --------------------------------------------------------------------------------------------
// Transition from Ticket-SEQ to tkt-vno tag
- // ============================================================================================
+ // --------------------------------------------------------------------------------------------
// Ticket ::= [APPLICATION 1] SEQUENCE {
// tkt-vno [0]
super.transitions[KerberosStatesEnum.TICKET_SEQ_STATE.ordinal()][KerberosConstants.TICKET_TKT_VNO_TAG] = new GrammarTransition(
KerberosStatesEnum.TICKET_SEQ_STATE, KerberosStatesEnum.TICKET_VNO_TAG_STATE, KerberosConstants.TICKET_TKT_VNO_TAG,
- new GrammarAction( "Kerberos Ticket tktvno tag" )
- {
- public void action( Asn1Container container ) throws DecoderException
- {
- KerberosMessageContainer kerberosMessageContainer = ( KerberosMessageContainer ) container;
-
- TLV tlv = kerberosMessageContainer.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 ) );
- }
- }
- } );
+ new CheckNotNullLength() );
- // ============================================================================================
+ // --------------------------------------------------------------------------------------------
// Transition from tkt-vno tag to tkt-vno
- // ============================================================================================
+ // --------------------------------------------------------------------------------------------
// Ticket ::= [APPLICATION 1] SEQUENCE {
// tkt-vno [0] INTEGER (5),
super.transitions[KerberosStatesEnum.TICKET_VNO_TAG_STATE.ordinal()][UniversalTag.INTEGER.getValue()] = new GrammarTransition(
@@ -200,36 +173,19 @@ public final class KerberosMessageGramma
}
} );
- // ============================================================================================
+ // --------------------------------------------------------------------------------------------
// Transition from tkt-vno to realm tag
- // ============================================================================================
+ // --------------------------------------------------------------------------------------------
// Ticket ::= [APPLICATION 1] SEQUENCE {
// tkt-vno [0] INTEGER (5),
// realm [1]
super.transitions[KerberosStatesEnum.TICKET_VNO_STATE.ordinal()][KerberosConstants.TICKET_REALM_TAG] = new GrammarTransition(
KerberosStatesEnum.TICKET_VNO_STATE, KerberosStatesEnum.TICKET_REALM_TAG_STATE, KerberosConstants.TICKET_REALM_TAG,
- new GrammarAction( "Kerberos Ticket realm tag" )
- {
- public void action( Asn1Container container ) throws DecoderException
- {
- KerberosMessageContainer kerberosMessageContainer = ( KerberosMessageContainer ) container;
-
- TLV tlv = kerberosMessageContainer.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 ) );
- }
- }
- } );
+ new CheckNotNullLength() );
- // ============================================================================================
- // Transition from Ticket-SEQ to tkt-vno
- // ============================================================================================
+ // --------------------------------------------------------------------------------------------
+ // Transition from realm tag to realm value
+ // --------------------------------------------------------------------------------------------
// Ticket ::= [APPLICATION 1] SEQUENCE {
// tkt-vno [0] INTEGER (5),
// realm [1] Realm,
@@ -266,6 +222,81 @@ public final class KerberosMessageGramma
}
} );
+ // --------------------------------------------------------------------------------------------
+ // Transition from realm value to sname tag
+ // --------------------------------------------------------------------------------------------
+ // Ticket ::= [APPLICATION 1] SEQUENCE {
+ // tkt-vno [0] INTEGER (5),
+ // realm [1] Realm,
+ // sname [2]
+ super.transitions[KerberosStatesEnum.TICKET_REALM_STATE.ordinal()][KerberosConstants.TICKET_SNAME_TAG] = new GrammarTransition(
+ KerberosStatesEnum.TICKET_REALM_STATE, KerberosStatesEnum.TICKET_SNAME_TAG_STATE, KerberosConstants.TICKET_SNAME_TAG,
+ new CheckNotNullLength() );
+
+ // --------------------------------------------------------------------------------------------
+ // Transition from sname tag to PrincipalName init
+ // --------------------------------------------------------------------------------------------
+ // Ticket ::= [APPLICATION 1] SEQUENCE {
+ // ...
+ // sname [2] PrincipalName,
+ //
+ // PrincipalName ::= SEQUENCE {
+ super.transitions[KerberosStatesEnum.TICKET_SNAME_TAG_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
+ KerberosStatesEnum.TICKET_SNAME_TAG_STATE, KerberosStatesEnum.PRINCIPAL_NAME_STATE, UniversalTag.SEQUENCE.getValue(),
+ new PrincipalNameInit() );
+
+ // ============================================================================================
+ // PrincipalName
+ // ============================================================================================
+ // --------------------------------------------------------------------------------------------
+ // Transition from PrincipalName init to name-type tag
+ // --------------------------------------------------------------------------------------------
+ // PrincipalName ::= SEQUENCE {
+ // name-type [0]
+ super.transitions[KerberosStatesEnum.PRINCIPAL_NAME_STATE.ordinal()][KerberosConstants.PRINCIPAL_NAME_NAME_TYPE_TAG] = new GrammarTransition(
+ KerberosStatesEnum.PRINCIPAL_NAME_STATE, KerberosStatesEnum.PRINCIPAL_NAME_NAME_TYPE_TAG_STATE, KerberosConstants.PRINCIPAL_NAME_NAME_TYPE_TAG,
+ new CheckNotNullLength() );
+
+ // --------------------------------------------------------------------------------------------
+ // Transition from name-type tag to name-type value
+ // --------------------------------------------------------------------------------------------
+ // PrincipalName ::= SEQUENCE {
+ // name-type [0] Int32,
+ super.transitions[KerberosStatesEnum.PRINCIPAL_NAME_NAME_TYPE_TAG_STATE.ordinal()][UniversalTag.INTEGER.getValue()] = new GrammarTransition(
+ KerberosStatesEnum.PRINCIPAL_NAME_NAME_TYPE_TAG_STATE, KerberosStatesEnum.PRINCIPAL_NAME_NAME_TYPE_STATE, UniversalTag.INTEGER.getValue(),
+ new PrincipalNameNameType() );
+
+ // --------------------------------------------------------------------------------------------
+ // Transition from name-type value to name-string tag
+ // --------------------------------------------------------------------------------------------
+ // PrincipalName ::= SEQUENCE {
+ // name-type [0] Int32,
+ // name-string [1]
+ super.transitions[KerberosStatesEnum.PRINCIPAL_NAME_NAME_TYPE_STATE.ordinal()][KerberosConstants.PRINCIPAL_NAME_NAME_STRING_TAG] = new GrammarTransition(
+ KerberosStatesEnum.PRINCIPAL_NAME_NAME_TYPE_STATE, KerberosStatesEnum.PRINCIPAL_NAME_NAME_STRING_TAG_STATE, KerberosConstants.PRINCIPAL_NAME_NAME_STRING_TAG,
+ new CheckNotNullLength() );
+
+ // --------------------------------------------------------------------------------------------
+ // Transition from name-string tag to name-string SEQ
+ // --------------------------------------------------------------------------------------------
+ // PrincipalName ::= SEQUENCE {
+ // name-type [0] Int32,
+ // name-string [1] SEQUENCE OF
+ super.transitions[KerberosStatesEnum.PRINCIPAL_NAME_NAME_STRING_TAG_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
+ KerberosStatesEnum.PRINCIPAL_NAME_NAME_STRING_TAG_STATE, KerberosStatesEnum.PRINCIPAL_NAME_NAME_STRING_SEQ_STATE, UniversalTag.SEQUENCE.getValue(),
+ new CheckNotNullLength() );
+
+ // --------------------------------------------------------------------------------------------
+ // Transition from name-string SEQ to name-string value
+ // --------------------------------------------------------------------------------------------
+ // PrincipalName ::= SEQUENCE {
+ // name-type [0] Int32,
+ // name-string [1] SEQUENCE OF KerberosString
+ super.transitions[KerberosStatesEnum.PRINCIPAL_NAME_NAME_STRING_SEQ_STATE.ordinal()][UniversalTag.GENERAL_STRING.getValue()] = new GrammarTransition(
+ KerberosStatesEnum.PRINCIPAL_NAME_NAME_STRING_SEQ_STATE, KerberosStatesEnum.PRINCIPAL_NAME_NAME_STRING_SEQ_STATE, UniversalTag.GENERAL_STRING.getValue(),
+ new PrincipalNameNameString() );
+
+
/*
// --------------------------------------------------------------------------------------------
// Transition from LdapMessage to Message ID
@@ -3461,9 +3492,9 @@ public final class KerberosMessageGramma
}
};
- // ============================================================================================
+ // --------------------------------------------------------------------------------------------
// Transition from Controls to Control
- // ============================================================================================
+ // --------------------------------------------------------------------------------------------
// ...
// Controls ::= SEQUENCE OF Control
// ...
@@ -3472,9 +3503,9 @@ public final class KerberosMessageGramma
super.transitions[LdapStatesEnum.CONTROLS_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
LdapStatesEnum.CONTROLS_STATE, LdapStatesEnum.CONTROL_STATE, UniversalTag.SEQUENCE.getValue(), addControl );
- // ============================================================================================
+ // --------------------------------------------------------------------------------------------
// Transition from Control to ControlType
- // ============================================================================================
+ // --------------------------------------------------------------------------------------------
// Control ::= SEQUENCE {
// ...
//
@@ -3534,9 +3565,9 @@ public final class KerberosMessageGramma
}
} );
- // ============================================================================================
+ // --------------------------------------------------------------------------------------------
// Transition from ControlType to Control Criticality
- // ============================================================================================
+ // --------------------------------------------------------------------------------------------
// Control ::= SEQUENCE {
// ...
// criticality BOOLEAN DEFAULT FALSE,
@@ -3591,9 +3622,9 @@ public final class KerberosMessageGramma
}
} );
- // ============================================================================================
+ // --------------------------------------------------------------------------------------------
// Transition from Control Criticality to Control Value
- // ============================================================================================
+ // --------------------------------------------------------------------------------------------
// Control ::= SEQUENCE {
// ...
// controlValue OCTET STRING OPTIONAL }
@@ -3603,9 +3634,9 @@ public final class KerberosMessageGramma
LdapStatesEnum.CRITICALITY_STATE, LdapStatesEnum.CONTROL_VALUE_STATE, UniversalTag.OCTET_STRING.getValue(),
new ControlValueAction() );
- // ============================================================================================
+ // --------------------------------------------------------------------------------------------
// Transition from Control Type to Control Value
- // ============================================================================================
+ // --------------------------------------------------------------------------------------------
// Control ::= SEQUENCE {
// ...
// controlValue OCTET STRING OPTIONAL }
@@ -3615,9 +3646,9 @@ public final class KerberosMessageGramma
LdapStatesEnum.CONTROL_TYPE_STATE, LdapStatesEnum.CONTROL_VALUE_STATE, UniversalTag.OCTET_STRING.getValue(),
new ControlValueAction() );
- // ============================================================================================
+ // --------------------------------------------------------------------------------------------
// Transition from Control Type to Control
- // ============================================================================================
+ // --------------------------------------------------------------------------------------------
// Control ::= SEQUENCE {
// ...
// controlValue OCTET STRING OPTIONAL }
@@ -3626,9 +3657,9 @@ public final class KerberosMessageGramma
super.transitions[LdapStatesEnum.CONTROL_TYPE_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
LdapStatesEnum.CONTROL_TYPE_STATE, LdapStatesEnum.CONTROL_STATE, UniversalTag.SEQUENCE.getValue(), addControl );
- // ============================================================================================
+ // --------------------------------------------------------------------------------------------
// Transition from Control Criticality to Control
- // ============================================================================================
+ // --------------------------------------------------------------------------------------------
// Control ::= SEQUENCE {
// ...
// controlValue OCTET STRING OPTIONAL }
@@ -3637,9 +3668,9 @@ public final class KerberosMessageGramma
super.transitions[LdapStatesEnum.CRITICALITY_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
LdapStatesEnum.CRITICALITY_STATE, LdapStatesEnum.CONTROL_STATE, UniversalTag.SEQUENCE.getValue(), addControl );
- // ============================================================================================
+ // --------------------------------------------------------------------------------------------
// Transition from Control Value to Control
- // ============================================================================================
+ // --------------------------------------------------------------------------------------------
// Control ::= SEQUENCE {
// ...
// controlValue OCTET STRING OPTIONAL }
@@ -4002,7 +4033,7 @@ public final class KerberosMessageGramma
}
} );
- //============================================================================================
+ //--------------------------------------------------------------------------------------------
// Search Request And Filter
// This is quite complicated, because we have a tree structure to build,
// and we may have many elements on each node. For instance, considering the
Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/KerberosStatesEnum.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/KerberosStatesEnum.java?rev=1031917&r1=1031916&r2=1031917&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/KerberosStatesEnum.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/KerberosStatesEnum.java Sat Nov 6 01:38:16 2010
@@ -55,6 +55,17 @@ public enum KerberosStatesEnum implement
TICKET_ENC_PART_TAG_STATE,
+ // ----- PrincipalName message --------------------------------------
+ PRINCIPAL_NAME_STATE,
+
+ PRINCIPAL_NAME_NAME_TYPE_TAG_STATE,
+ PRINCIPAL_NAME_NAME_TYPE_STATE,
+
+ PRINCIPAL_NAME_NAME_STRING_SEQ_STATE,
+
+ PRINCIPAL_NAME_NAME_STRING_TAG_STATE,
+ PRINCIPAL_NAME_NAME_STRING_STATE,
+
// End
LAST_KERBEROS_STATE;
Added: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/actions/CheckNotNullLength.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/actions/CheckNotNullLength.java?rev=1031917&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/actions/CheckNotNullLength.java (added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/actions/CheckNotNullLength.java Sat Nov 6 01:38:16 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.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.KerberosMessageContainer;
+import org.apache.directory.shared.kerberos.codec.KerberosMessageGrammar;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * An action that checks the length is not null
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class CheckNotNullLength extends GrammarAction
+{
+ /** The logger */
+ private static final Logger LOG = LoggerFactory.getLogger( KerberosMessageGrammar.class );
+
+ /**
+ * Instantiates the action.
+ */
+ public CheckNotNullLength()
+ {
+ super( "Check that the lebgth is not null" );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void action( Asn1Container container ) throws DecoderException
+ {
+ KerberosMessageContainer kerberosMessageContainer = ( KerberosMessageContainer ) container;
+
+ TLV tlv = kerberosMessageContainer.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 ) );
+ }
+ }
+}
Added: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/principalName/PrincipalNameContainer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/principalName/PrincipalNameContainer.java?rev=1031917&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/principalName/PrincipalNameContainer.java (added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/principalName/PrincipalNameContainer.java Sat Nov 6 01:38:16 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.principalName;
+
+import org.apache.directory.shared.asn1.ber.AbstractContainer;
+import org.apache.directory.shared.kerberos.components.PrincipalName;
+
+
+/**
+ * The PrincipalName container stores the PrincipalName decoded by the Asn1Decoder.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class PrincipalNameContainer extends AbstractContainer
+{
+ /** A PrincipalName container */
+ private PrincipalName principalName;
+
+ /**
+ * Creates a new PrincipalNameContainer object.
+ */
+ public PrincipalNameContainer()
+ {
+ super();
+ this.stateStack = new int[1];
+ this.grammar = PrincipalNameGrammar.getInstance();
+ setTransition( PrincipalNameStatesEnum.START_STATE );
+ }
+
+
+ /**
+ * @return Returns the PrincipalName.
+ */
+ public PrincipalName getPrincipalName()
+ {
+ return principalName;
+ }
+
+
+ /**
+ * Set a PrincipalName Object into the container. It will be completed by the
+ * KerberosDecoder.
+ *
+ * @param principalName The principalName to set.
+ */
+ public void setPrincipalName( PrincipalName principalName )
+ {
+ this.principalName = principalName;
+ }
+}
Added: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/principalName/PrincipalNameGrammar.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/principalName/PrincipalNameGrammar.java?rev=1031917&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/principalName/PrincipalNameGrammar.java (added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/principalName/PrincipalNameGrammar.java Sat Nov 6 01:38:16 2010
@@ -0,0 +1,168 @@
+/*
+ * 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.principalName;
+
+
+import org.apache.directory.shared.asn1.ber.Asn1Container;
+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.GrammarAction;
+import org.apache.directory.shared.asn1.ber.grammar.GrammarTransition;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.asn1.ber.tlv.UniversalTag;
+import org.apache.directory.shared.asn1.codec.DecoderException;
+import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.kerberos.KerberosConstants;
+import org.apache.directory.shared.kerberos.codec.principalName.actions.CheckNotNullLength;
+import org.apache.directory.shared.kerberos.codec.principalName.actions.PrincipalNameNameString;
+import org.apache.directory.shared.kerberos.codec.principalName.actions.PrincipalNameNameType;
+import org.apache.directory.shared.kerberos.components.PrincipalName;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * This class implements the PrincipalName. 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 PrincipalNameGrammar extends AbstractGrammar
+{
+ /** The logger */
+ static final Logger LOG = LoggerFactory.getLogger( PrincipalNameGrammar.class );
+
+ /** A speedup for logger */
+ static final boolean IS_DEBUG = LOG.isDebugEnabled();
+
+ /** The instance of grammar. PrincipalNameGrammar is a singleton */
+ private static Grammar instance = new PrincipalNameGrammar();
+
+
+ /**
+ * Creates a new PrincipalNameGrammar object.
+ */
+ private PrincipalNameGrammar()
+ {
+ setName( PrincipalNameGrammar.class.getName() );
+
+ // Create the transitions table
+ super.transitions = new GrammarTransition[PrincipalNameStatesEnum.LAST_PRINCIPAL_NAME_STATE.ordinal()][256];
+
+ // ============================================================================================
+ // PrincipalName
+ // ============================================================================================
+ // --------------------------------------------------------------------------------------------
+ // Transition from PrincipalName init to PrincipalName SEQ
+ // --------------------------------------------------------------------------------------------
+ // PrincipalName ::= SEQUENCE
+ super.transitions[PrincipalNameStatesEnum.START_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
+ PrincipalNameStatesEnum.START_STATE, PrincipalNameStatesEnum.PRINCIPAL_NAME_SEQ_STATE, UniversalTag.SEQUENCE.getValue(),
+ new GrammarAction( "principalName SEQUENCE" )
+ {
+ public void action( Asn1Container container ) throws DecoderException
+ {
+ PrincipalNameContainer principalNameContainer = ( PrincipalNameContainer ) container;
+
+ TLV tlv = principalNameContainer.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 ) );
+ }
+
+ PrincipalName principalName = new PrincipalName();
+ principalNameContainer.setPrincipalName( principalName );
+
+ if ( IS_DEBUG )
+ {
+ LOG.debug( "PrincipalName created" );
+ }
+ }
+ } );
+
+ // --------------------------------------------------------------------------------------------
+ // Transition from PrincipalName SEQ to name-type tag
+ // --------------------------------------------------------------------------------------------
+ // PrincipalName ::= SEQUENCE {
+ // name-type [0] Int32,
+ super.transitions[PrincipalNameStatesEnum.PRINCIPAL_NAME_SEQ_STATE.ordinal()][KerberosConstants.PRINCIPAL_NAME_NAME_TYPE_TAG] = new GrammarTransition(
+ PrincipalNameStatesEnum.PRINCIPAL_NAME_SEQ_STATE, PrincipalNameStatesEnum.PRINCIPAL_NAME_NAME_TYPE_TAG_STATE, KerberosConstants.PRINCIPAL_NAME_NAME_TYPE_TAG,
+ new CheckNotNullLength() );
+
+ // --------------------------------------------------------------------------------------------
+ // Transition from name-type tag to name-type value
+ // --------------------------------------------------------------------------------------------
+ // PrincipalName ::= SEQUENCE {
+ // name-type [0] Int32,
+ super.transitions[PrincipalNameStatesEnum.PRINCIPAL_NAME_NAME_TYPE_TAG_STATE.ordinal()][UniversalTag.INTEGER.getValue()] = new GrammarTransition(
+ PrincipalNameStatesEnum.PRINCIPAL_NAME_NAME_TYPE_TAG_STATE, PrincipalNameStatesEnum.PRINCIPAL_NAME_NAME_TYPE_STATE, UniversalTag.INTEGER.getValue(),
+ new PrincipalNameNameType() );
+
+ // --------------------------------------------------------------------------------------------
+ // Transition from name-type value to name-string tag
+ // --------------------------------------------------------------------------------------------
+ // PrincipalName ::= SEQUENCE {
+ // name-type [0] Int32,
+ // name-string [1]
+ super.transitions[PrincipalNameStatesEnum.PRINCIPAL_NAME_NAME_TYPE_STATE.ordinal()][KerberosConstants.PRINCIPAL_NAME_NAME_STRING_TAG] = new GrammarTransition(
+ PrincipalNameStatesEnum.PRINCIPAL_NAME_NAME_TYPE_STATE, PrincipalNameStatesEnum.PRINCIPAL_NAME_NAME_STRING_TAG_STATE, KerberosConstants.PRINCIPAL_NAME_NAME_STRING_TAG,
+ new CheckNotNullLength() );
+
+ // --------------------------------------------------------------------------------------------
+ // Transition from name-string tag to name-string SEQ
+ // --------------------------------------------------------------------------------------------
+ // PrincipalName ::= SEQUENCE {
+ // name-type [0] Int32,
+ // name-string [1] SEQUENCE OF
+ super.transitions[PrincipalNameStatesEnum.PRINCIPAL_NAME_NAME_STRING_TAG_STATE.ordinal()][UniversalTag.SEQUENCE.getValue()] = new GrammarTransition(
+ PrincipalNameStatesEnum.PRINCIPAL_NAME_NAME_STRING_TAG_STATE, PrincipalNameStatesEnum.PRINCIPAL_NAME_NAME_STRING_SEQ_STATE, UniversalTag.SEQUENCE.getValue(),
+ new CheckNotNullLength() );
+
+ // --------------------------------------------------------------------------------------------
+ // Transition from name-string SEQ to name-string value
+ // --------------------------------------------------------------------------------------------
+ // PrincipalName ::= SEQUENCE {
+ // name-type [0] Int32,
+ // name-string [1] SEQUENCE OF KerberosString
+ super.transitions[PrincipalNameStatesEnum.PRINCIPAL_NAME_NAME_STRING_SEQ_STATE.ordinal()][UniversalTag.GENERAL_STRING.getValue()] = new GrammarTransition(
+ PrincipalNameStatesEnum.PRINCIPAL_NAME_NAME_STRING_SEQ_STATE, PrincipalNameStatesEnum.PRINCIPAL_NAME_NAME_STRING_SEQ_STATE, UniversalTag.GENERAL_STRING.getValue(),
+ new PrincipalNameNameString() );
+ }
+
+
+ // ~ Methods
+ // ------------------------------------------------------------------------------------
+
+ /**
+ * Get the instance of this grammar
+ *
+ * @return An instance on the PrincipalName Grammar
+ */
+ public static Grammar getInstance()
+ {
+ return instance;
+ }
+}
Added: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/principalName/PrincipalNameStatesEnum.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/principalName/PrincipalNameStatesEnum.java?rev=1031917&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/principalName/PrincipalNameStatesEnum.java (added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/principalName/PrincipalNameStatesEnum.java Sat Nov 6 01:38:16 2010
@@ -0,0 +1,116 @@
+/*
+ * 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.principalName;
+
+
+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 PrincipalName grammar's constants. It is also used for debugging
+ * purpose
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public enum PrincipalNameStatesEnum implements States
+{
+ // ~ Static fields/initializers
+ // -----------------------------------------------------------------
+
+ // Start
+ START_STATE, // 0
+
+ // ----- PrincipalName message --------------------------------------
+ PRINCIPAL_NAME_SEQ_STATE, // 1
+
+ PRINCIPAL_NAME_NAME_TYPE_TAG_STATE, // 2
+ PRINCIPAL_NAME_NAME_TYPE_STATE, // 3
+
+ PRINCIPAL_NAME_NAME_STRING_SEQ_STATE, // 4
+
+ PRINCIPAL_NAME_NAME_STRING_TAG_STATE, // 5
+ PRINCIPAL_NAME_NAME_STRING_STATE, // 6
+
+ // End
+ LAST_PRINCIPAL_NAME_STATE; // 7
+
+
+ /**
+ * Get the grammar name
+ *
+ * @param grammar The grammar code
+ * @return The grammar name
+ */
+ public String getGrammarName( int grammar )
+ {
+ return "PRINCIPAL_NAME_GRAMMAR";
+ }
+
+
+ /**
+ * Get the grammar name
+ *
+ * @param grammar The grammar class
+ * @return The grammar name
+ */
+ public String getGrammarName( Grammar grammar )
+ {
+ if ( grammar instanceof KerberosMessageGrammar )
+ {
+ return "PRINCIPAL_NAME_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_PRINCIPAL_NAME_STATE.ordinal() ) ? "PRINCIPAL_NAME_END_STATE" : name() );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isEndState()
+ {
+ return this == LAST_PRINCIPAL_NAME_STATE;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public PrincipalNameStatesEnum getStartState()
+ {
+ return START_STATE;
+ }
+}
Added: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/principalName/actions/CheckNotNullLength.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/principalName/actions/CheckNotNullLength.java?rev=1031917&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/principalName/actions/CheckNotNullLength.java (added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/principalName/actions/CheckNotNullLength.java Sat Nov 6 01:38:16 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.principalName.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.KerberosMessageGrammar;
+import org.apache.directory.shared.kerberos.codec.principalName.PrincipalNameContainer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * An action that checks the length is not null
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class CheckNotNullLength extends GrammarAction
+{
+ /** The logger */
+ private static final Logger LOG = LoggerFactory.getLogger( KerberosMessageGrammar.class );
+
+ /**
+ * Instantiates the action.
+ */
+ public CheckNotNullLength()
+ {
+ super( "Check that the lebgth is not null" );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void action( Asn1Container container ) throws DecoderException
+ {
+ PrincipalNameContainer principalNameContainer = ( PrincipalNameContainer ) container;
+
+ TLV tlv = principalNameContainer.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 ) );
+ }
+ }
+}
Added: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/principalName/actions/PrincipalNameInit.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/principalName/actions/PrincipalNameInit.java?rev=1031917&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/principalName/actions/PrincipalNameInit.java (added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/principalName/actions/PrincipalNameInit.java Sat Nov 6 01:38:16 2010
@@ -0,0 +1,85 @@
+/*
+ * 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.principalName.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.KerberosMessageGrammar;
+import org.apache.directory.shared.kerberos.codec.principalName.PrincipalNameContainer;
+import org.apache.directory.shared.kerberos.components.PrincipalName;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to initialize the PrincipalName object
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class PrincipalNameInit 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 PrincipalNameInit action.
+ */
+ public PrincipalNameInit()
+ {
+ super( "Creates a PrincipalName instance" );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void action( Asn1Container container ) throws DecoderException
+ {
+ PrincipalNameContainer principalNameContainer = ( PrincipalNameContainer ) container;
+
+ TLV tlv = principalNameContainer.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 ) );
+ }
+
+ // We have to create a PrincipalName object here
+ PrincipalName principalName = new PrincipalName();
+ principalNameContainer.setPrincipalName( principalName );
+
+ if ( IS_DEBUG )
+ {
+ LOG.debug( "PrincipalName created" );
+ }
+ }
+}
Added: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/principalName/actions/PrincipalNameNameString.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/principalName/actions/PrincipalNameNameString.java?rev=1031917&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/principalName/actions/PrincipalNameNameString.java (added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/principalName/actions/PrincipalNameNameString.java Sat Nov 6 01:38:16 2010
@@ -0,0 +1,92 @@
+/*
+ * 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.principalName.actions;
+
+
+import org.apache.directory.shared.asn1.ber.Asn1Container;
+import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.asn1.ber.tlv.Value;
+import org.apache.directory.shared.asn1.codec.DecoderException;
+import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.kerberos.codec.KerberosMessageGrammar;
+import org.apache.directory.shared.kerberos.codec.principalName.PrincipalNameContainer;
+import org.apache.directory.shared.kerberos.components.PrincipalName;
+import org.apache.directory.shared.ldap.util.StringTools;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store the PrincipalName string
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class PrincipalNameNameString 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 PrincipalNameInit action.
+ */
+ public PrincipalNameNameString()
+ {
+ super( "Store the PrincipalName string" );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void action( Asn1Container container ) throws DecoderException
+ {
+ PrincipalNameContainer principalNameContainer = ( PrincipalNameContainer ) container;
+
+ TLV tlv = principalNameContainer.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 ) );
+ }
+
+ // Get the principalName
+ PrincipalName principalName = principalNameContainer.getPrincipalName();
+
+ Value value = tlv.getValue();
+ String nameString = StringTools.utf8ToString( value.getData() );
+
+ principalName.addName( nameString );
+ principalNameContainer.setGrammarEndAllowed( true );
+
+ if ( IS_DEBUG )
+ {
+ LOG.debug( "PrincipalName String : {}", nameString );
+ }
+ }
+}
Added: 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=1031917&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/principalName/actions/PrincipalNameNameType.java (added)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/principalName/actions/PrincipalNameNameType.java Sat Nov 6 01:38:16 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.principalName.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.principalName.PrincipalNameContainer;
+import org.apache.directory.shared.kerberos.components.PrincipalName;
+import org.apache.directory.shared.kerberos.components.PrincipalNameType;
+import org.apache.directory.shared.ldap.util.StringTools;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store the PrincipalName type
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class PrincipalNameNameType 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 PrincipalNameInit action.
+ */
+ public PrincipalNameNameType()
+ {
+ super( "Store the PrincipalName type" );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void action( Asn1Container container ) throws DecoderException
+ {
+ PrincipalNameContainer principalNameContainer = ( PrincipalNameContainer ) container;
+
+ TLV tlv = principalNameContainer.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 ) );
+ }
+
+ // Get the principalName
+ PrincipalName principalName = principalNameContainer.getPrincipalName();
+
+ Value value = tlv.getValue();
+ PrincipalNameType principalNameType = null;
+
+ try
+ {
+ int nameType = IntegerDecoder.parse( value, PrincipalNameType.FIRST_NAME_TYPE.ordinal(), PrincipalNameType.LAST_NAME_TYPE.ordinal() );
+ principalNameType = PrincipalNameType.getTypeByOrdinal( nameType );
+
+ principalName.setNameType( principalNameType );
+
+ if ( IS_DEBUG )
+ {
+ LOG.debug( "name-type : " + nameType );
+ }
+ }
+ 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() );
+ }
+
+ if ( IS_DEBUG )
+ {
+ LOG.debug( "PrincipalName type : {}", principalNameType );
+ }
+ }
+}
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=1031917&r1=1031916&r2=1031917&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 Sat Nov 6 01:38:16 2010
@@ -445,7 +445,7 @@ public class PrincipalName extends Abstr
sb.append( "PincipalName : {\n" );
- sb.append( " name-type: " ).append( nameType ).append( '\n' );
+ sb.append( " name-type: " ).append( nameType.name() ).append( '\n' );
if ( ( nameString != null ) && ( nameString.size() != 0 ) )
{
Modified: directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/PrincipalNameType.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/PrincipalNameType.java?rev=1031917&r1=1031916&r2=1031917&view=diff
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/PrincipalNameType.java (original)
+++ directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/components/PrincipalNameType.java Sat Nov 6 01:38:16 2010
@@ -42,49 +42,37 @@ package org.apache.directory.shared.kerb
*/
public enum PrincipalNameType
{
- /**
- * Constant for the "Name type not known" principal name type.
- */
+ /** The first possible ordinal value */
+ FIRST_NAME_TYPE( 0 ),
+
+ /** The last possible ordinal value */
+ LAST_NAME_TYPE( 10 ),
+
+ /** Constant for the "Name type not known" principal name type. */
KRB_NT_UNKNOWN( 0 ),
- /**
- * Constant for the "Just the name of the principal as in DCE, or for users" principal name type.
- */
+ /**Constant for the "Just the name of the principal as in DCE, or for users" principal name type. */
KRB_NT_PRINCIPAL( 1 ),
- /**
- * Constant for the "Service and other unique instance (krbtgt)" principal name type.
- */
+ /** Constant for the "Service and other unique instance (krbtgt)" principal name type. */
KRB_NT_SRV_INST( 2 ),
- /**
- * Constant for the "Service with host name as instance (telnet, rcommands)" principal name type.
- */
+ /** Constant for the "Service with host name as instance (telnet, rcommands)" principal name type. */
KRB_NT_SRV_HST( 3 ),
- /**
- * Constant for the "Service with host as remaining components" principal name type.
- */
+ /** Constant for the "Service with host as remaining components" principal name type. */
KRB_NT_SRV_XHST( 4 ),
- /**
- * Constant for the "Unique ID" principal name type.
- */
+ /** Constant for the "Unique ID" principal name type. */
KRB_NT_UID( 5 ),
- /**
- * Constant for the "Encoded X.509 Distinguished name [RFC2253]" principal name type.
- */
+ /** Constant for the "Encoded X.509 Distinguished name [RFC2253]" principal name type. */
KRB_NT_X500_PRINCIPAL( 6 ),
- /**
- * Constant for the "Name in form of SMTP email name (e.g., user@example.com)" principal name type.
- */
+ /** Constant for the "Name in form of SMTP email name (e.g., user@example.com)" principal name type. */
KRB_NT_SMTP_NAME( 7 ),
- /**
- * Constant for the "Enterprise name; may be mapped to principal name" principal name type.
- */
+ /** Constant for the "Enterprise name; may be mapped to principal name" principal name type. */
KRB_NT_ENTERPRISE( 10 );
/**
Added: directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/PrincipalNameDecoderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/PrincipalNameDecoderTest.java?rev=1031917&view=auto
==============================================================================
--- directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/PrincipalNameDecoderTest.java (added)
+++ directory/apacheds/trunk/kerberos-codec/src/test/java/org/apache/directory/shared/kerberos/codec/PrincipalNameDecoderTest.java Sat Nov 6 01:38:16 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;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.nio.ByteBuffer;
+
+import org.apache.directory.junit.tools.Concurrent;
+import org.apache.directory.junit.tools.ConcurrentJunitRunner;
+import org.apache.directory.shared.asn1.ber.Asn1Container;
+import org.apache.directory.shared.asn1.ber.Asn1Decoder;
+import org.apache.directory.shared.asn1.codec.DecoderException;
+import org.apache.directory.shared.kerberos.codec.principalName.PrincipalNameContainer;
+import org.apache.directory.shared.kerberos.components.PrincipalName;
+import org.apache.directory.shared.kerberos.components.PrincipalNameType;
+import org.apache.directory.shared.ldap.util.StringTools;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+/**
+ * Test the PrincipalName decoder
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@RunWith(ConcurrentJunitRunner.class)
+@Concurrent()
+public class PrincipalNameDecoderTest
+{
+ /** The encoder instance */
+ //LdapEncoder encoder = new LdapEncoder();
+
+ /**
+ * Test the decoding of a PrincipalName
+ */
+ @Test
+ public void testPrincipalName()
+ {
+ Asn1Decoder kerberosDecoder = new Asn1Decoder();
+
+ ByteBuffer stream = ByteBuffer.allocate( 0x29 );
+
+ stream.put( new byte[]
+ { 0x30, 0x27,
+ (byte)0xA0, 0x03, // name-type
+ 0x02, 0x01, 0x01, // NT-PRINCIPAL
+ (byte)0xA1, 0x20, // name-string
+ 0x30, 0x1E,
+ 0x1B, 0x08, 'h', 'n', 'e', 'l', 's', 'o', 'n', '1',
+ 0x1B, 0x08, 'h', 'n', 'e', 'l', 's', 'o', 'n', '2',
+ 0x1B, 0x08, 'h', 'n', 'e', 'l', 's', 'o', 'n', '3',
+ } );
+
+ String decodedPdu = StringTools.dumpBytes( stream.array() );
+ stream.flip();
+
+ // Allocate a PrincipalName Container
+ Asn1Container principalNameContainer = new PrincipalNameContainer();
+
+ // Decode the PrincipalName PDU
+ try
+ {
+ kerberosDecoder.decode( stream, principalNameContainer );
+ }
+ catch ( DecoderException de )
+ {
+ de.printStackTrace();
+ fail( de.getMessage() );
+ }
+
+ // Check the decoded BindRequest
+ PrincipalName principalName = ( ( PrincipalNameContainer ) principalNameContainer ).getPrincipalName();
+
+ assertEquals( PrincipalNameType.KRB_NT_PRINCIPAL, principalName.getNameType() );
+ assertTrue( principalName.getNames().contains( "hnelson1" ) );
+ assertTrue( principalName.getNames().contains( "hnelson2" ) );
+ assertTrue( principalName.getNames().contains( "hnelson3" ) );
+
+ /*
+ // Check the encoding
+ try
+ {
+ ByteBuffer bb = encoder.encodeMessage( bindRequest );
+
+ // Check the length
+ assertEquals( 0x35, bb.limit() );
+
+ String encodedPdu = StringTools.dumpBytes( bb.array() );
+
+ assertEquals( encodedPdu, decodedPdu );
+ }
+ catch ( EncoderException ee )
+ {
+ ee.printStackTrace();
+ fail( ee.getMessage() );
+ }
+ */
+ }
+}