You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2010/01/23 19:50:00 UTC
svn commit: r902460 [2/3] - in
/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory:
ldap/ ldap/client/ ldap/client/api/ ldap/client/api/exception/
ldap/client/api/future/ ldap/client/api/listener/ ldap/client/api/message/
l...
Added: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/AbstractResponseWithResult.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/AbstractResponseWithResult.java?rev=902460&view=auto
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/AbstractResponseWithResult.java (added)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/AbstractResponseWithResult.java Sat Jan 23 18:49:54 2010
@@ -0,0 +1,84 @@
+/*
+ * 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.ldap.client.api.message;
+
+
+/**
+ * A request who's one or more responses contains an LdapResult.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 760984 $
+ */
+public abstract class AbstractResponseWithResult extends AbstractMessage implements ResponseWithResult
+{
+ /** The result */
+ private LdapResult ldapResult;
+
+ /**
+ * Creates a new instance of AbstractResponseWithResult.
+ *
+ public AbstractResponseWithResult()
+ {
+ super();
+ }
+
+
+ /**
+ * Returns the response's result
+ *
+ * @return a result containing response with defaults and the messageId set
+ * in response to this specific request
+ */
+ public LdapResult getLdapResult()
+ {
+ return ldapResult;
+ }
+
+
+ /**
+ * Sets the result into the response.
+ *
+ * @param ldapResult The LdapResult instance associated with this response
+ */
+ public void setLdapResult( LdapResult ldapResult )
+ {
+ this.ldapResult = ldapResult;
+ }
+
+
+ /**
+ * Get a String representation of an Response
+ *
+ * @return An Response String
+ */
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( super.toString() );
+
+ if ( ldapResult != null )
+ {
+ sb.append( ldapResult );
+ }
+
+ return sb.toString();
+ }
+}
Added: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/AddRequest.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/AddRequest.java?rev=902460&view=auto
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/AddRequest.java (added)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/AddRequest.java Sat Jan 23 18:49:54 2010
@@ -0,0 +1,50 @@
+/*
+ * 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.ldap.client.api.message;
+
+
+import org.apache.directory.shared.ldap.entry.Entry;
+
+
+/**
+ * Class for representing client's add operation request.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class AddRequest extends AbstractRequest implements RequestWithResponse, AbandonableRequest
+{
+ /** the entry to be added */
+ private Entry entry;
+
+
+ public AddRequest( Entry entry )
+ {
+ this.entry = entry;
+ }
+
+
+ public Entry getEntry()
+ {
+ return entry;
+ }
+
+}
Added: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/AddResponse.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/AddResponse.java?rev=902460&view=auto
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/AddResponse.java (added)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/AddResponse.java Sat Jan 23 18:49:54 2010
@@ -0,0 +1,35 @@
+/*
+ * 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.ldap.client.api.message;
+
+/**
+ * Response object for add operation
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class AddResponse extends AbstractResponseWithResult
+{
+ public AddResponse()
+ {
+ super();
+ }
+}
Added: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/BindRequest.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/BindRequest.java?rev=902460&view=auto
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/BindRequest.java (added)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/BindRequest.java Sat Jan 23 18:49:54 2010
@@ -0,0 +1,279 @@
+/*
+ * 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.ldap.client.api.message;
+
+import org.apache.directory.shared.ldap.util.StringTools;
+
+
+/**
+ *
+ * Bind protocol operation request which authenticates and begins a client
+ * session.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class BindRequest extends AbstractRequest implements RequestWithResponse, AbandonableRequest
+{
+ /**
+ * 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;
+
+
+ /**
+ * Creates a new instance of BindRequest.
+ */
+ public BindRequest()
+ {
+ super();
+ }
+
+
+ /**
+ * 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.
+ */
+ public byte[] getCredentials()
+ {
+ return credentials;
+ }
+
+
+ /**
+ * 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
+ * @return The object itself, to allow chaining
+ */
+ public BindRequest setCredentials( byte[] credentials )
+ {
+ this.credentials = credentials;
+
+ return this;
+ }
+
+
+ /**
+ * 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
+ * @return The object itself, to allow chaining
+ */
+ public BindRequest setCredentials( String credentials )
+ {
+ this.credentials = StringTools.getBytesUtf8( credentials );
+
+ return this;
+ }
+
+
+ /**
+ * 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.
+ */
+ public String getName()
+ {
+ return name;
+ }
+
+
+ /**
+ * 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.
+ * @return The object itself, to allow chaining
+ */
+ public BindRequest setName( String name )
+ {
+ this.name = name;
+
+ return this;
+ }
+
+
+ /**
+ * 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
+ */
+ public String getSaslMechanism()
+ {
+ return saslMechanism;
+ }
+
+
+ /**
+ * Sets the SASL mechanism String associated with this BindRequest if the
+ * bind operation is using SASL.
+ *
+ * @param saslMechanism the SASL mechanism
+ * @return The object itself, to allow chaining
+ */
+ public BindRequest setSaslMechanism( String saslMechanism )
+ {
+ this.saslMechanism = saslMechanism;
+
+ return this;
+ }
+
+
+ /**
+ * 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
+ */
+ public int getVersion()
+ {
+ return version;
+ }
+
+
+ /**
+ * 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
+ * @return The object itself, to allow chaining
+ */
+ public BindRequest setVersion( int version )
+ {
+ this.version = version;
+
+ return this;
+ }
+
+
+ /**
+ * 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.
+ */
+ public boolean isSimple()
+ {
+ return isSimple;
+ }
+
+
+ /**
+ * 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.
+ */
+ public boolean isVersion3()
+ {
+ return version == 3;
+ }
+
+
+ /**
+ * Sets the authentication mechanism to SASL
+ * @return The object itself, to allow chaining
+ */
+ public BindRequest setSasl()
+ {
+ isSimple = false;
+
+ return this;
+ }
+
+
+ /**
+ * Get a String representation of a BindRequest
+ *
+ * @return A BindRequest String
+ */
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer();
+
+ sb.append( super.toString() );
+ sb.append( " BindRequest\n" );
+ sb.append( " Version : '" ).append( version ).append( "'\n" );
+
+ if ( ( null == name ) || StringTools.isEmpty( name.toString() ) )
+ {
+ sb.append( " Name : anonymous\n" );
+ }
+ else
+ {
+ sb.append( " Name : '" ).append( name ).append( "'\n" );
+
+ if ( isSimple )
+ {
+ sb.append( " Simple authentication : '" ).append( StringTools.utf8ToString( credentials ) ).append( "'\n" );
+ }
+ else
+ {
+ sb.append( " Sasl authentication : \n" );
+ sb.append( " mechanism : '" ).append( saslMechanism ).append( "'\n" );
+ sb.append( " credentials : '" ).append( StringTools.utf8ToString( credentials ) ).append( "'\n" );
+ }
+ }
+
+ return sb.toString();
+ }
+}
Added: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/BindResponse.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/BindResponse.java?rev=902460&view=auto
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/BindResponse.java (added)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/BindResponse.java Sat Jan 23 18:49:54 2010
@@ -0,0 +1,91 @@
+/*
+ * 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.ldap.client.api.message;
+
+import org.apache.directory.shared.ldap.util.StringTools;
+
+
+/**
+ * Bind protocol response message used to confirm the results of a bind request
+ * message. BindResponse consists simply of an indication from the server of the
+ * status of the client's request for authentication.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class BindResponse extends AbstractResponseWithResult
+{
+ /** optional property holding SASL authentication response parameters */
+ private byte[] credentials;
+
+
+ /**
+ * Creates a new instance of BindResponseImpl.
+ */
+ public BindResponse()
+ {
+ super();
+ }
+
+
+ /**
+ * Gets the optional property holding SASL authentication response parameters
+ * that are SASL mechanism specific. Will return null if the authentication
+ * is simple.
+ *
+ * @return the sasl mech. specific credentials or null of auth. is simple
+ */
+ public byte[] getServerSaslCreds()
+ {
+ return credentials;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setServerSaslCreds( byte[] credentials )
+ {
+ this.credentials = credentials;
+ }
+
+
+ /**
+ * Get a String representation of a BindResponse
+ *
+ * @return A BindResponse String
+ */
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer();
+
+ sb.append( super.toString() );
+ sb.append( " BindResponse\n" );
+
+ if ( credentials != null )
+ {
+ sb.append( " Server sasl credentials : '" ).
+ append( StringTools.utf8ToString( credentials ) ).
+ append( "'\n" );
+ }
+
+ return sb.toString();
+ }
+}
Added: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/CompareRequest.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/CompareRequest.java?rev=902460&view=auto
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/CompareRequest.java (added)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/CompareRequest.java Sat Jan 23 18:49:54 2010
@@ -0,0 +1,72 @@
+/*
+ * 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.ldap.client.api.message;
+
+
+import org.apache.directory.shared.ldap.name.LdapDN;
+
+
+/**
+ * Class for representing client's compare operation request.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class CompareRequest extends AbstractRequest implements RequestWithResponse, AbandonableRequest
+{
+ /** the target entry's DN */
+ private LdapDN entryDn;
+
+ private String attrName;
+
+ private Object value;
+
+ public LdapDN getEntryDn()
+ {
+ return entryDn;
+ }
+
+ public void setEntryDn( LdapDN dn )
+ {
+ this.entryDn = dn;
+ }
+
+ public String getAttrName()
+ {
+ return attrName;
+ }
+
+ public void setAttrName( String attrName )
+ {
+ this.attrName = attrName;
+ }
+
+ public Object getValue()
+ {
+ return value;
+ }
+
+ public void setValue( Object attrValue )
+ {
+ this.value = attrValue;
+ }
+
+}
Added: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/CompareResponse.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/CompareResponse.java?rev=902460&view=auto
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/CompareResponse.java (added)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/CompareResponse.java Sat Jan 23 18:49:54 2010
@@ -0,0 +1,45 @@
+/*
+ * 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.ldap.client.api.message;
+
+
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+
+
+/**
+ * Response object for compare operation
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class CompareResponse extends AbstractResponseWithResult
+{
+ public CompareResponse()
+ {
+ super();
+ }
+
+
+ public boolean isTrue()
+ {
+ return super.getLdapResult().getResultCode() == ResultCodeEnum.COMPARE_TRUE;
+ }
+}
Added: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/DeleteRequest.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/DeleteRequest.java?rev=902460&view=auto
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/DeleteRequest.java (added)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/DeleteRequest.java Sat Jan 23 18:49:54 2010
@@ -0,0 +1,65 @@
+/*
+ * 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.ldap.client.api.message;
+
+
+import org.apache.directory.shared.ldap.name.LdapDN;
+
+
+/**
+ * Class for representing the client's delete operation request.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class DeleteRequest extends AbstractRequest implements RequestWithResponse, AbandonableRequest
+{
+ /** the DN to be deleted */
+ private LdapDN targetDn;
+
+ /** flag to tell whether to delete all the children under the target DN */
+ private boolean deleteChildren;
+
+
+ public DeleteRequest( LdapDN targetDn )
+ {
+ super();
+ this.targetDn = targetDn;
+ }
+
+
+ public boolean isDeleteChildren()
+ {
+ return deleteChildren;
+ }
+
+
+ public void setDeleteChildren( boolean deleteChildren )
+ {
+ this.deleteChildren = deleteChildren;
+ }
+
+
+ public LdapDN getTargetDn()
+ {
+ return targetDn;
+ }
+}
Added: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/DeleteResponse.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/DeleteResponse.java?rev=902460&view=auto
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/DeleteResponse.java (added)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/DeleteResponse.java Sat Jan 23 18:49:54 2010
@@ -0,0 +1,35 @@
+/*
+ * 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.ldap.client.api.message;
+
+/**
+ * Client side response for delete operation
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class DeleteResponse extends AbstractResponseWithResult
+{
+ public DeleteResponse()
+ {
+ super();
+ }
+}
Added: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/ExtendedRequest.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/ExtendedRequest.java?rev=902460&view=auto
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/ExtendedRequest.java (added)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/ExtendedRequest.java Sat Jan 23 18:49:54 2010
@@ -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.ldap.client.api.message;
+
+
+import org.apache.directory.shared.asn1.codec.DecoderException;
+import org.apache.directory.shared.asn1.primitives.OID;
+import org.apache.directory.shared.ldap.util.StringTools;
+
+
+/**
+ * Class for representing client's extended operation request.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ExtendedRequest extends AbstractRequest implements RequestWithResponse, AbandonableRequest
+{
+ /** requested extended operation's OID (a.k.a request name) */
+ private OID oid;
+
+ /** requested extended operation's value (a.k.a request value) */
+ private byte[] value;
+
+
+ public ExtendedRequest( String oid )
+ {
+ try
+ {
+ this.oid = new OID( oid );
+ }
+ catch ( DecoderException e )
+ {
+ throw new IllegalArgumentException( e );
+ }
+ }
+
+
+ public ExtendedRequest( OID oid )
+ {
+ this.oid = oid;
+ }
+
+
+ public byte[] getValue()
+ {
+ return value;
+ }
+
+
+ public void setValue( String value )
+ {
+ this.value = StringTools.getBytesUtf8( value );
+ }
+
+
+ public void setValue( byte[] value )
+ {
+ this.value = value;
+ }
+
+
+ public OID getOid()
+ {
+ return oid;
+ }
+}
Added: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/ExtendedResponse.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/ExtendedResponse.java?rev=902460&view=auto
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/ExtendedResponse.java (added)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/ExtendedResponse.java Sat Jan 23 18:49:54 2010
@@ -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.ldap.client.api.message;
+
+import org.apache.directory.shared.asn1.codec.DecoderException;
+import org.apache.directory.shared.asn1.primitives.OID;
+
+
+/**
+ * Response object for extended operation
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ExtendedResponse extends AbstractResponseWithResult
+{
+ /** extended operation response OID */
+ private OID oid;
+
+ /** extended operation response value */
+ private Object value;
+
+ public ExtendedResponse()
+ {
+ }
+
+ public ExtendedResponse( String oid )
+ {
+ super();
+ try
+ {
+ this.oid = new OID( oid );
+ }
+ catch ( DecoderException e )
+ {
+ throw new IllegalArgumentException( e );
+ }
+ }
+
+
+ public ExtendedResponse( OID oid )
+ {
+ super();
+ this.oid = oid;
+ }
+
+
+ public Object getValue()
+ {
+ return value;
+ }
+
+
+ public void setValue( Object value )
+ {
+ this.value = value;
+ }
+
+
+ public void setOid( OID oid )
+ {
+ this.oid = oid;
+ }
+
+ public OID getOid()
+ {
+ return oid;
+ }
+}
Added: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/IntermediateResponse.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/IntermediateResponse.java?rev=902460&view=auto
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/IntermediateResponse.java (added)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/IntermediateResponse.java Sat Jan 23 18:49:54 2010
@@ -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.ldap.client.api.message;
+
+
+/**
+ * An class Intermediate responses.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class IntermediateResponse extends AbstractMessage
+{
+ /** The Response OID */
+ private String responseName;
+
+ /** The response value */
+ private byte[] responseValue;
+
+ /**
+ * Creates a new instance of IntermediateResponseImpl.
+ */
+ public IntermediateResponse()
+ {
+ super();
+ }
+
+
+ /**
+ * Get the original response OID.
+ *
+ * @return The response OID
+ */
+ public String getResponseName()
+ {
+ return responseName;
+ }
+
+
+ /**
+ * Sets the original response OID
+ *
+ * @param responseName The response OID
+ */
+ public void setResponseName( String responseName )
+ {
+ this.responseName = responseName;
+ }
+
+
+ /**
+ * Get the associated response value
+ *
+ * @return The response value
+ */
+ public byte[] getResponseValue()
+ {
+ return responseValue;
+ }
+
+
+ /**
+ * Sets the response's value
+ *
+ * @param responseValue The associated response's value
+ */
+ public void setResponseValue( byte[] responseValue )
+ {
+ this.responseValue = responseValue;
+ }
+}
Added: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/LdapResult.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/LdapResult.java?rev=902460&view=auto
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/LdapResult.java (added)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/LdapResult.java Sat Jan 23 18:49:54 2010
@@ -0,0 +1,173 @@
+/*
+ * 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.ldap.client.api.message;
+
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+
+/**
+ * LDAPv3 result structure embedded into Responses. See section 4.1.10 in <a
+ * href="">RFC 2251</a> for a description of the LDAPResult ASN.1 structure,
+ * here's a snippet from it:
+ *
+ * <pre>
+ * The LDAPResult is the construct used in this protocol to return
+ * success or failure indications from servers to clients. In response
+ * to various requests servers will return responses containing fields
+ * of type LDAPResult to indicate the final status of a protocol
+ * operation request.
+ * </pre>
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Revision: 760984 $
+ */
+public class LdapResult
+{
+ /** Lowest matched entry Dn - defaults to empty string */
+ private String matchedDn;
+
+ /** Referral associated with this LdapResult if the errorCode is REFERRAL */
+ private Referral referral;
+
+ /** Decriptive error message - defaults to empty string */
+ private String errorMessage;
+
+ /** Resultant operation error code - defaults to SUCCESS */
+ private ResultCodeEnum resultCode = ResultCodeEnum.SUCCESS;
+
+
+ /**
+ * Gets the descriptive error message associated with the error code. May be
+ * null for SUCCESS, COMPARETRUE, COMPAREFALSE and REFERRAL operations.
+ *
+ * @return the descriptive error message.
+ */
+ public String getErrorMessage()
+ {
+ return errorMessage;
+ }
+
+
+ /**
+ * Sets the descriptive error message associated with the error code. May be
+ * null for SUCCESS, COMPARETRUE, and COMPAREFALSE operations.
+ *
+ * @param errorMessage the descriptive error message.
+ */
+ public void setErrorMessage( String errorMessage )
+ {
+ this.errorMessage = errorMessage;
+ }
+
+
+ /**
+ * Gets the lowest entry in the directory that was matched. For result codes
+ * of noSuchObject, aliasProblem, invalidDNSyntax and
+ * aliasDereferencingProblem, the matchedDN field is set to the name of the
+ * lowest entry (object or alias) in the directory that was matched. If no
+ * aliases were dereferenced while attempting to locate the entry, this will
+ * be a truncated form of the name provided, or if aliases were
+ * dereferenced, of the resulting name, as defined in section 12.5 of X.511
+ * [8]. The matchedDN field is to be set to a zero length string with all
+ * other result codes.
+ *
+ * @return the Dn of the lowest matched entry.
+ */
+ public String getMatchedDn()
+ {
+ return matchedDn;
+ }
+
+
+ /**
+ * Sets the lowest entry in the directory that was matched.
+ *
+ * @see #getMatchedDn()
+ * @param dn the Dn of the lowest matched entry.
+ */
+ public void setMatchedDn( String matchedDn )
+ {
+ this.matchedDn = matchedDn;
+ }
+
+
+ /**
+ * Gets the result code enumeration associated with the response.
+ * Corresponds to the <b> resultCode </b> field within the LDAPResult ASN.1
+ * structure.
+ *
+ * @return the result code enum value.
+ */
+ public ResultCodeEnum getResultCode()
+ {
+ return resultCode;
+ }
+
+
+ /**
+ * Sets the result code enumeration associated with the response.
+ * Corresponds to the <b> resultCode </b> field within the LDAPResult ASN.1
+ * structure.
+ *
+ * @param resultCode the result code enum value.
+ */
+ public void setResultCode( ResultCodeEnum resultCode )
+ {
+ this.resultCode = resultCode;
+ }
+
+
+ /**
+ * Gets the Referral associated with this LdapResult if the resultCode
+ * property is set to the REFERRAL ResultCodeEnum.
+ *
+ * @return the referral on REFERRAL errors, null on all others.
+ */
+ public Referral getReferral()
+ {
+ return referral;
+ }
+
+
+ /**
+ * Gets whether or not this result represents a Referral. For referrals the
+ * error code is set to REFERRAL and the referral property is not null.
+ *
+ * @return true if this result represents a referral.
+ */
+ public boolean isReferral()
+ {
+ return referral != null;
+ }
+
+
+ /**
+ * Sets the Referral associated with this LdapResult if the resultCode
+ * property is set to the REFERRAL ResultCodeEnum. Setting this property
+ * will result in a true return from isReferral and the resultCode should be
+ * set to REFERRAL.
+ *
+ * @param referral optional referral on REFERRAL errors.
+ */
+ public void setReferral( Referral referral )
+ {
+ this.referral = referral;
+ }
+}
Added: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/Message.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/Message.java?rev=902460&view=auto
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/Message.java (added)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/Message.java Sat Jan 23 18:49:54 2010
@@ -0,0 +1,95 @@
+/*
+ * 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.ldap.client.api.message;
+
+
+import java.util.Map;
+
+import org.apache.directory.ldap.client.api.exception.LdapException;
+import org.apache.directory.ldap.client.api.message.control.Control;
+
+
+/**
+ * Root interface for all LDAP message type interfaces.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public interface Message
+{
+ /**
+ * Get the request messageId
+ *
+ * @return The request message ID
+ */
+ int getMessageId();
+
+
+ /**
+ * Set the request message ID
+ *
+ * @param messageId The request message ID
+ */
+ void setMessageId( int messageId );
+
+
+ /**
+ * Gets the controls associated with this message mapped by OID.
+ *
+ * @return Map of OID strings to Control object instances.
+ * @see Control
+ */
+ Map<String, Control> getControls();
+
+
+ /**
+ * Gets the control with a specific OID.
+ *
+ * @return The Control with the specified OID
+ * @see Control
+ */
+ Control getControl( String oid );
+
+
+ /**
+ * Checks whether or not this message has the specified control.
+ *
+ * @param oid the OID of the control
+ * @return true if this message has the control, false if it does not
+ */
+ boolean hasControl( String oid );
+
+
+ /**
+ * Adds controls to this Message.
+ *
+ * @param controls the controls to add.
+ */
+ Message add( Control... controls );
+
+
+ /**
+ * Deletes controls, removing them from this Message.
+ *
+ * @param controls the controls to remove.
+ * @throws LdapException if controls cannot be added to this Message
+ * or the control is not known etc.
+ */
+ Message remove( Control... control ) throws LdapException;
+}
Added: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/ModifyDnRequest.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/ModifyDnRequest.java?rev=902460&view=auto
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/ModifyDnRequest.java (added)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/ModifyDnRequest.java Sat Jan 23 18:49:54 2010
@@ -0,0 +1,103 @@
+/*
+ * 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.ldap.client.api.message;
+
+
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.name.RDN;
+
+
+/**
+ * Class for representing client's modifyDn operation request.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ModifyDnRequest extends AbstractRequest implements RequestWithResponse, AbandonableRequest
+{
+ /** the entry's DN to be changed */
+ private LdapDN entryDn;
+
+ /** the new RDN */
+ private RDN newRdn;
+
+ /** target entry's new parent DN */
+ private LdapDN newSuperior;
+
+ /** flag to indicate whether to delete the old RDN */
+ private boolean deleteOldRdn = false;
+
+
+ public ModifyDnRequest()
+ {
+ super();
+ }
+
+
+ public LdapDN getEntryDn()
+ {
+ return entryDn;
+ }
+
+
+ public void setEntryDn( LdapDN entryDn )
+ {
+ this.entryDn = entryDn;
+ }
+
+
+ public RDN getNewRdn()
+ {
+ return newRdn;
+ }
+
+
+ public void setNewRdn( RDN newRdn )
+ {
+ this.newRdn = newRdn;
+ }
+
+
+ public LdapDN getNewSuperior()
+ {
+ return newSuperior;
+ }
+
+
+ public void setNewSuperior( LdapDN newSuperior )
+ {
+ this.newSuperior = newSuperior;
+ }
+
+
+ public boolean isDeleteOldRdn()
+ {
+ return deleteOldRdn;
+ }
+
+
+ public void setDeleteOldRdn( boolean deleteOldRdn )
+ {
+ this.deleteOldRdn = deleteOldRdn;
+ }
+
+
+}
Added: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/ModifyDnResponse.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/ModifyDnResponse.java?rev=902460&view=auto
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/ModifyDnResponse.java (added)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/ModifyDnResponse.java Sat Jan 23 18:49:54 2010
@@ -0,0 +1,35 @@
+/*
+ * 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.ldap.client.api.message;
+
+/**
+ * Client side response object for modifyDn operation.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ModifyDnResponse extends AbstractResponseWithResult
+{
+ public ModifyDnResponse()
+ {
+ super();
+ }
+}
Added: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/ModifyRequest.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/ModifyRequest.java?rev=902460&view=auto
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/ModifyRequest.java (added)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/ModifyRequest.java Sat Jan 23 18:49:54 2010
@@ -0,0 +1,205 @@
+/*
+ * 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.ldap.client.api.message;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.Modification;
+import org.apache.directory.shared.ldap.entry.ModificationOperation;
+import org.apache.directory.shared.ldap.entry.client.ClientModification;
+import org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute;
+import org.apache.directory.shared.ldap.name.LdapDN;
+
+
+/**
+ * ModificationRequest for performing modify operation.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ModifyRequest extends AbstractRequest implements RequestWithResponse, AbandonableRequest
+{
+ /** DN of the target Entry to be modified */
+ private LdapDN dn;
+
+ /** modifications list */
+ private List<Modification> mods = new ArrayList<Modification>();
+
+
+ /**
+ *
+ * Creates a new instance of ModifyRequest.
+ *
+ * @param dn DN of the Entry to be modified
+ */
+ public ModifyRequest( LdapDN dn )
+ {
+ super();
+ this.dn = dn;
+ }
+
+
+ /**
+ *
+ * marks a given attribute for addition in the target entry with the
+ * given values.
+ *
+ * @param attributeName name of the attribute to be added
+ * @param attributeValue values of the attribute
+ */
+ public void add( String attributeName, String... attributeValue )
+ {
+ addModification( ModificationOperation.ADD_ATTRIBUTE, attributeName, attributeValue );
+ }
+
+
+ /**
+ * @see #add(String, String...)
+ */
+ public void add( String attributeName, byte[]... attributeValue )
+ {
+ addModification( ModificationOperation.ADD_ATTRIBUTE, attributeName, attributeValue );
+ }
+
+
+ /**
+ *
+ * marks a given attribute for addition in the target entry.
+ *
+ * @param attr the attribute to be added
+ */
+ public void add( EntryAttribute attr )
+ {
+ addModification( attr, ModificationOperation.ADD_ATTRIBUTE );
+ }
+
+
+ /**
+ *
+ * marks a given attribute for replacement with the given
+ * values in the target entry.
+ *
+ * @param attributeName name of the attribute to be added
+ * @param attributeValue values of the attribute
+ */
+ public void replace( String attributeName, String... attributeValue )
+ {
+ addModification( ModificationOperation.REPLACE_ATTRIBUTE, attributeName, attributeValue );
+ }
+
+
+ /**
+ * @see #remove(String, String...)
+ */
+ public void replace( String attributeName, byte[]... attributeValue )
+ {
+ addModification( ModificationOperation.REPLACE_ATTRIBUTE, attributeName, attributeValue );
+ }
+
+
+ /**
+ *
+ * marks a given attribute for replacement in the target entry.
+ *
+ * @param attr the attribute to be added
+ */
+ public void replace( EntryAttribute attr )
+ {
+ addModification( attr, ModificationOperation.REPLACE_ATTRIBUTE );
+ }
+
+
+ /**
+ *
+ * marks a given attribute for removal with the given
+ * values from the target entry.
+ *
+ * @param attributeName name of the attribute to be added
+ * @param attributeValue values of the attribute
+ */
+ public void remove( String attributeName, String... attributeValue )
+ {
+ addModification( ModificationOperation.REMOVE_ATTRIBUTE, attributeName, attributeValue );
+ }
+
+
+ /**
+ * @see #remove(String, String...)
+ */
+ public void remove( String attributeName, byte[]... attributeValue )
+ {
+ addModification( ModificationOperation.REMOVE_ATTRIBUTE, attributeName, attributeValue );
+ }
+
+
+ /**
+ *
+ * marks a given attribute for removal from the target entry.
+ *
+ * @param attr the attribute to be added
+ */
+ public void remove( EntryAttribute attr )
+ {
+ addModification( attr, ModificationOperation.REMOVE_ATTRIBUTE );
+ }
+
+
+ private void addModification( ModificationOperation modOp, String attributeName, String... attributeValue )
+ {
+ EntryAttribute attr = new DefaultClientAttribute( attributeName, attributeValue );
+ addModification( attr, modOp );
+ }
+
+
+ private void addModification( ModificationOperation modOp, String attributeName, byte[]... attributeValue )
+ {
+ EntryAttribute attr = new DefaultClientAttribute( attributeName, attributeValue );
+ addModification( attr, modOp );
+ }
+
+
+ public void addModification( EntryAttribute attr, ModificationOperation modOp )
+ {
+ mods.add( new ClientModification( modOp, attr ) );
+ }
+
+
+ /**
+ * @return the target entry's DN
+ */
+ public LdapDN getDn()
+ {
+ return dn;
+ }
+
+
+ /**
+ * @return the list of modifications
+ */
+ public List<Modification> getMods()
+ {
+ return mods;
+ }
+
+}
Added: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/ModifyResponse.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/ModifyResponse.java?rev=902460&view=auto
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/ModifyResponse.java (added)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/ModifyResponse.java Sat Jan 23 18:49:54 2010
@@ -0,0 +1,36 @@
+/*
+ * 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.ldap.client.api.message;
+
+
+/**
+ * Modify operation's response.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ModifyResponse extends AbstractResponseWithResult
+{
+ public ModifyResponse()
+ {
+ super();
+ }
+}
Added: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/Referral.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/Referral.java?rev=902460&view=auto
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/Referral.java (added)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/Referral.java Sat Jan 23 18:49:54 2010
@@ -0,0 +1,239 @@
+/*
+ * 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.ldap.client.api.message;
+
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.directory.shared.ldap.codec.util.LdapURLEncodingException;
+import org.apache.directory.shared.ldap.util.LdapURL;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Represents a referral which is a set of alternative locations where an entry
+ * can be found. Here's what <a href="http://www.faqs.org/rfcs/rfc2251.html">
+ * RFC 2251 </a> has to say about it:
+ *
+ * <pre>
+ * 4.1.11. Referral
+ *
+ * The referral error indicates that the contacted server does not hold
+ * the target entry of the request. The referral field is present in an
+ * LDAPResult if the LDAPResult.resultCode field value is referral, and
+ * absent with all other result codes. It contains a reference to
+ * another server (or set of servers) which may be accessed via LDAP or
+ * other protocols. Referrals can be returned in response to any
+ * operation request (except unbind and abandon which do not have
+ * responses). At least one URL MUST be present in the Referral.
+ *
+ * The referral is not returned for a singleLevel or wholeSubtree search
+ * in which the search scope spans multiple naming contexts, and several
+ * different servers would need to be contacted to complete the
+ * operation. Instead, continuation references, described in section
+ * 4.5.3, are returned.
+ *
+ * Referral ::= SEQUENCE OF LDAPURL -- one or more
+ *
+ * LDAPURL ::= LDAPString -- limited to characters permitted in URLs
+ *
+ * If the client wishes to progress the operation, it MUST follow the
+ * referral by contacting any one of servers. All the URLs MUST be
+ * equally capable of being used to progress the operation. (The
+ * mechanisms for how this is achieved by multiple servers are outside
+ * the scope of this document.)
+ *
+ * URLs for servers implementing the LDAP protocol are written according
+ * to <a href="http://www.faqs.org/rfcs/rfc2255.html">[9]</a>. If an alias
+ * was dereferenced, the <dn> part of the URL MUST be present, with the new
+ * target object name. If the <dn> part is present, the client MUST use this
+ * name in its next request to progress the operation, and if it is not present
+ * the client will use the same name as in the original request. Some servers
+ * (e.g. participating in distributed indexing) may provide a different filter
+ * in a referral for a search operation. If the filter part of the URL
+ * is present in an LDAPURL, the client MUST use this filter in its next
+ * request to progress this search, and if it is not present the client
+ * MUST use the same filter as it used for that search. Other aspects
+ * of the new request may be the same or different as the request which
+ * generated the referral.
+ *
+ * Note that UTF-8 characters appearing in a DN or search filter may not
+ * be legal for URLs (e.g. spaces) and MUST be escaped using the %
+ * method in RFC 1738 <a href="http://www.faqs.org/rfcs/rfc1738.html">[7]</a>.
+ *
+ * Other kinds of URLs may be returned, so long as the operation could
+ * be performed using that protocol.
+ * </pre>
+ *
+ * @author <a href="mailto:dev@directory.apache.org"> Apache Directory Project</a>
+ * @version $Rev: 761643 $
+ * TODO This interface should be located in a url package under common to be
+ * constructed from a LDAPv3 URL parser. The interface will eventually
+ * look very different once url support is added: for one it will add and
+ * remove LdapUrl objects instead of strings or provide both string and
+ * LdapUrl add/remove methods.
+ */
+public class Referral
+{
+ /** The logger */
+ static final Logger LOG = LoggerFactory.getLogger( Referral.class );
+
+ /** The list of LDAPUrls */
+ private List<LdapURL> referrals;
+
+ /**
+ * Gets an unmodifiable set of alternative referral urls.
+ *
+ * @return the alternative url objects.
+ */
+ public Collection<String> getLdapUrls()
+ {
+ if ( referrals == null )
+ {
+ return new ArrayList<String>();
+ }
+
+ List<String> urls = new ArrayList<String>( referrals.size() );
+
+ for ( LdapURL referral:referrals )
+ {
+ urls.add( referral.toString() );
+ }
+
+ return urls;
+ }
+
+
+ /**
+ * Adds an LDAPv3 URL to this Referral.
+ *
+ * @param urls the LDAPv3 URLs to add
+ */
+ public void addLdapUrls( String... urls )
+ {
+ if ( ( urls == null ) || ( urls.length == 0 ) )
+ {
+ return;
+ }
+
+ if ( referrals == null )
+ {
+ referrals = new ArrayList<LdapURL>( urls.length );
+ }
+
+ for ( String url:urls )
+ {
+ try
+ {
+ LdapURL ldapUrl = new LdapURL( url );
+
+ referrals.add( ldapUrl );
+ }
+ catch ( LdapURLEncodingException luee )
+ {
+ LOG.warn( "The given URL '{}' is invalid", url );
+ }
+ }
+ }
+
+
+ /**
+ * Adds an LDAPv3 URL to this Referral.
+ *
+ * @param urls the LDAPv3 URLs to add
+ */
+ public void addLdapUrls( LdapURL... urls )
+ {
+ if ( ( urls == null ) || ( urls.length == 0 ) )
+ {
+ return;
+ }
+
+ if ( referrals == null )
+ {
+ referrals = new ArrayList<LdapURL>( urls.length );
+ }
+
+ for ( LdapURL url:urls )
+ {
+ referrals.add( url );
+ }
+ }
+
+
+ /**
+ * Removes an LDAPv3 URL to this Referral.
+ *
+ * @param urls the LDAPv3 URLs to remove
+ */
+ public void removeLdapUrl( String... urls )
+ {
+ if ( ( urls == null ) || ( urls.length == 0 ) )
+ {
+ return;
+ }
+
+ if ( ( referrals == null ) || ( referrals.size() == 0 ) )
+ {
+ return;
+ }
+
+ for ( String url:urls )
+ {
+ try
+ {
+ LdapURL ldapUrl = new LdapURL( url );
+
+ referrals.remove( ldapUrl );
+ }
+ catch ( LdapURLEncodingException luee )
+ {
+ LOG.warn( "The given URL '{}' is invalid", url );
+ }
+ }
+ }
+
+
+ /**
+ * Removes an LDAPv3 URL to this Referral.
+ *
+ * @param urls the LDAPv3 URLs to remove
+ */
+ public void removeLdapUrl( LdapURL... urls )
+ {
+ if ( ( urls == null ) || ( urls.length == 0 ) )
+ {
+ return;
+ }
+
+ if ( ( referrals == null ) || ( referrals.size() == 0 ) )
+ {
+ return;
+ }
+
+ for ( LdapURL url:urls )
+ {
+ referrals.remove( url );
+ }
+ }
+}
Added: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/Request.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/Request.java?rev=902460&view=auto
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/Request.java (added)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/Request.java Sat Jan 23 18:49:54 2010
@@ -0,0 +1,47 @@
+/*
+ * 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.ldap.client.api.message;
+
+
+/**
+ * Ldap protocol request messages derive from this super interface.
+ *
+ * @author <a href="mailto:dev@directory.apache.org"> Apache Directory Project</a>
+ * @version $Rev: 760984 $
+ */
+public interface Request extends Message
+{
+ /**
+ * Get the client message timeout. When the timeout is reached, the
+ * request is canceled.
+ *
+ * @return The timeout
+ */
+ long getTimeout();
+
+
+ /**
+ * Set a request client timeout. When this timeout is reached, the request
+ * will be canceled. If <= 0, then we wait for the response forever.
+ *
+ * @param timeout The new timeout, expressed in milliseconds
+ */
+ Message setTimeout( long timeout );
+}
Added: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/RequestWithResponse.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/RequestWithResponse.java?rev=902460&view=auto
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/RequestWithResponse.java (added)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/RequestWithResponse.java Sat Jan 23 18:49:54 2010
@@ -0,0 +1,30 @@
+/*
+ * 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.ldap.client.api.message;
+
+
+/**
+ * An interface used to indicate that a Request has a response.
+ *
+ * @author <a href="mailto:dev@directory.apache.org"> Apache Directory Project</a>
+ */
+public interface RequestWithResponse extends Request
+{
+}
Added: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/Response.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/Response.java?rev=902460&view=auto
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/Response.java (added)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/Response.java Sat Jan 23 18:49:54 2010
@@ -0,0 +1,30 @@
+/*
+ * 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.ldap.client.api.message;
+
+
+/**
+ * Super interface used as a marker for all protocol response type messages.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public interface Response extends Message
+{
+}
Added: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/ResponseWithResult.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/ResponseWithResult.java?rev=902460&view=auto
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/ResponseWithResult.java (added)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/ResponseWithResult.java Sat Jan 23 18:49:54 2010
@@ -0,0 +1,46 @@
+/*
+ * 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.ldap.client.api.message;
+
+
+/**
+ * A request who's one or more responses contains an LdapResult.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 760984 $
+ */
+public interface ResponseWithResult extends Response
+{
+ /**
+ * Returns the response's result
+ *
+ * @return a result containing response with defaults and the messageId set
+ * in response to this specific request
+ */
+ LdapResult getLdapResult();
+
+
+ /**
+ * Sets the result into the response.
+ *
+ * @param ldapResult The LdapResult instance associated with this response
+ */
+ void setLdapResult( LdapResult ldapResult );
+}
Added: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/SearchRequest.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/SearchRequest.java?rev=902460&view=auto
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/SearchRequest.java (added)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/SearchRequest.java Sat Jan 23 18:49:54 2010
@@ -0,0 +1,330 @@
+/*
+ * 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.ldap.client.api.message;
+
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.directory.shared.ldap.filter.SearchScope;
+import org.apache.directory.shared.ldap.message.AliasDerefMode;
+
+
+/**
+ * Search request protocol message interface.
+ *
+ * @author <a href="mailto:dev@directory.apache.org"> Apache Directory Project</a>
+ * @version $Rev: 760724 $
+ */
+public class SearchRequest extends AbstractRequest implements AbandonableRequest, RequestWithResponse
+{
+ /** Search base distinguished name */
+ private String baseDn;
+
+ /** Search filter expression tree's root node */
+ private String filter;
+
+ /** Search scope enumeration value */
+ private SearchScope scope;
+
+ /** Types only return flag */
+ private boolean typesOnly;
+
+ /** Max size in entries to return */
+ private int sizeLimit;
+
+ /** Max seconds to wait for search to complete */
+ private int timeLimit;
+
+ /** Alias dereferencing mode enumeration value, default is set to "always" */
+ private AliasDerefMode aliasDerefMode = AliasDerefMode.DEREF_ALWAYS;
+
+ /** Attributes to return */
+ private Set<String> attributes = new HashSet<String>();
+
+
+ /**
+ *
+ * Creates a new instance of SearchRequestImpl.
+ *
+ * @param messageId The message ID
+ */
+ public SearchRequest()
+ {
+ super();
+ }
+
+
+ // ------------------------------------------------------------------------
+ // SearchRequest Interface Method Implementations
+ // ------------------------------------------------------------------------
+ /**
+ * Gets a list of the attributes to be returned from each entry which
+ * matches the search filter. There are two special values which may be
+ * used: an empty list with no attributes, and the attribute description
+ * string "*". Both of these signify that all user attributes are to be
+ * returned. (The "*" allows the client to request all user attributes in
+ * addition to specific operational attributes). Attributes MUST be named at
+ * most once in the list, and are returned at most once in an entry. If
+ * there are attribute descriptions in the list which are not recognized,
+ * they are ignored by the server. If the client does not want any
+ * attributes returned, it can specify a list containing only the attribute
+ * with OID "1.1". This OID was chosen arbitrarily and does not correspond
+ * to any attribute in use. Client implementors should note that even if all
+ * user attributes are requested, some attributes of the entry may not be
+ * included in search results due to access control or other restrictions.
+ * Furthermore, servers will not return operational attributes, such as
+ * objectClasses or attributeTypes, unless they are listed by name, since
+ * there may be extremely large number of values for certain operational
+ * attributes.
+ *
+ * @return the attributes to return for this request
+ */
+ public Set<String> getAttributes()
+ {
+ return attributes;
+ }
+
+
+ /**
+ * Gets the search base as a distinguished name.
+ *
+ * @return the search base
+ */
+ public String getBaseDn()
+ {
+ return baseDn;
+ }
+
+
+ /**
+ * Sets the search base as a distinguished name.
+ *
+ * @param baseDn the search base
+ */
+ public void setBaseDn( String baseDn )
+ {
+ this.baseDn = baseDn;
+ }
+
+
+ /**
+ * Gets the alias handling parameter.
+ *
+ * @return the alias handling parameter enumeration.
+ */
+ public AliasDerefMode getDerefAliases()
+ {
+ return aliasDerefMode;
+ }
+
+
+ /**
+ * Sets the alias handling parameter.
+ *
+ * @param aliasDerefAliases the alias handling parameter enumeration.
+ */
+ public void setDerefAliases( AliasDerefMode aliasDerefAliases )
+ {
+ this.aliasDerefMode = aliasDerefAliases;
+ }
+
+
+ /**
+ * Gets the search filter associated with this search request.
+ *
+ * @return the expression node for the root of the filter expression tree.
+ */
+ public String getFilter()
+ {
+ return filter;
+ }
+
+
+ /**
+ * Sets the search filter associated with this search request.
+ *
+ * @param filter the expression node for the root of the filter
+ * expression tree.
+ */
+ public void setFilter( String filter )
+ {
+ this.filter = filter;
+ }
+
+
+ /**
+ * Gets the search scope parameter enumeration.
+ *
+ * @return the scope enumeration parameter.
+ */
+ public SearchScope getScope()
+ {
+ return scope;
+ }
+
+
+ /**
+ * Sets the search scope parameter enumeration.
+ *
+ * @param scope the scope enumeration parameter.
+ */
+ public void setScope( SearchScope scope )
+ {
+ this.scope = scope;
+ }
+
+
+ /**
+ * A sizelimit that restricts the maximum number of entries to be returned
+ * as a result of the search. A value of 0 in this field indicates that no
+ * client-requested sizelimit restrictions are in effect for the search.
+ * Servers may enforce a maximum number of entries to return.
+ *
+ * @return search size limit.
+ */
+ public int getSizeLimit()
+ {
+ return sizeLimit;
+ }
+
+
+ /**
+ * Sets sizelimit that restricts the maximum number of entries to be
+ * returned as a result of the search. A value of 0 in this field indicates
+ * that no client-requested sizelimit restrictions are in effect for the
+ * search. Servers may enforce a maximum number of entries to return.
+ *
+ * @param entriesMax maximum search result entries to return.
+ */
+ public void setSizeLimit( int entriesMax )
+ {
+ sizeLimit = entriesMax;
+ }
+
+
+ /**
+ * Gets the timelimit that restricts the maximum time (in seconds) allowed
+ * for a search. A value of 0 in this field indicates that no client-
+ * requested timelimit restrictions are in effect for the search.
+ *
+ * @return the search time limit in seconds.
+ */
+ public int getTimeLimit()
+ {
+ return timeLimit;
+ }
+
+
+ /**
+ * Sets the timelimit that restricts the maximum time (in seconds) allowed
+ * for a search. A value of 0 in this field indicates that no client-
+ * requested timelimit restrictions are in effect for the search.
+ *
+ * @param secondsMax the search time limit in seconds.
+ */
+ public void setTimeLimit( int secondsMax )
+ {
+ timeLimit = secondsMax;
+ }
+
+
+ /**
+ * An indicator as to whether search results will contain both attribute
+ * types and values, or just attribute types. Setting this field to TRUE
+ * causes only attribute types (no values) to be returned. Setting this
+ * field to FALSE causes both attribute types and values to be returned.
+ *
+ * @return true for only types, false for types and values.
+ */
+ public boolean getTypesOnly()
+ {
+ return typesOnly;
+ }
+
+
+ /**
+ * An indicator as to whether search results will contain both attribute
+ * types and values, or just attribute types. Setting this field to TRUE
+ * causes only attribute types (no values) to be returned. Setting this
+ * field to FALSE causes both attribute types and values to be returned.
+ *
+ * @param typesOnly
+ * true for only types, false for types and values.
+ */
+ public void setTypesOnly( boolean typesOnly )
+ {
+ this.typesOnly = typesOnly;
+ }
+
+
+ /**
+ * Adds attributes to the set of entry attributes to return.
+ *
+ * @param attributes the attributes description or identifier.
+ * @return The object itself, to allow chaining
+ */
+ public SearchRequest addAttributes( String... attributes )
+ {
+ if ( ( attributes == null ) || ( attributes.length == 0 ) )
+ {
+ return this;
+ }
+
+ if ( this.attributes == null )
+ {
+ this.attributes = new HashSet<String>( attributes.length );
+ }
+
+ for ( String attribute:attributes )
+ {
+ this.attributes.add( attribute );
+ }
+
+ return this;
+ }
+
+
+ /**
+ * Removes attributes to the set of entry attributes to return.
+ *
+ * @param attributes the attributes description or identifier.
+ * @return The object itself, to allow chaining
+ */
+ public SearchRequest removeAttributes( String... attributes )
+ {
+ if ( ( attributes == null ) || ( attributes.length == 0 ) )
+ {
+ return this;
+ }
+
+ if ( this.attributes == null )
+ {
+ this.attributes = new HashSet<String>( attributes.length );
+ }
+
+ for ( String attribute:attributes )
+ {
+ this.attributes.remove( attribute );
+ }
+
+ return this;
+ }
+}