Class OAUTHBEARERBindRequest

All Implemented Interfaces:
ReadOnlyLDAPRequest, Serializable

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.
See Also:
  • Field Details

  • Constructor Details

    • OAUTHBEARERBindRequest

      public OAUTHBEARERBindRequest(@NotNull 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 be null or empty.
      controls - The set of controls to include in the bind request. It may be null or empty if no controls are needed.
    • OAUTHBEARERBindRequest

      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 be null.
      controls - The set of controls to include in the bind request. It may be null or empty if no controls are needed.
  • Method Details

    • getSASLMechanismName

      Retrieves the name of the SASL mechanism used in this SASL bind request.
      Specified by:
      getSASLMechanismName in class SASLBindRequest
      Returns:
      The name of the SASL mechanism used in this SASL bind request.
    • getAccessToken

      Retrieves the access token to include in the bind request.
      Returns:
      The access token to include in the bind request.
    • 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

      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

      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

      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

      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

      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

      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

      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 class BindRequest
      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

      Creates a new instance of this LDAP request that may be modified without impacting this request.
      Specified by:
      duplicate in interface ReadOnlyLDAPRequest
      Specified by:
      duplicate in class BindRequest
      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:
      duplicate in interface ReadOnlyLDAPRequest
      Specified by:
      duplicate in class BindRequest
      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 class SASLBindRequest
      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

      Retrieves a string representation of the OAUTHBEARER bind request.
      Specified by:
      toString in interface ReadOnlyLDAPRequest
      Overrides:
      toString in class LDAPRequest
      Returns:
      A string representation of the OAUTHBEARER bind request.
    • toString

      public void toString(@NotNull StringBuilder buffer)
      Appends a string representation of the OAUTHBEARER bind request to the provided buffer.
      Specified by:
      toString in interface ReadOnlyLDAPRequest
      Specified by:
      toString in class LDAPRequest
      Parameters:
      buffer - The buffer to which the information should be appended. It must not be null.
    • 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:
      toCode in interface ReadOnlyLDAPRequest
      Overrides:
      toCode in class SASLBindRequest
      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 is null 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 (if true), or just to generate the request (if false).