public interface BindRequest extends Request
Request.RequestType
Modifier and Type | Field and Description |
---|---|
static byte |
AUTHENTICATION_TYPE_SASL
The authentication type value (0xA3) reserved for SASL authentication.
|
static byte |
AUTHENTICATION_TYPE_SIMPLE
The authentication type value (0x80) reserved for simple authentication.
|
static String |
SASL_MECHANISM_NAME_ANONYMOUS
The name of the SASL mechanism that uses anonymous access and having the name "ANONYMOUS".
|
static String |
SASL_MECHANISM_NAME_CRAM_MD5
The name of the SASL mechanism that uses CRAM-MD5 authentication and having the name "CRAM-MD5".
|
static String |
SASL_MECHANISM_NAME_DIGEST_MD5
The name of the SASL mechanism that uses DIGEST-MD5 authentication and having the name "DIGEST-MD5".
|
static String |
SASL_MECHANISM_NAME_EXTERNAL
The name of the SASL mechanism that uses external authentication and having the name "EXTERNAL".
|
static String |
SASL_MECHANISM_NAME_GSSAPI
The name of the SASL mechanism that uses GSS-API authentication and having the name "GSSAPI".
|
static String |
SASL_MECHANISM_NAME_PLAIN
The name of the SASL mechanism that uses PLAIN authentication and having the name "PLAIN".
|
Modifier and Type | Method and Description |
---|---|
BindRequest |
addControl(Control control)
Adds the provided control to this protocol-op.
|
BindRequest |
addControls(Iterable<? extends Control> controls)
Adds the provided controls to this protocol-op.
|
void |
destroy()
Destroys the credentials contained within this bind request.
|
BindRequest |
evaluateSaslChallenge(byte[] serverSaslCredentials)
Evaluates the provided SASL credentials (challenge) returned by the server and creates the next SASL bind request
that should be sent to the server in order to continue or complete the SASL authentication sequence.
|
byte |
getAuthenticationType()
Returns the authentication mechanism identifier for this bind request as defined by the LDAP protocol.
|
byte[] |
getAuthenticationValue()
Returns a defensive copy of the encoded authentication value for this bind request as defined by the LDAP
protocol.
|
<C extends Control> |
getControl(ControlDecoder<C> decoder,
DecodeOptions options)
Decodes and returns the first control in this protocol-op having an OID
corresponding to the provided control decoder.
|
List<Control> |
getControls()
Returns a
List containing the controls included with this
protocol-op. |
Dn |
getName()
Returns the name of the Directory object that the client wishes to bind as.
|
SaslClient |
getSaslClient()
Returns the
SaslClient that will be responsible for continuing the SASL challenge-response sequence as
well as potentially installing a SASL security layer once the bind sequence completes, or null if a no
SaslClient has been provided. |
byte[] |
getSaslCredentials()
Returns a defensive copy of the optional SASL credentials, or
null if the authentication type is not
AUTHENTICATION_TYPE_SASL or if the SASL credentials are not present. |
String |
getSaslMechanism()
Returns the name of the SASL mechanism, e.g.
|
byte[] |
getSimplePassword()
Returns a defensive copy of the simple bind password, or
null if the authentication type is not
AUTHENTICATION_TYPE_SIMPLE . |
int |
getVersion()
Returns the version of the protocol to be used at the LDAP message layer.
|
boolean |
hasNegotiatedSaslQop()
Returns
true if the SASL bind sequence has negotiated a SASL security layer using Quality of Protection
(QOP). |
boolean |
isSaslBindRequest()
Return
true if this bind request's authentication type is AUTHENTICATION_TYPE_SASL . |
boolean |
isSimpleBindRequest()
Return
true if this bind request's authentication type is AUTHENTICATION_TYPE_SIMPLE . |
BindRequest |
setAuthenticationTypeAndValue(byte type,
byte[] value)
Sets the authentication type and value.
|
BindRequest |
setName(Dn name)
Sets the name of the Directory object that the client wishes to bind as.
|
BindRequest |
setSaslMechanismAndCredentials(SaslClient saslClient)
Configures this bind request for SASL authentication using the provided
SaslClient . |
BindRequest |
setSaslMechanismAndCredentials(String mechanism,
byte[] credentials)
Sets the authentication type to
AUTHENTICATION_TYPE_SASL , the SASL mechanism name, and the optional
SASL credentials. |
BindRequest |
setSimplePassword(byte[] password)
Sets the authentication type to
AUTHENTICATION_TYPE_SIMPLE and the authentication value to a copy of
the provided password. |
BindRequest |
setVersion(int version)
Sets the version of the protocol to be used at the LDAP message layer.
|
containsControl, getControl
static final byte AUTHENTICATION_TYPE_SIMPLE
static final byte AUTHENTICATION_TYPE_SASL
static final String SASL_MECHANISM_NAME_ANONYMOUS
static final String SASL_MECHANISM_NAME_CRAM_MD5
static final String SASL_MECHANISM_NAME_DIGEST_MD5
static final String SASL_MECHANISM_NAME_PLAIN
static final String SASL_MECHANISM_NAME_EXTERNAL
static final String SASL_MECHANISM_NAME_GSSAPI
int getVersion()
ResultCode.PROTOCOL_ERROR
.
By default LDAP version 3 will be used which is the most recent LDAP version and the one recommended for all client applications. Furthermore, OpenDJ only has partial support for LDAPv2.
BindRequest setVersion(int version)
ResultCode.PROTOCOL_ERROR
.
By default LDAP version 3 will be used which is the most recent LDAP version and the one recommended for all client applications. Furthermore, OpenDJ only has partial support for LDAPv2.
version
- The version of the protocol to be used at the LDAP message layer.IllegalArgumentException
- If version
is less than 1 or greater than 127.UnsupportedOperationException
- If this bind request does not permit the version to be set.Dn getName()
null
) when used for anonymous binds, or when using SASL authentication. The server shall not dereference
any aliases in locating the named object.
The LDAP protocol defines the Bind name to be a distinguished name, however some LDAP implementations have relaxed this constraint and allow other identities to be used, such as the user's email address.
null
.BindRequest setName(Dn name)
null
when used for of anonymous binds, or when using SASL authentication. The server shall not dereference any
aliases in locating the named object.
The LDAP protocol defines the Bind name to be a distinguished name, however some LDAP implementations have relaxed this constraint and allow other identities to be used, such as the user's email address.
name
- The name of the Directory object that the client wishes to bind as. May be empty, but cannot be null
.UnsupportedOperationException
- If this bind request does not permit the distinguished name to be set.NullPointerException
- If name
was null
.byte getAuthenticationType()
AUTHENTICATION_TYPE_SIMPLE
(0x80
) is reserved for simple authentication and
the value AUTHENTICATION_TYPE_SASL
( 0xA3
) is reserved for SASL authentication.boolean isSimpleBindRequest()
true
if this bind request's authentication type is AUTHENTICATION_TYPE_SIMPLE
.true
if this bind request's authentication type is AUTHENTICATION_TYPE_SIMPLE
.boolean isSaslBindRequest()
true
if this bind request's authentication type is AUTHENTICATION_TYPE_SASL
.true
if this bind request's authentication type is AUTHENTICATION_TYPE_SASL
.byte[] getAuthenticationValue()
BindRequest setAuthenticationTypeAndValue(byte type, byte[] value) throws IOException
type
is equal to AUTHENTICATION_TYPE_SIMPLE
then
the value will be interpreted as the password. If type
is equal to AUTHENTICATION_TYPE_SASL
then the value will be interpreted as the encoded SASL mechanism and credentials. Otherwise, the value will be
interpreted as an unrecognized extended authentication value.type
- The authentication mechanism identifier.value
- The encoded authentication value for this bind request as defined by the LDAP protocol, which may be an
empty array but must not be null
. The value will be defensively copied.IOException
- If the authentication type is AUTHENTICATION_TYPE_SASL
and the value could not be decoded as an
encoded SASL mechanism and credentials.UnsupportedOperationException
- If this bind request does not permit the authentication type or value to be set.NullPointerException
- If value
was null
.byte[] getSimplePassword()
null
if the authentication type is not
AUTHENTICATION_TYPE_SIMPLE
.null
if the authentication type is not AUTHENTICATION_TYPE_SIMPLE
.BindRequest setSimplePassword(byte[] password)
AUTHENTICATION_TYPE_SIMPLE
and the authentication value to a copy of
the provided password.password
- The non-null
simple bind password, which will be defensively copied.UnsupportedOperationException
- If this bind request does not permit the authentication type or value to be set.NullPointerException
- If password
was null
.String getSaslMechanism()
SASL_MECHANISM_NAME_PLAIN
, or null
if the
authentication type is not AUTHENTICATION_TYPE_SASL
.SASL_MECHANISM_NAME_PLAIN
, or null
if the
authentication type is not AUTHENTICATION_TYPE_SASL
.byte[] getSaslCredentials()
null
if the authentication type is not
AUTHENTICATION_TYPE_SASL
or if the SASL credentials are not present.null
if the authentication type is not
AUTHENTICATION_TYPE_SASL
or if the SASL credentials are not present.SaslClient getSaslClient()
SaslClient
that will be responsible for continuing the SASL challenge-response sequence as
well as potentially installing a SASL security layer once the bind sequence completes, or null
if a no
SaslClient
has been provided.
A SaslClient
is only required if the application is performing SASL authentication and wishes the network
layer (e.g. Grizzly) to drive the complete challenge-response sequence. An application may choose to drive the
SASL bind sequence itself, but the application:
SaslClient
that will be responsible for continuing the SASL challenge-response sequence, as
well as potentially installing a SASL security layer once the bind sequence completes, or null
if none
has been provided.setSaslMechanismAndCredentials(SaslClient)
BindRequest setSaslMechanismAndCredentials(String mechanism, byte[] credentials)
AUTHENTICATION_TYPE_SASL
, the SASL mechanism name, and the optional
SASL credentials.mechanism
- The SASL mechanism name, such as SASL_MECHANISM_NAME_PLAIN
.credentials
- The optional SASL credentials which will be defensively copied if provided.UnsupportedOperationException
- If this bind request does not permit the authentication type or value to be set.NullPointerException
- If mechanism
was null
.BindRequest setSaslMechanismAndCredentials(SaslClient saslClient)
SaslClient
. The authentication
type will be set to AUTHENTICATION_TYPE_SASL
, the SASL mechanism name will be obtained from the SaslClient
, and the SASL credentials will be derived from the SaslClient
if it has an initial response,
otherwise they will be left undefined.
This method should be used if the application is performing SASL authentication and wishes the network layer (e.g. Grizzly) to drive the complete challenge-response sequence. An application may choose to drive the SASL bind sequence itself, but the application a) will not be able to control where bind requests are sent if load-balancing is active, b) nor will it be able to install a security layer upon completion of the bind sequence if one is negotiated.
saslClient
- The SaslClient
that will be responsible for continuing the SASL challenge-response sequence, as
well as potentially installing a SASL security layer once the bind sequence completes.IllegalArgumentException
- If the provided SASL client has not been configured correctly.UnsupportedOperationException
- If this bind request does not permit the SaslClient
to be set.NullPointerException
- If saslClient
was null
.BindRequest evaluateSaslChallenge(byte[] serverSaslCredentials) throws SaslException
SaslClient
.serverSaslCredentials
- The non-null
SASL challenge sent from the server, which may be empty.null
if the SASL bind sequence has
completed.SaslException
- If an error occurred while evaluating the challenge or generating a response.IllegalStateException
- If this bind request has not been configured to use a SaslClient
.NullPointerException
- If serverSaslCredentials
was null
.setSaslMechanismAndCredentials(SaslClient)
boolean hasNegotiatedSaslQop()
true
if the SASL bind sequence has negotiated a SASL security layer using Quality of Protection
(QOP). This method may only be called if this request has been configured to use a SaslClient
and the
SASL bind sequence has completed (the previous call to evaluateSaslChallenge(byte[])
returned null
).true
if the SASL bind sequence has negotiated a SASL security layer (QOP).IllegalStateException
- If this bind request has not been configured to use a SaslClient
or the SASL bind sequence has
not completed.setSaslMechanismAndCredentials(SaslClient)
BindRequest addControl(Control control)
ProtocolOp
addControl
in interface ProtocolOp
addControl
in interface Request
control
- The control to be added to this protocol-op.BindRequest addControls(Iterable<? extends Control> controls)
ProtocolOp
addControls
in interface ProtocolOp
addControls
in interface Request
controls
- The controls to be added to this protocol-op.<C extends Control> C getControl(ControlDecoder<C> decoder, DecodeOptions options) throws DecodeException
ProtocolOp
getControl
in interface ProtocolOp
C
- The type of control to be decoded and returned.decoder
- The control decoder.options
- The set of decode options which should be used when decoding
the control.null
if the control is not
included with this protocol-op.DecodeException
- If the control could not be decoded because it was malformed in some way
(e.g. the control value was missing, or its content could not be decoded).List<Control> getControls()
ProtocolOp
List
containing the controls included with this
protocol-op. The returned List
may be modified if permitted by this
protocol-op.getControls
in interface ProtocolOp
List
containing the controls.void destroy()
SaslClient
. Instead the underlying network layer will dispose of the SaslClient
when it is no longer
in use. This bind request can no longer be used once this method returns.Copyright 2010-2022 ForgeRock AS.