org.apache.directory.ldap.client.api.message
Class BindRequest

java.lang.Object
  extended by org.apache.directory.ldap.client.api.message.AbstractMessage
      extended by org.apache.directory.ldap.client.api.message.AbstractRequest
          extended by org.apache.directory.ldap.client.api.message.BindRequest
All Implemented Interfaces:
AbandonableRequest, Message, Request, RequestWithResponse

public class BindRequest
extends AbstractRequest
implements RequestWithResponse, AbandonableRequest

Bind protocol operation request which authenticates and begins a client session.

Version:
$Rev$, $Date$
Author:
Apache Directory Project

Constructor Summary
BindRequest()
          Creates a new instance of BindRequest.
 
Method Summary
 byte[] getCredentials()
          Gets the simple credentials associated with a simple authentication attempt or null if this request uses SASL authentication mechanisms.
 java.lang.String getName()
          Gets the distinguished name of the subject in this authentication request.
 java.lang.String getSaslMechanism()
          Gets the SASL mechanism String associated with this BindRequest if the bind operation is using SASL.
 int getVersion()
          Gets the Ldap protocol version used.
 boolean isSimple()
          Checks to see if the authentication mechanism is simple and not SASL based.
 boolean isVersion3()
          Checks to see if the Ldap v3 protocol is used.
 BindRequest setCredentials(byte[] credentials)
          Sets the simple credentials associated with a simple authentication attempt ignored if this request uses SASL authentication mechanisms.
 BindRequest setCredentials(java.lang.String credentials)
          Sets the simple credentials associated with a simple authentication attempt ignored if this request uses SASL authentication mechanisms.
 BindRequest setName(java.lang.String name)
          Sets the distinguished name of the subject in this authentication request.
 BindRequest setSasl()
          Sets the authentication mechanism to SASL
 BindRequest setSaslMechanism(java.lang.String saslMechanism)
          Sets the SASL mechanism String associated with this BindRequest if the bind operation is using SASL.
 BindRequest setVersion(int version)
          Sets whether or not the LDAP v3 or v2 protocol is used.
 java.lang.String toString()
          Get a String representation of a BindRequest
 
Methods inherited from class org.apache.directory.ldap.client.api.message.AbstractRequest
getTimeout, setTimeout
 
Methods inherited from class org.apache.directory.ldap.client.api.message.AbstractMessage
add, getControl, getControls, getMessageId, hasControl, remove, setMessageId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.directory.ldap.client.api.message.Request
getTimeout, setTimeout
 
Methods inherited from interface org.apache.directory.ldap.client.api.message.Message
add, getControl, getControls, getMessageId, hasControl, remove, setMessageId
 

Constructor Detail

BindRequest

public BindRequest()
Creates a new instance of BindRequest.

Method Detail

getCredentials

public byte[] getCredentials()
Gets the simple credentials associated with a simple authentication attempt or null if this request uses SASL authentication mechanisms.

Returns:
null if the mechanism is SASL or the credentials if it is simple.

setCredentials

public BindRequest setCredentials(byte[] credentials)
Sets the simple credentials associated with a simple authentication attempt ignored if this request uses SASL authentication mechanisms.

Parameters:
credentials - the credentials if authentication is simple, null otherwise
Returns:
The object itself, to allow chaining

setCredentials

public BindRequest setCredentials(java.lang.String credentials)
Sets the simple credentials associated with a simple authentication attempt ignored if this request uses SASL authentication mechanisms.

Parameters:
credentials - the credentials if authentication is simple, null otherwise
Returns:
The object itself, to allow chaining

getName

public java.lang.String getName()
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 DN in the credentials.

Returns:
the DN of the authenticating user.

setName

public BindRequest setName(java.lang.String 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 DN in the credentials.

Parameters:
name - the DN of the authenticating user - leave null for annonymous user.
Returns:
The object itself, to allow chaining

getSaslMechanism

public java.lang.String getSaslMechanism()
Gets the SASL mechanism String associated with this BindRequest if the bind operation is using SASL.

Returns:
the SASL mechanism or null if the bind op is simple

setSaslMechanism

public BindRequest setSaslMechanism(java.lang.String saslMechanism)
Sets the SASL mechanism String associated with this BindRequest if the bind operation is using SASL.

Parameters:
saslMechanism - the SASL mechanism
Returns:
The object itself, to allow chaining

getVersion

public int getVersion()
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.

Returns:
3 for LdapV3, 2 for LDAPV2

setVersion

public BindRequest setVersion(int 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.

Parameters:
version - The version. Should be 3 or 2
Returns:
The object itself, to allow chaining

isSimple

public boolean isSimple()
Checks to see if the authentication mechanism is simple and not SASL based.

Returns:
true if the mechanism is simple false if it is SASL based.

isVersion3

public boolean isVersion3()
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.

Returns:
true if client using version 3 false if it is version 2.

setSasl

public BindRequest setSasl()
Sets the authentication mechanism to SASL

Returns:
The object itself, to allow chaining

toString

public java.lang.String toString()
Get a String representation of a BindRequest

Overrides:
toString in class AbstractMessage
Returns:
A BindRequest String


Copyright © 2009-2011 Apache Software Foundation. All Rights Reserved.