Package org.forgerock.oauth2.core
Interface TokenStore
-
- All Known Subinterfaces:
OpenIdConnectTokenStore
- All Known Implementing Classes:
OAuth2GuiceModule.RealmAgnosticStatefulTokenStore,OAuth2GuiceModule.RealmAgnosticStatelessTokenStore,OpenAMTokenStore,StatefulTokenStore,StatelessTokenStore
public interface TokenStoreInterface for a Token Store which the OAuth2 Provider will implement.
The Token Store will be where all types of OAuth2 tokens will be stored and later retrieved.- Since:
- 12.0.0
-
-
Field Summary
Fields Modifier and Type Field Description static StringREALM_AGNOSTIC_TOKEN_STOREA constant to identify the realm agnostic version of theTokenStoreimplementation when using dependency injection.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description AccessTokencreateAccessToken(String grantType, String accessTokenType, String authorizationCode, String resourceOwnerId, String clientId, String redirectUri, Set<String> scope, RefreshToken refreshToken, String nonce, String claims, OAuth2Request request)Creates an Access Token and stores it in the OAuth2 Provider's store.AccessTokencreateAccessToken(String grantType, String accessTokenType, String authorizationCode, String resourceOwnerId, String clientId, String redirectUri, Set<String> scope, RefreshToken refreshToken, String nonce, String claims, OAuth2Request request, long authTime)Creates an Access Token and stores it in the OAuth2 Provider's store.AuthorizationCodecreateAuthorizationCode(Set<String> scope, ResourceOwner resourceOwner, String clientId, String redirectUri, String nonce, OAuth2Request request, String codeChallenge, String codeChallengeMethod)Creates an Authorization Code and stores it in the OAuth2 Provider's store.DeviceCodecreateDeviceCode(Set<String> scope, ResourceOwner resourceOwner, String clientId, String nonce, String responseType, String state, String acrValues, String prompt, String uiLocales, String loginHint, Integer maxAge, String claims, OAuth2Request request, String codeChallenge, String codeChallengeMethod)Creates a new device code token.RefreshTokencreateRefreshToken(String grantType, String clientId, String resourceOwnerId, String redirectUri, Set<String> scope, OAuth2Request request)Creates a Refresh Token and stores it in the OAuth2 Provider's store.RefreshTokencreateRefreshToken(String grantType, String clientId, String resourceOwnerId, String redirectUri, Set<String> scope, OAuth2Request request, String validatedClaims)Creates a Refresh Token and stores it in the OAuth2 Provider's store.RefreshTokencreateRefreshToken(String grantType, String clientId, String resourceOwnerId, String redirectUri, Set<String> scope, OAuth2Request request, String validatedClaims, long authTime)Creates a Refresh Token and stores it in the OAuth2 Provider's store.RefreshTokencreateRefreshToken(String grantType, String clientId, String resourceOwnerId, String redirectUri, Set<String> scope, OAuth2Request request, String validatedClaims, String authGrantId)Creates a Refresh Token and stores it in the OAuth2 Provider's store.RefreshTokencreateRefreshToken(String grantType, String clientId, String resourceOwnerId, String redirectUri, Set<String> scope, OAuth2Request request, String validatedClaims, String authGrantId, long authTime)Creates a Refresh Token and stores it in the OAuth2 Provider's store.voiddelete(String realm, String tokenId)Deletes the Token from the OAuth2 Provider's store with the specified identifier.voiddeleteAccessToken(OAuth2Request request, String accessTokenId)Deletes an Access Token from the OAuth2 Provider's store.voiddeleteAuthorizationCode(OAuth2Request request, String authorizationCode)Deletes an Authorization Code from the OAuth2 Provider's store.voiddeleteDeviceCode(String clientId, String code, OAuth2Request request)Deletes a device code token.voiddeleteRefreshToken(OAuth2Request request, String refreshTokenId)Deletes a Refresh Token from the OAuth2 Provider's store.org.forgerock.json.JsonValuequeryForToken(String realm, org.forgerock.util.query.QueryFilter<CoreTokenField> queryFilter)Queries the OAuth2 Provider's store for tokens.org.forgerock.json.JsonValueread(String tokenId)Reads the Token from the OAuth2 Provider's store with the specified identifier.AccessTokenreadAccessToken(OAuth2Request request, String tokenId)Reads an Access Token from the OAuth2 Provider's store with the specified identifier.AuthorizationCodereadAuthorizationCode(OAuth2Request request, String code)Creates an Authorization Code and stores it in the OAuth2 Provider's store.DeviceCodereadDeviceCode(String clientId, String code, OAuth2Request request)Reads a device code token.DeviceCodereadDeviceCode(String userCode, OAuth2Request request)Reads a device code token.RefreshTokenreadRefreshToken(OAuth2Request request, String tokenId)Reads a Refresh Token from the OAuth2 Provider's store with the specified identifier.voidupdateAccessToken(OAuth2Request request, AccessToken accessToken)Updates an Access Token.voidupdateAuthorizationCode(OAuth2Request request, AuthorizationCode authorizationCode)Updates an Authorization Code.voidupdateDeviceCode(DeviceCode code, OAuth2Request request)Updates a device code token.
-
-
-
Field Detail
-
REALM_AGNOSTIC_TOKEN_STORE
static final String REALM_AGNOSTIC_TOKEN_STORE
A constant to identify the realm agnostic version of theTokenStoreimplementation when using dependency injection. The realm agnostic TokenStore does not verify whether the incomingOAuth2Request's realm is the same as the OAuth2 access token's realm.- See Also:
- Constant Field Values
-
-
Method Detail
-
createAuthorizationCode
AuthorizationCode createAuthorizationCode(Set<String> scope, ResourceOwner resourceOwner, String clientId, String redirectUri, String nonce, OAuth2Request request, String codeChallenge, String codeChallengeMethod) throws ServerException, NotFoundException
Creates an Authorization Code and stores it in the OAuth2 Provider's store.- Parameters:
scope- The requested scope.resourceOwner- The resource owner.clientId- The client's id.redirectUri- The redirect uri.nonce- The nonce.request- The OAuth2 request.codeChallenge-codeChallengeMethod-- Returns:
- An AuthorizationCode.
- Throws:
ServerException- If any internal server error occurs.NotFoundException- If the realm does not have an OAuth 2.0 provider service.
-
createAccessToken
AccessToken createAccessToken(String grantType, String accessTokenType, String authorizationCode, String resourceOwnerId, String clientId, String redirectUri, Set<String> scope, RefreshToken refreshToken, String nonce, String claims, OAuth2Request request) throws ServerException, NotFoundException
Creates an Access Token and stores it in the OAuth2 Provider's store.- Parameters:
grantType- The grant type.accessTokenType- The access token type.authorizationCode- The authorization code.resourceOwnerId- The resource owner's id.clientId- The client's id.redirectUri- The redirect uri.scope- The requested scope.refreshToken- The refresh token. May benull.nonce- The nonce.claims- Additional claims requested (for id_token or userinfo).request- The OAuth2 request.- Returns:
- An Access Token.
- Throws:
ServerException- If any internal server error occurs.NotFoundException- If the realm does not have an OAuth 2.0 provider service.
-
createAccessToken
AccessToken createAccessToken(String grantType, String accessTokenType, String authorizationCode, String resourceOwnerId, String clientId, String redirectUri, Set<String> scope, RefreshToken refreshToken, String nonce, String claims, OAuth2Request request, long authTime) throws ServerException, NotFoundException
Creates an Access Token and stores it in the OAuth2 Provider's store.- Parameters:
grantType- The grant type.accessTokenType- The access token type.authorizationCode- The authorization code.resourceOwnerId- The resource owner's id.clientId- The client's id.redirectUri- The redirect uri.scope- The requested scope.refreshToken- The refresh token. May benull.nonce- The nonce.claims- Additional claims requested (for id_token or userinfo).request- The OAuth2 request.authTime- The end user's authentication time.- Returns:
- An Access Token.
- Throws:
ServerException- If any internal server error occurs.NotFoundException- If the realm does not have an OAuth 2.0 provider service.
-
createRefreshToken
RefreshToken createRefreshToken(String grantType, String clientId, String resourceOwnerId, String redirectUri, Set<String> scope, OAuth2Request request) throws ServerException, NotFoundException
Creates a Refresh Token and stores it in the OAuth2 Provider's store.- Parameters:
grantType- The OAuth2 Grant Type.clientId- The client's id.resourceOwnerId- The resource owner's Id.redirectUri- The redirect uri.scope- The requested scope.request- The OAuth2 request.- Returns:
- A RefreshToken
- Throws:
ServerException- If any internal server error occurs.NotFoundException- If the realm does not have an OAuth 2.0 provider service.
-
createRefreshToken
RefreshToken createRefreshToken(String grantType, String clientId, String resourceOwnerId, String redirectUri, Set<String> scope, OAuth2Request request, String validatedClaims) throws ServerException, NotFoundException
Creates a Refresh Token and stores it in the OAuth2 Provider's store.- Parameters:
grantType- The OAuth2 Grant Type.clientId- The client's id.resourceOwnerId- The resource owner's Id.redirectUri- The redirect uri.scope- The requested scope.request- The OAuth2 request.validatedClaims- The validated claims.- Returns:
- A RefreshToken
- Throws:
ServerException- If any internal server error occurs.NotFoundException- If the realm does not have an OAuth 2.0 provider service.
-
createRefreshToken
RefreshToken createRefreshToken(String grantType, String clientId, String resourceOwnerId, String redirectUri, Set<String> scope, OAuth2Request request, String validatedClaims, long authTime) throws ServerException, NotFoundException
Creates a Refresh Token and stores it in the OAuth2 Provider's store.- Parameters:
grantType- The OAuth2 Grant Type.clientId- The client's id.resourceOwnerId- The resource owner's Id.redirectUri- The redirect uri.scope- The requested scope.request- The OAuth2 request.validatedClaims- The validated claims.authTime- The end user's authentication time.- Returns:
- A RefreshToken
- Throws:
ServerException- If any internal server error occurs.NotFoundException- If the realm does not have an OAuth 2.0 provider service.
-
createRefreshToken
RefreshToken createRefreshToken(String grantType, String clientId, String resourceOwnerId, String redirectUri, Set<String> scope, OAuth2Request request, String validatedClaims, String authGrantId) throws ServerException, NotFoundException
Creates a Refresh Token and stores it in the OAuth2 Provider's store.- Parameters:
grantType- The OAuth2 Grant Type.clientId- The client's id.resourceOwnerId- The resource owner's Id.redirectUri- The redirect uri.scope- The requested scope.request- The OAuth2 request.validatedClaims- The validated claims.authGrantId- The authorization grant Id.- Returns:
- A RefreshToken
- Throws:
ServerException- If any internal server error occurs.NotFoundException- If the realm does not have an OAuth 2.0 provider service.
-
createRefreshToken
RefreshToken createRefreshToken(String grantType, String clientId, String resourceOwnerId, String redirectUri, Set<String> scope, OAuth2Request request, String validatedClaims, String authGrantId, long authTime) throws ServerException, NotFoundException
Creates a Refresh Token and stores it in the OAuth2 Provider's store.- Parameters:
grantType- The OAuth2 Grant Type.clientId- The client's id.resourceOwnerId- The resource owner's Id.redirectUri- The redirect uri.scope- The requested scope.request- The OAuth2 request.validatedClaims- The validated claims.authGrantId- The authorization grant Id.authTime- The end user's authentication time.- Returns:
- A RefreshToken
- Throws:
ServerException- If any internal server error occurs.NotFoundException- If the realm does not have an OAuth 2.0 provider service.
-
readAuthorizationCode
AuthorizationCode readAuthorizationCode(OAuth2Request request, String code) throws InvalidGrantException, ServerException, NotFoundException
Creates an Authorization Code and stores it in the OAuth2 Provider's store.- Parameters:
request- The current request.code- The authorization code identifier.- Returns:
- The Authorization Code.
- Throws:
InvalidGrantException- If a problem occurs whilst retrieving the Authorization Code or if the read token is not an Authorization Code.ServerException- If any internal server error occurs.NotFoundException- If the requested realm does not exist.
-
updateAuthorizationCode
void updateAuthorizationCode(OAuth2Request request, AuthorizationCode authorizationCode) throws NotFoundException, ServerException
Updates an Authorization Code.- Parameters:
request- The current request.authorizationCode- The authorization code.- Throws:
ServerException- If the authorization code could not be updated.NotFoundException- If the requested realm does not exist.
-
updateAccessToken
void updateAccessToken(OAuth2Request request, AccessToken accessToken) throws NotFoundException, ServerException
Updates an Access Token.- Parameters:
request- The current request.accessToken- The access token.- Throws:
ServerException- If the token could not be updated.NotFoundException- If the requested realm does not exist.
-
deleteAuthorizationCode
void deleteAuthorizationCode(OAuth2Request request, String authorizationCode) throws NotFoundException, ServerException
Deletes an Authorization Code from the OAuth2 Provider's store.- Parameters:
request- The current request.authorizationCode- The authorization code.- Throws:
ServerException- If the authorization code could not be deleted.NotFoundException- If the requested realm does not exist.
-
deleteAccessToken
void deleteAccessToken(OAuth2Request request, String accessTokenId) throws ServerException, NotFoundException
Deletes an Access Token from the OAuth2 Provider's store.- Parameters:
request- The current request.accessTokenId- The access token identifier.- Throws:
ServerException- If the token could not be deleted.NotFoundException- If the requested realm does not exist.
-
deleteRefreshToken
void deleteRefreshToken(OAuth2Request request, String refreshTokenId) throws InvalidRequestException, NotFoundException, ServerException
Deletes a Refresh Token from the OAuth2 Provider's store.- Parameters:
request- The current request.refreshTokenId- The refresh token identifier.- Throws:
InvalidRequestException- If the token could not be deleted.ServerException- If the token could not be deleted.NotFoundException- If the requested realm does not exist.
-
readAccessToken
AccessToken readAccessToken(OAuth2Request request, String tokenId) throws ServerException, InvalidGrantException, NotFoundException
Reads an Access Token from the OAuth2 Provider's store with the specified identifier.- Parameters:
request- The current request.tokenId- The token identifier.- Returns:
- The Access Token.
- Throws:
InvalidGrantException- If the token is not an Access Token.ServerException- If the token could not be read by the server.NotFoundException- If the requested realm does not exist.
-
readRefreshToken
RefreshToken readRefreshToken(OAuth2Request request, String tokenId) throws ServerException, InvalidGrantException, NotFoundException
Reads a Refresh Token from the OAuth2 Provider's store with the specified identifier.- Parameters:
request- The current request.tokenId- The token identifier.- Returns:
- The Refresh Token.
- Throws:
InvalidGrantException- If the token is not a Refresh Token.ServerException- If the token could not be read by the server.NotFoundException- If the requested realm does not exist.
-
createDeviceCode
DeviceCode createDeviceCode(Set<String> scope, ResourceOwner resourceOwner, String clientId, String nonce, String responseType, String state, String acrValues, String prompt, String uiLocales, String loginHint, Integer maxAge, String claims, OAuth2Request request, String codeChallenge, String codeChallengeMethod) throws ServerException, NotFoundException
Creates a new device code token.- Parameters:
scope- The scope of the requested access token.resourceOwner- The resource owner ID.clientId- The client ID.nonce- The nonce for the ID token.responseType- The response type string.state- The client-side state token.acrValues- The requested ACR values.prompt- The prompt request parameter.uiLocales- The ui_locales request parameter.loginHint- The login_hint request parameter.maxAge- The max_age request parameter.claims- The claims request parameter for ID token claims.request- The request.codeChallenge- The submitted code challenge.codeChallengeMethod- The code challenge method.- Returns:
- The created device code object.
- Throws:
ServerException- If there was an error in constructing the code.NotFoundException- If the realm does not have an OAuth2Provider configured.
-
readDeviceCode
DeviceCode readDeviceCode(String clientId, String code, OAuth2Request request) throws ServerException, NotFoundException, InvalidGrantException
Reads a device code token.- Parameters:
clientId- The client ID.request- The request.code- The device code.- Returns:
- The device code object.
- Throws:
ServerException- If there was an error in constructing the code.NotFoundException- If the realm does not have an OAuth2Provider configured.InvalidGrantException
-
readDeviceCode
DeviceCode readDeviceCode(String userCode, OAuth2Request request) throws ServerException, NotFoundException, InvalidGrantException
Reads a device code token.- Parameters:
request- The request.userCode- The device code's user code.- Returns:
- The device code object.
- Throws:
ServerException- If there was an error in constructing the code.NotFoundException- If the realm does not have an OAuth2Provider configured.InvalidGrantException
-
updateDeviceCode
void updateDeviceCode(DeviceCode code, OAuth2Request request) throws ServerException, NotFoundException, InvalidGrantException
Updates a device code token.- Parameters:
request- The request.code- The device code object.- Throws:
ServerException- If there was an error in constructing the code.NotFoundException- If the realm does not have an OAuth2Provider configured.InvalidGrantException
-
deleteDeviceCode
void deleteDeviceCode(String clientId, String code, OAuth2Request request) throws ServerException, NotFoundException, InvalidGrantException
Deletes a device code token.- Parameters:
clientId- The client ID.request- The request.code- The device code.- Throws:
ServerException- If there was an error in constructing the code.NotFoundException- If the realm does not have an OAuth2Provider configured.InvalidGrantException
-
queryForToken
org.forgerock.json.JsonValue queryForToken(String realm, org.forgerock.util.query.QueryFilter<CoreTokenField> queryFilter) throws ServerException, NotFoundException
Queries the OAuth2 Provider's store for tokens.- Parameters:
realm- The Realm.queryFilter- The query keyed by auth grant id, client id and resource owner.- Returns:
- A JsonValue of the query results.
- Throws:
ServerException- If there was an error in reading the token using the id.NotFoundException- If the realm does not have an OAuth2Provider configured.
-
delete
void delete(String realm, String tokenId) throws ServerException, NotFoundException
Deletes the Token from the OAuth2 Provider's store with the specified identifier.- Parameters:
realm- The RealmtokenId- The token ID- Throws:
ServerException- If there was an error in reading the token using the id.NotFoundException- If the realm does not have an OAuth2Provider configured.
-
read
org.forgerock.json.JsonValue read(String tokenId) throws ServerException, NotFoundException
Reads the Token from the OAuth2 Provider's store with the specified identifier.- Parameters:
tokenId- The token ID- Returns:
- A JsonValue of the token. May be
nullif the token is not found. - Throws:
ServerException- If there was an error in reading the token using the id.NotFoundException- If the realm does not have an OAuth2Provider configured.
-
-