Class AbstractOAuthDataProvider
- java.lang.Object
-
- org.apache.cxf.rs.security.oauth2.provider.AbstractOAuthDataProvider
-
- All Implemented Interfaces:
ClientRegistrationProvider,OAuthDataProvider
- Direct Known Subclasses:
AbstractAuthorizationCodeDataProvider,AbstractCodeDataProvider,DefaultEncryptingOAuthDataProvider,JCacheOAuthDataProvider,JPAOAuthDataProvider
public abstract class AbstractOAuthDataProvider extends Object implements OAuthDataProvider, ClientRegistrationProvider
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractOAuthDataProvider()
-
Method Summary
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.cxf.rs.security.oauth2.provider.ClientRegistrationProvider
getClients, setClient
-
Methods inherited from interface org.apache.cxf.rs.security.oauth2.provider.OAuthDataProvider
getAccessToken, getAccessTokens, getRefreshTokens
-
-
-
-
Method Detail
-
createAccessToken
public ServerAccessToken createAccessToken(AccessTokenRegistration reg) throws OAuthServiceException
Description copied from interface:OAuthDataProviderCreate access token- Specified by:
createAccessTokenin interfaceOAuthDataProvider- Parameters:
reg- the token registration info- Returns:
- AccessToken
- Throws:
OAuthServiceException
-
doCreateAccessToken
protected ServerAccessToken doCreateAccessToken(AccessTokenRegistration atReg)
-
doCreateAccessToken
protected ServerAccessToken doCreateAccessToken(List<String> audiences, Client client, String clientCodeVerifier, Map<String,String> extraProperties, String grantCode, String grantType, String nonce, String responseType, List<OAuthPermission> scopes, UserSubject userSubject)
-
createJwtAccessToken
protected org.apache.cxf.rs.security.jose.jwt.JwtClaims createJwtAccessToken(ServerAccessToken at)
-
convertToJWTAccessToken
protected void convertToJWTAccessToken(ServerAccessToken at)
-
createNewAccessToken
protected ServerAccessToken createNewAccessToken(Client client, UserSubject userSub)
-
refreshAccessToken
public ServerAccessToken refreshAccessToken(Client client, String refreshTokenKey, List<String> restrictedScopes) throws OAuthServiceException
Description copied from interface:OAuthDataProviderRefresh access token- Specified by:
refreshAccessTokenin interfaceOAuthDataProvider- Parameters:
client- the clientrefreshTokenKey- refresh token keyrestrictedScopes- the scopes requested by the client- Returns:
- AccessToken
- Throws:
OAuthServiceException
-
revokeToken
public void revokeToken(Client client, String tokenKey, String tokenTypeHint) throws OAuthServiceException
Description copied from interface:OAuthDataProviderRevokes a refresh or access token- Specified by:
revokeTokenin interfaceOAuthDataProvider- Parameters:
client- the clienttokenKey- token identifiertokenTypeHint- can be access_token or refresh_token or null- Throws:
OAuthServiceException
-
revokeToken
public void revokeToken(Client client, UserSubject callerSubject, String tokenKey, String tokenTypeHint) throws OAuthServiceException
Description copied from interface:OAuthDataProviderRevokes 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.- Specified by:
revokeTokenin interfaceOAuthDataProvider- Parameters:
client- the authenticated clientcallerSubject- the authenticated resource owner, ornullfor M2M flowstokenKey- token identifiertokenTypeHint- can be access_token or refresh_token or null- Throws:
OAuthServiceException
-
handleLinkedRefreshToken
protected void handleLinkedRefreshToken(Client client, ServerAccessToken accessToken)
-
revokeAccessTokens
protected void revokeAccessTokens(Client client, RefreshToken currentRefreshToken)
-
unlinkRefreshAccessToken
protected void unlinkRefreshAccessToken(RefreshToken rt, String tokenKey)
-
convertScopeToPermissions
public List<OAuthPermission> convertScopeToPermissions(Client client, List<String> requestedScopes)
Description copied from interface:OAuthDataProviderConverts 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- Specified by:
convertScopeToPermissionsin interfaceOAuthDataProviderrequestedScopes- the scopes- Returns:
- list of permissions
-
checkRequestedScopes
protected void checkRequestedScopes(Client client, List<String> requestedScopes)
-
convertSingleScopeToPermission
protected void convertSingleScopeToPermission(Client client, String scope, List<OAuthPermission> perms)
-
getPreauthorizedToken
public ServerAccessToken getPreauthorizedToken(Client client, List<String> requestedScopes, UserSubject sub, String grantType) throws OAuthServiceException
Description copied from interface:OAuthDataProviderGet preauthorized access token- Specified by:
getPreauthorizedTokenin interfaceOAuthDataProvider- Parameters:
client- ClientrequestedScopes- the scopes requested by the clientsub- End User subject- Returns:
- AccessToken access token
- Throws:
OAuthServiceException
-
getCurrentRequestedGrantType
protected String getCurrentRequestedGrantType()
-
getCurrentClientSecret
protected String getCurrentClientSecret()
-
getCurrentTokenRequestParams
protected javax.ws.rs.core.MultivaluedMap<String,String> getCurrentTokenRequestParams()
-
updateExistingRefreshToken
protected RefreshToken updateExistingRefreshToken(RefreshToken rt, ServerAccessToken at)
-
updateRefreshToken
protected RefreshToken updateRefreshToken(RefreshToken rt, ServerAccessToken at)
-
createNewRefreshToken
protected RefreshToken createNewRefreshToken(ServerAccessToken at)
-
doCreateNewRefreshToken
protected RefreshToken doCreateNewRefreshToken(ServerAccessToken at)
-
linkAccessTokenToRefreshToken
protected void linkAccessTokenToRefreshToken(RefreshToken rt, ServerAccessToken at)
-
linkRefreshTokenToAccessToken
protected void linkRefreshTokenToAccessToken(RefreshToken rt, ServerAccessToken at)
-
doRefreshAccessToken
protected ServerAccessToken doRefreshAccessToken(Client client, RefreshToken oldRefreshToken, List<String> restrictedScopes)
-
setAccessTokenLifetime
public void setAccessTokenLifetime(long accessTokenLifetime)
-
setRefreshTokenLifetime
public void setRefreshTokenLifetime(long refreshTokenLifetime)
-
setRecycleRefreshTokens
public void setRecycleRefreshTokens(boolean recycleRefreshTokens)
-
isRecycleRefreshTokens
public boolean isRecycleRefreshTokens()
-
init
public void init()
-
close
public void close()
-
getPermissionMap
public Map<String,OAuthPermission> getPermissionMap()
-
setPermissionMap
public void setPermissionMap(Map<String,OAuthPermission> permissionMap)
-
getMessageContext
public org.apache.cxf.jaxrs.ext.MessageContext getMessageContext()
-
setMessageContext
public void setMessageContext(org.apache.cxf.jaxrs.ext.MessageContext messageContext)
-
removeClientTokens
protected void removeClientTokens(Client c)
-
removeClient
public Client removeClient(String clientId)
Description copied from interface:ClientRegistrationProviderRemove a Client with the given id- Specified by:
removeClientin interfaceClientRegistrationProvider- Parameters:
clientId- the client id- Returns:
- Client
-
getClient
public Client getClient(String clientId)
Description copied from interface:OAuthDataProviderReturns the previously registered third-partyClient- Specified by:
getClientin interfaceClientRegistrationProvider- Specified by:
getClientin interfaceOAuthDataProvider- Parameters:
clientId- the client id- Returns:
- Client
-
setAuthenticationStrategy
public void setAuthenticationStrategy(ProviderAuthenticationStrategy authenticationStrategy)
-
authenticateUnregisteredClient
protected boolean authenticateUnregisteredClient(String clientId, String clientSecret)
-
createClientCredentialsClient
protected Client createClientCredentialsClient(String clientId, String password)
-
revokeAccessToken
protected ServerAccessToken revokeAccessToken(Client client, String accessTokenKey)
-
revokeAccessToken
protected ServerAccessToken revokeAccessToken(Client client, UserSubject callerSubject, String accessTokenKey)
-
revokeRefreshToken
protected RefreshToken revokeRefreshToken(Client client, String refreshTokenKey)
-
revokeRefreshToken
protected RefreshToken revokeRefreshToken(Client client, UserSubject callerSubject, String refreshTokenKey)
-
saveAccessToken
protected abstract void saveAccessToken(ServerAccessToken serverToken)
-
saveRefreshToken
protected abstract void saveRefreshToken(RefreshToken refreshToken)
-
doRevokeAccessToken
protected abstract void doRevokeAccessToken(ServerAccessToken accessToken)
-
doRevokeRefreshToken
protected abstract void doRevokeRefreshToken(RefreshToken refreshToken)
-
getRefreshToken
protected abstract RefreshToken getRefreshToken(String refreshTokenKey)
-
doRemoveClient
protected abstract void doRemoveClient(Client c)
-
setInvisibleToClientScopes
public void setInvisibleToClientScopes(List<String> invisibleToClientScopes)
-
isSupportPreauthorizedTokens
public boolean isSupportPreauthorizedTokens()
-
setSupportPreauthorizedTokens
public void setSupportPreauthorizedTokens(boolean supportPreauthorizedTokens)
-
isClientMatched
protected static boolean isClientMatched(Client c, UserSubject resourceOwner)
-
isTokenMatched
protected static boolean isTokenMatched(ServerAccessToken token, Client c, UserSubject sub)
-
isUseJwtFormatForAccessTokens
public boolean isUseJwtFormatForAccessTokens()
-
setUseJwtFormatForAccessTokens
public void setUseJwtFormatForAccessTokens(boolean useJwtFormatForAccessTokens)
-
getJwtAccessTokenProducer
public OAuthJoseJwtProducer getJwtAccessTokenProducer()
-
setJwtAccessTokenProducer
public void setJwtAccessTokenProducer(OAuthJoseJwtProducer jwtAccessTokenProducer)
-
processJwtAccessToken
protected String processJwtAccessToken(org.apache.cxf.rs.security.jose.jwt.JwtClaims jwtCliams)
-
setJwtAccessTokenClaimMap
public void setJwtAccessTokenClaimMap(Map<String,String> jwtAccessTokenClaimMap)
-
isPersistJwtEncoding
public boolean isPersistJwtEncoding()
-
setPersistJwtEncoding
public void setPersistJwtEncoding(boolean persistJwtEncoding)
-
getIssuer
public String getIssuer()
-
setIssuer
public void setIssuer(String issuer)
-
-