Class AbstractAuthentication
java.lang.Object
io.camunda.identity.sdk.authentication.AbstractAuthentication
- All Implemented Interfaces:
Authentication
- Direct Known Subclasses:
Auth0Authentication,GenericAuthentication
The Authentication class provides functionality to authenticate a user with Identity
and verify access tokens.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final IdentityConfigurationstatic final longstatic final longprotected final RestClientstatic final String -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractAuthentication(IdentityConfiguration configuration, RestClient restClient) -
Method Summary
Modifier and TypeMethodDescriptioncom.auth0.jwt.interfaces.DecodedJWTDecodes a token.protected URIgenerateSingleSignOutUri(String callbackUrl) Verifies the validity of the passed token and return groups assigned to it.Verifies the validity of the passed token and audience and return groups assigned to it.getGroupsInOrganization(com.auth0.jwt.interfaces.DecodedJWT token, String organizationId) getGroupsInOrganization(String token, String organization) Verifies the validity of the passed token and return groups assigned to it within the organization.getGroupsInOrganization(String token, String audience, String organization) Verifies the validity of the passed token and audience and return groups assigned to it within the organization.getPermissions(com.auth0.jwt.interfaces.DecodedJWT token, String audience) getPermissions(String token) Verifies the validity of the passed token and return permissions assigned to it.getPermissions(String token, String audience) Verifies the validity of the passed token and audience and return permissions assigned to it.protected UserDetailsgetUserDetails(com.auth0.jwt.interfaces.DecodedJWT token, String organizationId) booleanReturns a true/false indicating if authentication is available or not.protected abstract booleanprotected abstract booleanprotected abstract com.auth0.jwk.JwkProviderprotected abstract TokensrequestFreshToken(String audience) requestToken(String audience) Requests a client token from the cache if available.singleSignOut(String refreshToken, String callbackUrl) Logs out from Identity backend based on the configuration, one of these cases is possible: 1.protected SingleSignOutUriBuildercom.auth0.jwt.interfaces.DecodedJWTverifyAndDecode(String token, String audience) verifyToken(String token) Verifies the validity of the passed token.verifyToken(String token, String organizationId) Verifies the validity of the passed token and organisation.protected AccessTokenverifyToken(String token, String audience, String organizationId) Verifies the validity of the passed token.Verifies the validity of the passed token.protected abstract WellKnownConfigurationMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.camunda.identity.sdk.authentication.Authentication
authorizeUriBuilder, exchangeAuthCode, getAssignedOrganizations, getClientId, isM2MToken, renewToken, revokeToken
-
Field Details
-
JWKS_CACHE_SIZE
public static final long JWKS_CACHE_SIZE- See Also:
-
JWKS_CACHE_LIFETIME_DAYS
public static final long JWKS_CACHE_LIFETIME_DAYS- See Also:
-
WELL_KNOWN_PATH
- See Also:
-
configuration
-
tokenCache
-
restClient
-
-
Constructor Details
-
AbstractAuthentication
-
-
Method Details
-
isAvailable
public boolean isAvailable()Description copied from interface:AuthenticationReturns a true/false indicating if authentication is available or not.- Specified by:
isAvailablein interfaceAuthentication- Returns:
- the availability of authentication
-
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.- Specified by:
requestTokenin interfaceAuthentication- 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- Specified by:
decodeJWTin interfaceAuthentication- Parameters:
token- token in JWT format- Returns:
- decoded token
- Throws:
TokenDecodeException- the token can not be decoded
-
verifyTokenIgnoringAudience
Description copied from interface:AuthenticationVerifies the validity of the passed token. Following checks will be performed:- The token is correctly signed
- The token has not expired
- Specified by:
verifyTokenIgnoringAudiencein interfaceAuthentication- Parameters:
token- the token- Returns:
- the decoded jwt
-
singleSignOut
Logs out from Identity backend based on the configuration, one of these cases is possible: 1. The refresh token is not empty and OAuth Provider (OP) has provided a revoke endpoint, then seeAuthentication.revokeToken(java.lang.String), in this case the method return an empty Optional. 2. end-session endpoint is available, so in this case the url for logout is returned and client should handle the redirection 3. otherwise this method will throw exception- Specified by:
singleSignOutin interfaceAuthentication- Parameters:
refreshToken- refresh token used for the requestcallbackUrl- the URL to redirect to post-SSO if supported by SSO provider- Throws:
IdentityException- if token revocation has failed or neither revokeorg.apache.commons.lang3.NotImplementedException- if case 3 happens
-
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
- Specified by:
verifyTokenin interfaceAuthentication- 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
-
verifyToken
Verifies the validity of the passed token and organisation. Following checks will be performed:- The token is correctly signed
- The token has not expired
- Token's audience (aud claim) matches application's audience
- Specified by:
verifyTokenin interfaceAuthentication- Parameters:
token- the tokenorganizationId- the organisation of 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
-
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 provided audience
- Parameters:
token- the tokenaudience- token's aud claim must match provided audience- 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
-
singleSignOutUriBuilder
-
generateSingleSignOutUri
-
getUserDetails
protected UserDetails getUserDetails(com.auth0.jwt.interfaces.DecodedJWT token, String organizationId) -
verifyAndDecode
- Specified by:
verifyAndDecodein interfaceAuthentication
-
getPermissions
Description copied from interface:AuthenticationVerifies the validity of the passed token and return permissions assigned to it. Following checks will be performed:- The token is correctly signed
- The token has not expired
- Token's audience (aud claim) matches application's audience
- Specified by:
getPermissionsin interfaceAuthentication- Parameters:
token- the token- Returns:
- list of permissions assigned to the token
-
getPermissions
Description copied from interface:AuthenticationVerifies the validity of the passed token and audience and return permissions assigned to it. Following checks will be performed:- The token is correctly signed
- The token has not expired
- Token's audience (aud claim) matches application's audience
- Specified by:
getPermissionsin interfaceAuthentication- Parameters:
token- the tokenaudience- the audience- Returns:
- list of permissions assigned to the token
-
getPermissions
-
getGroups
Description copied from interface:AuthenticationVerifies the validity of the passed token and return groups assigned to it. Following checks will be performed:- The token is correctly signed
- The token has not expired
- Token's audience (aud claim) matches application's audience
- Specified by:
getGroupsin interfaceAuthentication- Parameters:
token- the token- Returns:
- list of groups assigned to the token
-
getGroups
Description copied from interface:AuthenticationVerifies the validity of the passed token and audience and return groups assigned to it. Following checks will be performed:- The token is correctly signed
- The token has not expired
- Token's audience (aud claim) matches application's audience
- Specified by:
getGroupsin interfaceAuthentication- Parameters:
token- the tokenaudience- the audience- Returns:
- list of groups assigned to the token
-
getGroupsInOrganization
Description copied from interface:AuthenticationVerifies the validity of the passed token and return groups assigned to it within the organization. Following checks will be performed:- The token is correctly signed
- The token has not expired
- Token's audience (aud claim) matches application's audience
- Specified by:
getGroupsInOrganizationin interfaceAuthentication- Parameters:
token- the tokenorganization- the organization- Returns:
- list of groups assigned to the token within the organization. If organization is null, it returns groups that has no organization assigned to them.
-
getGroupsInOrganization
Description copied from interface:AuthenticationVerifies the validity of the passed token and audience and return groups assigned to it within the organization. Following checks will be performed:- The token is correctly signed
- The token has not expired
- Token's audience (aud claim) matches application's audience
- Specified by:
getGroupsInOrganizationin interfaceAuthentication- Parameters:
token- the tokenaudience- the audienceorganization- the organization- Returns:
- list of groups assigned to the token within the organization. If organization is null, it returns groups that has no organization assigned to them.
-
getGroupsInOrganization
-
jwkProvider
protected abstract com.auth0.jwk.JwkProvider jwkProvider() -
wellKnownConfiguration
-
requestFreshToken
-
isRevokeAvailable
protected abstract boolean isRevokeAvailable() -
isSingleSignOutAvailable
protected abstract boolean isSingleSignOutAvailable()
-