Package com.adobe.granite.auth.oauth
Interface AccessTokenProvider
Interface for an OAuth 2.0 access token provider using Authorization Grants as defined in the Assertion Framework
for OAuth 2.0 Client Authentication and Authorization Grants
(see RFC 7523).
- Since:
- 3.1
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiongetAccessToken(ResourceResolver resolver, String userId, Map<String, ?> claims) Return a valid access token or throws an exception.@NotNull StringReturn the ClientId, even called ApiKey, configured for the AccessTokenProvider@Nullable StringReturn the KeyPairAlias, configured for the AccessTokenProvider.@Nullable StringgetOrgId()Return the orgId, configured for the AccessTokenProvider.@Nullable StringReturn the TechnicalAccount, configured for the AccessTokenProvider.
-
Method Details
-
getAccessToken
String getAccessToken(ResourceResolver resolver, String userId, Map<String, ?> claims) throws CryptoException, IOException, NullPointerExceptionReturn a valid access token or throws an exception. A new access token is obtained from the authorization server if needed, by generating a JWT and using it as authorization grant. Custom claims may be added via the
claimparameter. The custom claims do override the claims computed by aAccessTokenProviderimplementation.An implementation may or may not reuse the access tokens.
- Parameters:
resolver- The resource resolver to access the user associated to theuserIduserId- The user identifier which has access to the required asymmetric cryptographic materialclaims- An optional map of JWT claims that overrides the claims computed by aAccessTokenProviderimplementation. Providing an empty map ornulluses the defaultAccessTokenProviderimplementation claims- Returns:
- A valid JWT access token or throws an Exception (does not return
null) - Throws:
CryptoException- If an error occurred while generating/signing the JWT claimIOException- If an error occurred while communicating with the authorization serverNullPointerException- If theresolveror theuserIdisnull
-
getApiKey
Return the ClientId, even called ApiKey, configured for the AccessTokenProvider- Returns:
-
getTechnicalAccount
Return the TechnicalAccount, configured for the AccessTokenProvider. This is not required by the OAuth Server-to-Server flow, but can be stored for backward compatibility- Returns:
-
getOrgId
Return the orgId, configured for the AccessTokenProvider. This is optional in the OAuth Server-to-Server flow, but can be stored for backward compatibility- Returns:
-
getKeyPairAlias
Return the KeyPairAlias, configured for the AccessTokenProvider. This is not required by the OAuth Server-to-Server flow, but can be stored for backward compatibility- Returns:
-