Package com.unboundid.ldap.sdk
Class SCRAMBindRequest
- java.lang.Object
-
- com.unboundid.ldap.sdk.LDAPRequest
-
- com.unboundid.ldap.sdk.BindRequest
-
- com.unboundid.ldap.sdk.SASLBindRequest
-
- com.unboundid.ldap.sdk.SCRAMBindRequest
-
- All Implemented Interfaces:
ReadOnlyLDAPRequest
,java.io.Serializable
- Direct Known Subclasses:
SCRAMSHA1BindRequest
,SCRAMSHA256BindRequest
,SCRAMSHA512BindRequest
@Extensible @ThreadSafety(level=INTERFACE_NOT_THREADSAFE) public abstract class SCRAMBindRequest extends SASLBindRequest
This class provides the basis for bind requests that use the salted challenge-response authentication mechanism (SCRAM) described in RFC 5802 and updated in RFC 7677. Subclasses should extend this class to provide support for specific algorithms.
Note that this implementation does not support the PLUS variants of these algorithms, which requires channel binding support.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class com.unboundid.ldap.sdk.SASLBindRequest
CRED_TYPE_SASL
-
Fields inherited from class com.unboundid.ldap.sdk.BindRequest
VERSION_ELEMENT
-
-
Constructor Summary
Constructors Constructor Description SCRAMBindRequest(java.lang.String username, ASN1OctetString password, Control... controls)
Creates a new SCRAM bind request with the provided information.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract SCRAMBindRequest
duplicate()
Creates a new instance of this LDAP request that may be modified without impacting this request.abstract SCRAMBindRequest
duplicate(Control[] controls)
Creates a new instance of this LDAP request that may be modified without impacting this request.protected abstract java.lang.String
getDigestAlgorithmName()
Retrieves the name of the digest algorithm that will be used in the authentication processing.protected abstract java.lang.String
getMACAlgorithmName()
Retrieves the name of the MAC algorithm that will be used in the authentication processing.byte[]
getPasswordBytes()
Retrieves the bytes that comprise the password for this bind request.java.lang.String
getPasswordString()
Retrieves the password for this bind request, as a string.abstract SCRAMBindRequest
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.java.lang.String
getUsername()
Retrieves the username for this bind request.protected BindResult
process(LDAPConnection connection, int depth)
Sends this bind request to the target server over the provided connection and returns the corresponding response.abstract void
toCode(java.util.List<java.lang.String> lineList, java.lang.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.abstract void
toString(java.lang.StringBuilder buffer)
Appends a string representation of this request to the provided buffer.-
Methods inherited from class com.unboundid.ldap.sdk.SASLBindRequest
getBindType, getLastMessageID, getSASLMechanismName, responseReceived, sendBindRequest, sendMessage
-
Methods inherited from class com.unboundid.ldap.sdk.BindRequest
getOperationType
-
Methods inherited from class com.unboundid.ldap.sdk.LDAPRequest
followReferrals, getControl, getControlList, getControls, getIntermediateResponseListener, getReferralConnector, getResponseTimeoutMillis, hasControl, hasControl, setFollowReferrals, setIntermediateResponseListener, setReferralConnector, setResponseTimeoutMillis, toString
-
-
-
-
Constructor Detail
-
SCRAMBindRequest
public SCRAMBindRequest(java.lang.String username, ASN1OctetString password, Control... controls)
Creates a new SCRAM bind request with the provided information.- Parameters:
username
- The username for this bind request. It must not benull
or empty.password
- The password for this bind request. It must not benull
or empty.controls
- The set of controls to include in the bind request. It may benull
or empty if no controls are needed.
-
-
Method Detail
-
getUsername
public final java.lang.String getUsername()
Retrieves the username for this bind request.- Returns:
- The password for this bind request.
-
getPasswordString
public final java.lang.String getPasswordString()
Retrieves the password for this bind request, as a string.- Returns:
- The password for this bind request, as a string.
-
getPasswordBytes
public final byte[] getPasswordBytes()
Retrieves the bytes that comprise the password for this bind request.- Returns:
- The bytes that comprise the password for this bind request.
-
getDigestAlgorithmName
protected abstract java.lang.String getDigestAlgorithmName()
Retrieves the name of the digest algorithm that will be used in the authentication processing.- Returns:
- The name of the digest algorithm that will be used in the authentication processing.
-
getMACAlgorithmName
protected abstract java.lang.String getMACAlgorithmName()
Retrieves the name of the MAC algorithm that will be used in the authentication processing.- Returns:
- The name of the MAC algorithm that will be used in the authentication processing.
-
process
protected final 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 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
public abstract SCRAMBindRequest 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.- Overrides:
getRebindRequest
in 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
null
to indicate that automatic re-binding is not supported for this type of bind request.
-
duplicate
public abstract SCRAMBindRequest duplicate()
Creates a new instance of this LDAP request that may be modified without impacting this request.- Specified by:
duplicate
in interfaceReadOnlyLDAPRequest
- Specified by:
duplicate
in classBindRequest
- Returns:
- A new instance of this LDAP request that may be modified without impacting this request.
-
duplicate
public abstract SCRAMBindRequest 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.- Specified by:
duplicate
in interfaceReadOnlyLDAPRequest
- Specified by:
duplicate
in 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
public abstract void toString(java.lang.StringBuilder buffer)
Appends a string representation of this request to the provided buffer.- Specified by:
toString
in interfaceReadOnlyLDAPRequest
- Specified by:
toString
in classLDAPRequest
- Parameters:
buffer
- The buffer to which to append a string representation of this request.
-
toCode
public abstract void toCode(java.util.List<java.lang.String> lineList, java.lang.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:
toCode
in interfaceReadOnlyLDAPRequest
- Overrides:
toCode
in 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 isnull
or 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
).
-
-