Interface OAuthDataProvider
-
- All Known Subinterfaces:
AuthorizationCodeDataProvider
- All Known Implementing Classes:
AbstractAuthorizationCodeDataProvider,AbstractCodeDataProvider,AbstractOAuthDataProvider,DefaultEncryptingCodeDataProvider,DefaultEncryptingOAuthDataProvider,JCacheCodeDataProvider,JCacheOAuthDataProvider,JPACMTCodeDataProvider,JPACodeDataProvider,JPAOAuthDataProvider
public interface OAuthDataProviderOAuth provider responsible for persisting the information about OAuth consumers, request and access tokens.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description List<OAuthPermission>convertScopeToPermissions(Client client, List<String> requestedScopes)Converts the requested scopes to the list of permissions.ServerAccessTokencreateAccessToken(AccessTokenRegistration accessToken)Create access tokenServerAccessTokengetAccessToken(String accessToken)Get access tokenList<ServerAccessToken>getAccessTokens(Client client, UserSubject subject)Return all access tokens associated with a given clientClientgetClient(String clientId)Returns the previously registered third-partyClientServerAccessTokengetPreauthorizedToken(Client client, List<String> requestedScopes, UserSubject subject, String grantType)Get preauthorized access tokenList<RefreshToken>getRefreshTokens(Client client, UserSubject subject)Return all refresh tokens associated with a given clientServerAccessTokenrefreshAccessToken(Client client, String refreshToken, List<String> requestedScopes)Refresh access tokenvoidrevokeToken(Client client, String tokenId, String tokenTypeHint)Revokes a refresh or access tokendefault voidrevokeToken(Client client, UserSubject callerSubject, String tokenId, String tokenTypeHint)Revokes a refresh or access token, verifying that the authenticated resource owner's identity (callerSubject) matches the subject bound to the token.
-
-
-
Method Detail
-
getClient
Client getClient(String clientId) throws OAuthServiceException
Returns the previously registered third-partyClient- Parameters:
clientId- the client id- Returns:
- Client
- Throws:
OAuthServiceException
-
createAccessToken
ServerAccessToken createAccessToken(AccessTokenRegistration accessToken) throws OAuthServiceException
Create access token- Parameters:
accessToken- the token registration info- Returns:
- AccessToken
- Throws:
OAuthServiceException
-
getAccessToken
ServerAccessToken getAccessToken(String accessToken) throws OAuthServiceException
Get access token- Parameters:
accessToken- the token key- Returns:
- AccessToken
- Throws:
OAuthServiceException
-
getPreauthorizedToken
ServerAccessToken getPreauthorizedToken(Client client, List<String> requestedScopes, UserSubject subject, String grantType) throws OAuthServiceException
Get preauthorized access token- Parameters:
client- ClientrequestedScopes- the scopes requested by the clientsubject- End User subject- Returns:
- AccessToken access token
- Throws:
OAuthServiceException
-
refreshAccessToken
ServerAccessToken refreshAccessToken(Client client, String refreshToken, List<String> requestedScopes) throws OAuthServiceException
Refresh access token- Parameters:
client- the clientrefreshToken- refresh token keyrequestedScopes- the scopes requested by the client- Returns:
- AccessToken
- Throws:
OAuthServiceException
-
getAccessTokens
List<ServerAccessToken> getAccessTokens(Client client, UserSubject subject) throws OAuthServiceException
Return all access tokens associated with a given client- Parameters:
client- the clientsubject- the user subject, can be null- Returns:
- list of access tokens
- Throws:
OAuthServiceException
-
getRefreshTokens
List<RefreshToken> getRefreshTokens(Client client, UserSubject subject) throws OAuthServiceException
Return all refresh tokens associated with a given client- Parameters:
client- the clientsubject- the user subject, can be null- Returns:
- list of refresh tokens
- Throws:
OAuthServiceException
-
revokeToken
void revokeToken(Client client, String tokenId, String tokenTypeHint) throws OAuthServiceException
Revokes a refresh or access token- Parameters:
client- the clienttokenId- token identifiertokenTypeHint- can be access_token or refresh_token or null- Throws:
OAuthServiceException
-
revokeToken
default void revokeToken(Client client, UserSubject callerSubject, String tokenId, String tokenTypeHint) throws OAuthServiceException
Revokes a refresh or access token, verifying that the authenticated resource owner's identity (callerSubject) matches the subject bound to the token. This prevents one user from revoking another user's token when multiple resource owners share the same OAuth2 client (IDOR guard).callerSubjectmay benullfor machine-to-machine (client credentials) flows where no end-user principal is present; in that case only the client-level check is applied.- Parameters:
client- the authenticated clientcallerSubject- the authenticated resource owner, ornullfor M2M flowstokenId- token identifiertokenTypeHint- can be access_token or refresh_token or null- Throws:
OAuthServiceException
-
convertScopeToPermissions
List<OAuthPermission> convertScopeToPermissions(Client client, List<String> requestedScopes)
Converts the requested scopes to the list of permissions. The scopes are extracted from OAuth2 'scope' property which if set may contain one or more space separated scope values- Parameters:
requestedScopes- the scopes- Returns:
- list of permissions
-
-