Interface Authentication
- All Known Implementing Classes:
AbstractAuthentication,Auth0Authentication,GenericAuthentication,KeycloakAuthentication,MicrosoftAuthentication
public interface Authentication
The Authentication class provides functionality to authenticate a user with Identity
and verify access tokens.
-
Method Summary
Modifier and TypeMethodDescriptionauthorizeUriBuilder(String redirectUri) Returns a new Authorize uri builder.static Authenticationcreate(IdentityConfiguration configuration) Factory function to create a new authentication instancecom.auth0.jwt.interfaces.DecodedJWTDecodes a token.exchangeAuthCode(AuthCodeDto authCodeDto, String redirectUri) Exchanges provided auth code with access tokens.getClientId(String token) Gets the client ID associated to the tokenbooleanReturns a true/false indicating if authentication is available or not.booleanisM2MToken(String token) Checks if the token passed in is considered an M2M token.renewToken(String refreshToken) Exchanges provided refresh token with an access tokens.requestToken(String audience) Requests a client token from the cache if available.voidrevokeToken(String refreshToken) Logs out from Identity backend.verifyToken(String token) Verifies the validity of the passed token.Verifies the validity of the passed token.
-
Method Details
-
create
Factory function to create a new authentication instance- Parameters:
configuration- Identity configuration- Returns:
- Authentication instance
-
isAvailable
boolean isAvailable()Returns a true/false indicating if authentication is available or not.- Returns:
- the availability of authentication
-
authorizeUriBuilder
Returns a new Authorize uri builder. It is used to build the authorize uri for user authentication.- Parameters:
redirectUri- the redirect uri- Returns:
- the authorize uri builder
-
exchangeAuthCode
Exchanges provided auth code with access tokens. The provided redirect uri argument must match the redirect uri that was used to build the authorize uri.- Parameters:
authCodeDto- the auth code dtoredirectUri- the redirect uri- Returns:
- the tokens
- Throws:
CodeExchangeException- if code exchange fails
-
renewToken
Exchanges provided refresh token with an access tokens.- Parameters:
refreshToken- refresh token used for the request- Returns:
- the tokens
- Throws:
IdentityException- if token renewal has failed
-
revokeToken
Logs out from Identity backend. This will invalidate the given refresh token and refresh tokens issued for other applications during the same session. The user's session or access token still has to be deleted by the client application.- Parameters:
refreshToken- refresh token used for the request- Throws:
IdentityException- if token revocation has failed
-
requestToken
Requests a client token from the cache if available. If no token is found with the required audience, a new token will be requested from the authentication provider and stored.- Parameters:
audience- the audience of the resource server- Returns:
- the tokens
- Throws:
IdentityException- if case of a failure
-
decodeJWT
Decodes a token. Can be used to access tokens data without validation- Parameters:
token- token in JWT format- Returns:
- decoded token
- Throws:
TokenDecodeException- the token can not be decoded
-
verifyToken
Verifies the validity of the passed token. Following checks will be performed:- The token is correctly signed
- The token has not expired
- Token's audience (aud claim) matches application's audience
- Parameters:
token- the token- Returns:
- the decoded jwt
- Throws:
TokenDecodeException- the token can not be decodedInvalidSignatureException- the token's signature is invalidTokenExpiredException- the token has expiredInvalidClaimException- the provided claim is invalidJsonWebKeyException- the JWK needed to verify token's signature can not be retrieved
-
verifyTokenIgnoringAudience
Verifies the validity of the passed token. Following checks will be performed:- The token is correctly signed
- The token has not expired
- Parameters:
token- the token- Returns:
- the decoded jwt
- Throws:
TokenDecodeException- the token can not be decodedInvalidSignatureException- the token's signature is invalidTokenExpiredException- the token has expiredInvalidClaimException- the provided claim is invalidJsonWebKeyException- the JWK needed to verify token's signature can not be retrieved
-
isM2MToken
Checks if the token passed in is considered an M2M token.- Parameters:
token- the token- Returns:
- true if the token is a M2M token, else false
-
getClientId
Gets the client ID associated to the token- Parameters:
token- the token- Returns:
- the clientID
-