directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r234264 [1/11] - in /directory/shared/ldap/branches/new-codec-integration/apache2-provider/src: ./ java/ java/main/ java/main/org/ java/main/org/apache/ java/main/org/apache/asn1new/ java/main/org/apache/asn1new/ldap/ java/main/org/apache/a...
Date Sun, 21 Aug 2005 16:54:00 GMT
Author: elecharny
Date: Sun Aug 21 09:53:27 2005
New Revision: 234264

URL: http://svn.apache.org/viewcvs?rev=234264&view=rev
Log:
Creation

Added:
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/TwixDecoder.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/LdapConstants.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/LdapDecoder.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/LdapMessageContainer.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AbandonRequestGrammar.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AddRequestGrammar.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AddResponseGrammar.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindRequestGrammar.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindResponseGrammar.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/CompareRequestGrammar.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/CompareResponseGrammar.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/DelRequestGrammar.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/DelResponseGrammar.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ExtendedRequestGrammar.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ExtendedResponseGrammar.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/FilterGrammar.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/LdapControlGrammar.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/LdapMessageGrammar.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/LdapResultGrammar.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/LdapStatesEnum.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ModifyDNRequestGrammar.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ModifyDNResponseGrammar.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ModifyRequestGrammar.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/ModifyResponseGrammar.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/SearchRequestGrammar.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/SearchResultDoneGrammar.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/SearchResultEntryGrammar.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/SearchResultReferenceGrammar.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/UnBindRequestGrammar.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/primitives/
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/primitives/LdapDN.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/primitives/LdapString.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/primitives/LdapURL.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/primitives/RelativeLdapDN.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/utils/
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/utils/DNUtils.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/utils/LdapResultEnum.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AbandonRequest.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AddRequest.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AddResponse.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/AttributeValueAssertion.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/BindRequest.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/BindResponse.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/CompareRequest.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/CompareResponse.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/Control.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/DelRequest.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/DelResponse.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ExtendedRequest.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ExtendedResponse.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/LdapMessage.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/LdapResponse.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/LdapResult.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ModifyDNRequest.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ModifyDNResponse.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ModifyRequest.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/ModifyResponse.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SaslCredentials.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchRequest.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchResultDone.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchResultEntry.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SearchResultReference.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/SimpleAuthentication.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/UnBindRequest.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/AndFilter.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/AttributeValueAssertionFilter.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/ConnectorFilter.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/ExtensibleMatchFilter.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/Filter.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/NotFilter.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/OrFilter.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/PresentFilter.java
    directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/pojo/filters/SubstringFilter.java

Added: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/TwixDecoder.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/TwixDecoder.java?rev=234264&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/TwixDecoder.java (added)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/TwixDecoder.java Sun Aug 21 09:53:27 2005
@@ -0,0 +1,77 @@
+package org.apache.asn1new.ldap;
+
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+
+import org.apache.asn1.codec.DecoderException;
+import org.apache.asn1.codec.stateful.DecoderCallback;
+import org.apache.asn1.codec.stateful.DecoderMonitor;
+import org.apache.ldap.common.message.spi.Provider;
+import org.apache.ldap.common.message.spi.ProviderDecoder;
+import org.apache.ldap.common.message.spi.ProviderException;
+
+public class TwixDecoder implements ProviderDecoder {
+    private final Provider provider;
+
+    /**
+     * Creates an instance of a Twix Decoder implementation.
+     *
+     * @param provider the owning provider.
+     */
+    public TwixDecoder( Provider provider )
+    {
+        this.provider = provider;
+    }
+
+    public void decode( Object encoded ) throws DecoderException
+    {
+        ByteBuffer buf = null;
+
+        if ( encoded instanceof ByteBuffer )
+        {
+            buf = ( ByteBuffer ) encoded;
+        }
+        else if ( encoded instanceof byte[] )
+        {
+            buf = ByteBuffer.wrap( ( byte[] ) encoded );
+        }
+        else
+        {
+            throw new DecoderException( "Expected either a byte[] or " +
+                    "ByteBuffer argument but got a " + encoded.getClass() );
+        }
+
+        LdapDecoder.decode( buf );
+    }
+    
+    /**
+     * Decodes a PDU from an input stream into a Snickers compiler generated
+     * stub envelope.
+     *
+     * @param lock lock object used to exclusively read from the input stream
+     * @param in the input stream to read and decode PDU bytes from
+     * @return return decoded stub
+     */
+    public Object decode( Object lock, InputStream in ) throws ProviderException
+    {
+    	return null;
+    }
+    
+    /**
+     * Gets the Provider that this Decoder implementation is part of.
+     *
+     * @return the owning provider.
+     */
+    public Provider getProvider()
+    {
+        return provider ;
+    }
+
+    public void setDecoderMonitor( DecoderMonitor monitor )
+    {
+    }
+
+    public void setCallback( DecoderCallback cb )
+    {
+    }
+}

Added: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/LdapConstants.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/LdapConstants.java?rev=234264&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/LdapConstants.java (added)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/LdapConstants.java Sun Aug 21 09:53:27 2005
@@ -0,0 +1,96 @@
+/*
+ *   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;
+
+/**
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class LdapConstants {
+    /** The scope constants */
+    public static final int SCOPE_BASE_OBJECT   = 0;
+    public static final int SCOPE_SINGLE_LEVEL  = 1;
+    public static final int SCOPE_WHOLE_SUBTREE = 2;
+    
+    /** The DerefAlias constants */
+    public static final int NEVER_DEREF_ALIASES    = 0;
+    public static final int DEREF_IN_SEARCHING     = 1;
+    public static final int DEREF_FINDING_BASE_OBJ = 2;
+    public static final int DEREF_ALWAYS           = 3;
+    
+    /** The operations */
+    public static final int OPERATION_ADD     = 0;
+    public static final int OPERATION_DELETE  = 1;
+    public static final int OPERATION_REPLACE = 2;
+    
+    /** The filters */
+    public static final int EQUALITY_MATCH_FILTER   = 0;
+    public static final int GREATER_OR_EQUAL_FILTER = 1;
+    public static final int LESS_OR_EQUAL_FILTER    = 2;
+    public static final int APPROX_MATCH_FILTER     = 3;
+    
+    /** LDAP contextual tags */
+    public static final byte UNBIND_REQUEST_TAG          = 0x42;
+    public static final byte DEL_REQUEST_TAG             = 0x4A;
+    public static final byte ABANDON_REQUEST_TAG         = 0x50;
+    public static final byte BIND_REQUEST_TAG            = 0x60;
+    public static final byte BIND_RESPONSE_TAG           = 0x61;
+    public static final byte SEARCH_REQUEST_TAG          = 0x63;
+    public static final byte SEARCH_RESULT_ENTRY_TAG     = 0x64;
+    public static final byte SEARCH_RESULT_DONE_TAG      = 0x65;
+    public static final byte MODIFY_REQUEST_TAG          = 0x66;
+    public static final byte MODIFY_RESPONSE_TAG         = 0x67;
+    public static final byte ADD_REQUEST_TAG             = 0x68;
+    public static final byte ADD_RESPONSE_TAG            = 0x69;
+    public static final byte DEL_RESPONSE_TAG            = 0x6B;
+    public static final byte MODIFY_DN_REQUEST_TAG       = 0x6C;
+    public static final byte MODIFY_DN_RESPONSE_TAG      = 0x6D;
+    public static final byte COMPARE_REQUEST_TAG         = 0x6E;
+    public static final byte COMPARE_RESPONSE_TAG        = 0x6F;
+    public static final byte SEARCH_RESULT_REFERENCE_TAG = 0x73;
+    public static final byte EXTENDED_REQUEST_TAG        = 0x77;
+    public static final byte EXTENDED_RESPONSE_TAG       = 0x78;
+    // The following tags are ints, because bytes above 127 are negative
+    // numbers, and we can't use them as array indexes.
+    public static final int BIND_REQUEST_SIMPLE_TAG             = 0x80;
+    public static final int EXTENDED_REQUEST_NAME_TAG           = 0x80;
+    public static final int MODIFY_DN_REQUEST_NEW_SUPERIOR_TAG  = 0x80;
+    public static final int SEARCH_SUBSTRINGS_INITIAL_TAG       = 0x80;
+    public static final int EXTENDED_REQUEST_VALUE_TAG          = 0x81;
+    public static final int SEARCH_MATCHING_RULE_TAG            = 0x81;
+    public static final int SEARCH_SUBSTRINGS_ANY_TAG           = 0x81;
+    public static final int SEARCH_TYPE_TAG                     = 0x82;
+    public static final int SEARCH_SUBSTRINGS_FINAL_TAG         = 0x82;
+    public static final int SEARCH_MATCH_VALUE_TAG              = 0x83;
+    public static final int BIND_REQUEST_SASL_TAG               = 0x83;
+    public static final int LDAP_RESULT_REFERRAL_SEQUENCE_TAG   = 0x83;
+    public static final int DN_ATTRIBUTES_FILTER_TAG            = 0x84;
+    public static final int SERVER_SASL_CREDENTIAL_TAG          = 0x87;
+    public static final int PRESENT_FILTER_TAG                  = 0x87;
+    public static final int EXTENDED_RESPONSE_RESPONSE_NAME_TAG = 0x8A;
+    public static final int EXTENDED_RESPONSE_RESPONSE_TAG      = 0x8B;
+    public static final int CONTROLS_TAG                        = 0xA0;
+    public static final int AND_FILTER_TAG                      = 0xA0;
+    public static final int OR_FILTER_TAG                       = 0xA1;
+    public static final int NOT_FILTER_TAG                      = 0xA2;
+    public static final int EQUALITY_MATCH_FILTER_TAG           = 0xA3;
+    public static final int SUBSTRINGS_FILTER_TAG               = 0xA4;
+    public static final int GREATER_OR_EQUAL_FILTER_TAG         = 0xA5;
+    public static final int LESS_OR_EQUAL_FILTER_TAG            = 0xA6;
+    public static final int APPROX_MATCH_FILTER_TAG             = 0xA8;
+    public static final int EXTENSIBLE_MATCH_FILTER_TAG         = 0xA9;
+    
+}

Added: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/LdapDecoder.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/LdapDecoder.java?rev=234264&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/LdapDecoder.java (added)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/LdapDecoder.java Sun Aug 21 09:53:27 2005
@@ -0,0 +1,34 @@
+/*
+ *   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;
+
+import org.apache.asn1new.ber.Asn1Decoder;
+
+/**
+ * The Ldap decoder. This class does the initialisation of the object's pools.
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class LdapDecoder extends Asn1Decoder {
+    
+    /**
+     * Standard LdapDecoder constructor. 
+     *
+     */
+    public LdapDecoder()
+    {
+    }
+}

Added: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/LdapMessageContainer.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/LdapMessageContainer.java?rev=234264&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/LdapMessageContainer.java (added)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/LdapMessageContainer.java Sun Aug 21 09:53:27 2005
@@ -0,0 +1,130 @@
+/*
+ *   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;
+
+import org.apache.asn1new.ber.AbstractContainer;
+import org.apache.asn1new.ber.containers.IAsn1Container;
+import org.apache.asn1new.ber.grammar.IGrammar;
+import org.apache.asn1new.ldap.codec.grammar.AbandonRequestGrammar;
+import org.apache.asn1new.ldap.codec.grammar.AddRequestGrammar;
+import org.apache.asn1new.ldap.codec.grammar.AddResponseGrammar;
+import org.apache.asn1new.ldap.codec.grammar.BindRequestGrammar;
+import org.apache.asn1new.ldap.codec.grammar.BindResponseGrammar;
+import org.apache.asn1new.ldap.codec.grammar.CompareRequestGrammar;
+import org.apache.asn1new.ldap.codec.grammar.CompareResponseGrammar;
+import org.apache.asn1new.ldap.codec.grammar.DelRequestGrammar;
+import org.apache.asn1new.ldap.codec.grammar.DelResponseGrammar;
+import org.apache.asn1new.ldap.codec.grammar.ExtendedRequestGrammar;
+import org.apache.asn1new.ldap.codec.grammar.ExtendedResponseGrammar;
+import org.apache.asn1new.ldap.codec.grammar.FilterGrammar;
+import org.apache.asn1new.ldap.codec.grammar.LdapControlGrammar;
+import org.apache.asn1new.ldap.codec.grammar.LdapMessageGrammar;
+import org.apache.asn1new.ldap.codec.grammar.LdapResultGrammar;
+import org.apache.asn1new.ldap.codec.grammar.LdapStatesEnum;
+import org.apache.asn1new.ldap.codec.grammar.ModifyDNRequestGrammar;
+import org.apache.asn1new.ldap.codec.grammar.ModifyDNResponseGrammar;
+import org.apache.asn1new.ldap.codec.grammar.ModifyRequestGrammar;
+import org.apache.asn1new.ldap.codec.grammar.ModifyResponseGrammar;
+import org.apache.asn1new.ldap.codec.grammar.SearchRequestGrammar;
+import org.apache.asn1new.ldap.codec.grammar.SearchResultDoneGrammar;
+import org.apache.asn1new.ldap.codec.grammar.SearchResultEntryGrammar;
+import org.apache.asn1new.ldap.codec.grammar.SearchResultReferenceGrammar;
+import org.apache.asn1new.ldap.codec.grammar.UnBindRequestGrammar;
+import org.apache.asn1new.ldap.pojo.LdapMessage;
+
+
+/**
+ * The LdapMessage container stores all the messages decoded by the
+ * Asn1Decoder. When dealing whith an incoding PDU, we will obtain
+ * a LdapMessage in the ILdapContainer.
+ *  
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class LdapMessageContainer extends AbstractContainer implements IAsn1Container //extends AbstractLdapContainer
+{
+    //~ Instance fields ----------------------------------------------------------------------------
+
+    /** The ldap message */
+    private LdapMessage ldapMessage;
+    
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * Creates a new LdapMessageContainer object.
+     * We will store ten grammars, it's enough ...
+     */
+    public LdapMessageContainer()
+    {
+        super( );
+        currentGrammar = 0;
+        grammars = new IGrammar[LdapStatesEnum.NB_GRAMMARS];
+        grammarStack = new IGrammar[10];
+        stateStack = new int[10];
+        nbGrammars = 0;
+
+        grammars[LdapStatesEnum.LDAP_MESSAGE_GRAMMAR] = LdapMessageGrammar.getInstance(); 
+        grammars[LdapStatesEnum.LDAP_CONTROL_GRAMMAR] = LdapControlGrammar.getInstance(); 
+        grammars[LdapStatesEnum.BIND_REQUEST_GRAMMAR] = BindRequestGrammar.getInstance(); 
+        grammars[LdapStatesEnum.LDAP_RESULT_GRAMMAR]  = LdapResultGrammar.getInstance(); 
+        grammars[LdapStatesEnum.BIND_RESPONSE_GRAMMAR] = BindResponseGrammar.getInstance(); 
+        grammars[LdapStatesEnum.UNBIND_REQUEST_GRAMMAR] = UnBindRequestGrammar.getInstance(); 
+        grammars[LdapStatesEnum.ABANDON_REQUEST_GRAMMAR] = AbandonRequestGrammar.getInstance(); 
+        grammars[LdapStatesEnum.ADD_RESPONSE_GRAMMAR] = AddResponseGrammar.getInstance(); 
+        grammars[LdapStatesEnum.COMPARE_RESPONSE_GRAMMAR] = CompareResponseGrammar.getInstance(); 
+        grammars[LdapStatesEnum.DEL_RESPONSE_GRAMMAR] = DelResponseGrammar.getInstance(); 
+        grammars[LdapStatesEnum.MODIFY_RESPONSE_GRAMMAR] = ModifyResponseGrammar.getInstance();
+        grammars[LdapStatesEnum.MODIFY_DN_RESPONSE_GRAMMAR] = ModifyDNResponseGrammar.getInstance();
+        grammars[LdapStatesEnum.SEARCH_RESULT_DONE_GRAMMAR] = SearchResultDoneGrammar.getInstance();
+        grammars[LdapStatesEnum.SEARCH_REQUEST_GRAMMAR] = SearchRequestGrammar.getInstance();
+        grammars[LdapStatesEnum.FILTER_GRAMMAR] = FilterGrammar.getInstance();
+        grammars[LdapStatesEnum.SEARCH_RESULT_ENTRY_GRAMMAR] = SearchResultEntryGrammar.getInstance();
+        grammars[LdapStatesEnum.MODIFY_REQUEST_GRAMMAR] = ModifyRequestGrammar.getInstance();
+        grammars[LdapStatesEnum.SEARCH_RESULT_REFERENCE_GRAMMAR] = SearchResultReferenceGrammar.getInstance();
+        grammars[LdapStatesEnum.ADD_REQUEST_GRAMMAR] = AddRequestGrammar.getInstance();
+        grammars[LdapStatesEnum.MODIFY_DN_REQUEST_GRAMMAR] = ModifyDNRequestGrammar.getInstance();
+        grammars[LdapStatesEnum.DEL_REQUEST_GRAMMAR] = DelRequestGrammar.getInstance();
+        grammars[LdapStatesEnum.COMPARE_REQUEST_GRAMMAR] = CompareRequestGrammar.getInstance();
+        grammars[LdapStatesEnum.EXTENDED_REQUEST_GRAMMAR] = ExtendedRequestGrammar.getInstance();
+        grammars[LdapStatesEnum.EXTENDED_RESPONSE_GRAMMAR] = ExtendedResponseGrammar.getInstance();
+
+        grammarStack[currentGrammar] = grammars[LdapStatesEnum.LDAP_MESSAGE_GRAMMAR];
+        
+        states = LdapStatesEnum.getInstance();
+    }
+
+    //~ Methods ------------------------------------------------------------------------------------
+    /**
+     * @return Returns the ldapMessage.
+     */
+    public LdapMessage getLdapMessage()
+    {
+
+        return ldapMessage;
+    }
+
+    /**
+     * Set a ldapMessage Object into the container. It will be completed
+     * by the ldapDecoder .
+     *
+     * @param ldapMessage The ldapMessage to set.
+     */
+    public void setLdapMessage( LdapMessage ldapMessage )
+    {
+        this.ldapMessage = ldapMessage;
+    }
+    
+}

Added: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AbandonRequestGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AbandonRequestGrammar.java?rev=234264&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AbandonRequestGrammar.java (added)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AbandonRequestGrammar.java Sun Aug 21 09:53:27 2005
@@ -0,0 +1,140 @@
+/*
+ *   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.asn1new.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.Value;
+import org.apache.asn1new.util.IntegerDecoder;
+import org.apache.asn1new.ldap.codec.LdapConstants;
+import org.apache.asn1new.ldap.codec.LdapMessageContainer;
+import org.apache.asn1new.ldap.pojo.AbandonRequest;
+import org.apache.asn1new.ldap.pojo.LdapMessage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * This class implements the AbandonRequest 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 AbandonRequestGrammar extends AbstractGrammar implements IGrammar
+{
+    //~ Static fields/initializers -----------------------------------------------------------------
+
+    /** The logger */
+    private static final Logger log = LoggerFactory.getLogger( AbandonRequestGrammar.class );
+
+    /** Logging speed up  */
+    private static final boolean DEBUG = log.isDebugEnabled();
+
+    /** The instance of grammar. AbandonRequestGrammar is a singleton */
+    private static IGrammar instance = new AbandonRequestGrammar();
+
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * Creates a new AbandonRequestGrammar object.
+     */
+    private AbandonRequestGrammar()
+    {
+
+        name       = AbandonRequestGrammar.class.getName();
+
+        statesEnum = LdapStatesEnum.getInstance();
+
+        // The transitions table
+        super.transitions = new GrammarTransition[LdapStatesEnum.LAST_ABANDON_REQUEST_STATE][256];
+
+        //--------------------------------------------------------------------------------------------
+        // AbandonRequest Message ID
+        //--------------------------------------------------------------------------------------------
+        // AbandonRequest ::= [APPLICATION 16] MessageID (Tag)
+        // The tag must be 0x50. It codes for an integer, as we use
+        // IMPLICIT tags (we won't have a 0x02 tag to code the integer).
+        // Nothing special to do.
+        super.transitions[LdapStatesEnum.ABANDON_REQUEST_MESSAGE_ID_TAG][LdapConstants.ABANDON_REQUEST_TAG] =
+            new GrammarTransition( LdapStatesEnum.ABANDON_REQUEST_MESSAGE_ID_TAG,
+                LdapStatesEnum.ABANDON_REQUEST_MESSAGE_ID_VALUE, null );
+
+        // AbandonRequest ::= [APPLICATION 16] MessageID (Value)
+        // (2147483647 = Integer.MAX_VALUE)
+        // Checks that MessageId is in [0 .. 2147483647] and store the value in the AbandonRequest Object
+        // This is the last state.
+        super.transitions[LdapStatesEnum.ABANDON_REQUEST_MESSAGE_ID_VALUE][LdapConstants.ABANDON_REQUEST_TAG] =
+            new GrammarTransition( LdapStatesEnum.ABANDON_REQUEST_MESSAGE_ID_VALUE,
+            		LdapStatesEnum.GRAMMAR_END, new GrammarAction( "Store MessageId" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+
+                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
+                            container;
+                        LdapMessage          ldapMessage          =
+                            ldapMessageContainer.getLdapMessage();
+
+                        // The current TLV should be a integer
+                        // We get it and store it in MessageId
+                        TLV   tlv       = ldapMessageContainer.getCurrentTLV();
+
+                        Value value     = tlv.getValue();
+
+                        int   messageId = IntegerDecoder.parse( value, 0, Integer.MAX_VALUE );
+
+                        if ( ( messageId < 0 ) || ( messageId > Integer.MAX_VALUE ) )
+                        {
+                            throw new DecoderException(
+                                "The message ID must be between (0 .. 2 147 483 647)" );
+                        }
+                        else
+                        {
+
+                            // Ok, the Message ID is correct. We have to store it
+                            // in the AbandonRequest object
+                            // Object in the LDAPMessage
+                            AbandonRequest abandonRequest = new AbandonRequest();
+                            abandonRequest.setMessageId( messageId );
+                            ldapMessage.setProtocolOP( abandonRequest );
+
+                            return;
+                        }
+                    }
+                } );
+
+    }
+
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * Get the instance of this grammar
+     *
+     * @return An instance on the AbandonRequest Grammar
+     */
+    public static IGrammar getInstance()
+    {
+        return instance;
+    }
+}

Added: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AddRequestGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AddRequestGrammar.java?rev=234264&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AddRequestGrammar.java (added)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AddRequestGrammar.java Sun Aug 21 09:53:27 2005
@@ -0,0 +1,327 @@
+/*
+ *   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.asn1new.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.AddRequest;
+import org.apache.asn1new.ldap.pojo.LdapMessage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * This class implements the AddRequest 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 AddRequestGrammar extends AbstractGrammar implements IGrammar
+{
+    //~ Static fields/initializers -----------------------------------------------------------------
+
+    /** The logger */
+    private static final Logger log = LoggerFactory.getLogger( AddRequestGrammar.class );
+
+    /** Logging speed up  */
+    private static final boolean DEBUG = log.isDebugEnabled();
+
+    /** The instance of grammar. AddRequestGrammar is a singleton */
+    private static IGrammar instance = new AddRequestGrammar();
+
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * Creates a new AddRequestGrammar object.
+     */
+    private AddRequestGrammar()
+    {
+        name       = AddRequestGrammar.class.getName();
+        statesEnum = LdapStatesEnum.getInstance();
+
+        // Intitialisation
+        super.transitions = new GrammarTransition[LdapStatesEnum.LAST_ADD_REQUEST_STATE][256];
+
+        //============================================================================================
+        // AddRequest Message
+        //============================================================================================
+        // LdapMessage ::= ... AddRequest ...
+        // AddRequest ::= [APPLICATION 8] SEQUENCE { (Tag)
+        // Nothing to do.
+        super.transitions[LdapStatesEnum.ADD_REQUEST_TAG][LdapConstants.ADD_REQUEST_TAG] = new GrammarTransition(
+                LdapStatesEnum.ADD_REQUEST_TAG, LdapStatesEnum.ADD_REQUEST_VALUE, null );
+
+        // LdapMessage ::= ... AddRequest ...
+        // AddRequest ::= [APPLICATION 8] SEQUENCE { (Value)
+        // Create the structure
+        super.transitions[LdapStatesEnum.ADD_REQUEST_VALUE][LdapConstants.ADD_REQUEST_TAG] = new GrammarTransition(
+                LdapStatesEnum.ADD_REQUEST_VALUE, LdapStatesEnum.ADD_REQUEST_ENTRY_TAG,
+                new GrammarAction( "Init addRequest" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+
+                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
+                            container;
+                        LdapMessage          ldapMessage          =
+                            ldapMessageContainer.getLdapMessage();
+
+                        // Now, we can allocate the ModifyRequest Object
+                        // And we associate it to the ldapMessage Object
+                        ldapMessage.setProtocolOP( new AddRequest() );
+                    }
+                } );
+
+        // AddRequest ::= [APPLICATION 8] SEQUENCE {
+        //    entry      LDAPDN, (Tag)
+        //    ...
+        // Nothing to do
+        super.transitions[LdapStatesEnum.ADD_REQUEST_ENTRY_TAG][UniversalTag.OCTET_STRING_TAG] = new GrammarTransition(
+                LdapStatesEnum.ADD_REQUEST_ENTRY_TAG, LdapStatesEnum.ADD_REQUEST_ENTRY_VALUE,
+                null );
+
+        // AddRequest ::= [APPLICATION 8] SEQUENCE {
+        //    entry      LDAPDN, (Value)
+        //    ...
+        // Store the object name.
+        super.transitions[LdapStatesEnum.ADD_REQUEST_ENTRY_VALUE][UniversalTag.OCTET_STRING_TAG] = new GrammarTransition(
+                LdapStatesEnum.ADD_REQUEST_ENTRY_VALUE, LdapStatesEnum.ADD_REQUEST_ATTRIBUTES_TAG,
+                new GrammarAction( "Store add request object Value" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+
+                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
+                            container;
+                        LdapMessage          ldapMessage          =
+                            ldapMessageContainer.getLdapMessage();
+                        AddRequest           addRequest           = ldapMessage.getAddRequest();
+
+                        TLV                  tlv                  =
+                            ldapMessageContainer.getCurrentTLV();
+
+                        // Store the entry. It can't be null
+                        if ( tlv.getLength().getLength() == 0 )
+                        {
+                            throw new DecoderException( "The DN can't be null" );
+                        }
+                        else
+                        {
+                            addRequest.setEntry( new LdapDN(
+                                    tlv.getValue().getData() ) );
+                        }
+                    }
+                } );
+
+        // AddRequest ::= [APPLICATION 8] SEQUENCE {
+        //    ...
+        //    attributes      AttributeList }
+        // AttributeList ::= *SEQUENCE* OF SEQUENCE { (Tag)
+        // Nothing to do
+        super.transitions[LdapStatesEnum.ADD_REQUEST_ATTRIBUTES_TAG][UniversalTag.SEQUENCE_TAG] =
+            new GrammarTransition(
+                LdapStatesEnum.ADD_REQUEST_ATTRIBUTES_TAG,
+                LdapStatesEnum.ADD_REQUEST_ATTRIBUTES_VALUE, null );
+
+        // AddRequest ::= [APPLICATION 8] SEQUENCE {
+        //    ...
+        //    attributes      AttributeList }
+        // AttributeList ::= *SEQUENCE* OF SEQUENCE { (Value)
+        // Allocate the attributes ArrayList
+        super.transitions[LdapStatesEnum.ADD_REQUEST_ATTRIBUTES_VALUE][UniversalTag.SEQUENCE_TAG] =
+            new GrammarTransition(
+                LdapStatesEnum.ADD_REQUEST_ATTRIBUTES_VALUE,
+                LdapStatesEnum.ADD_REQUEST_ATTRIBUTE_TAG,
+                new GrammarAction( "Init attributes array list" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+
+                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
+                            container;
+                        LdapMessage          ldapMessage          =
+                            ldapMessageContainer.getLdapMessage();
+                        AddRequest           addRequest           = ldapMessage.getAddRequest();
+
+                        addRequest.initAttributes();
+                    }
+                } );
+
+        // AttributeList ::= SEQUENCE OF *SEQUENCE* { (Tag)
+        //     ...
+        // Nothing to do
+        super.transitions[LdapStatesEnum.ADD_REQUEST_ATTRIBUTE_TAG][UniversalTag.SEQUENCE_TAG] = new GrammarTransition(
+                LdapStatesEnum.ADD_REQUEST_ATTRIBUTE_TAG,
+                LdapStatesEnum.ADD_REQUEST_ATTRIBUTE_VALUE, null );
+
+        // AttributeList ::= SEQUENCE OF *SEQUENCE* { (Tag)
+        //     ...
+        // Nothing to do
+        // This is a loop, when dealing with more than one attribute
+        super.transitions[LdapStatesEnum.ADD_REQUEST_ATTRIBUTES_VAL_OR_ATTRIBUTE_OR_END][UniversalTag.SEQUENCE_TAG] =
+            new GrammarTransition(
+                LdapStatesEnum.ADD_REQUEST_ATTRIBUTES_VAL_OR_ATTRIBUTE_OR_END,
+                LdapStatesEnum.ADD_REQUEST_ATTRIBUTE_VALUE, null );
+
+        // AttributeList ::= SEQUENCE OF *SEQUENCE* { (Value)
+        // Nothing to do
+        super.transitions[LdapStatesEnum.ADD_REQUEST_ATTRIBUTE_VALUE][UniversalTag.SEQUENCE_TAG] =
+            new GrammarTransition(
+                LdapStatesEnum.ADD_REQUEST_ATTRIBUTE_VALUE,
+                LdapStatesEnum.ADD_REQUEST_ATTRIBUTES_TYPE_TAG, null );
+
+        // AttributeList ::= SEQUENCE OF *SEQUENCE* {
+        //    type    AttributeDescription, (Tag)
+        //    ...
+        // Nothing to do
+        super.transitions[LdapStatesEnum.ADD_REQUEST_ATTRIBUTES_TYPE_TAG][UniversalTag.OCTET_STRING_TAG] =
+            new GrammarTransition(
+                LdapStatesEnum.ADD_REQUEST_ATTRIBUTES_TYPE_TAG,
+                LdapStatesEnum.ADD_REQUEST_ATTRIBUTES_TYPE_VALUE, null );
+
+        // AttributeList ::= SEQUENCE OF *SEQUENCE* {
+        //    type    AttributeDescription, (Value)
+        //    ...
+        // Store the attribute type.
+        super.transitions[LdapStatesEnum.ADD_REQUEST_ATTRIBUTES_TYPE_VALUE][UniversalTag.OCTET_STRING_TAG] =
+            new GrammarTransition(
+                LdapStatesEnum.ADD_REQUEST_ATTRIBUTES_TYPE_VALUE,
+                LdapStatesEnum.ADD_REQUEST_ATTRIBUTES_VALS_TAG,
+                new GrammarAction( "Store attribute type" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+
+                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
+                            container;
+                        LdapMessage          ldapMessage          =
+                            ldapMessageContainer.getLdapMessage();
+                        TLV                  tlv                  =
+                            ldapMessageContainer.getCurrentTLV();
+
+                        AddRequest           addRequest           = ldapMessage.getAddRequest();
+
+                        // Store the type. It can't be null.
+                        if ( tlv.getLength().getLength() == 0 )
+                        {
+                            throw new DecoderException( "The type can't be null" );
+                        }
+                        else
+                        {
+                            addRequest.addAttributeType( new LdapString(
+                                    tlv.getValue().getData() ) );
+                        }
+                    }
+                } );
+
+        // AttributeTypeAndValues ::= SEQUENCE {
+        //     ...
+        //     vals    *SET OF* AttributeValue } (Tag)
+        // Nothing to do
+        super.transitions[LdapStatesEnum.ADD_REQUEST_ATTRIBUTES_VALS_TAG][UniversalTag.SET_TAG] =
+            new GrammarTransition(
+                LdapStatesEnum.ADD_REQUEST_ATTRIBUTES_VALS_TAG,
+                LdapStatesEnum.ADD_REQUEST_ATTRIBUTES_VALS_VALUE, null );
+
+        // AttributeTypeAndValues ::= SEQUENCE {
+        //     ...
+        //     vals    *SET OF* AttributeValue } (Value)
+        // Nothing to do
+        super.transitions[LdapStatesEnum.ADD_REQUEST_ATTRIBUTES_VALS_VALUE][UniversalTag.SET_TAG] =
+            new GrammarTransition(
+                LdapStatesEnum.ADD_REQUEST_ATTRIBUTES_VALS_VALUE,
+                LdapStatesEnum.ADD_REQUEST_ATTRIBUTES_VAL_TAG, null );
+
+        // AttributeTypeAndValues ::= SEQUENCE {
+        //     ...
+        //     vals    SET OF *AttributeValue* } (Tag)
+        // Nothing to do
+        super.transitions[LdapStatesEnum.ADD_REQUEST_ATTRIBUTES_VAL_TAG][UniversalTag.OCTET_STRING_TAG] =
+            new GrammarTransition(
+                LdapStatesEnum.ADD_REQUEST_ATTRIBUTES_VAL_TAG,
+                LdapStatesEnum.ADD_REQUEST_ATTRIBUTES_VAL_VALUE, null );
+
+        // AttributeTypeAndValues ::= SEQUENCE {
+        //     ...
+        //     vals    SET OF *AttributeValue* } (Loop)
+        // This is a loop, when dealing with multi-valued attributes
+        super.transitions[LdapStatesEnum.ADD_REQUEST_ATTRIBUTES_VAL_OR_ATTRIBUTE_OR_END][UniversalTag.OCTET_STRING_TAG] =
+            new GrammarTransition(
+                LdapStatesEnum.ADD_REQUEST_ATTRIBUTES_VAL_OR_ATTRIBUTE_OR_END,
+                LdapStatesEnum.ADD_REQUEST_ATTRIBUTES_VAL_VALUE, null );
+
+        // AttributeTypeAndValues ::= SEQUENCE {
+        //     ...
+        //     vals    SET OF AttributeValue }
+        // AttributeValue ::= OCTET STRING (Value)
+        // Store a new attribute value.
+        super.transitions[LdapStatesEnum.ADD_REQUEST_ATTRIBUTES_VAL_VALUE][UniversalTag.OCTET_STRING_TAG] =
+            new GrammarTransition(
+                LdapStatesEnum.ADD_REQUEST_ATTRIBUTES_VAL_VALUE,
+                LdapStatesEnum.ADD_REQUEST_ATTRIBUTES_VAL_OR_ATTRIBUTE_OR_END,
+                new GrammarAction( "Store attribute value" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+
+                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
+                            container;
+                        LdapMessage          ldapMessage          =
+                            ldapMessageContainer.getLdapMessage();
+                        AddRequest           addRequest           = ldapMessage.getAddRequest();
+
+                        TLV                  tlv                  =
+                            ldapMessageContainer.getCurrentTLV();
+
+                        // Store the value. It can't be null
+                        if ( tlv.getLength().getLength() == 0 )
+                        {
+                            addRequest.addAttributeValue( OctetString.EMPTY_STRING );
+                        }
+                        else
+                        {
+                            addRequest.addAttributeValue( new OctetString(
+                                    tlv.getValue().getData() ) );
+                        }
+                    }
+                } );
+
+    }
+
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * Get the instance of this grammar
+     *
+     * @return An instance on the SearchResultEntry Grammar
+     */
+    public static IGrammar getInstance()
+    {
+        return instance;
+    }
+}

Added: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AddResponseGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AddResponseGrammar.java?rev=234264&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AddResponseGrammar.java (added)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/AddResponseGrammar.java Sun Aug 21 09:53:27 2005
@@ -0,0 +1,125 @@
+/*
+ *   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.asn1new.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.ldap.codec.LdapConstants;
+import org.apache.asn1new.ldap.codec.LdapMessageContainer;
+import org.apache.asn1new.ldap.pojo.AddResponse;
+import org.apache.asn1new.ldap.pojo.LdapMessage;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * This class implements the AddResponse 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 AddResponseGrammar extends AbstractGrammar implements IGrammar
+{
+    //~ Static fields/initializers -----------------------------------------------------------------
+
+    /** The logger */
+    private static final Logger log = LoggerFactory.getLogger( AddResponseGrammar.class );
+
+    /** Logging speed up  */
+    private static final boolean DEBUG = log.isDebugEnabled();
+
+    /** The instance of grammar. AddResponseGrammar is a singleton */
+    private static IGrammar instance = new AddResponseGrammar();
+
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * Creates a new AddResponseGrammar object.
+     */
+    private AddResponseGrammar()
+    {
+        name = AddResponseGrammar.class.getName();
+        statesEnum = LdapStatesEnum.getInstance();
+
+        // Intitialisation
+        super.transitions = new GrammarTransition[LdapStatesEnum.LAST_ADD_RESPONSE_STATE][256];
+
+        //============================================================================================
+        // AddResponse Message
+        //============================================================================================
+        // LdapMessage ::= ... AddResponse ...
+        // AddResponse ::= [APPLICATION 9] LDAPResult (Tag)
+        // Nothing to do.
+        super.transitions[LdapStatesEnum.ADD_RESPONSE_TAG][LdapConstants.ADD_RESPONSE_TAG] = new GrammarTransition(
+                LdapStatesEnum.ADD_RESPONSE_TAG, LdapStatesEnum.ADD_RESPONSE_VALUE, null );
+
+        // LdapMessage ::= ... AddResponse ...
+        // AddResponse ::= [APPLICATION 9] LDAPResult (Value)
+        // The next Tag will be the LDAPResult Tag (0x0A).
+        // We will switch the grammar then.
+        super.transitions[LdapStatesEnum.ADD_RESPONSE_VALUE][LdapConstants.ADD_RESPONSE_TAG] = new GrammarTransition(
+                LdapStatesEnum.ADD_RESPONSE_VALUE, LdapStatesEnum.ADD_RESPONSE_LDAP_RESULT, 
+                new GrammarAction( "Init AddResponse" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+
+                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
+                            container;
+                        LdapMessage      ldapMessage          =
+                            ldapMessageContainer.getLdapMessage();
+
+                        // Now, we can allocate the AddRequest Object
+                        AddResponse addResponse = new AddResponse();
+
+                        // As this is a new Constructed object, we have to init its length
+                        TLV tlv            = ldapMessageContainer.getCurrentTLV();
+                        int expectedLength = tlv.getLength().getLength();
+                        addResponse.setExpectedLength( expectedLength );
+                        addResponse.setCurrentLength( 0 );
+                        addResponse.setParent( ldapMessage );
+
+                        // And we associate it to the ldapMessage Object
+                        ldapMessage.setProtocolOP( addResponse );
+                    }
+                } );
+
+        // LdapMessage ::= ... AddResponse ...
+        // AddResponse ::= [APPLICATION 9] LDAPResult (Value)
+        // Ok, we have a LDAPResult Tag (0x0A). So we have to switch the grammar.
+        super.transitions[LdapStatesEnum.ADD_RESPONSE_LDAP_RESULT][UniversalTag.ENUMERATED_TAG] = new GrammarTransition(
+                LdapStatesEnum.ADD_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;
+    }
+}

Added: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindRequestGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindRequestGrammar.java?rev=234264&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindRequestGrammar.java (added)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindRequestGrammar.java Sun Aug 21 09:53:27 2005
@@ -0,0 +1,364 @@
+/*
+ *   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.asn1new.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 );
+
+    /** Logging speed up  */
+    private static final boolean DEBUG = log.isDebugEnabled();
+
+    /** 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
+        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;
+                    }
+                } );
+    }
+}

Added: directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindResponseGrammar.java
URL: http://svn.apache.org/viewcvs/directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindResponseGrammar.java?rev=234264&view=auto
==============================================================================
--- directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindResponseGrammar.java (added)
+++ directory/shared/ldap/branches/new-codec-integration/apache2-provider/src/java/main/org/apache/asn1new/ldap/codec/grammar/BindResponseGrammar.java Sun Aug 21 09:53:27 2005
@@ -0,0 +1,188 @@
+/*
+ *   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.asn1new.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 );
+
+    /** Logging speed up  */
+    private static final boolean DEBUG = log.isDebugEnabled();
+
+    /** 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;
+    }
+}



Mime
View raw message