directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r452504 [2/2] - /directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/
Date Tue, 03 Oct 2006 14:04:17 GMT
Added: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ResponseAction.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ResponseAction.java?view=auto&rev=452504
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ResponseAction.java
(added)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ResponseAction.java
Tue Oct  3 07:04:15 2006
@@ -0,0 +1,88 @@
+/*
+ *  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.ber.IAsn1Container;
+import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.asn1.codec.DecoderException;
+import org.apache.directory.shared.ldap.codec.LdapMessage;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.extended.ExtendedResponse;
+import org.apache.directory.shared.ldap.util.StringTools;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store a Response to an ExtendedResponse
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ResponseAction extends GrammarAction
+{
+    /** The logger */
+    private static final Logger log = LoggerFactory.getLogger( ResponseAction.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
+    public ResponseAction()
+    {
+        super( "Store response" );
+    }
+
+    /**
+     * The initialization action
+     */
+    public void action( IAsn1Container container ) throws DecoderException
+    {
+
+        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
+        LdapMessage ldapMessage = ldapMessageContainer.getLdapMessage();
+
+        // We can allocate the ExtendedResponse Object
+        ExtendedResponse extendedResponse = ldapMessage.getExtendedResponse();
+
+        // Get the Value and store it in the ExtendedResponse
+        TLV tlv = ldapMessageContainer.getCurrentTLV();
+
+        // We have to handle the special case of a 0 length matched
+        // OID
+        if ( tlv.getLength() == 0 )
+        {
+            extendedResponse.setResponse( StringTools.EMPTY_BYTES );
+        }
+        else
+        {
+            extendedResponse.setResponse( tlv.getValue().getData() );
+        }
+
+        // We can have an END transition
+        ldapMessageContainer.grammarEndAllowed( true );
+
+        if ( IS_DEBUG )
+        {
+            log.debug( "Extended value : {}", extendedResponse.getResponse() );
+        }
+    }
+}

Added: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ResponseNameAction.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ResponseNameAction.java?view=auto&rev=452504
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ResponseNameAction.java
(added)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ResponseNameAction.java
Tue Oct  3 07:04:15 2006
@@ -0,0 +1,90 @@
+/*
+ *  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.ber.IAsn1Container;
+import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.asn1.codec.DecoderException;
+import org.apache.directory.shared.asn1.primitives.OID;
+import org.apache.directory.shared.ldap.codec.LdapMessage;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.extended.ExtendedResponse;
+import org.apache.directory.shared.ldap.util.StringTools;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store a Response Name to an ExtendedResponse
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ResponseNameAction extends GrammarAction
+{
+    /** The logger */
+    private static final Logger log = LoggerFactory.getLogger( ResponseNameAction.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
+    public ResponseNameAction()
+    {
+        super( "Store response name" );
+    }
+
+    /**
+     * The initialization action
+     */
+    public void action( IAsn1Container container ) throws DecoderException
+    {
+        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
+        LdapMessage ldapMessage = ldapMessageContainer.getLdapMessage();
+
+        // We can allocate the ExtendedResponse Object
+        ExtendedResponse extendedResponse = ldapMessage.getExtendedResponse();
+
+        // Get the Value and store it in the ExtendedResponse
+        TLV tlv = ldapMessageContainer.getCurrentTLV();
+
+        // We have to handle the special case of a 0 length matched
+        // OID
+        if ( tlv.getLength() == 0 )
+        {
+            log.error( "The name must not be null" );
+            throw new DecoderException( "The name must not be null" );
+        }
+        else
+        {
+            extendedResponse
+                .setResponseName( new OID( StringTools.asciiBytesToString( tlv.getValue().getData()
) ) );
+        }
+
+        // We can have an END transition
+        ldapMessageContainer.grammarEndAllowed( true );
+
+        if ( IS_DEBUG )
+        {
+            log.debug( "OID read : {}", extendedResponse.getResponseName() );
+        }
+    }
+}

Added: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ResultCodeAction.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ResultCodeAction.java?view=auto&rev=452504
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ResultCodeAction.java
(added)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ResultCodeAction.java
Tue Oct  3 07:04:15 2006
@@ -0,0 +1,144 @@
+/*
+ *  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.ber.IAsn1Container;
+import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.asn1.ber.tlv.Value;
+import org.apache.directory.shared.asn1.codec.DecoderException;
+import org.apache.directory.shared.asn1.util.IntegerDecoder;
+import org.apache.directory.shared.asn1.util.IntegerDecoderException;
+import org.apache.directory.shared.ldap.codec.LdapMessage;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.LdapResponse;
+import org.apache.directory.shared.ldap.codec.LdapResult;
+import org.apache.directory.shared.ldap.codec.util.LdapResultEnum;
+import org.apache.directory.shared.ldap.util.StringTools;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to set the LdapResult result code.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ResultCodeAction extends GrammarAction
+{
+    /** The logger */
+    private static final Logger log = LoggerFactory.getLogger( ResultCodeAction.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
+    public ResultCodeAction()
+    {
+        super( "Store resultCode" );
+    }
+
+    /**
+     * The initialization action
+     */
+    public void action( IAsn1Container container ) throws DecoderException
+    {
+        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
+        LdapMessage message = ldapMessageContainer.getLdapMessage();
+        LdapResponse response = message.getLdapResponse();
+        LdapResult ldapResult = new LdapResult();
+        response.setLdapResult( ldapResult );
+
+        // We don't have to allocate a LdapResult first.
+
+        // The current TLV should be a integer
+        // We get it and store it in MessageId
+        TLV tlv = ldapMessageContainer.getCurrentTLV();
+
+        Value value = tlv.getValue();
+        int resultCode = 0;
+
+        try
+        {
+            resultCode = IntegerDecoder.parse( value, 0, 90 );
+        }
+        catch ( IntegerDecoderException ide )
+        {
+            log.error( "The result code " + StringTools.dumpBytes( value.getData() ) + "
is invalid : "
+                + ide.getMessage() + ". The result code must be between (0 .. 90)" );
+
+            throw new DecoderException( ide.getMessage() );
+        }
+
+        // Treat the 'normal' cases !
+        switch ( resultCode )
+        {
+            case LdapResultEnum.SUCCESS:
+            case LdapResultEnum.OPERATIONS_ERROR:
+            case LdapResultEnum.PROTOCOL_ERROR:
+            case LdapResultEnum.TIME_LIMIT_EXCEEDED:
+            case LdapResultEnum.SIZE_LIMIT_EXCEEDED:
+            case LdapResultEnum.COMPARE_FALSE:
+            case LdapResultEnum.COMPARE_TRUE:
+            case LdapResultEnum.AUTH_METHOD_NOT_SUPPORTED:
+            case LdapResultEnum.STRONG_AUTH_REQUIRED:
+            case LdapResultEnum.REFERRAL:
+            case LdapResultEnum.ADMIN_LIMIT_EXCEEDED:
+            case LdapResultEnum.UNAVAILABLE_CRITICAL_EXTENSION:
+            case LdapResultEnum.CONFIDENTIALITY_REQUIRED:
+            case LdapResultEnum.SASL_BIND_IN_PROGRESS:
+            case LdapResultEnum.NO_SUCH_ATTRIBUTE:
+            case LdapResultEnum.UNDEFINED_ATTRIBUTE_TYPE:
+            case LdapResultEnum.INAPPROPRIATE_MATCHING:
+            case LdapResultEnum.CONSTRAINT_VIOLATION:
+            case LdapResultEnum.ATTRIBUTE_OR_VALUE_EXISTS:
+            case LdapResultEnum.INVALID_ATTRIBUTE_SYNTAX:
+            case LdapResultEnum.NO_SUCH_OBJECT:
+            case LdapResultEnum.ALIAS_PROBLEM:
+            case LdapResultEnum.INVALID_DN_SYNTAX:
+            case LdapResultEnum.ALIAS_DEREFERENCING_PROBLEM:
+            case LdapResultEnum.INAPPROPRIATE_AUTHENTICATION:
+            case LdapResultEnum.INVALID_CREDENTIALS:
+            case LdapResultEnum.INSUFFICIENT_ACCESS_RIGHTS:
+            case LdapResultEnum.BUSY:
+            case LdapResultEnum.UNAVAILABLE:
+            case LdapResultEnum.UNWILLING_TO_PERFORM:
+            case LdapResultEnum.LOOP_DETECT:
+            case LdapResultEnum.NAMING_VIOLATION:
+            case LdapResultEnum.OBJECT_CLASS_VIOLATION:
+            case LdapResultEnum.NOT_ALLOWED_ON_NON_LEAF:
+            case LdapResultEnum.NOT_ALLOWED_ON_RDN:
+            case LdapResultEnum.ENTRY_ALREADY_EXISTS:
+            case LdapResultEnum.AFFECTS_MULTIPLE_DSAS:
+                ldapResult.setResultCode( resultCode );
+                break;
+
+            default:
+                log.warn( "The resultCode " + resultCode + " is unknown." );
+                ldapResult.setResultCode( LdapResultEnum.OTHER );
+        }
+
+        if ( IS_DEBUG )
+        {
+            log.debug( "The result code is set to " + LdapResultEnum.errorCode( resultCode
) );
+        }
+    }
+}

Added: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/SearchResultAttributeValueAction.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/SearchResultAttributeValueAction.java?view=auto&rev=452504
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/SearchResultAttributeValueAction.java
(added)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/SearchResultAttributeValueAction.java
Tue Oct  3 07:04:15 2006
@@ -0,0 +1,97 @@
+/*
+ *  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.ber.IAsn1Container;
+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.LdapMessage;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.search.SearchResultEntry;
+import org.apache.directory.shared.ldap.util.StringTools;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store a Value to an search result entry
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class SearchResultAttributeValueAction extends GrammarAction
+{
+    /** The logger */
+    private static final Logger log = LoggerFactory.getLogger( SearchResultAttributeValueAction.class
);
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
+    public SearchResultAttributeValueAction()
+    {
+        super( "Stores AttributeValue" );
+    }
+
+    /**
+     * The initialization action
+     */
+    public void action( IAsn1Container container )
+    {
+        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
+        LdapMessage ldapMessage = ldapMessageContainer.getLdapMessage();
+        SearchResultEntry searchResultEntry = ldapMessage.getSearchResultEntry();
+
+        TLV tlv = ldapMessageContainer.getCurrentTLV();
+
+        // Store the value
+        Object value = null;
+
+        if ( tlv.getLength() == 0 )
+        {
+            searchResultEntry.addAttributeValue( "" );
+
+            log.debug( "The attribute value is null" );
+        }
+        else
+        {
+            if ( ldapMessageContainer.isBinary( searchResultEntry.getCurrentAttributeValueType()
) )
+            {
+                value = tlv.getValue().getData();
+
+                if ( IS_DEBUG )
+                {
+                    log.debug( "Attribute value {}", StringTools.dumpBytes( ( byte[] ) value
) );
+                }
+            }
+            else
+            {
+                value = StringTools.utf8ToString( tlv.getValue().getData() );
+
+                log.debug( "Attribute value {}", value );
+            }
+
+            searchResultEntry.addAttributeValue( value );
+        }
+
+        // We can have an END transition
+        ldapMessageContainer.grammarEndAllowed( true );
+    }
+}

Added: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ServerSASLCredsAction.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ServerSASLCredsAction.java?view=auto&rev=452504
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ServerSASLCredsAction.java
(added)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ServerSASLCredsAction.java
Tue Oct  3 07:04:15 2006
@@ -0,0 +1,87 @@
+/*
+ *  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.ber.IAsn1Container;
+import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.asn1.codec.DecoderException;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.bind.BindResponse;
+import org.apache.directory.shared.ldap.util.StringTools;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store a SASL credentials
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ServerSASLCredsAction extends GrammarAction
+{
+    /** The logger */
+    private static final Logger log = LoggerFactory.getLogger( ServerSASLCredsAction.class
);
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
+    public ServerSASLCredsAction()
+    {
+        super( "Store server sasl credentials value" );
+    }
+
+    /**
+     * The initialization action
+     */
+    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() == 0 )
+        {
+            bindResponseMessage.setServerSaslCreds( StringTools.EMPTY_BYTES );
+        }
+        else
+        {
+            bindResponseMessage.setServerSaslCreds( tlv.getValue().getData() );
+        }
+
+        // We can have an END transition
+        ldapMessageContainer.grammarEndAllowed( true );
+
+        if ( IS_DEBUG )
+        {
+            log.debug( "The SASL credentials value is : {}", bindResponseMessage.getServerSaslCreds()
+                .toString() );
+        }
+
+        return;
+    }
+}

Added: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreAnyAction.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreAnyAction.java?view=auto&rev=452504
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreAnyAction.java
(added)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreAnyAction.java
Tue Oct  3 07:04:15 2006
@@ -0,0 +1,86 @@
+/*
+ *  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.ber.IAsn1Container;
+import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.asn1.codec.DecoderException;
+import org.apache.directory.shared.ldap.codec.LdapMessage;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.search.SearchRequest;
+import org.apache.directory.shared.ldap.codec.search.SubstringFilter;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store a any value into a substring filter
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoreAnyAction extends GrammarAction
+{
+    /** The logger */
+    private static final Logger log = LoggerFactory.getLogger( StoreAnyAction.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
+    public StoreAnyAction()
+    {
+        super( "Store a any value" );
+    }
+
+    /**
+     * The initialization action
+     */
+    public void action( IAsn1Container container ) throws DecoderException
+    {
+        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
+        LdapMessage ldapMessage = ldapMessageContainer.getLdapMessage();
+        SearchRequest searchRequest = ldapMessage.getSearchRequest();
+
+        TLV tlv = ldapMessageContainer.getCurrentTLV();
+
+        // Store the value.
+        SubstringFilter substringFilter = ( SubstringFilter ) searchRequest.getTerminalFilter();
+
+        if ( tlv.getLength() == 0 )
+        {
+            log.error( "The substring any filter is empty" );
+            throw new DecoderException( "The substring any filter is empty" );
+        }
+
+        String any = new String( tlv.getValue().getData() );
+        substringFilter.addAnySubstrings( any );
+
+        // We now have to get back to the nearest filter which is
+        // not terminal.
+        searchRequest.unstackFilters( container );
+
+        if ( IS_DEBUG )
+        {
+            log.debug( "Stored a any substring : {}", any );
+        }
+    }
+}

Added: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreFinalAction.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreFinalAction.java?view=auto&rev=452504
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreFinalAction.java
(added)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreFinalAction.java
Tue Oct  3 07:04:15 2006
@@ -0,0 +1,86 @@
+/*
+ *  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.ber.IAsn1Container;
+import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.asn1.codec.DecoderException;
+import org.apache.directory.shared.ldap.codec.LdapMessage;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.search.SearchRequest;
+import org.apache.directory.shared.ldap.codec.search.SubstringFilter;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store a final value into a substring filter
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoreFinalAction extends GrammarAction
+{
+    /** The logger */
+    private static final Logger log = LoggerFactory.getLogger( StoreFinalAction.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
+    public StoreFinalAction()
+    {
+        super( "Store a final value" );
+    }
+
+    /**
+     * The initialization action
+     */
+    public void action( IAsn1Container container ) throws DecoderException
+    {
+        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
+        LdapMessage ldapMessage = ldapMessageContainer.getLdapMessage();
+        SearchRequest searchRequest = ldapMessage.getSearchRequest();
+
+        TLV tlv = ldapMessageContainer.getCurrentTLV();
+
+        // Store the value.
+        SubstringFilter substringFilter = ( SubstringFilter ) searchRequest.getTerminalFilter();
+
+        if ( tlv.getLength() == 0 )
+        {
+            log.error( "The substring final filter is empty" );
+            throw new DecoderException( "The substring final filter is empty" );
+        }
+
+        String finalValue = new String( tlv.getValue().getData() );
+        substringFilter.setFinalSubstrings( finalValue );
+
+        // We now have to get back to the nearest filter which is
+        // not terminal.
+        searchRequest.unstackFilters( container );
+
+        if ( IS_DEBUG )
+        {
+            log.debug( "Stored a any substring : {}", finalValue );
+        }
+    }
+}

Added: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreMatchValueAction.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreMatchValueAction.java?view=auto&rev=452504
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreMatchValueAction.java
(added)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreMatchValueAction.java
Tue Oct  3 07:04:15 2006
@@ -0,0 +1,81 @@
+/*
+ *  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.ber.IAsn1Container;
+import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.asn1.codec.DecoderException;
+import org.apache.directory.shared.ldap.codec.LdapMessage;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.search.ExtensibleMatchFilter;
+import org.apache.directory.shared.ldap.codec.search.SearchRequest;
+import org.apache.directory.shared.ldap.util.StringTools;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store a match value
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoreMatchValueAction extends GrammarAction
+{
+    /** The logger */
+    private static final Logger log = LoggerFactory.getLogger( StoreMatchValueAction.class
);
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
+    public StoreMatchValueAction()
+    {
+        super( "Store match Value" );
+    }
+
+    /**
+     * The initialization action
+     */
+    public void action( IAsn1Container container ) throws DecoderException
+    {
+        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
+        LdapMessage ldapMessage = ldapMessageContainer.getLdapMessage();
+        SearchRequest searchRequest = ldapMessage.getSearchRequest();
+
+        TLV tlv = ldapMessageContainer.getCurrentTLV();
+
+        // Store the value.
+        ExtensibleMatchFilter extensibleMatchFilter = ( ExtensibleMatchFilter ) searchRequest
+            .getTerminalFilter();
+        
+        String value = StringTools.utf8ToString( tlv.getValue().getData() );
+        extensibleMatchFilter.setMatchValue( value );
+
+        // unstack the filters if needed
+        searchRequest.unstackFilters( container );
+
+        if ( IS_DEBUG )
+        {
+            log.debug( "Stored a match value : {}", value );
+        }
+    }
+}

Added: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreReferenceAction.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreReferenceAction.java?view=auto&rev=452504
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreReferenceAction.java
(added)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreReferenceAction.java
Tue Oct  3 07:04:15 2006
@@ -0,0 +1,101 @@
+/*
+ *  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.ber.IAsn1Container;
+import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.asn1.codec.DecoderException;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.search.SearchResultReference;
+import org.apache.directory.shared.ldap.codec.util.LdapURL;
+import org.apache.directory.shared.ldap.codec.util.LdapURLEncodingException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store a reference into a searchResultReference
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoreReferenceAction extends GrammarAction
+{
+    /** The logger */
+    private static final Logger log = LoggerFactory.getLogger( StoreReferenceAction.class
);
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
+    public StoreReferenceAction()
+    {
+        super( "Store a reference" );
+    }
+
+    /**
+     * The initialization action
+     */
+    public void action( IAsn1Container container ) throws DecoderException
+    {
+
+        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
+
+        SearchResultReference searchResultReference = ldapMessageContainer.getLdapMessage()
+            .getSearchResultReference();
+
+        // 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
+        LdapURL url = LdapURL.EMPTY_URL;
+
+        if ( tlv.getLength() == 0 )
+        {
+            searchResultReference.addSearchResultReference( url );
+        }
+        else
+        {
+            try
+            {
+                url = new LdapURL( tlv.getValue().getData() );
+                searchResultReference.addSearchResultReference( url );
+            }
+            catch ( LdapURLEncodingException luee )
+            {
+                String badUrl = new String( tlv.getValue().getData() );
+                log.error( "The URL {} is not valid : {}", badUrl, luee.getMessage() );
+                throw new DecoderException( "Invalid URL : " + luee.getMessage() );
+            }
+        }
+
+        if ( IS_DEBUG )
+        {
+            log.debug( "Search reference URL found : {}", url );
+        }
+
+        // We can have an END transition
+        ldapMessageContainer.grammarEndAllowed( true );
+
+        return;
+    }
+}

Added: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreTypeMatchingRuleAction.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreTypeMatchingRuleAction.java?view=auto&rev=452504
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreTypeMatchingRuleAction.java
(added)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/StoreTypeMatchingRuleAction.java
Tue Oct  3 07:04:15 2006
@@ -0,0 +1,85 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.shared.ldap.codec.actions;
+
+
+import org.apache.directory.shared.asn1.ber.IAsn1Container;
+import org.apache.directory.shared.asn1.ber.grammar.GrammarAction;
+import org.apache.directory.shared.asn1.ber.tlv.TLV;
+import org.apache.directory.shared.asn1.codec.DecoderException;
+import org.apache.directory.shared.ldap.codec.LdapMessage;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.search.ExtensibleMatchFilter;
+import org.apache.directory.shared.ldap.codec.search.SearchRequest;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store a type matching rule
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoreTypeMatchingRuleAction extends GrammarAction
+{
+    /** The logger */
+    private static final Logger log = LoggerFactory.getLogger( StoreTypeMatchingRuleAction.class
);
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
+    public StoreTypeMatchingRuleAction()
+    {
+        super( "Store matching type Value" );
+    }
+
+    /**
+     * The initialization action
+     */
+    public void action( IAsn1Container container ) throws DecoderException
+    {
+        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
+        LdapMessage ldapMessage = ldapMessageContainer.getLdapMessage();
+        SearchRequest searchRequest = ldapMessage.getSearchRequest();
+
+        TLV tlv = ldapMessageContainer.getCurrentTLV();
+
+        if ( tlv.getLength() == 0 )
+        {
+            log.error( "The type cannot be null in a MacthingRuleAssertion" );
+            throw new DecoderException( "The type cannot be null in a MacthingRuleAssertion"
);
+        }
+        else
+        {
+            // Store the value.
+            ExtensibleMatchFilter extensibleMatchFilter = ( ExtensibleMatchFilter ) searchRequest
+                .getTerminalFilter();
+
+            String type = new String( tlv.getValue().getData() );
+            extensibleMatchFilter.setType( type );
+
+            if ( IS_DEBUG )
+            {
+                log.debug( "Stored a type matching rule : {}", type );
+            }
+        }
+    }
+}

Added: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ValueAction.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ValueAction.java?view=auto&rev=452504
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ValueAction.java
(added)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ValueAction.java
Tue Oct  3 07:04:15 2006
@@ -0,0 +1,96 @@
+/*
+ *  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.ber.IAsn1Container;
+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.LdapMessage;
+import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.add.AddRequest;
+import org.apache.directory.shared.ldap.util.StringTools;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * The action used to store a Value to an AddRequest
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ValueAction extends GrammarAction
+{
+    /** The logger */
+    private static final Logger log = LoggerFactory.getLogger( ValueAction.class );
+
+    /** Speedup for logs */
+    private static final boolean IS_DEBUG = log.isDebugEnabled();
+
+    public ValueAction()
+    {
+        super( "Store a value" );
+    }
+
+    /**
+     * The initialization action
+     */
+    public void action( IAsn1Container container )
+    {
+
+        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
+        LdapMessage ldapMessage = ldapMessageContainer.getLdapMessage();
+        AddRequest addRequest = ldapMessage.getAddRequest();
+
+        TLV tlv = ldapMessageContainer.getCurrentTLV();
+
+        // Store the value. It can't be null
+        Object value = null;
+
+        if ( tlv.getLength() == 0 )
+        {
+            addRequest.addAttributeValue( "" );
+        }
+        else
+        {
+            if ( ldapMessageContainer.isBinary( addRequest.getCurrentAttributeType() ) )
+            {
+                value = tlv.getValue().getData();
+
+                if ( IS_DEBUG )
+                {
+                    log.debug( "Adding value {}", StringTools.dumpBytes( ( byte[] ) value
) );
+                }
+            }
+            else
+            {
+                value = StringTools.utf8ToString( tlv.getValue().getData() );
+
+                log.debug( "Adding value {}" + value );
+            }
+
+            addRequest.addAttributeValue( value );
+        }
+
+        // We can have an END transition
+        ldapMessageContainer.grammarEndAllowed( true );
+    }
+}



Mime
View raw message