public class JPACMTCodeDataProvider extends JPACodeDataProvider
JPACodeDataProvider
(stores Clients and tokens in a rdbms using
JPA APIs).
The transaction demarcation is handled by the container (be it Spring
or Java EE).
Sample usage with Spring XML:
<bean id="oauthProvider" class="org.apache.cxf.rs.security.oauth2.grants.code.JPACMTCodeDataProvider"
init-method="init" destroy-method="close">
<property name="entityManager" ref="entityManager"/>
<!-- List of accepted scopes -->
<property name="supportedScopes" ref="supportedScopes"/>
<!-- List of required scopes -->
<!-- commented because bug in Resource Owner Flow
<property name="requiredScopes" ref="coreScopes"/>
-->
<!--
List of scopes that the consent/authorization form should make
selected by default. For example, asking a user to do an extra click
to approve an "oidc" scope is a redundant operation because this scope
is required anyway.
-->
<property name="defaultScopes" ref="coreScopes"/>
<property name="invisibleToClientScopes" ref="invisibleToClientScopes"/>
</bean>
<bean name="entityManager" class="org.springframework.orm.jpa.support.SharedEntityManagerBean">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>
...
You can also extend this class and inject your own entityManager:
{@code
public class MyJPACodeDataProvider extends JPACMTCodeDataProvider {JPAOAuthDataProvider.EntityManagerOperation<T>
Constructor and Description |
---|
JPACMTCodeDataProvider() |
Modifier and Type | Method and Description |
---|---|
protected javax.persistence.EntityTransaction |
beginIfNeeded(javax.persistence.EntityManager em)
Doesn't do anything, beginning tx is handled by container.
|
protected void |
closeIfNeeded(javax.persistence.EntityManager em)
Doesn't do anything, em lifecycle is handled by container.
|
protected void |
commitIfNeeded(javax.persistence.EntityManager em)
Doesn't do anything, commit is handled by container.
|
protected javax.persistence.EntityManager |
getEntityManager()
Returns the entityManaged used for the current operation.
|
protected void |
lockRefreshTokenForUpdate(RefreshToken refreshToken) |
void |
setEntityManager(javax.persistence.EntityManager entityManager) |
void |
setPessimisticLockTimeout(int pessimisticLockTimeout) |
void |
setUseJpaLockForExistingRefreshToken(boolean useJpaLockForExistingRefreshToken) |
protected RefreshToken |
updateExistingRefreshToken(RefreshToken rt,
ServerAccessToken at) |
createCodeGrant, doCreateCodeGrant, doRemoveClient, getCodeGrants, getCodesQuery, removeClientCodeGrants, removeClientCodeGrants, removeCodeGrant, saveCodeGrant, setCodeLifetime
doCreateAccessToken, doGetClient, doRevokeAccessToken, doRevokeRefreshToken, execute, executeInTransaction, flushIfNeeded, getAccessToken, getAccessTokens, getClients, getClientsQuery, getRefreshToken, getRefreshTokens, getRefreshTokensQuery, getTokensQuery, linkRefreshTokenToAccessToken, persistEntity, removeEntity, saveAccessToken, saveRefreshToken, setClient, setEntityManagerFactory
authenticateUnregisteredClient, checkRequestedScopes, close, convertScopeToPermissions, convertSingleScopeToPermission, createAccessToken, createClientCredentialsClient, createJwtAccessToken, createNewAccessToken, createNewRefreshToken, doCreateNewRefreshToken, doRefreshAccessToken, getClient, getCurrentClientSecret, getCurrentRequestedGrantType, getCurrentTokenRequestParams, getDefaultScopes, getInvisibleToClientScopes, getIssuer, getJwtAccessTokenClaimMap, getJwtAccessTokenProducer, getMessageContext, getPermissionMap, getPreauthorizedToken, getRequiredScopes, handleLinkedRefreshToken, init, isClientMatched, isPersistJwtEncoding, isRecycleRefreshTokens, isRefreshTokenSupported, isSupportPreauthorizedTokens, isTokenMatched, isUseJwtFormatForAccessTokens, linkAccessTokenToRefreshToken, processJwtAccessToken, refreshAccessToken, removeClient, removeClientTokens, revokeAccessToken, revokeAccessTokens, revokeRefreshToken, revokeToken, setAccessTokenLifetime, setAuthenticationStrategy, setClients, setDefaultScopes, setInvisibleToClientScopes, setIssuer, setJwtAccessTokenClaimMap, setJwtAccessTokenProducer, setMessageContext, setPermissionMap, setPersistJwtEncoding, setRecycleRefreshTokens, setRefreshTokenLifetime, setRequiredScopes, setSupportedScopes, setSupportPreauthorizedTokens, setUseJwtFormatForAccessTokens, unlinkRefreshAccessToken, updateRefreshToken
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
convertScopeToPermissions, createAccessToken, getAccessToken, getAccessTokens, getClient, getPreauthorizedToken, getRefreshTokens, refreshAccessToken, revokeToken
protected javax.persistence.EntityManager getEntityManager()
getEntityManager
in class JPAOAuthDataProvider
public void setEntityManager(javax.persistence.EntityManager entityManager)
protected javax.persistence.EntityTransaction beginIfNeeded(javax.persistence.EntityManager em)
beginIfNeeded
in class JPAOAuthDataProvider
protected void commitIfNeeded(javax.persistence.EntityManager em)
commitIfNeeded
in class JPAOAuthDataProvider
protected void closeIfNeeded(javax.persistence.EntityManager em)
closeIfNeeded
in class JPAOAuthDataProvider
protected RefreshToken updateExistingRefreshToken(RefreshToken rt, ServerAccessToken at)
updateExistingRefreshToken
in class AbstractOAuthDataProvider
protected void lockRefreshTokenForUpdate(RefreshToken refreshToken)
public void setPessimisticLockTimeout(int pessimisticLockTimeout)
public void setUseJpaLockForExistingRefreshToken(boolean useJpaLockForExistingRefreshToken)
Apache CXF