Class AbstractPersistentClientIdMetadataDocumentProvider<CONFIG extends AbstractClientIdMetadataDocumentExecutor.Configuration>
- All Implemented Interfaces:
ClientIdMetadataDocumentProvider<CONFIG>,Provider
- Direct Known Subclasses:
PersistentClientIdMetadataDocumentProvider
Creating and updating a client metadata:
The class does almost the same process in Dynamic Client Registration (DCR)in OIDCClientRegistrationProvider.
The reason is that a client sends its metadata to an authorization server in DCR by RFC 7591 while an authorization server fetches a client metadata in CIMD, which means that only the method of getting a client metadata is different.
The reason why not directly calling methods of OIDCClientRegistrationProvider is as follows:
client_idproperty is not allowed in DCR while it is mandatory in CIMD.OIDCClientRegistrationProviderdoes not allow client metadata includingclient_id.- A registration access token is issued in DCR
(to say more precisely, RFC 7592 OAuth 2.0 Dynamic Client Registration Management Protocol) while it is not needed in CIMD.
OIDCClientRegistrationProviderissues the registration access token.
Cache expiry time:
The provider stores the cache expiry time in an attribute of ClientRepresentation/ClientModel.
Process when a cache expires
Do nothing. After keycloak supports workflow for clients, it would be used to delete a client metadata.Roles of the abstract class and its concrete class:
The abstract class itself covers all about persisting a client metadata while the concrete class can see
a configuration of the concrete class of (AbstractClientIdMetadataDocumentExecutor) and augment a client metadata based on it.
Moreover, the concrete class can add or modify the abstract class, which makes it easy to implement custom persistent CIMD provider.
- Author:
- Takashi Norimatsu
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected -
Method Summary
Modifier and TypeMethodDescriptioncreateClientMetadata(AbstractClientIdMetadataDocumentExecutor.OIDCClientRepresentationWithCacheControl clientOIDCWithCacheControl) Creates a client metadata.determineFetchOperation(String clientId) Returns if fetching a client metadata to newly create it is needed, or re-fetching a client metadata to update it is needed, or re-fetching is not needed because a client metadata does not expire.protected abstract org.jboss.logging.LoggervoidsetCacheExpiryTimeToClientMetadata(ClientModel clientModel, int cacheExpiryTimeInSec) Sets a cache expiry time in sec to a client metadata.voidsetCacheExpiryTimeToClientMetadata(ClientRepresentation clientRep, int cacheExpiryTimeInSec) Sets a cache expiry time in sec to a client metadata.updateClientMetadata(AbstractClientIdMetadataDocumentExecutor.OIDCClientRepresentationWithCacheControl clientOIDCWithCacheControl) Updates a client metadata.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.keycloak.protocol.oauth2.cimd.provider.ClientIdMetadataDocumentProvider
augmentClientMetadata, close, getConfiguration, setConfiguration
-
Field Details
-
session
-
configuration
-
CIMD_CACHE_EXPIRY_TIME_IN_SEC
- See Also:
-
-
Constructor Details
-
AbstractPersistentClientIdMetadataDocumentProvider
-
-
Method Details
-
getLogger
protected abstract org.jboss.logging.Logger getLogger() -
setCacheExpiryTimeToClientMetadata
public void setCacheExpiryTimeToClientMetadata(ClientRepresentation clientRep, int cacheExpiryTimeInSec) Description copied from interface:ClientIdMetadataDocumentProviderSets a cache expiry time in sec to a client metadata.- Specified by:
setCacheExpiryTimeToClientMetadatain interfaceClientIdMetadataDocumentProvider<CONFIG extends AbstractClientIdMetadataDocumentExecutor.Configuration>- Parameters:
clientRep- a client metadata inClientRepresentation, notnullcacheExpiryTimeInSec- when a cache expires in sec
-
setCacheExpiryTimeToClientMetadata
Description copied from interface:ClientIdMetadataDocumentProviderSets a cache expiry time in sec to a client metadata.- Specified by:
setCacheExpiryTimeToClientMetadatain interfaceClientIdMetadataDocumentProvider<CONFIG extends AbstractClientIdMetadataDocumentExecutor.Configuration>- Parameters:
clientModel- a client metadata inClientModel, notnullcacheExpiryTimeInSec- when a cache expires in sec
-
determineFetchOperation
public AbstractClientIdMetadataDocumentExecutor.FetchOperation determineFetchOperation(String clientId) Description copied from interface:ClientIdMetadataDocumentProviderReturns if fetching a client metadata to newly create it is needed, or re-fetching a client metadata to update it is needed, or re-fetching is not needed because a client metadata does not expire.- Specified by:
determineFetchOperationin interfaceClientIdMetadataDocumentProvider<CONFIG extends AbstractClientIdMetadataDocumentExecutor.Configuration>- Parameters:
clientId-client_idparameter of an authorization request, notnull- Returns:
AbstractClientIdMetadataDocumentExecutor.FetchOperation
-
createClientMetadata
public ClientModel createClientMetadata(AbstractClientIdMetadataDocumentExecutor.OIDCClientRepresentationWithCacheControl clientOIDCWithCacheControl) throws ClientPolicyException Description copied from interface:ClientIdMetadataDocumentProviderCreates a client metadata.- Specified by:
createClientMetadatain interfaceClientIdMetadataDocumentProvider<CONFIG extends AbstractClientIdMetadataDocumentExecutor.Configuration>- Parameters:
clientOIDCWithCacheControl- a combination of a fetched client metadata and Cache-Control header accompanied by it, notnull- Returns:
ClientModela created client metadata inClientModel- Throws:
ClientPolicyException- when creating a client metadata fails
-
updateClientMetadata
public ClientModel updateClientMetadata(AbstractClientIdMetadataDocumentExecutor.OIDCClientRepresentationWithCacheControl clientOIDCWithCacheControl) throws ClientPolicyException Description copied from interface:ClientIdMetadataDocumentProviderUpdates a client metadata.- Specified by:
updateClientMetadatain interfaceClientIdMetadataDocumentProvider<CONFIG extends AbstractClientIdMetadataDocumentExecutor.Configuration>- Parameters:
clientOIDCWithCacheControl- a combination of a re-fetched client metadata and Cache-Control header accompanied by it, notnull- Returns:
ClientModelan updated client metadata inClientModel- Throws:
ClientPolicyException- when updating a client metadata fails
-