directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1069199 - in /directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec: ./ actions/ actions/intermediateResponse/
Date Thu, 10 Feb 2011 01:35:59 GMT
Author: elecharny
Date: Thu Feb 10 01:35:59 2011
New Revision: 1069199

URL: http://svn.apache.org/viewvc?rev=1069199&view=rev
Log:
Moved some more actions

Added:
    directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/CheckLengthNotNull.java
    directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/intermediateResponse/
    directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/intermediateResponse/InitIntermediateResponse.java
    directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/intermediateResponse/StoreIntermediateResponseName.java
    directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/intermediateResponse/StoreIntermediateResponseValue.java
Modified:
    directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java

Modified: directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java?rev=1069199&r1=1069198&r2=1069199&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
(original)
+++ directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
Thu Feb 10 01:35:59 2011
@@ -29,7 +29,6 @@ import static org.apache.directory.share
 
 import org.apache.directory.shared.asn1.DecoderException;
 import org.apache.directory.shared.asn1.ber.grammar.AbstractGrammar;
-import org.apache.directory.shared.asn1.ber.grammar.Action;
 import org.apache.directory.shared.asn1.ber.grammar.Grammar;
 import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
 import org.apache.directory.shared.asn1.ber.grammar.GrammarTransition;
@@ -44,6 +43,7 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.util.OID;
 import org.apache.directory.shared.i18n.I18n;
 import org.apache.directory.shared.ldap.codec.actions.AllowGrammarEnd;
+import org.apache.directory.shared.ldap.codec.actions.CheckLengthNotNull;
 import org.apache.directory.shared.ldap.codec.actions.InitAndFilterAction;
 import org.apache.directory.shared.ldap.codec.actions.InitApproxMatchFilterAction;
 import org.apache.directory.shared.ldap.codec.actions.InitAssertionValueFilterAction;
@@ -91,6 +91,9 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.codec.actions.extendedResponse.InitExtendedResponse;
 import org.apache.directory.shared.ldap.codec.actions.extendedResponse.StoreExtendedResponseValue;
 import org.apache.directory.shared.ldap.codec.actions.extendedResponse.StoreResponseName;
+import org.apache.directory.shared.ldap.codec.actions.intermediateResponse.InitIntermediateResponse;
+import org.apache.directory.shared.ldap.codec.actions.intermediateResponse.StoreIntermediateResponseName;
+import org.apache.directory.shared.ldap.codec.actions.intermediateResponse.StoreIntermediateResponseValue;
 import org.apache.directory.shared.ldap.codec.actions.ldapMessage.InitLdapMessage;
 import org.apache.directory.shared.ldap.codec.actions.ldapMessage.StoreMessageId;
 import org.apache.directory.shared.ldap.codec.actions.ldapResult.AddReferral;
@@ -122,7 +125,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.codec.actions.unbindRequest.InitUnbindRequest;
 import org.apache.directory.shared.ldap.codec.api.LdapConstants;
 import org.apache.directory.shared.ldap.codec.api.ResponseCarryingException;
-import org.apache.directory.shared.ldap.codec.decorators.IntermediateResponseDecorator;
 import org.apache.directory.shared.ldap.codec.decorators.MessageDecorator;
 import org.apache.directory.shared.ldap.codec.decorators.SearchRequestDecorator;
 import org.apache.directory.shared.ldap.codec.search.ExtensibleMatchFilter;
@@ -131,15 +133,12 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.filter.SearchScope;
 import org.apache.directory.shared.ldap.model.message.AliasDerefMode;
 import org.apache.directory.shared.ldap.model.message.Control;
-import org.apache.directory.shared.ldap.model.message.IntermediateResponse;
-import org.apache.directory.shared.ldap.model.message.IntermediateResponseImpl;
 import org.apache.directory.shared.ldap.model.message.Message;
 import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.model.message.SearchRequest;
 import org.apache.directory.shared.ldap.model.message.SearchRequestImpl;
 import org.apache.directory.shared.ldap.model.message.SearchResultDoneImpl;
 import org.apache.directory.shared.ldap.model.name.Dn;
-import org.apache.directory.shared.util.StringConstants;
 import org.apache.directory.shared.util.Strings;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -2156,21 +2155,12 @@ public final class LdapMessageGrammar<E>
         // IntermediateResponse ::= [APPLICATION 25] SEQUENCE {
         //
         // Creates the IntermediateResponse object
-        super.transitions[LdapStatesEnum.MESSAGE_ID_STATE.ordinal()][LdapConstants.INTERMEDIATE_RESPONSE_TAG]
= new GrammarTransition(
-            LdapStatesEnum.MESSAGE_ID_STATE, LdapStatesEnum.INTERMEDIATE_RESPONSE_STATE,
-            LdapConstants.INTERMEDIATE_RESPONSE_TAG, new GrammarAction<LdapMessageContainer<IntermediateResponseDecorator>>(
"Init Intermediate Response" )
-            {
-                public void action( LdapMessageContainer<IntermediateResponseDecorator>
container ) throws DecoderException
-                {
-                    // Now, we can allocate the IntermediateResponse Object
-                    IntermediateResponseDecorator intermediateResponse =
-                        new IntermediateResponseDecorator( container.getLdapCodecService(),
-                            new IntermediateResponseImpl( container.getMessageId() ) );
-                    container.setMessage( intermediateResponse );
-
-                    LOG.debug( "Intermediate Response" );
-                }
-            } );
+        super.transitions[LdapStatesEnum.MESSAGE_ID_STATE.ordinal()][LdapConstants.INTERMEDIATE_RESPONSE_TAG]
=
+            new GrammarTransition(
+                LdapStatesEnum.MESSAGE_ID_STATE,
+                LdapStatesEnum.INTERMEDIATE_RESPONSE_STATE,
+                LdapConstants.INTERMEDIATE_RESPONSE_TAG,
+                new InitIntermediateResponse() );
 
         // --------------------------------------------------------------------------------------------
         // Transition from IntermediateResponse Message to ResponseName
@@ -2180,59 +2170,12 @@ public final class LdapMessageGrammar<E>
         //     ...
         //
         // Stores the name
-        super.transitions[LdapStatesEnum.INTERMEDIATE_RESPONSE_STATE.ordinal()][LdapConstants.INTERMEDIATE_RESPONSE_NAME_TAG]
= new GrammarTransition(
-            LdapStatesEnum.INTERMEDIATE_RESPONSE_STATE, LdapStatesEnum.INTERMEDIATE_RESPONSE_NAME_STATE,
-            LdapConstants.INTERMEDIATE_RESPONSE_NAME_TAG, new GrammarAction<LdapMessageContainer<IntermediateResponseDecorator>>(
"Store response name" )
-            {
-                public void action( LdapMessageContainer<IntermediateResponseDecorator>
container ) throws DecoderException
-                {
-                    // We can get the IntermediateResponse Object
-                    IntermediateResponse intermediateResponse = container.getMessage();
-
-                    // Get the Value and store it in the IntermediateResponse
-                    TLV tlv = container.getCurrentTLV();
-
-                    // We have to handle the special case of a 0 length matched
-                    // OID.
-                    if ( tlv.getLength() == 0 )
-                    {
-                        String msg = I18n.err( I18n.ERR_04095 );
-                        LOG.error( msg );
-                        // This will generate a PROTOCOL_ERROR
-                        throw new DecoderException( msg );
-                    }
-                    else
-                    {
-                        byte[] responseNameBytes = tlv.getValue().getData();
-
-                        String oidStr = Strings.utf8ToString(responseNameBytes);
-
-                        if ( OID.isOID( oidStr ) )
-                        {
-                            OID.isOID( oidStr );
-                            intermediateResponse.setResponseName( oidStr );
-                        }
-                        else
-                        {
-                            String msg = "The Intermediate Response name is not a valid OID
: "
-                                + Strings.utf8ToString(responseNameBytes) + " ("
-                                + Strings.dumpBytes(responseNameBytes) + ") is invalid";
-                            LOG.error( "{} : {}", msg, oidStr );
-
-                            // Rethrow the exception, we will get a PROTOCOL_ERROR
-                            throw new DecoderException( msg );
-                        }
-                    }
-
-                    // We can have an END transition
-                    container.setGrammarEndAllowed( true );
-
-                    if ( IS_DEBUG )
-                    {
-                        LOG.debug( "OID read : {}", intermediateResponse.getResponseName()
);
-                    }
-                }
-            } );
+        super.transitions[LdapStatesEnum.INTERMEDIATE_RESPONSE_STATE.ordinal()][LdapConstants.INTERMEDIATE_RESPONSE_NAME_TAG]
=
+            new GrammarTransition(
+                LdapStatesEnum.INTERMEDIATE_RESPONSE_STATE,
+                LdapStatesEnum.INTERMEDIATE_RESPONSE_NAME_STATE,
+                LdapConstants.INTERMEDIATE_RESPONSE_NAME_TAG,
+                new StoreIntermediateResponseName() );
 
         // --------------------------------------------------------------------------------------------
         // Transition from IntermediateResponse Message to ResponseValue (ResponseName is
null)
@@ -2243,39 +2186,12 @@ public final class LdapMessageGrammar<E>
         //     }
         //
         // Stores the value
-        super.transitions[LdapStatesEnum.INTERMEDIATE_RESPONSE_STATE.ordinal()][LdapConstants.INTERMEDIATE_RESPONSE_VALUE_TAG]
= new GrammarTransition(
-            LdapStatesEnum.INTERMEDIATE_RESPONSE_STATE, LdapStatesEnum.INTERMEDIATE_RESPONSE_VALUE_STATE,
-            LdapConstants.INTERMEDIATE_RESPONSE_VALUE_TAG,
-            new GrammarAction<LdapMessageContainer<IntermediateResponseDecorator>>(
"Store response value" )
-            {
-                public void action( LdapMessageContainer<IntermediateResponseDecorator>
container ) throws DecoderException
-                {
-                    // We can get the IntermediateResponse Object
-                    IntermediateResponse intermediateResponse = container.getMessage();
-
-                    // Get the Value and store it in the IntermediateResponse
-                    TLV tlv = container.getCurrentTLV();
-
-                    // We have to handle the special case of a 0 length matched
-                    // value
-                    if ( tlv.getLength() == 0 )
-                    {
-                        intermediateResponse.setResponseValue( StringConstants.EMPTY_BYTES
);
-                    }
-                    else
-                    {
-                        intermediateResponse.setResponseValue( tlv.getValue().getData() );
-                    }
-
-                    // We can have an END transition
-                    container.setGrammarEndAllowed( true );
-
-                    if ( IS_DEBUG )
-                    {
-                        LOG.debug( "Value read : {}", Strings.dumpBytes(intermediateResponse.getResponseValue())
);
-                    }
-                }
-            } );
+        super.transitions[LdapStatesEnum.INTERMEDIATE_RESPONSE_STATE.ordinal()][LdapConstants.INTERMEDIATE_RESPONSE_VALUE_TAG]
=
+            new GrammarTransition(
+                LdapStatesEnum.INTERMEDIATE_RESPONSE_STATE,
+                LdapStatesEnum.INTERMEDIATE_RESPONSE_VALUE_STATE,
+                LdapConstants.INTERMEDIATE_RESPONSE_VALUE_TAG,
+                new StoreIntermediateResponseValue() );
 
         // --------------------------------------------------------------------------------------------
         // Transition from ResponseName to ResponseValue
@@ -2285,39 +2201,12 @@ public final class LdapMessageGrammar<E>
         //     responseValue  [1] OCTET STRING OPTIONAL }
         //
         // Stores the value
-        super.transitions[LdapStatesEnum.INTERMEDIATE_RESPONSE_NAME_STATE.ordinal()][LdapConstants.INTERMEDIATE_RESPONSE_VALUE_TAG]
= new GrammarTransition(
-            LdapStatesEnum.INTERMEDIATE_RESPONSE_NAME_STATE, LdapStatesEnum.INTERMEDIATE_RESPONSE_VALUE_STATE,
-            LdapConstants.INTERMEDIATE_RESPONSE_VALUE_TAG,
-            new GrammarAction<LdapMessageContainer<IntermediateResponseDecorator>>(
"Store value" )
-            {
-                public void action( LdapMessageContainer<IntermediateResponseDecorator>
container ) throws DecoderException
-                {
-                    // We can allocate the ExtendedRequest Object
-                    IntermediateResponse intermediateResponse = container.getMessage();
-
-                    // Get the Value and store it in the IntermediateResponse
-                    TLV tlv = container.getCurrentTLV();
-
-                    // We have to handle the special case of a 0 length matched
-                    // value
-                    if ( tlv.getLength() == 0 )
-                    {
-                        intermediateResponse.setResponseValue( StringConstants.EMPTY_BYTES
);
-                    }
-                    else
-                    {
-                        intermediateResponse.setResponseValue( tlv.getValue().getData() );
-                    }
-
-                    // We can have an END transition
-                    container.setGrammarEndAllowed( true );
-
-                    if ( IS_DEBUG )
-                    {
-                        LOG.debug( "Response value : {}", intermediateResponse.getResponseValue()
);
-                    }
-                }
-            } );
+        super.transitions[LdapStatesEnum.INTERMEDIATE_RESPONSE_NAME_STATE.ordinal()][LdapConstants.INTERMEDIATE_RESPONSE_VALUE_TAG]
=
+            new GrammarTransition(
+                LdapStatesEnum.INTERMEDIATE_RESPONSE_NAME_STATE,
+                LdapStatesEnum.INTERMEDIATE_RESPONSE_VALUE_STATE,
+                LdapConstants.INTERMEDIATE_RESPONSE_VALUE_TAG,
+                new StoreIntermediateResponseValue() );
 
         // --------------------------------------------------------------------------------------------
         // Transition from ResponseName to Controls
@@ -2349,29 +2238,6 @@ public final class LdapMessageGrammar<E>
                 LdapConstants.CONTROLS_TAG,
                 new InitControls() );
 
-        // --------------------------------------------------------------------------------------------
-        // Controls
-        // --------------------------------------------------------------------------------------------
-        Action<LdapMessageContainer<MessageDecorator<? extends Message>>>
addControl =
-            new GrammarAction<LdapMessageContainer<MessageDecorator<? extends Message>>>(
"Add Control" )
-        {
-            public void action( LdapMessageContainer<MessageDecorator<? extends Message>>
container ) throws DecoderException
-            {
-                TLV tlv = container.getCurrentTLV();
-                int expectedLength = tlv.getLength();
-
-                // The Length should be null
-                if ( expectedLength == 0 )
-                {
-                    String msg = I18n.err( I18n.ERR_04096 );
-                    LOG.error( msg );
-
-                    // This will generate a PROTOCOL_ERROR
-                    throw new DecoderException( msg );
-                }
-            }
-        };
-
         // ============================================================================================
         // Transition from Controls to Control
         // ============================================================================================
@@ -2385,7 +2251,7 @@ public final class LdapMessageGrammar<E>
                 LdapStatesEnum.CONTROLS_STATE,
                 LdapStatesEnum.CONTROL_STATE,
                 SEQUENCE.getValue(),
-                addControl );
+                new CheckLengthNotNull() );
 
         // ============================================================================================
         // Transition from Control to ControlType
@@ -2539,7 +2405,7 @@ public final class LdapMessageGrammar<E>
                 LdapStatesEnum.CONTROL_TYPE_STATE,
                 LdapStatesEnum.CONTROL_STATE,
                 SEQUENCE.getValue(),
-                addControl );
+                new CheckLengthNotNull() );
 
         // ============================================================================================
         // Transition from Control Criticality to Control
@@ -2554,7 +2420,7 @@ public final class LdapMessageGrammar<E>
                 LdapStatesEnum.CRITICALITY_STATE,
                 LdapStatesEnum.CONTROL_STATE,
                 SEQUENCE.getValue(),
-                addControl );
+                new CheckLengthNotNull() );
 
         // ============================================================================================
         // Transition from Control Value to Control
@@ -2569,7 +2435,7 @@ public final class LdapMessageGrammar<E>
                 LdapStatesEnum.CONTROL_VALUE_STATE,
                 LdapStatesEnum.CONTROL_STATE,
                 SEQUENCE.getValue(),
-                addControl );
+                new CheckLengthNotNull() );
 
         // --------------------------------------------------------------------------------------------
         // Transition from message ID to SearchRequest Message

Added: directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/CheckLengthNotNull.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/CheckLengthNotNull.java?rev=1069199&view=auto
==============================================================================
--- directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/CheckLengthNotNull.java
(added)
+++ directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/CheckLengthNotNull.java
Thu Feb 10 01:35:59 2011
@@ -0,0 +1,71 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.directory.shared.ldap.codec.actions;
+
+
+import org.apache.directory.shared.asn1.DecoderException;
+import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.decorators.MessageDecorator;
+import org.apache.directory.shared.ldap.model.message.Message;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to check that the TLV length is not null
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class CheckLengthNotNull extends GrammarAction<LdapMessageContainer<MessageDecorator<?
extends Message>>>
+{
+    /** The logger */
+    private static final Logger LOG = LoggerFactory.getLogger( CheckLengthNotNull.class );
+
+    /**
+     * Instantiates the action.
+     */
+    public CheckLengthNotNull()
+    {
+        super( "Check that the length is not null" );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void action( LdapMessageContainer<MessageDecorator<? extends Message>>
container ) throws DecoderException
+    {
+        TLV tlv = container.getCurrentTLV();
+        int expectedLength = tlv.getLength();
+
+        // The Length should be null
+        if ( expectedLength == 0 )
+        {
+            String msg = I18n.err( I18n.ERR_04096 );
+            LOG.error( msg );
+
+            // This will generate a PROTOCOL_ERROR
+            throw new DecoderException( msg );
+        }
+    }
+}

Added: directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/intermediateResponse/InitIntermediateResponse.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/intermediateResponse/InitIntermediateResponse.java?rev=1069199&view=auto
==============================================================================
--- directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/intermediateResponse/InitIntermediateResponse.java
(added)
+++ directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/intermediateResponse/InitIntermediateResponse.java
Thu Feb 10 01:35:59 2011
@@ -0,0 +1,67 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.directory.shared.ldap.codec.actions.intermediateResponse;
+
+
+import org.apache.directory.shared.asn1.DecoderException;
+import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.decorators.IntermediateResponseDecorator;
+import org.apache.directory.shared.ldap.model.message.IntermediateResponseImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to initialize the IntermediateResponse message
+ * <pre>
+ * LdapMessage ::= ... IntermediateResponse ...
+ * IntermediateResponse ::= [APPLICATION 25] SEQUENCE {
+ * </pre>
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class InitIntermediateResponse extends GrammarAction<LdapMessageContainer<IntermediateResponseDecorator>>
+{
+    /** The logger */
+    private static final Logger LOG = LoggerFactory.getLogger( InitIntermediateResponse.class
);
+
+    /**
+     * Instantiates a new action.
+     */
+    public InitIntermediateResponse()
+    {
+        super( "Init Intermediate Response" );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void action( LdapMessageContainer<IntermediateResponseDecorator> container
) throws DecoderException
+    {
+        // Now, we can allocate the IntermediateResponse Object
+        IntermediateResponseDecorator intermediateResponse =
+            new IntermediateResponseDecorator( container.getLdapCodecService(),
+                new IntermediateResponseImpl( container.getMessageId() ) );
+        container.setMessage( intermediateResponse );
+
+        LOG.debug( "Intermediate Response" );
+    }
+}

Added: directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/intermediateResponse/StoreIntermediateResponseName.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/intermediateResponse/StoreIntermediateResponseName.java?rev=1069199&view=auto
==============================================================================
--- directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/intermediateResponse/StoreIntermediateResponseName.java
(added)
+++ directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/intermediateResponse/StoreIntermediateResponseName.java
Thu Feb 10 01:35:59 2011
@@ -0,0 +1,113 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.directory.shared.ldap.codec.actions.intermediateResponse;
+
+
+import org.apache.directory.shared.asn1.DecoderException;
+import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.asn1.util.OID;
+import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.decorators.IntermediateResponseDecorator;
+import org.apache.directory.shared.ldap.model.message.IntermediateResponse;
+import org.apache.directory.shared.util.Strings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store a IntermediateResponse Name
+ * <pre>
+ * IntermediateResponse ::= [APPLICATION 25] SEQUENCE {
+ *     responseName [0] LDAPOID OPTIONAL,
+ * </pre>
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoreIntermediateResponseName extends GrammarAction<LdapMessageContainer<IntermediateResponseDecorator>>
+{
+    /** The logger */
+    private static final Logger LOG = LoggerFactory.getLogger( StoreIntermediateResponseName.class
);
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
+
+
+    /**
+     * Instantiates a new response name action.
+     */
+    public StoreIntermediateResponseName()
+    {
+        super( "Store response name" );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void action( LdapMessageContainer<IntermediateResponseDecorator> container
) throws DecoderException
+    {
+        // We can get the IntermediateResponse Object
+        IntermediateResponse intermediateResponse = container.getMessage();
+
+        // Get the Value and store it in the IntermediateResponse
+        TLV tlv = container.getCurrentTLV();
+
+        // We have to handle the special case of a 0 length matched
+        // OID.
+        if ( tlv.getLength() == 0 )
+        {
+            String msg = I18n.err( I18n.ERR_04095 );
+            LOG.error( msg );
+            // This will generate a PROTOCOL_ERROR
+            throw new DecoderException( msg );
+        }
+        else
+        {
+            byte[] responseNameBytes = tlv.getValue().getData();
+
+            String oidStr = Strings.utf8ToString(responseNameBytes);
+
+            if ( OID.isOID( oidStr ) )
+            {
+                OID.isOID( oidStr );
+                intermediateResponse.setResponseName( oidStr );
+            }
+            else
+            {
+                String msg = "The Intermediate Response name is not a valid OID : "
+                    + Strings.utf8ToString(responseNameBytes) + " ("
+                    + Strings.dumpBytes(responseNameBytes) + ") is invalid";
+                LOG.error( "{} : {}", msg, oidStr );
+
+                // Rethrow the exception, we will get a PROTOCOL_ERROR
+                throw new DecoderException( msg );
+            }
+        }
+
+        // We can have an END transition
+        container.setGrammarEndAllowed( true );
+
+        if ( IS_DEBUG )
+        {
+            LOG.debug( "OID read : {}", intermediateResponse.getResponseName() );
+        }
+    }
+}

Added: directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/intermediateResponse/StoreIntermediateResponseValue.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/intermediateResponse/StoreIntermediateResponseValue.java?rev=1069199&view=auto
==============================================================================
--- directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/intermediateResponse/StoreIntermediateResponseValue.java
(added)
+++ directory/shared/branches/m1/ldap-codec/src/main/java/org/apache/directory/shared/ldap/codec/actions/intermediateResponse/StoreIntermediateResponseValue.java
Thu Feb 10 01:35:59 2011
@@ -0,0 +1,93 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ *
+ */
+package org.apache.directory.shared.ldap.codec.actions.intermediateResponse;
+
+
+import org.apache.directory.shared.asn1.DecoderException;
+import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.decorators.IntermediateResponseDecorator;
+import org.apache.directory.shared.ldap.model.message.IntermediateResponse;
+import org.apache.directory.shared.util.StringConstants;
+import org.apache.directory.shared.util.Strings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store a IntermediateResponse value
+ * <pre>
+ * IntermediateResponse ::= [APPLICATION 25] SEQUENCE {
+ *     ...
+ *     responseValue [1] OCTET STRING OPTIONAL
+ *     }
+ * </pre>
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoreIntermediateResponseValue extends GrammarAction<LdapMessageContainer<IntermediateResponseDecorator>>
+{
+    /** The logger */
+    private static final Logger LOG = LoggerFactory.getLogger( StoreIntermediateResponseValue.class
);
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
+
+
+    /**
+     * Instantiates a new response name action.
+     */
+    public StoreIntermediateResponseValue()
+    {
+        super( "Store response value" );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void action( LdapMessageContainer<IntermediateResponseDecorator> container
) throws DecoderException
+    {
+        // We can get the IntermediateResponse Object
+        IntermediateResponse intermediateResponse = container.getMessage();
+
+        // Get the Value and store it in the IntermediateResponse
+        TLV tlv = container.getCurrentTLV();
+
+        // We have to handle the special case of a 0 length matched
+        // value
+        if ( tlv.getLength() == 0 )
+        {
+            intermediateResponse.setResponseValue( StringConstants.EMPTY_BYTES );
+        }
+        else
+        {
+            intermediateResponse.setResponseValue( tlv.getValue().getData() );
+        }
+
+        // We can have an END transition
+        container.setGrammarEndAllowed( true );
+
+        if ( IS_DEBUG )
+        {
+            LOG.debug( "Value read : {}", Strings.dumpBytes(intermediateResponse.getResponseValue())
);
+        }
+    }
+}



Mime
View raw message