Package com.unboundid.ldap.sdk
Class DIGESTMD5BindRequest
java.lang.Object
com.unboundid.ldap.sdk.LDAPRequest
com.unboundid.ldap.sdk.BindRequest
com.unboundid.ldap.sdk.SASLBindRequest
com.unboundid.ldap.sdk.DIGESTMD5BindRequest
- All Implemented Interfaces:
ReadOnlyLDAPRequest,Serializable,CallbackHandler
@NotMutable
@ThreadSafety(level=NOT_THREADSAFE)
public final class DIGESTMD5BindRequest
extends SASLBindRequest
implements CallbackHandler
This class provides a SASL DIGEST-MD5 bind request implementation as
described in RFC 2831. The
DIGEST-MD5 mechanism can be used to authenticate over an insecure channel
without exposing the credentials (although it requires that the server have
access to the clear-text password). It is similar to CRAM-MD5, but provides
better security by combining random data from both the client and the server,
and allows for greater security and functionality, including the ability to
specify an alternate authorization identity and the ability to use data
integrity or confidentiality protection.
Elements included in a DIGEST-MD5 bind request include:
Elements included in a DIGEST-MD5 bind request include:
- Authentication ID -- A string which identifies the user that is attempting to authenticate. It should be an "authzId" value as described in section 5.2.1.8 of RFC 4513. That is, it should be either "dn:" followed by the distinguished name of the target user, or "u:" followed by the username. If the "u:" form is used, then the mechanism used to resolve the provided username to an entry may vary from server to server.
- Authorization ID -- An optional string which specifies an alternate authorization identity that should be used for subsequent operations requested on the connection. Like the authentication ID, the authorization ID should use the "authzId" syntax.
- Realm -- An optional string which specifies the realm into which the user should authenticate.
- Password -- The clear-text password for the target user.
Example
The following example demonstrates the process for performing a DIGEST-MD5 bind against a directory server with a username of "john.doe" and a password of "password":
DIGESTMD5BindRequest bindRequest =
new DIGESTMD5BindRequest("u:john.doe", "password");
BindResult bindResult;
try
{
bindResult = connection.bind(bindRequest);
// If we get here, then the bind was successful.
}
catch (LDAPException le)
{
// The bind failed for some reason.
bindResult = new BindResult(le.toLDAPResult());
ResultCode resultCode = le.getResultCode();
String errorMessageFromServer = le.getDiagnosticMessage();
}
- See Also:
-
Field Summary
FieldsFields inherited from class com.unboundid.ldap.sdk.SASLBindRequest
CRED_TYPE_SASLFields inherited from class com.unboundid.ldap.sdk.BindRequest
VERSION_ELEMENT -
Constructor Summary
ConstructorsConstructorDescriptionDIGESTMD5BindRequest(DIGESTMD5BindRequestProperties properties, Control... controls) Creates a new SASL DIGEST-MD5 bind request with the provided set of properties.DIGESTMD5BindRequest(String authenticationID, byte[] password) Creates a new SASL DIGEST-MD5 bind request with the provided authentication ID and password.DIGESTMD5BindRequest(String authenticationID, ASN1OctetString password) Creates a new SASL DIGEST-MD5 bind request with the provided authentication ID and password.DIGESTMD5BindRequest(String authenticationID, String password) Creates a new SASL DIGEST-MD5 bind request with the provided authentication ID and password.DIGESTMD5BindRequest(String authenticationID, String authorizationID, byte[] password, String realm, Control... controls) Creates a new SASL DIGEST-MD5 bind request with the provided information.DIGESTMD5BindRequest(String authenticationID, String authorizationID, ASN1OctetString password, String realm, Control... controls) Creates a new SASL DIGEST-MD5 bind request with the provided information.DIGESTMD5BindRequest(String authenticationID, String authorizationID, String password, String realm, Control... controls) Creates a new SASL DIGEST-MD5 bind request with the provided information. -
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.Retrieves the list of allowed qualities of protection that may be used for communication that occurs on the connection after the authentication has completed, in order from most preferred to least preferred.Retrieves the authentication ID for this bind request.Retrieves the authorization ID for this bind request, if any.intRetrieves the message ID for the last LDAP message sent using this request.byte[]Retrieves the bytes that comprise the the password for this bind request.Retrieves the string representation of the password for this bind request.getRealm()Retrieves the realm for this bind request, if any.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.Retrieves the name of the SASL mechanism used in this SASL bind request.voidHandles any necessary callbacks required for SASL authentication.protected BindResultprocess(LDAPConnection connection, int depth) Sends this bind request to the target server over the provided connection and returns the corresponding 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.Methods inherited from class com.unboundid.ldap.sdk.SASLBindRequest
getBindType, responseReceived, sendBindRequest, sendMessageMethods 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
-
Field Details
-
DIGESTMD5_MECHANISM_NAME
The name for the DIGEST-MD5 SASL mechanism.- See Also:
-
-
Constructor Details
-
DIGESTMD5BindRequest
Creates a new SASL DIGEST-MD5 bind request with the provided authentication ID and password. It will not include an authorization ID, a realm, or any controls.- Parameters:
authenticationID- The authentication ID for this bind request. It must not benull.password- The password for this bind request. It must not benull.
-
DIGESTMD5BindRequest
Creates a new SASL DIGEST-MD5 bind request with the provided authentication ID and password. It will not include an authorization ID, a realm, or any controls.- Parameters:
authenticationID- The authentication ID for this bind request. It must not benull.password- The password for this bind request. It must not benull.
-
DIGESTMD5BindRequest
Creates a new SASL DIGEST-MD5 bind request with the provided authentication ID and password. It will not include an authorization ID, a realm, or any controls.- Parameters:
authenticationID- The authentication ID for this bind request. It must not benull.password- The password for this bind request. It must not benull.
-
DIGESTMD5BindRequest
public DIGESTMD5BindRequest(@NotNull String authenticationID, @Nullable String authorizationID, @NotNull String password, @Nullable String realm, @Nullable Control... controls) Creates a new SASL DIGEST-MD5 bind request with the provided information.- Parameters:
authenticationID- The authentication ID for this bind request. It must not benull.authorizationID- The authorization ID for this bind request. It may benullif there will not be an alternate authorization identity.password- The password for this bind request. It must not benull.realm- The realm to use for the authentication. It may benullif the server supports a default realm.controls- The set of controls to include in the request.
-
DIGESTMD5BindRequest
public DIGESTMD5BindRequest(@NotNull String authenticationID, @Nullable String authorizationID, @NotNull byte[] password, @Nullable String realm, @Nullable Control... controls) Creates a new SASL DIGEST-MD5 bind request with the provided information.- Parameters:
authenticationID- The authentication ID for this bind request. It must not benull.authorizationID- The authorization ID for this bind request. It may benullif there will not be an alternate authorization identity.password- The password for this bind request. It must not benull.realm- The realm to use for the authentication. It may benullif the server supports a default realm.controls- The set of controls to include in the request.
-
DIGESTMD5BindRequest
public DIGESTMD5BindRequest(@NotNull String authenticationID, @Nullable String authorizationID, @NotNull ASN1OctetString password, @Nullable String realm, @Nullable Control... controls) Creates a new SASL DIGEST-MD5 bind request with the provided information.- Parameters:
authenticationID- The authentication ID for this bind request. It must not benull.authorizationID- The authorization ID for this bind request. It may benullif there will not be an alternate authorization identity.password- The password for this bind request. It must not benull.realm- The realm to use for the authentication. It may benullif the server supports a default realm.controls- The set of controls to include in the request.
-
DIGESTMD5BindRequest
public DIGESTMD5BindRequest(@NotNull DIGESTMD5BindRequestProperties properties, @Nullable Control... controls) Creates a new SASL DIGEST-MD5 bind request with the provided set of properties.- Parameters:
properties- The properties to use for thiscontrols- The set of controls to include in the request.
-
-
Method Details
-
getSASLMechanismName
Retrieves the name of the SASL mechanism used in this SASL bind request.- Specified by:
getSASLMechanismNamein classSASLBindRequest- Returns:
- The name of the SASL mechanism used in this SASL bind request.
-
getAuthenticationID
Retrieves the authentication ID for this bind request.- Returns:
- The authentication ID for this bind request.
-
getAuthorizationID
Retrieves the authorization ID for this bind request, if any.- Returns:
- The authorization ID for this bind request, or
nullif there should not be a separate authorization identity.
-
getPasswordString
Retrieves the string representation of the password for this bind request.- Returns:
- The string representation of the password for this bind request.
-
getPasswordBytes
Retrieves the bytes that comprise the the password for this bind request.- Returns:
- The bytes that comprise the password for this bind request.
-
getRealm
Retrieves the realm for this bind request, if any.- Returns:
- The realm for this bind request, or
nullif none was defined and the server should use the default realm.
-
getAllowedQoP
Retrieves the list of allowed qualities of protection that may be used for communication that occurs on the connection after the authentication has completed, in order from most preferred to least preferred.- Returns:
- The list of allowed qualities of protection that may be used for communication that occurs on the connection after the authentication has completed, in order from most preferred to least preferred.
-
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.
-
handle
Handles any necessary callbacks required for SASL authentication.- Specified by:
handlein interfaceCallbackHandler- Parameters:
callbacks- The set of callbacks to be handled.
-
getLastMessageID
Retrieves the message ID for the last LDAP message sent using this request.- Overrides:
getLastMessageIDin classSASLBindRequest- 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 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- Overrides:
toCodein classSASLBindRequest- 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).
-