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 2005/09/09 23:43:24 UTC
svn commit: r279887 [3/15] - in
/directory/shared/ldap/branches/elecharny-cleanup/apache2-provider: ./
conf/ perfs/ perfs/org/ perfs/org/apache/ perfs/org/apache/asn1new/
perfs/org/apache/asn1new/ber/ src/ src/java/ src/java/main/
src/java/main/org/ sr...
Added: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindRequestGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindRequestGrammar.java?rev=279887&view=auto
==============================================================================
--- directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindRequestGrammar.java (added)
+++ directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindRequestGrammar.java Fri Sep 9 14:41:22 2005
@@ -0,0 +1,363 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed 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.asn1new.ldap.codec.grammar;
+
+import org.apache.asn1.codec.DecoderException;
+import org.apache.asn1new.ber.containers.IAsn1Container;
+import org.apache.asn1new.ber.grammar.AbstractGrammar;
+import org.apache.asn1new.ber.grammar.GrammarAction;
+import org.apache.asn1new.ber.grammar.GrammarTransition;
+import org.apache.asn1new.ber.grammar.IGrammar;
+import org.apache.asn1new.ber.tlv.TLV;
+import org.apache.asn1new.ber.tlv.UniversalTag;
+import org.apache.asn1new.ber.tlv.Value;
+import org.apache.asn1new.util.IntegerDecoder;
+import org.apache.asn1new.primitives.OctetString;
+import org.apache.asn1new.ldap.codec.LdapConstants;
+import org.apache.asn1new.ldap.codec.LdapMessageContainer;
+import org.apache.asn1new.ldap.codec.primitives.LdapDN;
+import org.apache.asn1new.ldap.codec.primitives.LdapString;
+import org.apache.asn1new.ldap.pojo.BindRequest;
+import org.apache.asn1new.ldap.pojo.LdapMessage;
+import org.apache.asn1new.ldap.pojo.SaslCredentials;
+import org.apache.asn1new.ldap.pojo.SimpleAuthentication;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * This class implements the BindRequest LDAP message. 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 class BindRequestGrammar extends AbstractGrammar implements IGrammar
+{
+ //~ Static fields/initializers -----------------------------------------------------------------
+
+ /** The logger */
+ private static final Logger log = LoggerFactory.getLogger( BindRequestGrammar.class );
+
+ /** The instance of grammar. BindRequestGrammar is a singleton */
+ private static IGrammar instance = new BindRequestGrammar();
+
+ //~ Methods ------------------------------------------------------------------------------------
+
+ /**
+ * Get the instance of this grammar
+ *
+ * @return An instance on the BindRequest Grammar
+ */
+ public static IGrammar getInstance()
+ {
+ return instance;
+ }
+
+ //~ Constructors -------------------------------------------------------------------------------
+
+ /**
+ * Creates a new LdapMessageGrammar object.
+ */
+ private BindRequestGrammar()
+ {
+
+ name = BindRequestGrammar.class.getName();
+
+ statesEnum = LdapStatesEnum.getInstance();
+
+ // We have 17 differents states, so 16 transitions between states.
+ super.transitions = new GrammarTransition[LdapStatesEnum.LAST_BIND_REQUEST_STATE][256];
+
+ //============================================================================================
+ // protocolOp : Bind Request
+ //============================================================================================
+ // We have to allocate a BindRequest
+ // LdapMessage ::= ... BindRequest ...
+ // BindRequest ::= [APPLICATION 0] SEQUENCE { ... (Length)
+ super.transitions[LdapStatesEnum.BIND_REQUEST_TAG][LdapConstants.BIND_REQUEST_TAG] = new GrammarTransition(
+ LdapStatesEnum.BIND_REQUEST_TAG, LdapStatesEnum.BIND_REQUEST_VALUE, null );
+
+ // LdapMessage ::= ... BindRequest ...
+ // BindRequest ::= [APPLICATION 0] SEQUENCE { ... (Value)
+ // Nothing to do, the Value is empty, this is a constructed TLV. We now can swith to the BindRequest Grammar
+ super.transitions[LdapStatesEnum.BIND_REQUEST_VALUE][LdapConstants.BIND_REQUEST_TAG] = new GrammarTransition(
+ LdapStatesEnum.BIND_REQUEST_VALUE, LdapStatesEnum.BIND_REQUEST_VERSION_TAG,
+ new GrammarAction( "Init BindRequest" )
+ {
+ public void action( IAsn1Container container ) throws DecoderException
+ {
+
+ LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
+ container;
+ LdapMessage ldapMessage =
+ ldapMessageContainer.getLdapMessage();
+
+ // Now, we can allocate the BindRequest Object
+ ldapMessage.setProtocolOP( new BindRequest() );
+ }
+ } );
+
+ // BindRequest ::= ... version INTEGER (1 .. 127 ), ... (Tag)
+ // Nothing to do.
+ super.transitions[LdapStatesEnum.BIND_REQUEST_VERSION_TAG][UniversalTag.INTEGER_TAG] = new GrammarTransition(
+ LdapStatesEnum.BIND_REQUEST_VERSION_TAG, LdapStatesEnum.BIND_REQUEST_VERSION_VALUE, null );
+
+ // BindRequest ::= ... version INTEGER (1 .. 127 ), ... (value)
+ // Checks that the Version is in [1, 127]
+ super.transitions[LdapStatesEnum.BIND_REQUEST_VERSION_VALUE][UniversalTag.INTEGER_TAG] = new GrammarTransition(
+ LdapStatesEnum.BIND_REQUEST_VERSION_VALUE, LdapStatesEnum.BIND_REQUEST_NAME_TAG,
+ new GrammarAction( "Store version" )
+ {
+ public void action( IAsn1Container container ) throws DecoderException
+ {
+
+ LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
+ container;
+ BindRequest bindRequestMessage =
+ ldapMessageContainer.getLdapMessage().getBindRequest();
+
+ // The current TLV should be a integer between 1 and 127
+ // We get it and store it in Version
+ TLV tlv = ldapMessageContainer.getCurrentTLV();
+
+ Value value = tlv.getValue();
+
+ int version = IntegerDecoder.parse( value, 1, 127 );
+
+ bindRequestMessage.setVersion( version );
+
+ return;
+ }
+ } );
+
+ // BindRequest ::= ... name LDAPDN, ... (Tag)
+ // Nothing to do. The tag is supposed to be 0x04
+ super.transitions[LdapStatesEnum.BIND_REQUEST_NAME_TAG][UniversalTag.OCTET_STRING_TAG] = new GrammarTransition(
+ LdapStatesEnum.BIND_REQUEST_NAME_TAG, LdapStatesEnum.BIND_REQUEST_NAME_VALUE, null );
+
+ // BindRequest ::= ... name LDAPDN, ... (Value)
+ // We have to store the name
+ // The name may be null, for anonymous binds or for SASL
+ // authentication
+ super.transitions[LdapStatesEnum.BIND_REQUEST_NAME_VALUE][UniversalTag.OCTET_STRING_TAG] = new GrammarTransition(
+ LdapStatesEnum.BIND_REQUEST_NAME_VALUE,
+ LdapStatesEnum.BIND_REQUEST_AUTHENTICATION_CHOICE_TAG,
+ new GrammarAction( "Store Bind Name value" )
+ {
+ public void action( IAsn1Container container ) throws DecoderException
+ {
+
+ LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
+ container;
+ BindRequest bindRequestMessage =
+ ldapMessageContainer.getLdapMessage().getBindRequest();
+
+ // Get the Value and store it in the BindRequest
+ TLV tlv = ldapMessageContainer.getCurrentTLV();
+
+ // We have to handle the special case of a 0 length name
+ if (tlv.getLength().getLength() == 0)
+ {
+ bindRequestMessage.setName( LdapDN.EMPTY_STRING );
+ }
+ else
+ {
+ bindRequestMessage.setName( new LdapDN( tlv.getValue().getData() ) );
+ }
+
+ return;
+ }
+ } );
+
+ // BindRequest ::= ... authentication AuthenticationChoice }
+ // AuthenticationChoice ::= CHOICE {
+ // The tag might be either 0x80 (SimpleAuthentication) or 0x83 (SaslCredentials)
+ //--------------------------------------------------------------------------------------------
+ // If it's 0x80, it is a SimpleAuthentication.
+ //--------------------------------------------------------------------------------------------
+ // Nothing to do.
+ super.transitions[LdapStatesEnum.BIND_REQUEST_AUTHENTICATION_CHOICE_TAG][LdapConstants.BIND_REQUEST_SIMPLE_TAG] =
+ new GrammarTransition( LdapStatesEnum.BIND_REQUEST_AUTHENTICATION_CHOICE_TAG,
+ LdapStatesEnum.BIND_REQUEST_AUTHENTICATION_SIMPLE_VALUE, null );
+
+ // AuthenticationChoice ::= CHOICE {
+ // simple [0] OCTET STRING, (Value)
+ // We have to create an Authentication Object to store the credentials.
+ // The nextState is GRAMMAR_END
+ super.transitions[LdapStatesEnum.BIND_REQUEST_AUTHENTICATION_SIMPLE_VALUE][LdapConstants.BIND_REQUEST_SIMPLE_TAG] =
+ new GrammarTransition( LdapStatesEnum.BIND_REQUEST_AUTHENTICATION_SIMPLE_VALUE,
+ LdapStatesEnum.GRAMMAR_END,
+ new GrammarAction( "Store Bind Simple Authentication value" )
+ {
+ public void action( IAsn1Container container ) throws DecoderException
+ {
+
+ LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
+ container;
+
+ BindRequest bindRequestMessage =
+ ldapMessageContainer.getLdapMessage().getBindRequest();
+ TLV tlv = ldapMessageContainer.getCurrentTLV();
+
+ // Allocate the Authentication Object
+ SimpleAuthentication authentication = null;
+
+ authentication = new SimpleAuthentication();
+
+ authentication.setParent( bindRequestMessage );
+
+ bindRequestMessage.setAuthentication( authentication );
+
+ // We have to handle the special case of a 0 length simple
+ if (tlv.getLength().getLength() == 0)
+ {
+ authentication.setSimple( OctetString.EMPTY_STRING );
+ }
+ else
+ {
+ authentication.setSimple( new OctetString( tlv.getValue().getData() ) );
+ }
+ }
+ } );
+
+ //--------------------------------------------------------------------------------------------
+ // If it's 0x83, it is a Sasl Credentials.
+ // AuthenticationChoice ::= CHOICE {
+ // ...
+ // sasl [3] SaslCredentials }
+ //
+ // SaslCredentials ::= SEQUENCE {
+ // mechanism LDAPSTRING,
+ // credentials OCTET STRING OPTIONNAL }
+ //--------------------------------------------------------------------------------------------
+ // AuthenticationChoice ::= CHOICE {
+ // sasl [3] saslCredentials, (Tag)
+ // Nothing to do. In fact, 0x83 is the mechanism tag.
+ super.transitions[LdapStatesEnum.BIND_REQUEST_AUTHENTICATION_CHOICE_TAG][LdapConstants.BIND_REQUEST_SASL_TAG] =
+ new GrammarTransition( LdapStatesEnum.BIND_REQUEST_AUTHENTICATION_CHOICE_TAG,
+ LdapStatesEnum.BIND_REQUEST_AUTHENTICATION_MECHANISM_VALUE, null );
+
+ // AuthenticationChoice ::= CHOICE {
+ // sasl [3] saslCredentials }
+ //
+ // SaslCredentials ::= SEQUENCE {
+ // mechanism LDAPSTRING, (Value)
+ // ...
+ // We have to store the mechanism.
+ super.transitions[LdapStatesEnum.BIND_REQUEST_AUTHENTICATION_MECHANISM_VALUE][LdapConstants.BIND_REQUEST_SASL_TAG] =
+ new GrammarTransition( LdapStatesEnum.BIND_REQUEST_AUTHENTICATION_MECHANISM_VALUE,
+ LdapStatesEnum.BIND_REQUEST_AUTHENTICATION_CREDENTIALS_TAG,
+ new GrammarAction( "Create Bind sasl Authentication Object" )
+ {
+ public void action( IAsn1Container container ) throws DecoderException
+ {
+
+ LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
+ container;
+ BindRequest bindRequestMessage =
+ ldapMessageContainer.getLdapMessage().getBindRequest();
+ TLV tlv = ldapMessageContainer.getCurrentTLV();
+
+ // Create the SaslCredentials Object
+ SaslCredentials authentication = new SaslCredentials();
+
+ authentication.setParent( bindRequestMessage );
+
+ bindRequestMessage.setAuthentication( authentication );
+
+ // We have to handle the special case of a 0 length mechanism
+ if (tlv.getLength().getLength() == 0)
+ {
+ authentication.setMechanism( LdapString.EMPTY_STRING );
+ }
+ else
+ {
+ authentication.setMechanism( new LdapString(tlv.getValue().getData() ) );
+ }
+
+ return;
+ }
+ } );
+
+ //--------------------------------------------------------------------------------------------
+ // SaslCredentials ::= SEQUENCE {
+ // ...
+ // credentials OCTET STRING OPTIONAL } (Tag)
+ //--------------------------------------------------------------------------------------------
+ // We may have a credential, or nothing, as it's an optional element.
+ // The tag will have one of those values :
+ // - 0x04 if it's a credentials
+ // - 0x90 if it's a control
+ // - any other value is an error.
+ //
+ // It's a credential if it's 0x04
+ super.transitions[LdapStatesEnum.BIND_REQUEST_AUTHENTICATION_CREDENTIALS_TAG][UniversalTag.OCTET_STRING_TAG] =
+ new GrammarTransition( LdapStatesEnum.BIND_REQUEST_AUTHENTICATION_CREDENTIALS_TAG,
+ LdapStatesEnum.BIND_REQUEST_AUTHENTICATION_CREDENTIALS_VALUE, null );
+
+ // It's a control if it's 0x90
+ //super.transitions[LdapStatesEnum.BIND_REQUEST_AUTHENTICATION_CREDENTIALS_TAG][0x90] =
+ // new GrammarTransition( LdapStatesEnum.BIND_REQUEST_AUTHENTICATION_CREDENTIALS_TAG,
+ // LdapStatesEnum.GRAMMAR_END, null );
+
+ // SaslCredentials ::= SEQUENCE {
+ // ...
+ // credentials OCTET STRING OPTIONAL } (Value)
+ //
+ // We have to get the Credentials and store it in the SaslCredentials.
+ // Two different following states are possible :
+ // - a Control tag (0x90)
+ // - or nothing at all (end of the BindRequest).
+ // We just have to transit to the first case, which will accept or not the transition.
+ // This is done by transiting to the GRAMMAR_END state
+ super.transitions[LdapStatesEnum.BIND_REQUEST_AUTHENTICATION_CREDENTIALS_VALUE][UniversalTag.OCTET_STRING_TAG] =
+ new GrammarTransition( LdapStatesEnum.BIND_REQUEST_AUTHENTICATION_CREDENTIALS_VALUE,
+ LdapStatesEnum.GRAMMAR_END,
+ new GrammarAction( "Store Bind sasl Authentication credentials value" )
+ {
+ public void action( IAsn1Container container ) throws DecoderException
+ {
+
+ LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
+ container;
+
+ BindRequest bindRequestMessage =
+ ldapMessageContainer.getLdapMessage().getBindRequest();
+
+ // Get the Value and store it in the BindRequest
+ TLV tlv = ldapMessageContainer.getCurrentTLV();
+
+ SaslCredentials credentials = bindRequestMessage
+ .getSaslAuthentication();
+
+ // We have to handle the special case of a 0 length credentials
+ if (tlv.getLength().getLength() == 0)
+ {
+ credentials.setCredentials( OctetString.EMPTY_STRING );
+ }
+ else
+ {
+ credentials.setCredentials( new OctetString( tlv.getValue().getData() ) );
+ }
+
+ return;
+ }
+ } );
+ }
+}
Propchange: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindRequestGrammar.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindResponseGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindResponseGrammar.java?rev=279887&view=auto
==============================================================================
--- directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindResponseGrammar.java (added)
+++ directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindResponseGrammar.java Fri Sep 9 14:41:22 2005
@@ -0,0 +1,185 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed 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.asn1new.ldap.codec.grammar;
+
+import org.apache.asn1.codec.DecoderException;
+import org.apache.asn1new.ber.containers.IAsn1Container;
+import org.apache.asn1new.ber.grammar.AbstractGrammar;
+import org.apache.asn1new.ber.grammar.GrammarAction;
+import org.apache.asn1new.ber.grammar.GrammarTransition;
+import org.apache.asn1new.ber.grammar.IGrammar;
+import org.apache.asn1new.ber.tlv.TLV;
+import org.apache.asn1new.ber.tlv.UniversalTag;
+import org.apache.asn1new.primitives.OctetString;
+import org.apache.asn1new.ldap.codec.LdapConstants;
+import org.apache.asn1new.ldap.codec.LdapMessageContainer;
+import org.apache.asn1new.ldap.pojo.BindResponse;
+import org.apache.asn1new.ldap.pojo.LdapMessage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * This class implements the BindResponse LDAP message. 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 class BindResponseGrammar extends AbstractGrammar implements IGrammar
+{
+ //~ Static fields/initializers -----------------------------------------------------------------
+
+ /** The logger */
+ private static final Logger log = LoggerFactory.getLogger( BindResponseGrammar.class );
+
+ /** The instance of grammar. BindResponseGrammar is a singleton */
+ private static IGrammar instance = new BindResponseGrammar();
+
+ //~ Constructors -------------------------------------------------------------------------------
+
+ /**
+ * Creates a new BindResponseGrammar object.
+ */
+ private BindResponseGrammar()
+ {
+ name = BindResponseGrammar.class.getName();
+ statesEnum = LdapStatesEnum.getInstance();
+
+ // Initialisation of the transitions table
+ super.transitions = new GrammarTransition[LdapStatesEnum.LAST_BIND_RESPONSE_STATE][256];
+
+ //============================================================================================
+ // BindResponse Message
+ //============================================================================================
+ // BindResponse ::= [APPLICATION 1] SEQUENCE {
+ // COMPONENTS OF LDAPResult,
+ // ...
+ // Nothing to do
+ super.transitions[LdapStatesEnum.BIND_RESPONSE_TAG][LdapConstants.BIND_RESPONSE_TAG] = new GrammarTransition(
+ LdapStatesEnum.BIND_RESPONSE_TAG, LdapStatesEnum.BIND_RESPONSE_VALUE, null );
+
+ // LdapMessage ::= ... BindResponse ...
+ // BindResponse ::= [APPLICATION 1] SEQUENCE { ... (Value)
+ // We won't have a value. The next Tag will be the LDAPResult Tag (0x0A)
+ super.transitions[LdapStatesEnum.BIND_RESPONSE_VALUE][LdapConstants.BIND_RESPONSE_TAG] = new GrammarTransition(
+ LdapStatesEnum.BIND_RESPONSE_VALUE, LdapStatesEnum.BIND_RESPONSE_LDAP_RESULT,
+ new GrammarAction( "Init BindReponse" )
+ {
+ public void action( IAsn1Container container ) throws DecoderException
+ {
+
+ LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
+ container;
+ LdapMessage ldapMessage =
+ ldapMessageContainer.getLdapMessage();
+
+ // Now, we can allocate the BindRequest Object
+ BindResponse bindResponse = new BindResponse();
+
+ // As this is a new Constructed object, we have to init its length
+ bindResponse.setParent( ldapMessage );
+
+ // And we associate it to the ldapMessage Object
+ ldapMessage.setProtocolOP( bindResponse );
+ }
+ } );
+
+ // LdapMessage ::= ... BindResponse ...
+ // BindResponse ::= [APPLICATION 1] SEQUENCE { ... (Value)
+ // COMPONENTS OF LDAPResult, ...
+ // The Tag will be the LDAPResult Tag (0x0A). So we have to switch the grammar.
+ // The current state will be stored.
+ super.transitions[LdapStatesEnum.BIND_RESPONSE_LDAP_RESULT][UniversalTag.ENUMERATED_TAG] = new GrammarTransition(
+ LdapStatesEnum.BIND_RESPONSE_LDAP_RESULT, LdapStatesEnum.LDAP_RESULT_GRAMMAR_SWITCH,
+ null );
+
+ // LdapMessage ::= ... BindResponse ...
+ // BindResponse ::= [APPLICATION 1] SEQUENCE {
+ // COMPONENTS OF LDAPResult,
+ // serverSaslCreds [7] OCTET STRING OPTIONAL }
+ // If there is a sasl credential, we will decode it here. We must control that we had a LdapResult
+ //
+ super.transitions[LdapStatesEnum.BIND_RESPONSE_LDAP_RESULT][LdapConstants.SERVER_SASL_CREDENTIAL_TAG] = new GrammarTransition(
+ LdapStatesEnum.BIND_RESPONSE_LDAP_RESULT,
+ LdapStatesEnum.BIND_RESPONSE_SERVER_SASL_CREDS_VALUE, null );
+
+ // BindResponse ::= APPLICATION 1] SEQUENCE {
+ // ...
+ // serverSaslCreds [7] OCTET STRING OPTIONAL } (Tag)
+ // It's a server sasl credential if the tag is 0x87
+ // Otherwise, if the tag is 0x90, it's a control
+ super.transitions[LdapStatesEnum.BIND_RESPONSE_SERVER_SASL_CREDS_TAG][LdapConstants.SERVER_SASL_CREDENTIAL_TAG] =
+ new GrammarTransition( LdapStatesEnum.BIND_RESPONSE_SERVER_SASL_CREDS_TAG,
+ LdapStatesEnum.BIND_RESPONSE_SERVER_SASL_CREDS_VALUE, null );
+
+ // BindResponse ::= APPLICATION 1] SEQUENCE {
+ // ...
+ // serverSaslCreds [7] OCTET STRING OPTIONAL } (Length)
+ //
+ // We have to get the server sasl Credentials and store it in the BindResponse Object.
+ // Two different following states are possible :
+ // - a Control tag (0x90)
+ // - nothing at all (end of the BindResponse).
+ // We just have to transit to the first case, which will accept or not the transition.
+ // This is done by transiting to the GRAMMAR_END state
+ super.transitions[LdapStatesEnum.BIND_RESPONSE_SERVER_SASL_CREDS_VALUE][LdapConstants.SERVER_SASL_CREDENTIAL_TAG] =
+ new GrammarTransition( LdapStatesEnum.BIND_RESPONSE_SERVER_SASL_CREDS_VALUE,
+ LdapStatesEnum.GRAMMAR_END,
+ new GrammarAction( "Store server sasl credentials value" )
+ {
+ public void action( IAsn1Container container ) throws DecoderException
+ {
+
+ LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
+ container;
+
+ BindResponse bindResponseMessage =
+ ldapMessageContainer.getLdapMessage().getBindResponse();
+
+ // Get the Value and store it in the BindRequest
+ TLV tlv = ldapMessageContainer.getCurrentTLV();
+
+ // We have to handle the special case of a 0 length server sasl credentials
+ if ( tlv.getLength().getLength() == 0 )
+ {
+ bindResponseMessage.setServerSaslCreds( OctetString.EMPTY_STRING );
+ }
+ else
+ {
+ bindResponseMessage.setServerSaslCreds( new OctetString( tlv.getValue().getData() ) );
+ }
+
+ return;
+ }
+ } );
+
+ }
+
+ //~ Methods ------------------------------------------------------------------------------------
+
+ /**
+ * Get the instance of this grammar
+ *
+ * @return An instance on the LdapMessage Grammar
+ */
+ public static IGrammar getInstance()
+ {
+ return instance;
+ }
+}
Propchange: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindResponseGrammar.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/CompareRequestGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/CompareRequestGrammar.java?rev=279887&view=auto
==============================================================================
--- directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/CompareRequestGrammar.java (added)
+++ directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/CompareRequestGrammar.java Fri Sep 9 14:41:22 2005
@@ -0,0 +1,253 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed 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.asn1new.ldap.codec.grammar;
+
+import org.apache.asn1.codec.DecoderException;
+import org.apache.asn1new.ber.containers.IAsn1Container;
+import org.apache.asn1new.ber.grammar.AbstractGrammar;
+import org.apache.asn1new.ber.grammar.GrammarAction;
+import org.apache.asn1new.ber.grammar.GrammarTransition;
+import org.apache.asn1new.ber.grammar.IGrammar;
+import org.apache.asn1new.ber.tlv.TLV;
+import org.apache.asn1new.ber.tlv.UniversalTag;
+import org.apache.asn1new.primitives.OctetString;
+import org.apache.asn1new.ldap.codec.LdapConstants;
+import org.apache.asn1new.ldap.codec.LdapMessageContainer;
+import org.apache.asn1new.ldap.codec.primitives.LdapDN;
+import org.apache.asn1new.ldap.codec.primitives.LdapString;
+import org.apache.asn1new.ldap.pojo.CompareRequest;
+import org.apache.asn1new.ldap.pojo.LdapMessage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * This class implements the CompareRequest LDAP message. 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 class CompareRequestGrammar extends AbstractGrammar implements IGrammar
+{
+ //~ Static fields/initializers -----------------------------------------------------------------
+
+ /** The logger */
+ private static final Logger log = LoggerFactory.getLogger( CompareRequestGrammar.class );
+
+ /** The instance of grammar. CompareRequest is a singleton */
+ private static IGrammar instance = new CompareRequestGrammar();
+
+ //~ Constructors -------------------------------------------------------------------------------
+
+ /**
+ * Creates a new CompareRequest object.
+ */
+ private CompareRequestGrammar()
+ {
+ name = CompareRequestGrammar.class.getName();
+ statesEnum = LdapStatesEnum.getInstance();
+
+ super.transitions = new GrammarTransition[LdapStatesEnum.LAST_COMPARE_REQUEST_STATE][256];
+
+ //============================================================================================
+ // CompareRequest
+ //============================================================================================
+ // CompareRequest ::= [APPLICATION 14] SEQUENCE { (Tag)
+ // Nothing to do
+ super.transitions[LdapStatesEnum.COMPARE_REQUEST_TAG][LdapConstants.COMPARE_REQUEST_TAG] = new GrammarTransition(
+ LdapStatesEnum.COMPARE_REQUEST_TAG,
+ LdapStatesEnum.COMPARE_REQUEST_VALUE, null );
+
+ // CompareRequest ::= [APPLICATION 14] SEQUENCE { (Value)
+ // Initialize the compare request pojo
+ super.transitions[LdapStatesEnum.COMPARE_REQUEST_VALUE][LdapConstants.COMPARE_REQUEST_TAG] = new GrammarTransition(
+ LdapStatesEnum.COMPARE_REQUEST_VALUE, LdapStatesEnum.COMPARE_REQUEST_ENTRY_TAG,
+ new GrammarAction( "Init Compare Request" )
+ {
+ public void action( IAsn1Container container ) throws DecoderException
+ {
+
+ LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
+ container;
+ LdapMessage ldapMessage =
+ ldapMessageContainer.getLdapMessage();
+
+ // We can allocate the CompareRequest Object
+ ldapMessage.setProtocolOP( new CompareRequest() );
+ }
+ } );
+
+ // CompareRequest ::= [APPLICATION 14] SEQUENCE {
+ // entry LDAPDN, (Tag)
+ // ...
+ // Nothing to do
+ super.transitions[LdapStatesEnum.COMPARE_REQUEST_ENTRY_TAG][UniversalTag.OCTET_STRING_TAG] = new GrammarTransition(
+ LdapStatesEnum.COMPARE_REQUEST_ENTRY_TAG,
+ LdapStatesEnum.COMPARE_REQUEST_ENTRY_VALUE, null );
+
+ // CompareRequest ::= [APPLICATION 14] SEQUENCE {
+ // entry LDAPDN, (Tag)
+ // ...
+ // Store the DN to be compared
+ super.transitions[LdapStatesEnum.COMPARE_REQUEST_ENTRY_VALUE][UniversalTag.OCTET_STRING_TAG] = new GrammarTransition(
+ LdapStatesEnum.COMPARE_REQUEST_ENTRY_VALUE, LdapStatesEnum.COMPARE_REQUEST_AVA_TAG,
+ new GrammarAction( "Store entry" )
+ {
+ public void action( IAsn1Container container ) throws DecoderException
+ {
+
+ LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
+ container;
+ LdapMessage ldapMessage =
+ ldapMessageContainer.getLdapMessage();
+
+ // We can allocate the CompareRequest Object
+ CompareRequest compareRequest = ldapMessage.getCompareRequest();
+
+ // Get the Value and store it in the CompareRequest
+ TLV tlv = ldapMessageContainer.getCurrentTLV();
+
+ // We have to handle the special case of a 0 length matched DN
+ if ( tlv.getLength().getLength() == 0 )
+ {
+ throw new DecoderException( "The entry must not be null" );
+ }
+ else
+ {
+ compareRequest.setEntry( new LdapDN( tlv.getValue().getData() ) );
+ }
+ }
+ } );
+
+ // CompareRequest ::= [APPLICATION 14] SEQUENCE {
+ // ...
+ // ava AttributeValueAssertion }
+ // AttributeValueAssertion ::= SEQUENCE { (Tag)
+ // Nothing to do
+ super.transitions[LdapStatesEnum.COMPARE_REQUEST_AVA_TAG][UniversalTag.SEQUENCE_TAG] = new GrammarTransition(
+ LdapStatesEnum.COMPARE_REQUEST_AVA_TAG,
+ LdapStatesEnum.COMPARE_REQUEST_AVA_VALUE, null );
+
+ // CompareRequest ::= [APPLICATION 14] SEQUENCE {
+ // ...
+ // ava AttributeValueAssertion }
+ // AttributeValueAssertion ::= SEQUENCE { (Value)
+ // Nothing to do
+ super.transitions[LdapStatesEnum.COMPARE_REQUEST_AVA_VALUE][UniversalTag.SEQUENCE_TAG] = new GrammarTransition(
+ LdapStatesEnum.COMPARE_REQUEST_AVA_VALUE, LdapStatesEnum.COMPARE_REQUEST_ATTRIBUTE_DESC_TAG, null);
+
+ // AttributeValueAssertion ::= SEQUENCE {
+ // attributeDesc AttributeDescription, (Tag)
+ // ...
+ // Nothing to do
+ super.transitions[LdapStatesEnum.COMPARE_REQUEST_ATTRIBUTE_DESC_TAG][UniversalTag.OCTET_STRING_TAG] = new GrammarTransition(
+ LdapStatesEnum.COMPARE_REQUEST_ATTRIBUTE_DESC_TAG,
+ LdapStatesEnum.COMPARE_REQUEST_ATTRIBUTE_DESC_VALUE, null );
+
+ // AttributeValueAssertion ::= SEQUENCE {
+ // attributeDesc AttributeDescription, (Value)
+ // ...
+ // Nothing to do
+ super.transitions[LdapStatesEnum.COMPARE_REQUEST_ATTRIBUTE_DESC_VALUE][UniversalTag.OCTET_STRING_TAG] = new GrammarTransition(
+ LdapStatesEnum.COMPARE_REQUEST_ATTRIBUTE_DESC_VALUE,
+ LdapStatesEnum.COMPARE_REQUEST_ASSERTION_VALUE_TAG,
+ new GrammarAction( "Store attribute desc" )
+ {
+ public void action( IAsn1Container container ) throws DecoderException
+ {
+
+ LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
+ container;
+ LdapMessage ldapMessage =
+ ldapMessageContainer.getLdapMessage();
+
+ // Get the CompareRequest Object
+ CompareRequest compareRequest = ldapMessage.getCompareRequest();
+
+ // Get the Value and store it in the CompareRequest
+ TLV tlv = ldapMessageContainer.getCurrentTLV();
+
+ // We have to handle the special case of a 0 length matched DN
+ if ( tlv.getLength().getLength() == 0 )
+ {
+ throw new DecoderException( "The attribute description must not be null" );
+ }
+ else
+ {
+ compareRequest.setAttributeDesc( new LdapString( tlv.getValue().getData() ) );
+ }
+ }
+ } );
+
+ // AttributeValueAssertion ::= SEQUENCE {
+ // ...
+ // assertionValue AssertionValue } (Tag)
+ // Nothing to do
+ super.transitions[LdapStatesEnum.COMPARE_REQUEST_ASSERTION_VALUE_TAG][UniversalTag.OCTET_STRING_TAG] = new GrammarTransition(
+ LdapStatesEnum.COMPARE_REQUEST_ASSERTION_VALUE_TAG,
+ LdapStatesEnum.COMPARE_REQUEST_ASSERTION_VALUE_VALUE, null );
+
+ // AttributeValueAssertion ::= SEQUENCE {
+ // ...
+ // assertionValue AssertionValue } (Value)
+ // Nothing to do
+ super.transitions[LdapStatesEnum.COMPARE_REQUEST_ASSERTION_VALUE_VALUE][UniversalTag.OCTET_STRING_TAG] = new GrammarTransition(
+ LdapStatesEnum.COMPARE_REQUEST_ASSERTION_VALUE_VALUE,
+ LdapStatesEnum.END_STATE,
+ new GrammarAction( "Store assertion value" )
+ {
+ public void action( IAsn1Container container ) throws DecoderException
+ {
+
+ LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
+ container;
+ LdapMessage ldapMessage =
+ ldapMessageContainer.getLdapMessage();
+
+ // Get the CompareRequest Object
+ CompareRequest compareRequest = ldapMessage.getCompareRequest();
+
+ // Get the Value and store it in the CompareRequest
+ TLV tlv = ldapMessageContainer.getCurrentTLV();
+
+ // We have to handle the special case of a 0 length matched DN
+ if ( tlv.getLength().getLength() == 0 )
+ {
+ compareRequest.setAssertionValue( OctetString.EMPTY_STRING );
+ }
+ else
+ {
+ compareRequest.setAssertionValue( new OctetString( tlv.getValue().getData() ) );
+ }
+ }
+ } );
+ }
+
+ //~ Methods ------------------------------------------------------------------------------------
+
+ /**
+ * This class is a singleton.
+ *
+ * @return An instance on this grammar
+ */
+ public static IGrammar getInstance()
+ {
+ return instance;
+ }
+}
Propchange: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/CompareRequestGrammar.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/CompareResponseGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/CompareResponseGrammar.java?rev=279887&view=auto
==============================================================================
--- directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/CompareResponseGrammar.java (added)
+++ directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/CompareResponseGrammar.java Fri Sep 9 14:41:22 2005
@@ -0,0 +1,112 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed 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.asn1new.ldap.codec.grammar;
+
+import org.apache.asn1.codec.DecoderException;
+import org.apache.asn1new.ber.containers.IAsn1Container;
+import org.apache.asn1new.ber.grammar.AbstractGrammar;
+import org.apache.asn1new.ber.grammar.GrammarAction;
+import org.apache.asn1new.ber.grammar.GrammarTransition;
+import org.apache.asn1new.ber.grammar.IGrammar;
+import org.apache.asn1new.ber.tlv.UniversalTag;
+import org.apache.asn1new.ldap.codec.LdapConstants;
+import org.apache.asn1new.ldap.codec.LdapMessageContainer;
+import org.apache.asn1new.ldap.pojo.CompareResponse;
+import org.apache.asn1new.ldap.pojo.LdapMessage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * This class implements the CompareResponse LDAP message. All the actions are declared in this
+ * class. As it is a singleton, these declaration are only done once.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class CompareResponseGrammar extends AbstractGrammar implements IGrammar
+{
+ //~ Static fields/initializers -----------------------------------------------------------------
+
+ /** The logger */
+ private static final Logger log = LoggerFactory.getLogger( CompareResponseGrammar.class );
+
+ /** The instance of grammar. CompareResponseGrammar is a singleton */
+ private static IGrammar instance = new CompareResponseGrammar();
+
+ //~ Constructors -------------------------------------------------------------------------------
+
+ /**
+ * Creates a new CompareResponseGrammar object.
+ */
+ private CompareResponseGrammar()
+ {
+ name = CompareResponseGrammar.class.getName();
+ statesEnum = LdapStatesEnum.getInstance();
+
+ // Intitialisation
+ super.transitions = new GrammarTransition[LdapStatesEnum.LAST_COMPARE_RESPONSE_STATE][256];
+
+ //============================================================================================
+ // CompareResponse Message
+ //============================================================================================
+ // LdapMessage ::= ... CompareResponse ...
+ // CompareResponse ::= [APPLICATION 15] LDAPResult (Tag)
+ // Nothing to do.
+ super.transitions[LdapStatesEnum.COMPARE_RESPONSE_TAG][LdapConstants.COMPARE_RESPONSE_TAG] = new GrammarTransition(
+ LdapStatesEnum.COMPARE_RESPONSE_TAG, LdapStatesEnum.COMPARE_RESPONSE_VALUE, null );
+
+ // LdapMessage ::= ... CompareResponse ...
+ // CompareResponse ::= [APPLICATION 15] LDAPResult (Value)
+ // The next Tag will be the LDAPResult Tag (0x0A).
+ // We will switch the grammar then.
+ super.transitions[LdapStatesEnum.COMPARE_RESPONSE_VALUE][LdapConstants.COMPARE_RESPONSE_TAG] = new GrammarTransition(
+ LdapStatesEnum.COMPARE_RESPONSE_VALUE, LdapStatesEnum.COMPARE_RESPONSE_LDAP_RESULT,
+ new GrammarAction( "Init CompareResponse" )
+ {
+ public void action( IAsn1Container container ) throws DecoderException
+ {
+
+ LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
+ container;
+ LdapMessage ldapMessage =
+ ldapMessageContainer.getLdapMessage();
+
+ // Now, we can allocate the CompareResponse Object
+ // And we associate it to the ldapMessage Object
+ ldapMessage.setProtocolOP( new CompareResponse() );
+ }
+ } );
+
+ // LdapMessage ::= ... CompareResponse ...
+ // CompareResponse ::= [APPLICATION 15] LDAPResult (Value)
+ // Ok, we have a LDAPResult Tag (0x0A). So we have to switch the grammar.
+ super.transitions[LdapStatesEnum.COMPARE_RESPONSE_LDAP_RESULT][UniversalTag.ENUMERATED_TAG] = new GrammarTransition(
+ LdapStatesEnum.COMPARE_RESPONSE_LDAP_RESULT, LdapStatesEnum.LDAP_RESULT_GRAMMAR_SWITCH, null );
+ }
+
+ //~ Methods ------------------------------------------------------------------------------------
+
+ /**
+ * Get the instance of this grammar
+ *
+ * @return An instance on the LdapMessage Grammar
+ */
+ public static IGrammar getInstance()
+ {
+ return instance;
+ }
+}
Propchange: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/CompareResponseGrammar.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/DelRequestGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/DelRequestGrammar.java?rev=279887&view=auto
==============================================================================
--- directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/DelRequestGrammar.java (added)
+++ directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/DelRequestGrammar.java Fri Sep 9 14:41:22 2005
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed 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.asn1new.ldap.codec.grammar;
+
+import org.apache.asn1.codec.DecoderException;
+import org.apache.asn1new.ber.containers.IAsn1Container;
+import org.apache.asn1new.ber.grammar.AbstractGrammar;
+import org.apache.asn1new.ber.grammar.GrammarAction;
+import org.apache.asn1new.ber.grammar.GrammarTransition;
+import org.apache.asn1new.ber.grammar.IGrammar;
+import org.apache.asn1new.ber.tlv.TLV;
+import org.apache.asn1new.ldap.codec.LdapConstants;
+import org.apache.asn1new.ldap.codec.LdapMessageContainer;
+import org.apache.asn1new.ldap.codec.primitives.LdapDN;
+import org.apache.asn1new.ldap.pojo.DelRequest;
+import org.apache.asn1new.ldap.pojo.LdapMessage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * This class implements the DelRequest LDAP message. 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 class DelRequestGrammar extends AbstractGrammar implements IGrammar
+{
+ //~ Static fields/initializers -----------------------------------------------------------------
+
+ /** The logger */
+ private static final Logger log = LoggerFactory.getLogger( DelRequestGrammar.class );
+
+ /** The instance of grammar. DelRequestGrammar is a singleton */
+ private static IGrammar instance = new DelRequestGrammar();
+
+ //~ Constructors -------------------------------------------------------------------------------
+
+ /**
+ * Creates a new DelRequestGrammar object.
+ */
+ private DelRequestGrammar()
+ {
+ name = DelRequestGrammar.class.getName();
+ statesEnum = LdapStatesEnum.getInstance();
+
+ super.transitions = new GrammarTransition[LdapStatesEnum.LAST_DEL_REQUEST_STATE][256];
+
+ //============================================================================================
+ // DelRequest
+ //============================================================================================
+ // DelRequestGrammar ::= [APPLICATION 10] LDAPDN { (Tag)
+ // Nothing to do
+ super.transitions[LdapStatesEnum.DEL_REQUEST_TAG][LdapConstants.DEL_REQUEST_TAG] = new GrammarTransition(
+ LdapStatesEnum.DEL_REQUEST_TAG,
+ LdapStatesEnum.DEL_REQUEST_VALUE, null );
+
+ // DelRequestGrammar ::= [APPLICATION 10] LDAPDN { (Value)
+ // Initialise the del request pojo and store the DN to be deleted
+ super.transitions[LdapStatesEnum.DEL_REQUEST_VALUE][LdapConstants.DEL_REQUEST_TAG] = new GrammarTransition(
+ LdapStatesEnum.DEL_REQUEST_VALUE, LdapStatesEnum.END_STATE,
+ new GrammarAction( "Init del Request" )
+ {
+ public void action( IAsn1Container container ) throws DecoderException
+ {
+
+ LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
+ container;
+ LdapMessage ldapMessage =
+ ldapMessageContainer.getLdapMessage();
+
+ // We can allocate the DelRequest Object
+ DelRequest delRequest = new DelRequest();
+
+ // And store the DN into it
+ // Get the Value and store it in the DelRequest
+ TLV tlv = ldapMessageContainer.getCurrentTLV();
+
+ // We have to handle the special case of a 0 length matched DN
+ if ( tlv.getLength().getLength() == 0 )
+ {
+ throw new DecoderException( "The entry must not be null" );
+ }
+ else
+ {
+ delRequest.setEntry( new LdapDN( tlv.getValue().getData() ) );
+ }
+
+ // then we associate it to the ldapMessage Object
+ ldapMessage.setProtocolOP( delRequest );
+ }
+ } );
+
+ }
+
+ //~ Methods ------------------------------------------------------------------------------------
+
+ /**
+ * This class is a singleton.
+ *
+ * @return An instance on this grammar
+ */
+ public static IGrammar getInstance()
+ {
+ return instance;
+ }
+}
Propchange: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/DelRequestGrammar.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/DelResponseGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/DelResponseGrammar.java?rev=279887&view=auto
==============================================================================
--- directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/DelResponseGrammar.java (added)
+++ directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/DelResponseGrammar.java Fri Sep 9 14:41:22 2005
@@ -0,0 +1,113 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed 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.asn1new.ldap.codec.grammar;
+
+import org.apache.asn1.codec.DecoderException;
+import org.apache.asn1new.ber.containers.IAsn1Container;
+import org.apache.asn1new.ber.grammar.AbstractGrammar;
+import org.apache.asn1new.ber.grammar.GrammarAction;
+import org.apache.asn1new.ber.grammar.GrammarTransition;
+import org.apache.asn1new.ber.grammar.IGrammar;
+import org.apache.asn1new.ber.tlv.UniversalTag;
+import org.apache.asn1new.ldap.codec.LdapConstants;
+import org.apache.asn1new.ldap.codec.LdapMessageContainer;
+import org.apache.asn1new.ldap.pojo.DelResponse;
+import org.apache.asn1new.ldap.pojo.LdapMessage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * This class implements the DelResponse LDAP message. All the actions are declared in this
+ * class. As it is a singleton, these declaration are only done once.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class DelResponseGrammar extends AbstractGrammar implements IGrammar
+{
+ //~ Static fields/initializers -----------------------------------------------------------------
+
+ /** The logger */
+ private static final Logger log = LoggerFactory.getLogger( DelResponseGrammar.class );
+
+ /** The instance of grammar. DelResponseGrammar is a singleton */
+ private static IGrammar instance = new DelResponseGrammar();
+
+ //~ Constructors -------------------------------------------------------------------------------
+
+ /**
+ * Creates a new DelResponseGrammar object.
+ */
+ private DelResponseGrammar()
+ {
+ name = DelResponseGrammar.class.getName();
+ statesEnum = LdapStatesEnum.getInstance();
+
+ // Intitialisation
+ super.transitions = new GrammarTransition[LdapStatesEnum.LAST_DEL_RESPONSE_STATE][256];
+
+ //============================================================================================
+ // DelResponse Message
+ //============================================================================================
+ // LdapMessage ::= ... DelResponse ...
+ // DelResponse ::= [APPLICATION 11] LDAPResult (Tag)
+ // Nothing to do.
+ super.transitions[LdapStatesEnum.DEL_RESPONSE_TAG][LdapConstants.DEL_RESPONSE_TAG] = new GrammarTransition(
+ LdapStatesEnum.DEL_RESPONSE_TAG, LdapStatesEnum.DEL_RESPONSE_VALUE, null );
+
+ // LdapMessage ::= ... DelResponse ...
+ // DelResponse ::= [APPLICATION 11] LDAPResult (Value)
+ // The next Tag will be the LDAPResult Tag (0x0A).
+ // We will switch the grammar then.
+ super.transitions[LdapStatesEnum.DEL_RESPONSE_VALUE][LdapConstants.DEL_RESPONSE_TAG] = new GrammarTransition(
+ LdapStatesEnum.DEL_RESPONSE_VALUE, LdapStatesEnum.DEL_RESPONSE_LDAP_RESULT,
+ new GrammarAction( "Init DelResponse" )
+ {
+ public void action( IAsn1Container container ) throws DecoderException
+ {
+
+ LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
+ container;
+ LdapMessage ldapMessage =
+ ldapMessageContainer.getLdapMessage();
+
+ // Now, we can allocate the DelResponse Object
+
+ // And we associate it to the ldapMessage Object
+ ldapMessage.setProtocolOP( new DelResponse() );
+ }
+ } );
+
+ // LdapMessage ::= ... DelResponse ...
+ // DelResponse ::= [APPLICATION 11] LDAPResult (Value)
+ // Ok, we have a LDAPResult Tag (0x0A). So we have to switch the grammar.
+ super.transitions[LdapStatesEnum.DEL_RESPONSE_LDAP_RESULT][UniversalTag.ENUMERATED_TAG] = new GrammarTransition(
+ LdapStatesEnum.DEL_RESPONSE_LDAP_RESULT, LdapStatesEnum.LDAP_RESULT_GRAMMAR_SWITCH, null );
+ }
+
+ //~ Methods ------------------------------------------------------------------------------------
+
+ /**
+ * Get the instance of this grammar
+ *
+ * @return An instance on the LdapMessage Grammar
+ */
+ public static IGrammar getInstance()
+ {
+ return instance;
+ }
+}
Propchange: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/DelResponseGrammar.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ExtendedRequestGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ExtendedRequestGrammar.java?rev=279887&view=auto
==============================================================================
--- directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ExtendedRequestGrammar.java (added)
+++ directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ExtendedRequestGrammar.java Fri Sep 9 14:41:22 2005
@@ -0,0 +1,192 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed 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.asn1new.ldap.codec.grammar;
+
+import org.apache.asn1.codec.DecoderException;
+import org.apache.asn1new.ber.containers.IAsn1Container;
+import org.apache.asn1new.ber.grammar.AbstractGrammar;
+import org.apache.asn1new.ber.grammar.GrammarAction;
+import org.apache.asn1new.ber.grammar.GrammarTransition;
+import org.apache.asn1new.ber.grammar.IGrammar;
+import org.apache.asn1new.ber.tlv.TLV;
+import org.apache.asn1new.primitives.OID;
+import org.apache.asn1new.primitives.OctetString;
+import org.apache.asn1new.ldap.codec.LdapConstants;
+import org.apache.asn1new.ldap.codec.LdapMessageContainer;
+import org.apache.asn1new.ldap.pojo.ExtendedRequest;
+import org.apache.asn1new.ldap.pojo.LdapMessage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+
+/**
+ * This class implements the ExtendedRequest LDAP message. 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 class ExtendedRequestGrammar extends AbstractGrammar implements IGrammar
+{
+ //~ Static fields/initializers -----------------------------------------------------------------
+
+ /** The logger */
+ private static final Logger log = LoggerFactory.getLogger( ExtendedRequestGrammar.class );
+
+ /** The instance of grammar. ExtendedRequest is a singleton */
+ private static IGrammar instance = new ExtendedRequestGrammar();
+
+ //~ Constructors -------------------------------------------------------------------------------
+
+ /**
+ * Creates a new ExtendedRequest object.
+ */
+ private ExtendedRequestGrammar()
+ {
+ name = ExtendedRequestGrammar.class.getName();
+ statesEnum = LdapStatesEnum.getInstance();
+
+ super.transitions = new GrammarTransition[LdapStatesEnum.LAST_EXTENDED_REQUEST_STATE][256];
+
+ //============================================================================================
+ // ExtendedRequest
+ //============================================================================================
+ // ExtendedRequest ::= [APPLICATION 23] SEQUENCE { (Tag)
+ // Nothing to do
+ super.transitions[LdapStatesEnum.EXTENDED_REQUEST_TAG][LdapConstants.EXTENDED_REQUEST_TAG] = new GrammarTransition(
+ LdapStatesEnum.EXTENDED_REQUEST_TAG,
+ LdapStatesEnum.EXTENDED_REQUEST_VALUE, null );
+
+ // ExtendedRequest ::= [APPLICATION 23] SEQUENCE { (Value)
+ // Initialize the compare request pojo
+ super.transitions[LdapStatesEnum.EXTENDED_REQUEST_VALUE][LdapConstants.EXTENDED_REQUEST_TAG] = new GrammarTransition(
+ LdapStatesEnum.EXTENDED_REQUEST_VALUE, LdapStatesEnum.EXTENDED_REQUEST_NAME_TAG,
+ new GrammarAction( "Init Extended Request" )
+ {
+ public void action( IAsn1Container container ) throws DecoderException
+ {
+
+ LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
+ container;
+ LdapMessage ldapMessage =
+ ldapMessageContainer.getLdapMessage();
+
+ // We can allocate the ExtendedRequest Object
+ ldapMessage.setProtocolOP( new ExtendedRequest() );
+ }
+ } );
+
+ // ExtendedRequest ::= [APPLICATION 23] SEQUENCE {
+ // requestName [0] LDAPOID, (Tag)
+ // ...
+ // Nothing to do
+ super.transitions[LdapStatesEnum.EXTENDED_REQUEST_NAME_TAG][LdapConstants.EXTENDED_REQUEST_NAME_TAG] = new GrammarTransition(
+ LdapStatesEnum.EXTENDED_REQUEST_NAME_TAG,
+ LdapStatesEnum.EXTENDED_REQUEST_NAME_VALUE, null );
+
+ // ExtendedRequest ::= [APPLICATION 23] SEQUENCE {
+ // requestName [0] LDAPOID, (Value)
+ // ...
+ // Store the DN to be compared
+ super.transitions[LdapStatesEnum.EXTENDED_REQUEST_NAME_VALUE][LdapConstants.EXTENDED_REQUEST_NAME_TAG] = new GrammarTransition(
+ LdapStatesEnum.EXTENDED_REQUEST_NAME_VALUE, LdapStatesEnum.EXTENDED_REQUEST_VALUE_TAG,
+ new GrammarAction( "Store name" )
+ {
+ public void action( IAsn1Container container ) throws DecoderException
+ {
+
+ LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
+ container;
+ LdapMessage ldapMessage =
+ ldapMessageContainer.getLdapMessage();
+
+ // We can allocate the ExtendedRequest Object
+ ExtendedRequest extendedRequest = ldapMessage.getExtendedRequest();
+
+ // Get the Value and store it in the ExtendedRequest
+ TLV tlv = ldapMessageContainer.getCurrentTLV();
+
+ // We have to handle the special case of a 0 length matched OID
+ if ( tlv.getLength().getLength() == 0 )
+ {
+ throw new DecoderException( "The name must not be null" );
+ }
+ else
+ {
+ extendedRequest.setRequestName( new OID( tlv.getValue().getData() ) );
+ }
+ }
+ } );
+
+ // ExtendedRequest ::= [APPLICATION 23] SEQUENCE {
+ // ...
+ // requestValue [1] OCTET STRING OPTIONAL } (Tag)
+ // Nothing to do
+ super.transitions[LdapStatesEnum.EXTENDED_REQUEST_VALUE_TAG][LdapConstants.EXTENDED_REQUEST_VALUE_TAG] = new GrammarTransition(
+ LdapStatesEnum.EXTENDED_REQUEST_VALUE_TAG,
+ LdapStatesEnum.EXTENDED_REQUEST_VALUE_VALUE, null );
+
+ // ExtendedRequest ::= [APPLICATION 23] SEQUENCE {
+ // ...
+ // requestValue [1] OCTET STRING OPTIONAL } (Value)
+ // Store the DN to be compared
+ super.transitions[LdapStatesEnum.EXTENDED_REQUEST_VALUE_VALUE][LdapConstants.EXTENDED_REQUEST_VALUE_TAG] = new GrammarTransition(
+ LdapStatesEnum.EXTENDED_REQUEST_VALUE_VALUE, LdapStatesEnum.END_STATE,
+ new GrammarAction( "Store value" )
+ {
+ public void action( IAsn1Container container ) throws DecoderException
+ {
+
+ LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
+ container;
+ LdapMessage ldapMessage =
+ ldapMessageContainer.getLdapMessage();
+
+ // We can allocate the ExtendedRequest Object
+ ExtendedRequest extendedRequest = ldapMessage.getExtendedRequest();
+
+ // Get the Value and store it in the ExtendedRequest
+ TLV tlv = ldapMessageContainer.getCurrentTLV();
+
+ // We have to handle the special case of a 0 length matched OID
+ if ( tlv.getLength().getLength() == 0 )
+ {
+ extendedRequest.setRequestValue( OctetString.EMPTY_STRING );
+ }
+ else
+ {
+ extendedRequest.setRequestValue( new OctetString( tlv.getValue().getData() ) );
+ }
+ }
+ } );
+
+ }
+
+ //~ Methods ------------------------------------------------------------------------------------
+
+ /**
+ * This class is a singleton.
+ *
+ * @return An instance on this grammar
+ */
+ public static IGrammar getInstance()
+ {
+ return instance;
+ }
+}
Propchange: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ExtendedRequestGrammar.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ExtendedResponseGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ExtendedResponseGrammar.java?rev=279887&view=auto
==============================================================================
--- directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ExtendedResponseGrammar.java (added)
+++ directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ExtendedResponseGrammar.java Fri Sep 9 14:41:22 2005
@@ -0,0 +1,203 @@
+/*
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed 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.asn1new.ldap.codec.grammar;
+
+import org.apache.asn1.codec.DecoderException;
+import org.apache.asn1new.ber.containers.IAsn1Container;
+import org.apache.asn1new.ber.grammar.AbstractGrammar;
+import org.apache.asn1new.ber.grammar.GrammarAction;
+import org.apache.asn1new.ber.grammar.GrammarTransition;
+import org.apache.asn1new.ber.grammar.IGrammar;
+import org.apache.asn1new.ber.tlv.TLV;
+import org.apache.asn1new.ber.tlv.UniversalTag;
+import org.apache.asn1new.primitives.OID;
+import org.apache.asn1new.primitives.OctetString;
+import org.apache.asn1new.ldap.codec.LdapConstants;
+import org.apache.asn1new.ldap.codec.LdapMessageContainer;
+import org.apache.asn1new.ldap.pojo.ExtendedResponse;
+import org.apache.asn1new.ldap.pojo.LdapMessage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * This class implements the ExtendedResponse LDAP message. 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 class ExtendedResponseGrammar extends AbstractGrammar implements IGrammar
+{
+ //~ Static fields/initializers -----------------------------------------------------------------
+
+ /** The logger */
+ private static final Logger log = LoggerFactory.getLogger( ExtendedResponseGrammar.class );
+
+ /** The instance of grammar. ExtendedResponseGrammar is a singleton */
+ private static IGrammar instance = new ExtendedResponseGrammar();
+
+ //~ Constructors -------------------------------------------------------------------------------
+
+ /**
+ * Creates a new ExtendedResponseGrammar object.
+ */
+ private ExtendedResponseGrammar()
+ {
+ name = ExtendedResponseGrammar.class.getName();
+ statesEnum = LdapStatesEnum.getInstance();
+
+ super.transitions = new GrammarTransition[LdapStatesEnum.LAST_EXTENDED_RESPONSE_STATE][256];
+
+ //============================================================================================
+ // ExtendedResponse
+ //============================================================================================
+ // ExtendedResponse ::= [APPLICATION 24] SEQUENCE { (Tag)
+ // Nothing to do
+ super.transitions[LdapStatesEnum.EXTENDED_RESPONSE_TAG][LdapConstants.EXTENDED_RESPONSE_TAG] = new GrammarTransition(
+ LdapStatesEnum.EXTENDED_RESPONSE_TAG,
+ LdapStatesEnum.EXTENDED_RESPONSE_VALUE, null );
+
+ // ExtendedResponse ::= [APPLICATION 24] SEQUENCE { (Value)
+ // Initialize the compare request pojo
+ super.transitions[LdapStatesEnum.EXTENDED_RESPONSE_VALUE][LdapConstants.EXTENDED_RESPONSE_TAG] = new GrammarTransition(
+ LdapStatesEnum.EXTENDED_RESPONSE_VALUE, LdapStatesEnum.EXTENDED_RESPONSE_LDAP_RESULT,
+ new GrammarAction( "Init Extended Reponse" )
+ {
+ public void action( IAsn1Container container ) throws DecoderException
+ {
+
+ LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
+ container;
+ LdapMessage ldapMessage =
+ ldapMessageContainer.getLdapMessage();
+
+ // We can allocate the ExtendedResponse Object
+ ldapMessage.setProtocolOP( new ExtendedResponse() );
+ }
+ } );
+
+ // ExtendedResponse ::= [APPLICATION 24] SEQUENCE {
+ // COMPONENTS OF LDAPResult, (Tag)
+ // ...
+ // The Tag will be the LDAPResult Tag (0x0A). So we have to switch the grammar.
+ // The current state will be stored.
+ super.transitions[LdapStatesEnum.EXTENDED_RESPONSE_LDAP_RESULT][UniversalTag.ENUMERATED_TAG] = new GrammarTransition(
+ LdapStatesEnum.EXTENDED_RESPONSE_LDAP_RESULT,
+ LdapStatesEnum.LDAP_RESULT_GRAMMAR_SWITCH, null );
+
+ // ExtendedResponse ::= [APPLICATION 24] SEQUENCE {
+ // ...
+ // responseName [10] LDAPOID OPTIONAL, (Tag)
+ // ...
+ // Nothing to do.
+ super.transitions[LdapStatesEnum.EXTENDED_RESPONSE_LDAP_RESULT][LdapConstants.EXTENDED_RESPONSE_RESPONSE_NAME_TAG] = new GrammarTransition(
+ LdapStatesEnum.EXTENDED_RESPONSE_LDAP_RESULT, LdapStatesEnum.EXTENDED_RESPONSE_NAME_VALUE, null
+ );
+
+ // ExtendedResponse ::= [APPLICATION 24] SEQUENCE {
+ // ...
+ // responseName [10] LDAPOID OPTIONAL, (Value)
+ // ...
+ // Store the response name.
+ super.transitions[LdapStatesEnum.EXTENDED_RESPONSE_NAME_VALUE][LdapConstants.EXTENDED_RESPONSE_RESPONSE_NAME_TAG] = new GrammarTransition(
+ LdapStatesEnum.EXTENDED_RESPONSE_NAME_VALUE, LdapStatesEnum.EXTENDED_RESPONSE_RESPONSE_TAG,
+ new GrammarAction( "Store name" )
+ {
+ public void action( IAsn1Container container ) throws DecoderException
+ {
+
+ LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
+ container;
+ LdapMessage ldapMessage =
+ ldapMessageContainer.getLdapMessage();
+
+ // We can allocate the ExtendedResponse Object
+ ExtendedResponse extendedResponse = ldapMessage.getExtendedResponse();
+
+ // Get the Value and store it in the ExtendedResponse
+ TLV tlv = ldapMessageContainer.getCurrentTLV();
+
+ // We have to handle the special case of a 0 length matched OID
+ if ( tlv.getLength().getLength() == 0 )
+ {
+ throw new DecoderException( "The name must not be null" );
+ }
+ else
+ {
+ extendedResponse.setResponseName( new OID( tlv.getValue().getData() ) );
+ }
+ }
+ } );
+
+ // ExtendedResponse ::= [APPLICATION 24] SEQUENCE {
+ // ...
+ // response [11] OCTET STRING OPTIONAL } (Tag)
+ // Nothing to do
+ super.transitions[LdapStatesEnum.EXTENDED_RESPONSE_RESPONSE_TAG][LdapConstants.EXTENDED_RESPONSE_RESPONSE_TAG] = new GrammarTransition(
+ LdapStatesEnum.EXTENDED_RESPONSE_RESPONSE_TAG,
+ LdapStatesEnum.EXTENDED_RESPONSE_RESPONSE_VALUE, null );
+
+ // ExtendedResponse ::= [APPLICATION 24] SEQUENCE {
+ // ...
+ // response [11] OCTET STRING OPTIONAL } (Value)
+ // Store the response
+ super.transitions[LdapStatesEnum.EXTENDED_RESPONSE_RESPONSE_VALUE][LdapConstants.EXTENDED_RESPONSE_RESPONSE_TAG] = new GrammarTransition(
+ LdapStatesEnum.EXTENDED_RESPONSE_RESPONSE_VALUE, LdapStatesEnum.END_STATE,
+ new GrammarAction( "Store response" )
+ {
+ public void action( IAsn1Container container ) throws DecoderException
+ {
+
+ LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
+ container;
+ LdapMessage ldapMessage =
+ ldapMessageContainer.getLdapMessage();
+
+ // We can allocate the ExtendedResponse Object
+ ExtendedResponse extendedResponse = ldapMessage.getExtendedResponse();
+
+ // Get the Value and store it in the ExtendedResponse
+ TLV tlv = ldapMessageContainer.getCurrentTLV();
+
+ // We have to handle the special case of a 0 length matched OID
+ if ( tlv.getLength().getLength() == 0 )
+ {
+ extendedResponse.setResponse( OctetString.EMPTY_STRING );
+ }
+ else
+ {
+ extendedResponse.setResponse( new OctetString( tlv.getValue().getData() ) );
+ }
+ }
+ } );
+
+ }
+
+ //~ Methods ------------------------------------------------------------------------------------
+
+ /**
+ * This class is a singleton.
+ *
+ * @return An instance on this grammar
+ */
+ public static IGrammar getInstance()
+ {
+ return instance;
+ }
+}
Propchange: directory/shared/ldap/branches/elecharny-cleanup/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ExtendedResponseGrammar.java
------------------------------------------------------------------------------
svn:eol-style = native