Class ClientStorageManager

java.lang.Object
org.keycloak.storage.ClientStorageManager
All Implemented Interfaces:
ClientProvider, Provider, ClientLookupProvider

public class ClientStorageManager extends Object implements ClientProvider
Version:
$Revision: 1 $
Author:
Bill Burke
  • Field Details

  • Constructor Details

    • ClientStorageManager

      public ClientStorageManager(KeycloakSession session, long clientStorageProviderTimeout)
  • Method Details

    • isStorageProviderEnabled

      public static boolean isStorageProviderEnabled(RealmModel realm, String providerId)
    • 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

      public ClientModel getClientById(RealmModel realm, String id)
      Description copied from interface: ClientLookupProvider
      Exact search for a client by its internal ID.
      Specified by:
      getClientById in interface ClientLookupProvider
      Parameters:
      realm - Realm to limit the search.
      id - Internal ID
      Returns:
      Model of the client, or null if no client is found.
    • getClientByClientId

      public ClientModel getClientByClientId(RealmModel realm, String clientId)
      Description copied from interface: ClientLookupProvider
      Exact search for a client by its public client identifier.
      Specified by:
      getClientByClientId in interface ClientLookupProvider
      Parameters:
      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.
      Returns:
      Model of the client, or null if no client is found.
    • searchClientsByClientIdStream

      public Stream<ClientModel> searchClientsByClientIdStream(RealmModel realm, String clientId, Integer firstResult, Integer maxResults)
      Description copied from interface: ClientLookupProvider
      Case-insensitive search for clients that contain the given string in their public client identifier.
      Specified by:
      searchClientsByClientIdStream in interface ClientLookupProvider
      Parameters:
      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.
      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:
      searchClientsByAttributes in interface ClientLookupProvider
    • searchClientsByAuthenticationFlowBindingOverrides

      public Stream<ClientModel> searchClientsByAuthenticationFlowBindingOverrides(RealmModel realm, Map<String,String> overrides, Integer firstResult, Integer maxResults)
      Specified by:
      searchClientsByAuthenticationFlowBindingOverrides in interface ClientLookupProvider
    • 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: ClientLookupProvider
      Return all default scopes (if defaultScope is true) or all optional scopes (if defaultScope is false) linked with the client
      Specified by:
      getClientScopes in interface ClientLookupProvider
      Parameters:
      realm - Realm
      client - Client
      defaultScopes - 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

      public ClientModel addClient(RealmModel realm, String clientId)
      Description copied from interface: ClientProvider
      Adds a client with given clientId to the given realm. The internal ID of the client will be created automatically.
      Specified by:
      addClient in interface ClientProvider
      Parameters:
      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.
      Returns:
      Model of the created client.
    • addClient

      public ClientModel addClient(RealmModel realm, String id, String clientId)
      Description copied from interface: ClientProvider
      Adds a client with given internal ID and clientId to the given realm.
      Specified by:
      addClient in interface ClientProvider
      Parameters:
      realm - Realm owning this client.
      id - Internal ID of the client or null if one is to be created by the underlying store
      clientId - String that identifies the client to the external parties. Maps to client_id in OIDC or entityID in SAML.
      Returns:
      Model of the created client.
    • getClientsStream

      public Stream<ClientModel> getClientsStream(RealmModel realm, Integer firstResult, Integer maxResults)
      Description copied from interface: ClientProvider
      Returns the clients of the given realm as a stream.
      Specified by:
      getClientsStream in interface ClientProvider
      Parameters:
      realm - Realm.
      firstResult - First result to return. Ignored if negative or null.
      maxResults - Maximum number of results to return. Ignored if negative or null.
      Returns:
      Stream of the clients. Never returns null.
    • getClientsStream

      public Stream<ClientModel> getClientsStream(RealmModel realm)
      Description copied from interface: ClientProvider
      Returns all the clients of the given realm as a stream. Effectively the same as the call getClientsStream(realm, null, null).
      Specified by:
      getClientsStream in interface ClientProvider
      Parameters:
      realm - Realm.
      Returns:
      Stream of the clients. Never returns null.
    • getClientsCount

      public long getClientsCount(RealmModel realm)
      Description copied from interface: ClientProvider
      Returns number of clients in the given realm
      Specified by:
      getClientsCount in interface ClientProvider
      Parameters:
      realm - Realm.
      Returns:
      Number of the clients in the given realm.
    • getAlwaysDisplayInConsoleClientsStream

      public Stream<ClientModel> getAlwaysDisplayInConsoleClientsStream(RealmModel realm)
      Description copied from interface: ClientProvider
      Returns a stream of clients that are expected to always show up in account console.
      Specified by:
      getAlwaysDisplayInConsoleClientsStream in interface ClientProvider
      Parameters:
      realm - Realm owning the clients.
      Returns:
      Stream of the clients. Never returns null.
    • removeClients

      public void removeClients(RealmModel realm)
      Description copied from interface: ClientProvider
      Removes all clients from the given realm.
      Specified by:
      removeClients in interface ClientProvider
      Parameters:
      realm - Realm.
    • addClientScopes

      public void addClientScopes(RealmModel realm, ClientModel client, Set<ClientScopeModel> clientScopes, boolean defaultScope)
      Description copied from interface: ClientProvider
      Assign clientScopes to the client. Add as default scopes (if parameter 'defaultScope' is true) or optional scopes (if parameter 'defaultScope' is false)
      Specified by:
      addClientScopes in interface ClientProvider
      Parameters:
      realm - Realm.
      client - Client.
      clientScopes - to be assigned
      defaultScope - if true the scopes are assigned as default, or optional in case of false
    • removeClientScope

      public void removeClientScope(RealmModel realm, ClientModel client, ClientScopeModel clientScope)
      Description copied from interface: ClientProvider
      Unassign clientScope from the client.
      Specified by:
      removeClientScope in interface ClientProvider
      Parameters:
      realm - Realm.
      client - Client.
      clientScope - to be unassigned
    • addClientScopeToAllClients

      public void addClientScopeToAllClients(RealmModel realm, ClientScopeModel clientScope, boolean defaultClientScope)
      Description copied from interface: ClientProvider
      Add 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:
      addClientScopeToAllClients in interface ClientProvider
      Parameters:
      realm - Realm
      clientScope - client scope from the specified realm, which would be added to all clients
      defaultClientScope - If true, then it will be added as "default" client scope. If false, then it will be added as "optional" client scope
    • getAllRedirectUrisOfEnabledClients

      public Map<ClientModel,Set<String>> getAllRedirectUrisOfEnabledClients(RealmModel realm)
      Description copied from interface: ClientProvider
      Returns a map of (rootUrl, {validRedirectUris}) for all enabled clients.
      Specified by:
      getAllRedirectUrisOfEnabledClients in interface ClientProvider
      Returns:
    • close

      public void close()
      Specified by:
      close in interface Provider
    • removeClient

      public boolean removeClient(RealmModel realm, String id)
      Description copied from interface: ClientProvider
      Removes given client from the given realm.
      Specified by:
      removeClient in interface ClientProvider
      Parameters:
      realm - Realm.
      id - Internal ID of the client
      Returns:
      true if the client existed and has been removed, false otherwise.