Package com.unboundid.ldap.sdk
Class OAUTHBEARERBindRequest
- java.lang.Object
-
- com.unboundid.ldap.sdk.LDAPRequest
-
- com.unboundid.ldap.sdk.BindRequest
-
- com.unboundid.ldap.sdk.SASLBindRequest
-
- com.unboundid.ldap.sdk.OAUTHBEARERBindRequest
-
- All Implemented Interfaces:
ReadOnlyLDAPRequest
,java.io.Serializable
@NotMutable @ThreadSafety(level=COMPLETELY_THREADSAFE) public final class OAUTHBEARERBindRequest extends SASLBindRequest
This class provides an implementation of a SASL bind request that uses the OAUTHBEARER SASL mechanism described in RFC 7628 to allow a user to authenticate with an OAuth 2.0 bearer token.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
OAUTHBEARER_MECHANISM_NAME
The name for the OAUTHBEARER SASL mechanism.-
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 OAUTHBEARERBindRequest(OAUTHBEARERBindRequestProperties properties, Control... controls)
Creates a new OAUTHBEARER bind request with the provided set of properties.OAUTHBEARERBindRequest(java.lang.String accessToken, Control... controls)
Creates a new OAUTHBEARER bind request with the provided access token.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description OAUTHBEARERBindRequest
duplicate()
Creates a new instance of this LDAP request that may be modified without impacting this request.OAUTHBEARERBindRequest
duplicate(Control[] controls)
Creates a new instance of this LDAP request that may be modified without impacting this request.java.lang.String
getAccessToken()
Retrieves the access token to include in the bind request.java.util.Map<java.lang.String,java.lang.String>
getAdditionalKeyValuePairs()
Retrieves an unmodifiable map of additional key-value pairs that should be included in the bind request.java.lang.String
getAuthorizationID()
Retrieves the authorization ID to include in the GS2 header for the bind request, if any.int
getLastMessageID()
Retrieves the message ID for the last LDAP message sent using this request.java.lang.String
getRequestMethod()
Retrieves the method to use for HTTP-based requests, if any.java.lang.String
getRequestPath()
Retrieves the path to use for HTTP-based requests, if any.java.lang.String
getRequestPostData()
Retrieves the data to submit when posting an HTTP-based request, if any.java.lang.String
getRequestQueryString()
Retrieves the query string to use for HTTP-based requests, if any.java.lang.String
getSASLMechanismName()
Retrieves the name of the SASL mechanism used in this SASL bind request.java.lang.String
getServerAddress()
Retrieves the server address to include in the bind request, if any.java.lang.Integer
getServerPort()
Retrieves the server port to include in the bind request, if any.protected OAUTHBEARERBindResult
process(LDAPConnection connection, int depth)
Sends this bind request to the target server over the provided connection and returns the corresponding response.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.java.lang.String
toString()
Retrieves a string representation of the OAUTHBEARER bind request.void
toString(java.lang.StringBuilder buffer)
Appends a string representation of the OAUTHBEARER bind request to the provided buffer.-
Methods inherited from class com.unboundid.ldap.sdk.SASLBindRequest
getBindType, responseReceived, sendBindRequest, sendMessage
-
Methods inherited from class com.unboundid.ldap.sdk.BindRequest
getOperationType, getRebindRequest
-
Methods inherited from class com.unboundid.ldap.sdk.LDAPRequest
followReferrals, getControl, getControlList, getControls, getIntermediateResponseListener, getReferralConnector, getReferralConnectorInternal, getReferralDepth, getResponseTimeoutMillis, hasControl, hasControl, setFollowReferrals, setIntermediateResponseListener, setReferralConnector, setReferralDepth, setResponseTimeoutMillis
-
-
-
-
Field Detail
-
OAUTHBEARER_MECHANISM_NAME
@NotNull public static final java.lang.String OAUTHBEARER_MECHANISM_NAME
The name for the OAUTHBEARER SASL mechanism.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
OAUTHBEARERBindRequest
public OAUTHBEARERBindRequest(@NotNull java.lang.String accessToken, @Nullable Control... controls)
Creates a new OAUTHBEARER bind request with the provided access token. All other properties will be unset.- Parameters:
accessToken
- The access token to use 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.
-
OAUTHBEARERBindRequest
public OAUTHBEARERBindRequest(@NotNull OAUTHBEARERBindRequestProperties properties, @Nullable Control... controls)
Creates a new OAUTHBEARER bind request with the provided set of properties.- Parameters:
properties
- The set of properties to use to create this bind request. It must not benull
.controls
- The set of controls to include in the bind request. It may benull
or empty if no controls are needed.
-
-
Method Detail
-
getSASLMechanismName
@NotNull public java.lang.String getSASLMechanismName()
Retrieves the name of the SASL mechanism used in this SASL bind request.- Specified by:
getSASLMechanismName
in classSASLBindRequest
- Returns:
- The name of the SASL mechanism used in this SASL bind request.
-
getAccessToken
@NotNull public java.lang.String getAccessToken()
Retrieves the access token to include in the bind request.- Returns:
- The access token to include in the bind request.
-
getAuthorizationID
@Nullable public java.lang.String getAuthorizationID()
Retrieves the authorization ID to include in the GS2 header for the bind request, if any.- Returns:
- The authorization ID to include in the GS2 header for the bind
request, or
null
if no authorization ID should be included.
-
getServerAddress
@Nullable public java.lang.String getServerAddress()
Retrieves the server address to include in the bind request, if any.- Returns:
- The server address to include in the bind request, or
null
if it should be omitted.
-
getServerPort
@Nullable public java.lang.Integer getServerPort()
Retrieves the server port to include in the bind request, if any.- Returns:
- The server port to include in the bind request, or
null
if it should be omitted.
-
getRequestMethod
@Nullable public java.lang.String getRequestMethod()
Retrieves the method to use for HTTP-based requests, if any.- Returns:
- The method to use for HTTP-based requests, or
null
if it should be omitted from the bind request.
-
getRequestPath
@Nullable public java.lang.String getRequestPath()
Retrieves the path to use for HTTP-based requests, if any.- Returns:
- The path to use for HTTP-based requests, or
null
if it should be omitted from the bind request.
-
getRequestPostData
@Nullable public java.lang.String getRequestPostData()
Retrieves the data to submit when posting an HTTP-based request, if any.- Returns:
- The post data for HTTP-based requests, or
null
if it should be omitted from the bind request.
-
getRequestQueryString
@Nullable public java.lang.String getRequestQueryString()
Retrieves the query string to use for HTTP-based requests, if any.- Returns:
- The query string to use for HTTP-based requests, or
null
if it should be omitted from the bind request.
-
getAdditionalKeyValuePairs
@NotNull public java.util.Map<java.lang.String,java.lang.String> getAdditionalKeyValuePairs()
Retrieves an unmodifiable map of additional key-value pairs that should be included in the bind request.- Returns:
- An unmodifiable map of additional key-value pairs that should be
included in the bind request. It will not be
null
but may be empty.
-
process
@NotNull protected OAUTHBEARERBindResult 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:
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.
-
duplicate
@NotNull public OAUTHBEARERBindRequest 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
@NotNull public OAUTHBEARERBindRequest duplicate(@Nullable 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.
-
getLastMessageID
public int getLastMessageID()
Retrieves the message ID for the last LDAP message sent using this request.- Overrides:
getLastMessageID
in 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.
-
toString
@NotNull public java.lang.String toString()
Retrieves a string representation of the OAUTHBEARER bind request.- Specified by:
toString
in interfaceReadOnlyLDAPRequest
- Overrides:
toString
in classLDAPRequest
- Returns:
- A string representation of the OAUTHBEARER bind request.
-
toString
public void toString(@NotNull java.lang.StringBuilder buffer)
Appends a string representation of the OAUTHBEARER bind request to the provided buffer.- Specified by:
toString
in interfaceReadOnlyLDAPRequest
- Specified by:
toString
in classLDAPRequest
- Parameters:
buffer
- The buffer to which the information should be appended. It must not benull
.
-
toCode
public void toCode(@NotNull java.util.List<java.lang.String> lineList, @NotNull 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
).
-
-