com.unboundid.ldap.sdk
Class BindRequest

java.lang.Object
  extended by com.unboundid.ldap.sdk.LDAPRequest
      extended by com.unboundid.ldap.sdk.BindRequest
All Implemented Interfaces:
ReadOnlyLDAPRequest, java.io.Serializable
Direct Known Subclasses:
SASLBindRequest, SimpleBindRequest

@Extensible
@ThreadSafety(level=NOT_THREADSAFE)
public abstract class BindRequest
extends LDAPRequest

This class provides an API that is used to represent an LDAP bind request. It should be extended by subclasses that provide the logic for processing specific types of bind operations (e.g., simple binds, and the various SASL mechanisms).

It is strongly recommended that all bind request types which implement the rebind capability be made immutable. If this is not done, then changes made to a bind request object may alter the authentication/authorization identity and/or credentials associated with that request so that a rebind request created from it will not match the original request used to authenticate on a connection. Note, however, that it is not threadsafe to use the same BindRequest object to attempt to bind concurrently over multiple connections.

Note that even though this class is marked with the @Extensible annotation type, it should not be directly subclassed by third-party code. Only the SASLBindRequest subclass is actually intended to be extended by third-party code.

See Also:
Serialized Form

Field Summary
protected static ASN1Integer VERSION_ELEMENT
          The pre-encoded ASN.1 element used to represent the protocol version.
 
Constructor Summary
protected BindRequest(Control[] controls)
          Creates a new bind request with the provided set of controls.
 
Method Summary
abstract  BindRequest duplicate()
          Creates a new instance of this LDAP request that may be modified without impacting this request.
abstract  BindRequest duplicate(Control[] controls)
          Creates a new instance of this LDAP request that may be modified without impacting this request.
abstract  java.lang.String getBindType()
          Retrieves a human-readable string that describes the type of bind request.
 OperationType getOperationType()
          Retrieves the type of operation that is represented by this request.
 BindRequest getRebindRequest(java.lang.String host, int port)
          Retrieves a bind request that may be used to re-bind using the same credentials authentication type and credentials as previously used to perform the initial bind.
protected abstract  BindResult process(LDAPConnection connection, int depth)
          Sends this bind request to the target server over the provided connection and returns the corresponding response.
 
Methods inherited from class com.unboundid.ldap.sdk.LDAPRequest
followReferrals, getControl, getControlList, getControls, getIntermediateResponseListener, getLastMessageID, getResponseTimeoutMillis, hasControl, hasControl, setFollowReferrals, setIntermediateResponseListener, setResponseTimeoutMillis, toString, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.unboundid.ldap.sdk.ReadOnlyLDAPRequest
toCode
 

Field Detail

VERSION_ELEMENT

protected static final ASN1Integer VERSION_ELEMENT
The pre-encoded ASN.1 element used to represent the protocol version.

Constructor Detail

BindRequest

protected BindRequest(Control[] controls)
Creates a new bind request with the provided set of controls.

Parameters:
controls - The set of controls to include in this bind request.
Method Detail

process

protected abstract BindResult process(LDAPConnection connection,
                                      int depth)
                               throws LDAPException
Sends this bind request to the target server over the provided connection and returns the corresponding response.

Specified by:
process in class LDAPRequest
Parameters:
connection - The connection to use to send this bind request to the server and read the associated response.
depth - The current referral depth for this request. It should always be one for the initial request, and should only be incremented when following referrals.
Returns:
The bind response read from the server.
Throws:
LDAPException - If a problem occurs while sending the request or reading the response.

getOperationType

public final OperationType getOperationType()
Retrieves the type of operation that is represented by this request.

Specified by:
getOperationType in class LDAPRequest
Returns:
The type of operation that is represented by this request.

getBindType

public abstract java.lang.String getBindType()
Retrieves a human-readable string that describes the type of bind request.

Returns:
A human-readable string that describes the type of bind request.

duplicate

public abstract BindRequest duplicate()
Creates a new instance of this LDAP request that may be modified without impacting this request.

Returns:
A new instance of this LDAP request that may be modified without impacting this request.

duplicate

public abstract BindRequest duplicate(Control[] controls)
Creates a new instance of this LDAP request that may be modified without impacting this request. The provided controls will be used for the new request instead of duplicating the controls from this request.

Parameters:
controls - The set of controls to include in the duplicate request.
Returns:
A new instance of this LDAP request that may be modified without impacting this request.

getRebindRequest

public BindRequest getRebindRequest(java.lang.String host,
                                    int port)
Retrieves a bind request that may be used to re-bind using the same credentials authentication type and credentials as previously used to perform the initial bind. This may be used in an attempt to automatically re-establish a connection that is lost, or potentially when following a referral to another directory instance.

It is recommended that all bind request types which implement this capability be implemented so that the elements needed to create a new request are immutable. If this is not done, then changes made to a bind request object may alter the authentication/authorization identity and/or credentials associated with that request so that a rebind request created from it will not match the original request used to authenticate on a connection.

Parameters:
host - The address of the directory server to which the connection is established.
port - The port of the directory server to which the connection is established.
Returns:
A bind request that may be used to re-bind using the same authentication type and credentials as previously used to perform the initial bind, or null to indicate that automatic re-binding is not supported for this type of bind request.