Class OAuth2Client
- java.lang.Object
-
- org.wildfly.security.mechanism.oauth2.OAuth2Client
-
public class OAuth2Client extends Object
Implementation of the client side of the OAuth2 SASL mechanism.- Author:
- Pedro Igor
-
-
Constructor Summary
Constructors Constructor Description OAuth2Client(String authorizationId, CallbackHandler callbackHandler, ElytronMessages log)Constructs a newOAuth2Clientinstance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description OAuth2InitialClientMessagegetInitialResponse()Gets the initial response message from the client that will be sent to the server.byte[]handleServerResponse(byte[] serverMessage)Handles the server's response to the initial client message.
-
-
-
Constructor Detail
-
OAuth2Client
public OAuth2Client(String authorizationId, CallbackHandler callbackHandler, ElytronMessages log)
Constructs a newOAuth2Clientinstance.- 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 isnull.
-
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:
nullif the response was successful, aborting the authentication otherwise.
-
-