Package com.unboundid.ldap.sdk
Class ANONYMOUSBindRequest
java.lang.Object
com.unboundid.ldap.sdk.LDAPRequest
com.unboundid.ldap.sdk.BindRequest
com.unboundid.ldap.sdk.SASLBindRequest
com.unboundid.ldap.sdk.ANONYMOUSBindRequest
- All Implemented Interfaces:
ReadOnlyLDAPRequest,Serializable
@NotMutable
@ThreadSafety(level=NOT_THREADSAFE)
public final class ANONYMOUSBindRequest
extends SASLBindRequest
This class provides a SASL ANONYMOUS bind request implementation as described
in RFC 4505. Binding with
The ANONYMOUS SASL mechanism is essentially equivalent to using an anonymous
simple bind (i.e., a simple bind with an empty password), although the SASL
ANONYMOUS mechanism does provide the ability to include additional trace
information with the request that may be logged or otherwise handled by
the server.
Example
The following example demonstrates the process for performing an ANONYMOUS bind, including a trace string of "Demo Application" against a directory server:
ANONYMOUSBindRequest bindRequest =
new ANONYMOUSBindRequest("Demo Application");
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
ConstructorsConstructorDescriptionCreates a new SASL ANONYMOUS bind request with no trace string and no controls.ANONYMOUSBindRequest(Control... controls) Creates a new SASL ANONYMOUS bind request with the provided set of controls and no trace string.ANONYMOUSBindRequest(String traceString) Creates a new SASL ANONYMOUS bind request with the provided trace string and no controls.ANONYMOUSBindRequest(String traceString, Control... controls) Creates a new SASL ANONYMOUS bind request with the provided trace string and controls. -
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.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.Retrieves the trace string that will be included with the bind request.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, getLastMessageID, 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
-
ANONYMOUS_MECHANISM_NAME
The name for the ANONYMOUS SASL mechanism.- See Also:
-
-
Constructor Details
-
ANONYMOUSBindRequest
public ANONYMOUSBindRequest()Creates a new SASL ANONYMOUS bind request with no trace string and no controls. -
ANONYMOUSBindRequest
Creates a new SASL ANONYMOUS bind request with the provided trace string and no controls.- Parameters:
traceString- The trace string to include in the bind request, ornullif no trace string is to be provided.
-
ANONYMOUSBindRequest
Creates a new SASL ANONYMOUS bind request with the provided set of controls and no trace string.- Parameters:
controls- The set of controls to include in the request.
-
ANONYMOUSBindRequest
Creates a new SASL ANONYMOUS bind request with the provided trace string and controls.- Parameters:
traceString- The trace string to include in the bind request, ornullif no trace string is to be provided.controls- 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.
-
getTraceString
Retrieves the trace string that will be included with the bind request.- Returns:
- The trace string that will be included with the bind request, or
nullif there is to be no trace string.
-
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.
-
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).
-