public class ClientStorageManager extends Object implements ClientProvider
Modifier and Type | Field and Description |
---|---|
protected KeycloakSession |
session |
Constructor and Description |
---|
ClientStorageManager(KeycloakSession session,
long clientStorageProviderTimeout) |
Modifier and Type | Method and Description |
---|---|
ClientModel |
addClient(RealmModel realm,
String clientId)
Adds a client with given
clientId to the given realm. |
ClientModel |
addClient(RealmModel realm,
String id,
String clientId)
Adds a client with given internal ID and
clientId to the given realm. |
void |
addClientScopes(RealmModel realm,
ClientModel client,
Set<ClientScopeModel> clientScopes,
boolean defaultScope)
Assign clientScopes to the client.
|
void |
close() |
Map<ClientModel,Set<String>> |
getAllRedirectUrisOfEnabledClients(RealmModel realm)
Returns a map of (rootUrl, {validRedirectUris}) for all enabled clients.
|
Stream<ClientModel> |
getAlwaysDisplayInConsoleClientsStream(RealmModel realm)
Returns a stream of clients that are expected to always show up in account console.
|
ClientModel |
getClientByClientId(RealmModel realm,
String clientId)
Exact search for a client by its public client identifier.
|
ClientModel |
getClientById(RealmModel realm,
String id)
Exact search for a client by its internal ID.
|
Map<String,ClientScopeModel> |
getClientScopes(RealmModel realm,
ClientModel client,
boolean defaultScopes)
Return all default scopes (if
defaultScope is true ) or all optional scopes (if defaultScope is false ) linked with the client |
long |
getClientsCount(RealmModel realm)
Returns number of clients in the given realm
|
Stream<ClientModel> |
getClientsStream(RealmModel realm)
Returns all the clients of the given realm as a stream.
|
Stream<ClientModel> |
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 ClientStorageProvider |
getStorageProvider(KeycloakSession session,
RealmModel realm,
String componentId) |
static ClientStorageProvider |
getStorageProviderInstance(KeycloakSession session,
ClientStorageProviderModel model,
ClientStorageProviderFactory factory) |
static ClientStorageProviderModel |
getStorageProviderModel(RealmModel realm,
String componentId) |
static <T> Stream<T> |
getStorageProviders(KeycloakSession session,
RealmModel realm,
Class<T> type) |
static boolean |
hasEnabledStorageProviders(KeycloakSession session,
RealmModel realm,
Class<?> type) |
static boolean |
isStorageProviderEnabled(RealmModel realm,
String providerId) |
protected Stream<ClientModel> |
query(org.keycloak.storage.ClientStorageManager.PaginatedQuery paginatedQuery,
RealmModel realm,
Integer firstResult,
Integer maxResults) |
boolean |
removeClient(RealmModel realm,
String id)
Removes given client from the given realm.
|
void |
removeClients(RealmModel realm)
Removes all clients from the given realm.
|
void |
removeClientScope(RealmModel realm,
ClientModel client,
ClientScopeModel clientScope)
Unassign clientScope from the client.
|
Stream<ClientModel> |
searchClientsByAttributes(RealmModel realm,
Map<String,String> attributes,
Integer firstResult,
Integer maxResults) |
Stream<ClientModel> |
searchClientsByClientIdStream(RealmModel realm,
String clientId,
Integer firstResult,
Integer maxResults)
Case-insensitive search for clients that contain the given string in their public client identifier.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getAlwaysDisplayInConsoleClients, getClients, getClients, removeClient
getClientByClientId, getClientById, searchClientsByClientId
protected KeycloakSession session
public ClientStorageManager(KeycloakSession session, long clientStorageProviderTimeout)
public static boolean isStorageProviderEnabled(RealmModel realm, String providerId)
public static ClientStorageProviderModel getStorageProviderModel(RealmModel realm, String componentId)
public static ClientStorageProvider getStorageProvider(KeycloakSession session, RealmModel realm, String componentId)
public static ClientStorageProvider getStorageProviderInstance(KeycloakSession session, ClientStorageProviderModel model, ClientStorageProviderFactory factory)
public static <T> Stream<T> getStorageProviders(KeycloakSession session, RealmModel realm, Class<T> type)
public static <T> Stream<T> getEnabledStorageProviders(KeycloakSession session, RealmModel realm, Class<T> type)
public static boolean hasEnabledStorageProviders(KeycloakSession session, RealmModel realm, Class<?> type)
public ClientModel getClientById(RealmModel realm, String id)
ClientLookupProvider
getClientById
in interface ClientLookupProvider
realm
- Realm to limit the search.id
- Internal IDnull
if no client is found.public ClientModel getClientByClientId(RealmModel realm, String clientId)
ClientLookupProvider
getClientByClientId
in interface ClientLookupProvider
realm
- Realm to limit the search for clients.clientId
- String that identifies the client to the external parties.
Maps to client_id
in OIDC or entityID
in SAML.null
if no client is found.public Stream<ClientModel> searchClientsByClientIdStream(RealmModel realm, String clientId, Integer firstResult, Integer maxResults)
ClientLookupProvider
searchClientsByClientIdStream
in interface ClientLookupProvider
realm
- Realm to limit the search for clients.clientId
- Searched substring of the public client
identifier (client_id
in OIDC or entityID
in SAML.)firstResult
- First result to return. Ignored if negative or null
.maxResults
- Maximum number of results to return. Ignored if negative or null
.null
.public Stream<ClientModel> searchClientsByAttributes(RealmModel realm, Map<String,String> attributes, Integer firstResult, Integer maxResults)
searchClientsByAttributes
in interface ClientLookupProvider
protected Stream<ClientModel> query(org.keycloak.storage.ClientStorageManager.PaginatedQuery paginatedQuery, RealmModel realm, Integer firstResult, Integer maxResults)
public Map<String,ClientScopeModel> getClientScopes(RealmModel realm, ClientModel client, boolean defaultScopes)
ClientLookupProvider
defaultScope
is true
) or all optional scopes (if defaultScope
is false
) linked with the clientgetClientScopes
in interface ClientLookupProvider
realm
- Realmclient
- ClientdefaultScopes
- if true default scopes, if false optional scopes, are returnedpublic ClientModel addClient(RealmModel realm, String clientId)
ClientProvider
clientId
to the given realm.
The internal ID of the client will be created automatically.addClient
in interface ClientProvider
realm
- Realm owning this client.clientId
- String that identifies the client to the external parties.
Maps to client_id
in OIDC or entityID
in SAML.public ClientModel addClient(RealmModel realm, String id, String clientId)
ClientProvider
clientId
to the given realm.addClient
in interface ClientProvider
realm
- Realm owning this client.id
- Internal ID of the client or null
if one is to be created by the underlying storeclientId
- String that identifies the client to the external parties.
Maps to client_id
in OIDC or entityID
in SAML.public Stream<ClientModel> getClientsStream(RealmModel realm, Integer firstResult, Integer maxResults)
ClientProvider
getClientsStream
in interface ClientProvider
realm
- Realm.firstResult
- First result to return. Ignored if negative or null
.maxResults
- Maximum number of results to return. Ignored if negative or null
.null
.public Stream<ClientModel> getClientsStream(RealmModel realm)
ClientProvider
getClientsStream(realm, null, null)
.getClientsStream
in interface ClientProvider
realm
- Realm.null
.public long getClientsCount(RealmModel realm)
ClientProvider
getClientsCount
in interface ClientProvider
realm
- Realm.public Stream<ClientModel> getAlwaysDisplayInConsoleClientsStream(RealmModel realm)
ClientProvider
getAlwaysDisplayInConsoleClientsStream
in interface ClientProvider
realm
- Realm owning the clients.null
.public void removeClients(RealmModel realm)
ClientProvider
removeClients
in interface ClientProvider
realm
- Realm.public void addClientScopes(RealmModel realm, ClientModel client, Set<ClientScopeModel> clientScopes, boolean defaultScope)
ClientProvider
addClientScopes
in interface ClientProvider
realm
- Realm.client
- Client.clientScopes
- to be assigneddefaultScope
- if true the scopes are assigned as default, or optional in case of falsepublic void removeClientScope(RealmModel realm, ClientModel client, ClientScopeModel clientScope)
ClientProvider
removeClientScope
in interface ClientProvider
realm
- Realm.client
- Client.clientScope
- to be unassignedpublic Map<ClientModel,Set<String>> getAllRedirectUrisOfEnabledClients(RealmModel realm)
ClientProvider
getAllRedirectUrisOfEnabledClients
in interface ClientProvider
public boolean removeClient(RealmModel realm, String id)
ClientProvider
removeClient
in interface ClientProvider
realm
- Realm.id
- Internal ID of the clienttrue
if the client existed and has been removed, false
otherwise.Copyright © 2021 JBoss by Red Hat. All rights reserved.