Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 83166 invoked from network); 27 Mar 2005 18:40:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 27 Mar 2005 18:40:23 -0000 Received: (qmail 8043 invoked by uid 500); 27 Mar 2005 18:40:23 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 8003 invoked by uid 500); 27 Mar 2005 18:40:23 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 7987 invoked by uid 99); 27 Mar 2005 18:40:22 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Sun, 27 Mar 2005 10:40:22 -0800 Received: (qmail 83153 invoked by uid 65534); 27 Mar 2005 18:40:20 -0000 Message-ID: <20050327184020.83152.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Mailer: svnmailer-1.0.0-dev Date: Sun, 27 Mar 2005 18:40:20 -0000 Subject: svn commit: r159164 - directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec To: commits@directory.apache.org From: elecharny@apache.org X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: elecharny Date: Sun Mar 27 10:40:20 2005 New Revision: 159164 URL: http://svn.apache.org/viewcvs?view=3Drev&rev=3D159164 Log: A first working version of the new ASN.1 LDAP decoder. Added: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/co= dec/LdapMessageContainer.java directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/co= dec/LdapMessageContainerFactory.java directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/co= dec/LdapMessageGrammar.java Added: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap= /codec/LdapMessageContainer.java URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/s= rc/java/org/apache/asn1/ldap/codec/LdapMessageContainer.java?view=3Dauto&re= v=3D159164 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/co= dec/LdapMessageContainer.java (added) +++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/co= dec/LdapMessageContainer.java Sun Mar 27 10:40:20 2005 @@ -0,0 +1,191 @@ +/* + * 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 impli= ed. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.asn1.ldap.codec; + +import org.apache.asn1.ber.containers.IAsn1Container; +import org.apache.asn1.ber.grammar.IGrammar; +import org.apache.asn1.ber.tlv.TLV; +import org.apache.asn1.ldap.pojo.LdapMessagePOJO; +import org.apache.asn1.util.pools.LocalPoolManager; +import org.apache.asn1.util.pools.PoolObject; + + +/** + * The LdapMessage container stores all the messages decoded by the + * Asn1Decoder. When dealing whith an incoding PDU, we will obtain + * a LdapMessagePOJO in the ILdapContainer. + * =20 + * @author Apache Directory Pr= oject + */ +public class LdapMessageContainer extends PoolObject implements IAsn1Conta= iner //extends AbstractLdapContainer +{ + //~ Instance fields --------------------------------------------------= -------------------------- + + /** The current state of the decoding */ + protected int state; + + /** The current transition */ + protected int transition; + + /** The current TLV */ + protected TLV tlv; + + /** The pool that is associated with this container */ + protected LocalPoolManager poolManager; + + /** The grammar that is used to decode the ldapMessage */ + protected IGrammar grammar; + + /** The ldap message */ + private LdapMessagePOJO ldapMessage; + + //~ Constructors -----------------------------------------------------= -------------------------- + + /** + * Creates a new LdapMessageContainer object. + */ + public LdapMessageContainer() + { + super( ); + } + + //~ Methods ----------------------------------------------------------= -------------------------- + + /** + * Release the LdapMessage POJO + */ + public void free() + { + state =3D 0; + transition =3D 0; + ldapMessage.free(); + + super.free(); + } + + /** + * @return Returns the ldapMessage. + */ + public LdapMessagePOJO getLdapMessage() + { + + return ldapMessage; + } + + /** + * Set a ldapMessage POJO into the container. It will be completed + * by the ldapDecoder . + * + * @param ldapMessage The ldapMessage to set. + */ + public void setLdapMessage( LdapMessagePOJO ldapMessage ) + { + this.ldapMessage =3D ldapMessage; + } + + /** + * Associate a pool Manager to the container + * + * @param poolManager The pool manager + */ + public void setPoolManager( LocalPoolManager poolManager ) + { + this.poolManager =3D poolManager; + } + + /** + * @return The poolManager associated with this container + */ + public LocalPoolManager getPoolManager() + { + return poolManager; + } + + /** + * @return Returns the grammar used to decode a LdapMessage. + */ + public IGrammar getGrammar() + { + return grammar; + } + + /** + * Set the IGrammar to use + * + * @param grammar The grammar to set. + */ + public void setGrammar( IGrammar grammar ) + { + this.grammar =3D grammar; + } + + /** + * Set the current TLV + * + * @param tlv The current TLV + */ + public void setCurrentTLV( TLV tlv ) + { + this.tlv =3D tlv; + } + + /** + * @return Returns the current TLV being decoded + */ + public TLV getCurrentTLV() + { + + return this.tlv; + } + + /** + * @return Returns the current grammar state + */ + public int getState() + { + return state; + } + + /** + * Set the new current state + * + * @param state The new state + */ + public void setState( int state ) + { + this.state =3D state; + } + + /** + * @return Returns the transition from the previous state to the new=20 + * state + */ + public int getTransition() + { + return transition; + } + + /** + * Update the transition from a state to another + * + * @param transition The transition to set + */ + public void setTransition( int transition ) + { + this.transition =3D transition; + } +} Added: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap= /codec/LdapMessageContainerFactory.java URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/s= rc/java/org/apache/asn1/ldap/codec/LdapMessageContainerFactory.java?view=3D= auto&rev=3D159164 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/co= dec/LdapMessageContainerFactory.java (added) +++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/co= dec/LdapMessageContainerFactory.java Sun Mar 27 10:40:20 2005 @@ -0,0 +1,42 @@ +/* + * 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 impli= ed. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.asn1.ldap.codec; + +import org.apache.asn1.util.ObjectFactory; +import org.apache.asn1.util.pools.PoolObject; + + +/** + * Create a LdapMessageContainer object + *=20 + * @author Apache Directory Pr= oject + */ +public class LdapMessageContainerFactory implements ObjectFactory +{ + //~ Methods ----------------------------------------------------------= -------------------------- + + /** + * The method that creates the object + * + * @return The created object + */ + public PoolObject makeObject() + { + + return new LdapMessageContainer(); + } +} Added: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap= /codec/LdapMessageGrammar.java URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/s= rc/java/org/apache/asn1/ldap/codec/LdapMessageGrammar.java?view=3Dauto&rev= =3D159164 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/co= dec/LdapMessageGrammar.java (added) +++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/co= dec/LdapMessageGrammar.java Sun Mar 27 10:40:20 2005 @@ -0,0 +1,379 @@ +/* + * 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 impli= ed. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +package org.apache.asn1.ldap.codec; + +import org.apache.asn1.ber.containers.IAsn1Container; +import org.apache.asn1.ber.grammar.AbstractGrammar; +import org.apache.asn1.ber.grammar.GrammarAction; +import org.apache.asn1.ber.grammar.GrammarTransition; +import org.apache.asn1.ber.grammar.IGrammar; +import org.apache.asn1.ber.grammar.StatesEnum; +import org.apache.asn1.ber.tlv.TLV; +import org.apache.asn1.ber.tlv.Value; +import org.apache.asn1.ldap.codec.primitives.IntegerDecoder; +import org.apache.asn1.ldap.codec.primitives.LdapDNDecoder; +import org.apache.asn1.ldap.pojo.AbstractPOJO; +import org.apache.asn1.ldap.pojo.BindRequestPOJO; +import org.apache.asn1.ldap.pojo.LdapMessagePOJO; +import org.apache.asn1.ldap.pojo.LdapPOJO; +import org.apache.asn1.ldap.pojo.SimpleAuthenticationPOJO; +import org.apache.asn1.util.pools.PoolEnum; +import org.apache.asn1.util.pools.PoolException; + +import org.apache.log4j.Logger; + + +/** + * This class implements the LdapMessage. All the actions are declared in = this + * class. As it is a singleton, these declaration are only done once. + *=20 + * If an action is to be added or modified, this is where the work is to b= e done ! + *=20 + * @author Apache Directory Pr= oject + */ +public class LdapMessageGrammar extends AbstractGrammar implements IGrammar +{ + //~ Static fields/initializers ---------------------------------------= -------------------------- + + /** The logger */ + private static final Logger log =3D Logger.getLogger( LdapMessageGramm= ar.class ); + + /** Logging speed up */ + private static final boolean DEBUG =3D log.isDebugEnabled(); + + /** The instance of grammar. LdapMessage is a singleton */ + private static IGrammar instance =3D new LdapMessageGrammar(); + + //~ Constructors -----------------------------------------------------= -------------------------- + /** + * DOCUMENT ME! + * + * @return DOCUMENT ME! + */ + public static IGrammar getInstance() + { + return instance; + } + + private void checkLength(LdapPOJO ldapPOJO, TLV tlv) throws DecoderExc= eption + { + // Create a new expected Length + int expectedLength =3D tlv.getLength().getLength(); + =20 + int tlvLength =3D tlv.getSize(); +=09 + // An exception will be thrown if the current length exceed the expec= ted length + ((AbstractPOJO)ldapPOJO).addLength(expectedLength + tlvLength); + } + + /** + * Creates a new LdapMessageGrammar object. + */ + private LdapMessageGrammar() + { + + // We have 17 differents states, so 16 transitions between states. + super.transitions =3D new GrammarTransition[StatesEnum.LAST_STATE]= [256]; + + // LDAPMessage --> SEQUENCE { ... (Tag) + // We have a LDAPMessage, and the tag must be 0x30 + super.transitions[StatesEnum.LDAP_MESSAGE_TAG][0x30] =3D new Gramm= arTransition( "LdapMessage Tag", + StatesEnum.LDAP_MESSAGE_LENGTH, new GrammarAction( "LdapMe= ssage Tag" ) + { + public void action( IAsn1Container container ) throws = DecoderException + { + try { + LdapMessageContainer ldapMessageContainer =3D (LdapM= essageContainer)container; +=09 + // First, create a empty LdapMessage POJO + LdapMessagePOJO ldapMessage =3D ( LdapMessagePOJO ) + ldapMessageContainer.getPoolManager().allocat= e( + PoolEnum.LDAP_MESSAGE_POJO_POOL ); +=09 + // Then stores it into the container + ldapMessageContainer.setLdapMessage(ldapMessage); + =20 + return; + } + catch ( PoolException pe ) + { + throw new DecoderException( + "Cannot allocate a LdapMessage Pojo : " + pe.= getMessage() ); + } + } + } ); + + // LDAPMessage --> SEQUENCE { ... (Length) + // Ok, get the LdapMessage length + super.transitions[StatesEnum.LDAP_MESSAGE_LENGTH][0x30] =3D new Gr= ammarTransition( "LdapMessage Length", + StatesEnum.LDAP_MESSAGE_VALUE, new GrammarAction( "LdapMes= sage Length" ) + { + public void action( IAsn1Container container ) throws = DecoderException + { + // We have to store the expected Length of the PDU + LdapMessageContainer ldapMessageContainer =3D (LdapMe= ssageContainer)container; + LdapMessagePOJO ldapMessage =3D ldapMessageContainer.= getLdapMessage(); + + ldapMessage.setExpectedLength(ldapMessageContainer.ge= tCurrentTLV().getLength().getLength()); + ldapMessage.setCurrentLength(0); + + return; + } + } ); + =20 + // LDAPMessage --> SEQUENCE { ... (Value) + // Nothing to do, it's a constructed TLV + super.transitions[StatesEnum.LDAP_MESSAGE_VALUE][0x30] =3D new Gra= mmarTransition( "LdapMessage Value", StatesEnum.LDAP_MESSAGE_ID_TAG, null); + + // LDAPMessage --> ... MessageId ...(Tag) + // The tag must be 0x02. Nothing special to do. + super.transitions[StatesEnum.LDAP_MESSAGE_ID_TAG][0x02] =3D new Gr= ammarTransition( "MessageId Tag", StatesEnum.LDAP_MESSAGE_ID_LENGTH, null); + + // LDAPMessage --> ... MessageId ...(Length) + // Checks the length + super.transitions[StatesEnum.LDAP_MESSAGE_ID_LENGTH][0x02] =3D new= GrammarTransition( "MessageId Length", StatesEnum.LDAP_MESSAGE_ID_VALUE,=20 + new GrammarAction( "Check MessageId Length " ) + { + public void action( IAsn1Container container ) throws = DecoderException + { + checkLength(((LdapMessageContainer)container).getLdap= Message(), ((LdapMessageContainer)container).getCurrentTLV()); + + return; + } + } ); + =20 + // LDAPMessage --> ... MessageId ...(Value) + // Checks that MessageId is in [0 .. 2147483647] and store the val= ue in the LdapMessage POJO + super.transitions[StatesEnum.LDAP_MESSAGE_ID_VALUE][0x02] =3D new = GrammarTransition( "MessageId Value", StatesEnum.PROTOCOL_OP_TAG, + new GrammarAction( "Store MessageId" ) + { + public void action( IAsn1Container container ) throws = DecoderException + { + + LdapMessageContainer ldapMessageContainer =3D (LdapMe= ssageContainer)container; + LdapMessagePOJO ldapMessage =3D ldapMessageContainer.= getLdapMessage(); + + // The current TLV should be a integer + // We get it and store it in MessageId + TLV tlv =3D ldapMessageContainer.getCurren= tTLV(); + + Value value =3D tlv.getValue(); + + int messageId =3D IntegerDecoder.parse( value , = 0, 2147483647); + + if ( ( messageId < 0 ) || ( messageId > 2147483647= ) ) + { + throw new DecoderException( + "The message ID must be between (0 .. 2 14= 7 483 647)" ); + } + else + { + ldapMessage.setMessageId( messageId ); + =09 + return; + } + } + } ); + + // If the Tag is 0x60, then it's a BindRequest. Nothing to do whil= e the length is not verified. + // LdapMessage ::=3D ... BindRequest ... + // BindRequest ::=3D [APPLICATION 0] SEQUENCE { ... (Tag) + super.transitions[StatesEnum.PROTOCOL_OP_TAG][0x60] =3D new Gramma= rTransition( "BindRequest Tag", StatesEnum.PROTOCOL_OP_LENGTH, null ); + + // We have to allocate a BindRequestPOJO + // LdapMessage ::=3D ... BindRequest ... + // BindRequest ::=3D [APPLICATION 0] SEQUENCE { ... (Length) + super.transitions[StatesEnum.PROTOCOL_OP_LENGTH][0x60] =3D new Gra= mmarTransition( "BindRequest Length", StatesEnum.PROTOCOL_OP_VALUE,=20 + new GrammarAction( "Init BindRequest" ) + { + public void action( IAsn1Container container ) throws = DecoderException + { + + LdapMessageContainer ldapMessageContainer =3D (LdapMe= ssageContainer)container; + LdapMessagePOJO ldapMessage =3D ldapMessageContainer.= getLdapMessage(); + + checkLength(((LdapMessageContainer)container).getLdap= Message(), ((LdapMessageContainer)container).getCurrentTLV()); + =09 + try=20 + { + // Now, we can allocate the BindRequest POJO + LdapPOJO bindRequest =3D (LdapPOJO)ldapMessageContai= ner.getPoolManager().allocate(PoolEnum.BIND_REQUEST_POJO_POOL); + =09 + // As this is a new Constructed object, we have to i= nit its length + TLV tlv =3D ldapMessageContainer.getCurre= ntTLV(); + int expectedLength =3D tlv.getLength().getLength(= ); + ((BindRequestPOJO)bindRequest).setExpectedLength(exp= ectedLength); + ((BindRequestPOJO)bindRequest).setCurrentLength(0); + + // And we associate it to the ldapMessage POJO + ldapMessage.setProtocolOP(bindRequest); + =09 + } catch (PoolException pe)=20 + { + throw new DecoderException( + "Cannot allocate a BindRequest Pojo : = " + pe.getMessage() ); + } + } + }); + + // LdapMessage ::=3D ... BindRequest ... + // BindRequest ::=3D [APPLICATION 0] SEQUENCE { ... (Value) + // Nothing to do, the Value is empty, this is a constructed TLV + super.transitions[StatesEnum.PROTOCOL_OP_VALUE][0x60] =3D new Gram= marTransition( "BindRequest Value", StatesEnum.BIND_VERSION_TAG, null); + + // BindRequest ::=3D ... version INTEGER (1 .. 127 ), ... (Tag) + // Nothing to do. + super.transitions[StatesEnum.BIND_VERSION_TAG][0x02] =3D new Gramm= arTransition( "Bind version Tag", StatesEnum.BIND_VERSION_LENGTH, null); + =20 + // BindRequest ::=3D ... version INTEGER (1 .. 127 ), ... (Length) + // Checks the length + super.transitions[StatesEnum.BIND_VERSION_LENGTH][0x02] =3D new Gr= ammarTransition( "Bind version Length", StatesEnum.BIND_VERSION_VALUE, + new GrammarAction( "Store version" ) + { + public void action( IAsn1Container container ) throws = DecoderException + { + + checkLength(((LdapMessageContainer)container).getLdap= Message().getProtocolOp(), ((LdapMessageContainer)container).getCurrentTLV(= )); + return; + } + } ); + + // BindRequest ::=3D ... version INTEGER (1 .. 127 ), ... (value) + // Checks that the Version is in [1, 127] + super.transitions[StatesEnum.BIND_VERSION_VALUE][0x02] =3D new Gra= mmarTransition( "Bind version Length", StatesEnum.BIND_NAME_TAG, + new GrammarAction( "Store version" ) + { + public void action( IAsn1Container container ) throws = DecoderException + { + + LdapMessageContainer ldapMessageContainer =3D ( Ld= apMessageContainer ) + container; + BindRequestPOJO bindRequestMessage =3D + (BindRequestPOJO)ldapMessageContainer.getLdapMess= age().getProtocolOp(); + + // The current TLV should be a integer between 1 a= nd 127 + // We get it and store it in Version + TLV tlv =3D ldapMessageContainer.getCurrentT= LV(); + + Value value =3D tlv.getValue(); + + int version =3D IntegerDecoder.parse( value, 1, = 127 ); + + bindRequestMessage.setVersion( version ); + + return; + } + } ); + + // BindRequest ::=3D ... name LDAPDN, ... (Tag) + // Nothing to do. The tag is supposed to be 0x04 + super.transitions[StatesEnum.BIND_NAME_TAG][0x04] =3D new GrammarT= ransition( "bind name tag", StatesEnum.BIND_NAME_LENGTH, null); + =20 + // BindRequest ::=3D ... name LDAPDN, ... (Length) + // We just check the length. + super.transitions[StatesEnum.BIND_NAME_LENGTH][0x04] =3D new Gramm= arTransition( "bind name length", StatesEnum.BIND_NAME_VALUE, + new GrammarAction( "Check Bind Name Length" ) + { + public void action( IAsn1Container container ) throws = DecoderException + { + checkLength(((LdapMessageContainer)container).getLdap= Message().getProtocolOp(), ((LdapMessageContainer)container).getCurrentTLV(= )); + return; + } + } ); + + // BindRequest ::=3D ... name LDAPDN, ... (Value) + // We just check the length. + super.transitions[StatesEnum.BIND_NAME_VALUE][0x04] =3D new Gramma= rTransition( "bind name value", StatesEnum.BIND_AUTHENTICATION_CHOICE_TAG, + new GrammarAction( "Store Bind Name value" ) + { + public void action( IAsn1Container container ) throws = DecoderException + { + + LdapMessageContainer ldapMessageContainer =3D ( Ld= apMessageContainer )container; + =20 + // Get the Value and store it in the BindRequest=20 + TLV tlv =3D ldapMessageContainer.getCurrentTLV(= ); + =20 + // TODO : allocate the string from a pool. + String value =3D LdapDNDecoder.parse(tlv.getValue()); + //String value =3D new String(tlv.getValue().getDa= ta()); + + BindRequestPOJO bindRequestMessage =3D (Bin= dRequestPOJO)ldapMessageContainer.getLdapMessage().getProtocolOp(); + + bindRequestMessage.setName(value); + return; + } + } ); + + // BindRequest ::=3D ... authentication AuthenticationChoice } + // AuthenticationChoice ::=3D CHOICE { + // The tag might be either 0x80 (SimpleAuthentication) or 0x83 (Sa= slAuthentication) + // Here, it's 0x80, so a SimpleAuthentication.=20 + // Nothing to do. + super.transitions[StatesEnum.BIND_AUTHENTICATION_CHOICE_TAG][( 0x8= 0 & 0x00FF )] =3D new GrammarTransition( "Bind Simple Authentication Tag", = StatesEnum.BIND_AUTHENTICATION_SIMPLE_LENGTH, null); + =20 + // AuthenticationChoice ::=3D CHOICE { + // simple [0] OCTET STRING, (Length) + super.transitions[StatesEnum.BIND_AUTHENTICATION_SIMPLE_LENGTH][( = 0x80 & 0x00FF )] =3D new GrammarTransition( "Bind Simple Authentication Len= gth", StatesEnum.BIND_AUTHENTICATION_SIMPLE_VALUE,=20 + new GrammarAction( "Check simple authentication length" )=20 + { + public void action( IAsn1Container container ) throws = DecoderException + { + checkLength(((LdapMessageContainer)container).getLdap= Message().getProtocolOp(), ((LdapMessageContainer)container).getCurrentTLV(= )); + =20 + return; + } + } ); + + // AuthenticationChoice ::=3D CHOICE { + // simple [0] OCTET STRING, (Value) + super.transitions[StatesEnum.BIND_AUTHENTICATION_SIMPLE_VALUE][( 0= x80 & 0x00FF )] =3D new GrammarTransition( "Bind Simple Authentication Valu= e", -1, //StatesEnum.CONTROLS_TAG,=20 + new GrammarAction( "Store Bind Simple Authentication value= " ) + { + public void action( IAsn1Container container ) throws = DecoderException + { + + LdapMessageContainer ldapMessageContainer =3D ( Ld= apMessageContainer )container; + =20 + // Get the Value and store it in the BindRequest=20 + TLV tlv =3D ldapMessageContainer.getCurrentTLV(= ); + =20 + // TODO : allocate the string from a pool. + String simple =3D new String(tlv.getValue().getDat= a()); + + BindRequestPOJO bindRequestMessage =3D (Bin= dRequestPOJO)ldapMessageContainer.getLdapMessage().getProtocolOp(); + + try=20 + { + SimpleAuthenticationPOJO authentication =3D ( Sim= pleAuthenticationPOJO ) + ldapMessageContainer.getPoolManager().allocate( + PoolEnum.SIMPLE_AUTH_POJO_POOL ); + =20 + authentication.setSimple(simple); +=09 + bindRequestMessage.setAuthentication(authenticati= on); + return; + }=20 + catch (PoolException pe)=20 + { + throw new DecoderException( + "Cannot allocate a SimpleAuthenticatio= n Pojo : " + pe.getMessage() ); + } + } + } ); + } +}