directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r760556 - in /directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api: exception/ listeners/ messages/
Date Tue, 31 Mar 2009 18:07:20 GMT
Author: elecharny
Date: Tue Mar 31 18:07:19 2009
New Revision: 760556

URL: http://svn.apache.org/viewvc?rev=760556&view=rev
Log:
Added some new classes to manage client requests

Added:
    directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/exception/
    directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/exception/InvalidConnectionException.java
    directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/listeners/
    directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/listeners/BindListener.java
    directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/listeners/SearchListener.java
      - copied, changed from r760265, directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/SearchListener.java
    directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/BindRequest.java
    directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/BindRequestImpl.java

Added: directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/exception/InvalidConnectionException.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/exception/InvalidConnectionException.java?rev=760556&view=auto
==============================================================================
--- directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/exception/InvalidConnectionException.java
(added)
+++ directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/exception/InvalidConnectionException.java
Tue Mar 31 18:07:19 2009
@@ -0,0 +1,43 @@
+/*
+ *  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.client.api.exception;
+
+
+/**
+ * A InvalidConnectionException is thrown if one tries to apply an operation
+ * on a closed connection
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class InvalidConnectionException extends Exception
+{
+    static final long serialVersionUID = 1L;
+
+
+    public InvalidConnectionException()
+    {
+        super();
+    }
+
+
+    public InvalidConnectionException(String explanation)
+    {
+        super( explanation );
+    }
+}

Added: directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/listeners/BindListener.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/listeners/BindListener.java?rev=760556&view=auto
==============================================================================
--- directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/listeners/BindListener.java
(added)
+++ directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/listeners/BindListener.java
Tue Mar 31 18:07:19 2009
@@ -0,0 +1,42 @@
+/*
+ *  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.client.api.listeners;
+
+import org.apache.directory.shared.ldap.client.api.LdapConnection;
+import org.apache.directory.shared.ldap.codec.bind.BindResponse;
+
+/**
+ * A listener used for asynchronous bind handling. When wanting to handle
+ * bind as a non-blocking operation, simply associate a BindListener
+ * to the bind operation : When the bind as been completed this listener
+ * will be called. 
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface BindListener
+{
+    /**
+     * A callback method called when the bind operation completed.
+     *
+     * @param BindResponse The bind response
+     */
+    void bindCompleted( LdapConnection connection, BindResponse bindResponse );
+}

Copied: directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/listeners/SearchListener.java
(from r760265, directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/SearchListener.java)
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/listeners/SearchListener.java?p2=directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/listeners/SearchListener.java&p1=directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/SearchListener.java&r1=760265&r2=760556&rev=760556&view=diff
==============================================================================
--- directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/SearchListener.java
(original)
+++ directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/listeners/SearchListener.java
Tue Mar 31 18:07:19 2009
@@ -17,9 +17,12 @@
  *  under the License. 
  *  
  */
-package org.apache.directory.shared.ldap.client.api;
+package org.apache.directory.shared.ldap.client.api.listeners;
 
-import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.client.api.LdapConnection;
+import org.apache.directory.shared.ldap.codec.LdapResponse;
+import org.apache.directory.shared.ldap.codec.search.SearchResultEntry;
+import org.apache.directory.shared.ldap.codec.search.SearchResultReference;
 
 /**
  * A listener used for asynchronous search handling. When wanting to handle
@@ -35,12 +38,21 @@
     /**
      * A callback method for each entry returned by a search operation.
      *
-     * @param entry The found entry
+     * @param searchResultEntry The found entry
      */
-    void resultReturned( Entry entry );
+    void entryFound( LdapConnection connection, SearchResultEntry searchResultEntry );
+    
+    
+    /**
+     * A callback method for each referral returned by a search operation.
+     *
+     * @param referrals The referral message
+     */
+    void referralFound( LdapConnection connection, SearchResultReference referrals );
+
     
     /**
      * A callback method called when the search is done.
      */
-    void searchDone();
+    void searchDone( LdapConnection connection, LdapResponse searchDone );
 }

Added: directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/BindRequest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/BindRequest.java?rev=760556&view=auto
==============================================================================
--- directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/BindRequest.java
(added)
+++ directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/BindRequest.java
Tue Mar 31 18:07:19 2009
@@ -0,0 +1,148 @@
+/*
+ *  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.client.api.messages;
+
+/**
+ * Bind protocol operation request which authenticates and begins a client
+ * session.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public interface BindRequest extends Message
+{
+    /**
+     * Checks to see if the authentication mechanism is simple and not SASL
+     * based.
+     * 
+     * @return true if the mechanism is simple false if it is SASL based.
+     */
+    boolean isSimple();
+
+
+    /**
+     * Sets the authentication mechanism to SASL
+     */
+    void setSasl();
+
+
+    /**
+     * Gets the simple credentials associated with a simple authentication
+     * attempt or null if this request uses SASL authentication mechanisms.
+     * 
+     * @return null if the mechanism is SASL or the credentials if it is simple.
+     */
+    byte[] getCredentials();
+
+
+    /**
+     * Sets the simple credentials associated with a simple authentication
+     * attempt ignored if this request uses SASL authentication mechanisms.
+     * 
+     * @param credentials
+     *            the credentials if authentication is simple, null otherwise
+     */
+    void setCredentials( byte[] credentials );
+
+
+    /**
+     * Gets the distinguished name of the subject in this authentication
+     * request. This field may take on a null value (a zero length string) for
+     * the purposes of anonymous binds, when authentication has been performed
+     * at a lower layer, or when using SASL credentials with a mechanism that
+     * includes the LDAPDN in the credentials.
+     * 
+     * @return the DN of the authenticating user.
+     */
+    String getName();
+
+
+    /**
+     * Sets the distinguished name of the subject in this authentication
+     * request. This field may take on a null value (or a zero length string)
+     * for the purposes of anonymous binds, when authentication has been
+     * performed at a lower layer, or when using SASL credentials with a
+     * mechanism that includes the LDAPDN in the credentials.
+     * 
+     * @param name the DN of the authenticating user - leave null for annonymous
+     * user.
+     */
+    void setName( String name );
+
+
+    /**
+     * Checks to see if the Ldap v3 protocol is used. Normally this would
+     * extract a version number from the bind request sent by the client
+     * indicating the version of the protocol to be used in this protocol
+     * session. The integer is either a 2 or a 3 at the moment. We thought it
+     * was better to just check if the protocol used is 3 or not rather than use
+     * an type-safe enumeration type for a binary value. If an LDAPv4 comes out
+     * then we shall convert the return type to a type safe enumeration.
+     * 
+     * @return true if client using version 3 false if it is version 2.
+     */
+    boolean isVersion3();
+
+
+    /**
+     * Gets the Ldap protocol version used. Normally this would
+     * extract a version number from the bind request sent by the client
+     * indicating the version of the protocol to be used in this protocol
+     * session. The integer is either a 2 or a 3 at the moment. We thought it
+     * was better to just check if the protocol used is 3 or not rather than use
+     * an type-safe enumeration type for a binary value. If an LDAPv4 comes out
+     * then we shall convert the return type to a type safe enumeration.
+     * 
+     * @return 3 for LdapV3, 2 for LDAPV2
+     */
+    int getVersion();
+
+
+    /**
+     * Sets whether or not the LDAP v3 or v2 protocol is used. Normally this
+     * would extract a version number from the bind request sent by the client
+     * indicating the version of the protocol to be used in this protocol
+     * session. The integer is either a 2 or a 3 at the moment. We thought it
+     * was better to just check if the protocol used is 3 or not rather than use
+     * an type-safe enumeration type for a binary value. If an LDAPv4 comes out
+     * then we shall convert the return type to a type safe enumeration.
+     * 
+     * @param version The version. Should be 3 or 2
+     */
+    void setVersion( int version );
+
+
+    /**
+     * Gets the SASL mechanism String associated with this BindRequest if the
+     * bind operation is using SASL.
+     * 
+     * @return the SASL mechanism or null if the bind op is simple
+     */
+    String getSaslMechanism();
+
+
+    /**
+     * Sets the SASL mechanism String associated with this BindRequest if the
+     * bind operation is using SASL.
+     * 
+     * @param saslMechanism
+     *            the SASL mechanism
+     */
+    void setSaslMechanism( String saslMechanism );
+}

Added: directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/BindRequestImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/BindRequestImpl.java?rev=760556&view=auto
==============================================================================
--- directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/BindRequestImpl.java
(added)
+++ directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/messages/BindRequestImpl.java
Tue Mar 31 18:07:19 2009
@@ -0,0 +1,246 @@
+/*
+ *  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.client.api.messages;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.naming.ldap.Control;
+
+import org.apache.directory.shared.ldap.message.MessageException;
+
+/**
+ * A client implementation of the client BindRequest LDAP message.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class BindRequestImpl implements BindRequest
+{
+    /**
+     * Distinguished name identifying the name of the authenticating subject -
+     * defaults to the empty string
+     */
+    private String name;
+    
+    /** The passwords, keys or tickets used to verify user identity */
+    private byte[] credentials;
+    
+    /** The mechanism used to decode user identity */
+    private String saslMechanism;
+    
+    /** Simple vs. SASL authentication mode flag */
+    private boolean isSimple = true;
+
+    /** Returns the protocol version */
+    private int version = 3;
+    
+    /** The set of controls */
+    private Map<String, Control> controls;
+    
+    /** The client request timeout */
+    private int timeout = 0;
+
+
+    /**
+     * Creates a new instance of BindRequestImpl.
+     */
+    public BindRequestImpl()
+    {
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public byte[] getCredentials()
+    {
+        return credentials;
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public String getName()
+    {
+        return name;
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public String getSaslMechanism()
+    {
+        return saslMechanism;
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public int getVersion()
+    {
+        return version;
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isSimple()
+    {
+        return isSimple;
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isVersion3()
+    {
+        return version == 3;
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public void setCredentials( byte[] credentials )
+    {
+        this.credentials = credentials;
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+    
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setSasl()
+    {
+        isSimple = false;
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public void setSaslMechanism( String saslMechanism )
+    {
+        this.saslMechanism = saslMechanism;
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public void setVersion( int version )
+    {
+        this.version = version;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void add( Control control ) throws MessageException
+    {
+        if ( controls == null )
+        {
+            controls = new HashMap<String, Control>();
+        }
+        
+        controls.put( control.getID(), control );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void addAll( Control[] controls ) throws MessageException
+    {
+        if ( controls == null )
+        {
+            this.controls = new HashMap<String, Control>();
+        }
+        
+        for ( Control control:controls )
+        {
+            this.controls.put( control.getID(), control );
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public Map<String, Control> getControls()
+    {
+        return controls;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public int getTimeout()
+    {
+        return timeout;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean hasControl( String oid )
+    {
+        return ( controls != null ) && ( controls.size() > 0 );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void remove( Control control ) throws MessageException
+    {
+        if ( controls != null )
+        {
+            controls.remove( control.getID() );
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setTimeout( int timeout )
+    {
+        this.timeout = timeout;
+    }
+}



Mime
View raw message