directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r208855 - /directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/SearchResultReferenceGrammar.java
Date Sat, 02 Jul 2005 18:04:09 GMT
Author: elecharny
Date: Sat Jul  2 11:04:08 2005
New Revision: 208855

URL: http://svn.apache.org/viewcvs?rev=208855&view=rev
Log:
Added the SearchResultReference grammar

Added:
    directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/SearchResultReferenceGrammar.java

Added: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/SearchResultReferenceGrammar.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/SearchResultReferenceGrammar.java?rev=208855&view=auto
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/SearchResultReferenceGrammar.java
(added)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/SearchResultReferenceGrammar.java
Sat Jul  2 11:04:08 2005
@@ -0,0 +1,156 @@
+/*
+ *   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.asn1.ldap.codec.grammars;
+
+import org.apache.asn1.DecoderException;
+import org.apache.asn1.ber.containers.IAsn1Container;
+import org.apache.asn1.ber.grammar.AbstractGrammar;
+import org.apache.asn1.ber.grammar.GrammarAction;
+import org.apache.asn1.ber.grammar.GrammarTransition;
+import org.apache.asn1.ber.grammar.IGrammar;
+import org.apache.asn1.ber.tlv.TLV;
+import org.apache.asn1.ldap.codec.LdapMessageContainer;
+import org.apache.asn1.ldap.codec.primitives.LdapURL;
+import org.apache.asn1.ldap.pojo.LdapMessage;
+import org.apache.asn1.ldap.pojo.SearchResultReference;
+
+import org.apache.log4j.Logger;
+
+
+/**
+ * This class implements the SearchResultReference 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 SearchResultReferenceGrammar extends AbstractGrammar implements IGrammar
+{
+    //~ Static fields/initializers -----------------------------------------------------------------
+
+    /** The logger */
+    private static final Logger log = Logger.getLogger( SearchResultReferenceGrammar.class
);
+
+    /** Logging speed up  */
+    private static final boolean DEBUG = log.isDebugEnabled();
+
+    /** The instance of grammar. SearchResultReferenceGrammar is a singleton */
+    private static IGrammar instance = new SearchResultReferenceGrammar();
+
+    //~ Constructors -------------------------------------------------------------------------------
+
+    /**
+     * Creates a new SearchResultReferenceGrammar object.
+     */
+    private SearchResultReferenceGrammar()
+    {
+        name       = SearchResultReferenceGrammar.class.getName();
+        statesEnum = LdapStatesEnum.getInstance();
+
+        // Initialisation of the transitions table
+        super.transitions = new GrammarTransition[LdapStatesEnum.LAST_SEARCH_RESULT_REFERENCE_STATE_STATE][256];
+
+        //============================================================================================
+        // SearchResultReference Message
+        //============================================================================================
+        // SearchResultReference ::= [APPLICATION 19] SEQUENCE OF LDAPURL (Tag)
+        // Nothing to do
+        super.transitions[LdapStatesEnum.SEARCH_RESULT_REFERENCE_TAG][0x73] = new GrammarTransition(
+                LdapStatesEnum.SEARCH_RESULT_REFERENCE_TAG, LdapStatesEnum.SEARCH_RESULT_REFERENCE_VALUE,
null );
+
+        // SearchResultReference ::= [APPLICATION 19] SEQUENCE OF LDAPURL (Value)
+        // We won't have a value. The next Tag will be the LDAPUrl Tag (0x04)
+        super.transitions[LdapStatesEnum.SEARCH_RESULT_REFERENCE_VALUE][0x73] = new GrammarTransition(
+                LdapStatesEnum.SEARCH_RESULT_REFERENCE_VALUE, LdapStatesEnum.SEARCH_RESULT_REFERENCE_LDAP_URL_TAG,
+                new GrammarAction( "Init SearchResultReference" )
+                {
+                    public void action( IAsn1Container container ) throws DecoderException
+                    {
+
+                        LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer
)
+                            container;
+                        LdapMessage      ldapMessage          =
+                            ldapMessageContainer.getLdapMessage();
+
+                        // Now, we can allocate the BindRequest Object
+                        SearchResultReference searchResultReference = new SearchResultReference();
+
+                        // As this is a new Constructed object, we have to init its length
+                        searchResultReference.setParent( ldapMessage );
+
+                        // And we associate it to the ldapMessage Object
+                        ldapMessage.setProtocolOP( searchResultReference );
+                    }
+                }  );
+
+        // LDAPURL (Tag)
+        super.transitions[LdapStatesEnum.SEARCH_RESULT_REFERENCE_LDAP_URL_TAG][0x04] = new
GrammarTransition(
+                LdapStatesEnum.SEARCH_RESULT_REFERENCE_LDAP_URL_TAG, LdapStatesEnum.SEARCH_RESULT_REFERENCE_LDAP_URL_VALUE,
+                null );
+
+        // LDAPURL loop (Tag)
+        super.transitions[LdapStatesEnum.SEARCH_RESULT_REFERENCE_LOOP_OR_END_TAG][0x04] =
new GrammarTransition(
+                LdapStatesEnum.SEARCH_RESULT_REFERENCE_LOOP_OR_END_TAG, LdapStatesEnum.SEARCH_RESULT_REFERENCE_LDAP_URL_VALUE,
+                null );
+
+        // LDAPURL (Value)
+        super.transitions[LdapStatesEnum.SEARCH_RESULT_REFERENCE_LDAP_URL_VALUE][0x04] =
new GrammarTransition(
+                LdapStatesEnum.SEARCH_RESULT_REFERENCE_LDAP_URL_VALUE,
+                LdapStatesEnum.SEARCH_RESULT_REFERENCE_LOOP_OR_END_TAG, 
+                new GrammarAction( "Store ldapUrl value" )
+                {
+                    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
+                        if ( tlv.getLength().getLength() == 0 )
+                        {
+                            searchResultReference.addSearchResultReference( LdapURL.EMPTY_STRING
);
+                        }
+                        else
+                        {
+                            searchResultReference.addSearchResultReference( new LdapURL(
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