Package com.unboundid.ldap.sdk
Class SimpleBindRequest
java.lang.Object
com.unboundid.ldap.sdk.LDAPRequest
com.unboundid.ldap.sdk.BindRequest
com.unboundid.ldap.sdk.SimpleBindRequest
- All Implemented Interfaces:
ProtocolOp,ReadOnlyLDAPRequest,Serializable
@NotMutable
@ThreadSafety(level=NOT_THREADSAFE)
public final class SimpleBindRequest
extends BindRequest
implements ProtocolOp
This class implements the processing necessary to perform an LDAPv3 simple
bind operation, which authenticates using a bind DN and password.
- See Also:
-
Field Summary
Fields inherited from class com.unboundid.ldap.sdk.BindRequest
VERSION_ELEMENT -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new simple bind request that may be used to perform an anonymous bind to the directory server (i.e., with a zero-length bind DN and a zero-length password).SimpleBindRequest(DN bindDN, byte[] password) Creates a new simple bind request with the provided bind DN and password.SimpleBindRequest(DN bindDN, byte[] password, Control... controls) Creates a new simple bind request with the provided bind DN and password.SimpleBindRequest(DN bindDN, PasswordProvider passwordProvider, Control... controls) Creates a new simple bind request with the provided bind DN and that will use a password provider in order to obtain the bind password.SimpleBindRequest(DN bindDN, String password) Creates a new simple bind request with the provided bind DN and password.SimpleBindRequest(DN bindDN, String password, Control... controls) Creates a new simple bind request with the provided bind DN and password.SimpleBindRequest(String bindDN, byte[] password) Creates a new simple bind request with the provided bind DN and password.SimpleBindRequest(String bindDN, byte[] password, Control... controls) Creates a new simple bind request with the provided bind DN and password.SimpleBindRequest(String bindDN, PasswordProvider passwordProvider, Control... controls) Creates a new simple bind request with the provided bind DN and that will use a password provider in order to obtain the bind password.SimpleBindRequest(String bindDN, String password) Creates a new simple bind request with the provided bind DN and password.SimpleBindRequest(String bindDN, String password, Control... controls) Creates a new simple bind request with the provided bind DN and password. -
Method Summary
Modifier and TypeMethodDescriptionCreates a new instance of this LDAP request that may be modified without impacting this request.Creates a new instance of this LDAP request that may be modified without impacting this request.Encodes this protocol op to an ASN.1 element suitable for inclusion in an encoded LDAP message.Retrieves the bind DN for this simple bind request.Retrieves a human-readable string that describes the type of bind request.intRetrieves the message ID for the last LDAP message sent using this request.Retrieves the password for this simple bind request, if no password provider has been configured.Retrieves the password provider for this simple bind request, if defined.byteRetrieves the BER type for this protocol op.getRebindRequest(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 BindResultprocess(LDAPConnection connection, int depth) Sends this bind request to the target server over the provided connection and returns the corresponding response.voidresponseReceived(LDAPResponse response) voidAppends a number of lines comprising the Java source code that can be used to recreate this request to the given list.voidtoString(StringBuilder buffer) Appends a string representation of this request to the provided buffer.voidwriteTo(ASN1Buffer buffer) Writes an ASN.1-encoded representation of this LDAP protocol op to the provided ASN.1 buffer.Methods inherited from class com.unboundid.ldap.sdk.BindRequest
getOperationTypeMethods inherited from class com.unboundid.ldap.sdk.LDAPRequest
followReferrals, getControl, getControlList, getControls, getIntermediateResponseListener, getReferralConnector, getReferralConnectorInternal, getReferralDepth, getResponseTimeoutMillis, hasControl, hasControl, setFollowReferrals, setIntermediateResponseListener, setReferralConnector, setReferralDepth, setResponseTimeoutMillis, toString
-
Constructor Details
-
SimpleBindRequest
public SimpleBindRequest()Creates a new simple bind request that may be used to perform an anonymous bind to the directory server (i.e., with a zero-length bind DN and a zero-length password). -
SimpleBindRequest
Creates a new simple bind request with the provided bind DN and password.- Parameters:
bindDN- The bind DN for this simple bind request.password- The password for this simple bind request.
-
SimpleBindRequest
Creates a new simple bind request with the provided bind DN and password.- Parameters:
bindDN- The bind DN for this simple bind request.password- The password for this simple bind request.
-
SimpleBindRequest
Creates a new simple bind request with the provided bind DN and password.- Parameters:
bindDN- The bind DN for this simple bind request.password- The password for this simple bind request.
-
SimpleBindRequest
Creates a new simple bind request with the provided bind DN and password.- Parameters:
bindDN- The bind DN for this simple bind request.password- The password for this simple bind request.
-
SimpleBindRequest
public SimpleBindRequest(@Nullable String bindDN, @Nullable String password, @Nullable Control... controls) Creates a new simple bind request with the provided bind DN and password.- Parameters:
bindDN- The bind DN for this simple bind request.password- The password for this simple bind request.controls- The set of controls for this simple bind request.
-
SimpleBindRequest
public SimpleBindRequest(@Nullable String bindDN, @Nullable byte[] password, @Nullable Control... controls) Creates a new simple bind request with the provided bind DN and password.- Parameters:
bindDN- The bind DN for this simple bind request.password- The password for this simple bind request.controls- The set of controls for this simple bind request.
-
SimpleBindRequest
public SimpleBindRequest(@Nullable DN bindDN, @Nullable String password, @Nullable Control... controls) Creates a new simple bind request with the provided bind DN and password.- Parameters:
bindDN- The bind DN for this simple bind request.password- The password for this simple bind request.controls- The set of controls for this simple bind request.
-
SimpleBindRequest
public SimpleBindRequest(@Nullable DN bindDN, @Nullable byte[] password, @Nullable Control... controls) Creates a new simple bind request with the provided bind DN and password.- Parameters:
bindDN- The bind DN for this simple bind request.password- The password for this simple bind request.controls- The set of controls for this simple bind request.
-
SimpleBindRequest
public SimpleBindRequest(@NotNull String bindDN, @NotNull PasswordProvider passwordProvider, @Nullable Control... controls) Creates a new simple bind request with the provided bind DN and that will use a password provider in order to obtain the bind password.- Parameters:
bindDN- The bind DN for this simple bind request. It must not benull.passwordProvider- The password provider that will be used to obtain the password for this simple bind request. It must not benull.controls- The set of controls for this simple bind request.
-
SimpleBindRequest
public SimpleBindRequest(@NotNull DN bindDN, @NotNull PasswordProvider passwordProvider, @Nullable Control... controls) Creates a new simple bind request with the provided bind DN and that will use a password provider in order to obtain the bind password.- Parameters:
bindDN- The bind DN for this simple bind request. It must not benull.passwordProvider- The password provider that will be used to obtain the password for this simple bind request. It must not benull.controls- The set of controls for this simple bind request.
-
-
Method Details
-
getBindDN
Retrieves the bind DN for this simple bind request.- Returns:
- The bind DN for this simple bind request.
-
getPassword
Retrieves the password for this simple bind request, if no password provider has been configured.- Returns:
- The password for this simple bind request, or
nullif a password provider will be used to obtain the password.
-
getPasswordProvider
Retrieves the password provider for this simple bind request, if defined.- Returns:
- The password provider for this simple bind request, or
nullif this bind request was created with an explicit password rather than a password provider.
-
getProtocolOpType
Retrieves the BER type for this protocol op.- Specified by:
getProtocolOpTypein interfaceProtocolOp- Returns:
- The BER type for this protocol op.
-
writeTo
Writes an ASN.1-encoded representation of this LDAP protocol op to the provided ASN.1 buffer. This method is intended for internal use only and should not be used by third-party code.- Specified by:
writeToin interfaceProtocolOp- Parameters:
buffer- The ASN.1 buffer to which the encoded representation should be written.
-
encodeProtocolOp
Encodes this protocol op to an ASN.1 element suitable for inclusion in an encoded LDAP message. Use of this method is only supported if the bind request was created with a static password. It is not allowed if the password will be obtained through a password provider.- Specified by:
encodeProtocolOpin interfaceProtocolOp- Returns:
- The ASN.1 element containing the encoded protocol op.
- Throws:
LDAPSDKUsageException- If this bind request was created with a password provider rather than a static password.
-
process
@NotNull protected BindResult process(@NotNull 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:
processin classBindRequest- 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.
-
getRebindRequest
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.- Overrides:
getRebindRequestin classBindRequest- 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
nullto indicate that automatic re-binding is not supported for this type of bind request.
-
responseReceived
- Throws:
LDAPException
-
getBindType
Retrieves a human-readable string that describes the type of bind request.- Specified by:
getBindTypein classBindRequest- Returns:
- A human-readable string that describes the type of bind request.
-
getLastMessageID
Retrieves the message ID for the last LDAP message sent using this request.- Specified by:
getLastMessageIDin classLDAPRequest- Returns:
- The message ID for the last LDAP message sent using this request, or -1 if it no LDAP messages have yet been sent using this request.
-
duplicate
Creates a new instance of this LDAP request that may be modified without impacting this request.- Specified by:
duplicatein interfaceReadOnlyLDAPRequest- Specified by:
duplicatein classBindRequest- Returns:
- A new instance of this LDAP request that may be modified without impacting this request.
-
duplicate
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.- Specified by:
duplicatein interfaceReadOnlyLDAPRequest- Specified by:
duplicatein classBindRequest- 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.
-
toString
Appends a string representation of this request to the provided buffer.- Specified by:
toStringin interfaceProtocolOp- Specified by:
toStringin interfaceReadOnlyLDAPRequest- Specified by:
toStringin classLDAPRequest- Parameters:
buffer- The buffer to which to append a string representation of this request.
-
toCode
public void toCode(@NotNull List<String> lineList, @NotNull String requestID, int indentSpaces, boolean includeProcessing) Appends a number of lines comprising the Java source code that can be used to recreate this request to the given list.- Specified by:
toCodein interfaceReadOnlyLDAPRequest- Parameters:
lineList- The list to which the source code lines should be added.requestID- The name that should be used as an identifier for the request. If this isnullor empty, then a generic ID will be used.indentSpaces- The number of spaces that should be used to indent the generated code. It must not be negative.includeProcessing- Indicates whether the generated code should include code required to actually process the request and handle the result (iftrue), or just to generate the request (iffalse).
-