Package org.keycloak.storage
Class ClientStorageManager
java.lang.Object
org.keycloak.storage.ClientStorageManager
- All Implemented Interfaces:
ClientProvider,Provider,ClientLookupProvider
- Version:
- $Revision: 1 $
- Author:
- Bill Burke
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionClientStorageManager(KeycloakSession session, long clientStorageProviderTimeout) -
Method Summary
Modifier and TypeMethodDescriptionaddClient(RealmModel realm, String clientId) Adds a client with givenclientIdto the given realm.addClient(RealmModel realm, String id, String clientId) Adds a client with given internal ID andclientIdto the given realm.voidaddClientScopes(RealmModel realm, ClientModel client, Set<ClientScopeModel> clientScopes, boolean defaultScope) Assign clientScopes to the client.voidaddClientScopeToAllClients(RealmModel realm, ClientScopeModel clientScope, boolean defaultClientScope) Add specified client scope to all non bearer-only clients in the realm, which have same protocol as specified client scope.voidclose()Returns a map of (rootUrl, {validRedirectUris}) for all enabled clients.Returns a stream of clients that are expected to always show up in account console.getClientByClientId(RealmModel realm, String clientId) Exact search for a client by its public client identifier.getClientById(RealmModel realm, String id) Exact search for a client by its internal ID.getClientScopes(RealmModel realm, ClientModel client, boolean defaultScopes) Return all default scopes (ifdefaultScopeistrue) or all optional scopes (ifdefaultScopeisfalse) linked with the clientlonggetClientsCount(RealmModel realm) Returns number of clients in the given realmgetClientsStream(RealmModel realm) Returns all the clients of the given realm as a stream.getClientsStream(RealmModel realm, Integer firstResult, Integer maxResults) Returns the clients of the given realm as a stream.static <T> Stream<T>getEnabledStorageProviders(KeycloakSession session, RealmModel realm, Class<T> type) static ClientStorageProvidergetStorageProvider(KeycloakSession session, RealmModel realm, String componentId) static ClientStorageProvidergetStorageProviderInstance(KeycloakSession session, ClientStorageProviderModel model, ClientStorageProviderFactory factory) static ClientStorageProviderModelgetStorageProviderModel(RealmModel realm, String componentId) static <T> Stream<T>getStorageProviders(KeycloakSession session, RealmModel realm, Class<T> type) static booleanhasEnabledStorageProviders(KeycloakSession session, RealmModel realm, Class<?> type) static booleanisStorageProviderEnabled(RealmModel realm, String providerId) protected Stream<ClientModel>query(org.keycloak.storage.ClientStorageManager.PaginatedQuery paginatedQuery, RealmModel realm, Integer firstResult, Integer maxResults) booleanremoveClient(RealmModel realm, String id) Removes given client from the given realm.voidremoveClients(RealmModel realm) Removes all clients from the given realm.voidremoveClientScope(RealmModel realm, ClientModel client, ClientScopeModel clientScope) Unassign clientScope from the client.searchClientsByAttributes(RealmModel realm, Map<String, String> attributes, Integer firstResult, Integer maxResults) searchClientsByAuthenticationFlowBindingOverrides(RealmModel realm, Map<String, String> overrides, Integer firstResult, Integer maxResults) searchClientsByClientIdStream(RealmModel realm, String clientId, Integer firstResult, Integer maxResults) Case-insensitive search for clients that contain the given string in their public client identifier.
-
Field Details
-
session
-
-
Constructor Details
-
ClientStorageManager
-
-
Method Details
-
isStorageProviderEnabled
-
getStorageProviderModel
public static ClientStorageProviderModel getStorageProviderModel(RealmModel realm, String componentId) -
getStorageProvider
public static ClientStorageProvider getStorageProvider(KeycloakSession session, RealmModel realm, String componentId) -
getStorageProviderInstance
public static ClientStorageProvider getStorageProviderInstance(KeycloakSession session, ClientStorageProviderModel model, ClientStorageProviderFactory factory) -
getStorageProviders
public static <T> Stream<T> getStorageProviders(KeycloakSession session, RealmModel realm, Class<T> type) -
getEnabledStorageProviders
public static <T> Stream<T> getEnabledStorageProviders(KeycloakSession session, RealmModel realm, Class<T> type) -
hasEnabledStorageProviders
public static boolean hasEnabledStorageProviders(KeycloakSession session, RealmModel realm, Class<?> type) -
getClientById
Description copied from interface:ClientLookupProviderExact search for a client by its internal ID.- Specified by:
getClientByIdin interfaceClientLookupProvider- Parameters:
realm- Realm to limit the search.id- Internal ID- Returns:
- Model of the client, or
nullif no client is found.
-
getClientByClientId
Description copied from interface:ClientLookupProviderExact search for a client by its public client identifier.- Specified by:
getClientByClientIdin interfaceClientLookupProvider- Parameters:
realm- Realm to limit the search for clients.clientId- String that identifies the client to the external parties. Maps toclient_idin OIDC orentityIDin SAML.- Returns:
- Model of the client, or
nullif no client is found.
-
searchClientsByClientIdStream
public Stream<ClientModel> searchClientsByClientIdStream(RealmModel realm, String clientId, Integer firstResult, Integer maxResults) Description copied from interface:ClientLookupProviderCase-insensitive search for clients that contain the given string in their public client identifier.- Specified by:
searchClientsByClientIdStreamin interfaceClientLookupProvider- Parameters:
realm- Realm to limit the search for clients.clientId- Searched substring of the public client identifier (client_idin OIDC orentityIDin SAML.)firstResult- First result to return. Ignored if negative ornull.maxResults- Maximum number of results to return. Ignored if negative ornull.- Returns:
- Stream of ClientModel or an empty stream if no client is found. Never returns
null.
-
searchClientsByAttributes
public Stream<ClientModel> searchClientsByAttributes(RealmModel realm, Map<String, String> attributes, Integer firstResult, Integer maxResults) - Specified by:
searchClientsByAttributesin interfaceClientLookupProvider
-
searchClientsByAuthenticationFlowBindingOverrides
public Stream<ClientModel> searchClientsByAuthenticationFlowBindingOverrides(RealmModel realm, Map<String, String> overrides, Integer firstResult, Integer maxResults) - Specified by:
searchClientsByAuthenticationFlowBindingOverridesin interfaceClientLookupProvider
-
query
protected Stream<ClientModel> query(org.keycloak.storage.ClientStorageManager.PaginatedQuery paginatedQuery, RealmModel realm, Integer firstResult, Integer maxResults) -
getClientScopes
public Map<String,ClientScopeModel> getClientScopes(RealmModel realm, ClientModel client, boolean defaultScopes) Description copied from interface:ClientLookupProviderReturn all default scopes (ifdefaultScopeistrue) or all optional scopes (ifdefaultScopeisfalse) linked with the client- Specified by:
getClientScopesin interfaceClientLookupProvider- Parameters:
realm- Realmclient- ClientdefaultScopes- if true default scopes, if false optional scopes, are returned- Returns:
- map where key is the name of the clientScope, value is particular clientScope. Returns empty map if no scopes linked (never returns null).
-
addClient
Description copied from interface:ClientProviderAdds a client with givenclientIdto the given realm. The internal ID of the client will be created automatically.- Specified by:
addClientin interfaceClientProvider- Parameters:
realm- Realm owning this client.clientId- String that identifies the client to the external parties. Maps toclient_idin OIDC orentityIDin SAML.- Returns:
- Model of the created client.
-
addClient
Description copied from interface:ClientProviderAdds a client with given internal ID andclientIdto the given realm.- Specified by:
addClientin interfaceClientProvider- Parameters:
realm- Realm owning this client.id- Internal ID of the client ornullif one is to be created by the underlying storeclientId- String that identifies the client to the external parties. Maps toclient_idin OIDC orentityIDin SAML.- Returns:
- Model of the created client.
-
getClientsStream
public Stream<ClientModel> getClientsStream(RealmModel realm, Integer firstResult, Integer maxResults) Description copied from interface:ClientProviderReturns the clients of the given realm as a stream.- Specified by:
getClientsStreamin interfaceClientProvider- Parameters:
realm- Realm.firstResult- First result to return. Ignored if negative ornull.maxResults- Maximum number of results to return. Ignored if negative ornull.- Returns:
- Stream of the clients. Never returns
null.
-
getClientsStream
Description copied from interface:ClientProviderReturns all the clients of the given realm as a stream. Effectively the same as the callgetClientsStream(realm, null, null).- Specified by:
getClientsStreamin interfaceClientProvider- Parameters:
realm- Realm.- Returns:
- Stream of the clients. Never returns
null.
-
getClientsCount
Description copied from interface:ClientProviderReturns number of clients in the given realm- Specified by:
getClientsCountin interfaceClientProvider- Parameters:
realm- Realm.- Returns:
- Number of the clients in the given realm.
-
getAlwaysDisplayInConsoleClientsStream
Description copied from interface:ClientProviderReturns a stream of clients that are expected to always show up in account console.- Specified by:
getAlwaysDisplayInConsoleClientsStreamin interfaceClientProvider- Parameters:
realm- Realm owning the clients.- Returns:
- Stream of the clients. Never returns
null.
-
removeClients
Description copied from interface:ClientProviderRemoves all clients from the given realm.- Specified by:
removeClientsin interfaceClientProvider- Parameters:
realm- Realm.
-
addClientScopes
public void addClientScopes(RealmModel realm, ClientModel client, Set<ClientScopeModel> clientScopes, boolean defaultScope) Description copied from interface:ClientProviderAssign clientScopes to the client. Add as default scopes (if parameter 'defaultScope' is true) or optional scopes (if parameter 'defaultScope' is false)- Specified by:
addClientScopesin interfaceClientProvider- Parameters:
realm- Realm.client- Client.clientScopes- to be assigneddefaultScope- if true the scopes are assigned as default, or optional in case of false
-
removeClientScope
Description copied from interface:ClientProviderUnassign clientScope from the client.- Specified by:
removeClientScopein interfaceClientProvider- Parameters:
realm- Realm.client- Client.clientScope- to be unassigned
-
addClientScopeToAllClients
public void addClientScopeToAllClients(RealmModel realm, ClientScopeModel clientScope, boolean defaultClientScope) Description copied from interface:ClientProviderAdd specified client scope to all non bearer-only clients in the realm, which have same protocol as specified client scope. Method may be used just for new client scopes, which are not yet assigned to any clients as if specified clientScope is already assigned to some client, there might be issues related to duplicate entries.- Specified by:
addClientScopeToAllClientsin interfaceClientProvider- Parameters:
realm- RealmclientScope- client scope from the specified realm, which would be added to all clientsdefaultClientScope- If true, then it will be added as "default" client scope. If false, then it will be added as "optional" client scope
-
getAllRedirectUrisOfEnabledClients
Description copied from interface:ClientProviderReturns a map of (rootUrl, {validRedirectUris}) for all enabled clients.- Specified by:
getAllRedirectUrisOfEnabledClientsin interfaceClientProvider- Returns:
-
close
public void close() -
removeClient
Description copied from interface:ClientProviderRemoves given client from the given realm.- Specified by:
removeClientin interfaceClientProvider- Parameters:
realm- Realm.id- Internal ID of the client- Returns:
trueif the client existed and has been removed,falseotherwise.
-