Class OAuth2Client


  • public class OAuth2Client
    extends Object
    Implementation of the client side of the OAuth2 SASL mechanism.
    Author:
    Pedro Igor
    • Constructor Detail

      • OAuth2Client

        public OAuth2Client​(String authorizationId,
                            CallbackHandler callbackHandler,
                            ElytronMessages log)
        Constructs a new OAuth2Client instance.
        Parameters:
        authorizationId - the ID of the user to be authorized.
        callbackHandler - the callback handler for verifying the Bearer token.
        log - the logger to use.
    • Method Detail

      • getInitialResponse

        public OAuth2InitialClientMessage getInitialResponse()
                                                      throws AuthenticationMechanismException
        Gets the initial response message from the client that will be sent to the server. It retrieves the Bearer token from a callback and constructs an encoded message that includes the token.
        Returns:
        encoded message that includes the Bearer token.
        Throws:
        AuthenticationMechanismException - if an error occurs during the callback or the token is null.
      • handleServerResponse

        public byte[] handleServerResponse​(byte[] serverMessage)
        Handles the server's response to the initial client message.
        Parameters:
        serverMessage - the byte array containing the server's response.
        Returns:
        null if the response was successful, aborting the authentication otherwise.