Class JWTAuthenticationProvider
- java.lang.Object
-
- com.inteliqua.rest.authentication.JWTAuthenticationProvider
-
- All Implemented Interfaces:
EliquaAuthenticationProvider
public class JWTAuthenticationProvider extends Object implements EliquaAuthenticationProvider
A provider for JWT (JSON Web Token) authentication for Eliqua services. This class is responsible for obtaining a JWT token by authenticating with the Eliqua authorization server using the provided username, password, and account details.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classJWTAuthenticationProvider.JWTAuthenticationPayloadPayload class for the JWT authentication request.
-
Constructor Summary
Constructors Constructor Description JWTAuthenticationProvider(String username, String password, String account, String authorizationHost)Constructs a JWTAuthenticationProvider with the provided credentials and authorization host.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringauthenticate()Authenticates using the provided credentials and retrieves the JWT token from the authorization service.AuthenticationTypegetAuthenticationType()Returns the authentication type, which is JWT in this case.StringgetHeaderKey()Returns the header key used for the JWT token.
-
-
-
Constructor Detail
-
JWTAuthenticationProvider
public JWTAuthenticationProvider(String username, String password, String account, String authorizationHost)
Constructs a JWTAuthenticationProvider with the provided credentials and authorization host.- Parameters:
username- The username to be used for authentication.password- The password associated with the username.account- The account identifier associated with the authentication.authorizationHost- The URI of the authorization host where JWT authentication occurs.
-
-
Method Detail
-
getAuthenticationType
public AuthenticationType getAuthenticationType()
Returns the authentication type, which is JWT in this case.- Specified by:
getAuthenticationTypein interfaceEliquaAuthenticationProvider- Returns:
- The
AuthenticationTyperepresenting JWT authentication.
-
getHeaderKey
public String getHeaderKey()
Returns the header key used for the JWT token. In this case, it's "Cookie".- Specified by:
getHeaderKeyin interfaceEliquaAuthenticationProvider- Returns:
- A string representing the header key ("Cookie").
-
authenticate
public String authenticate()
Authenticates using the provided credentials and retrieves the JWT token from the authorization service.- Specified by:
authenticatein interfaceEliquaAuthenticationProvider- Returns:
- The JWT token, which is retrieved from the "x-jwt-token" header in the response.
- Throws:
RuntimeException- If any error occurs during the authentication process.
-
-