public class RealmCacheSession extends Object implements CacheRealmProvider
| Modifier and Type | Field and Description |
|---|---|
protected RealmCacheManager |
cache |
protected boolean |
clearAll |
protected ClientProvider |
clientDelegate |
protected GroupProvider |
groupDelegate |
protected Set<InvalidationEvent> |
invalidationEvents |
protected Set<String> |
invalidations |
protected Set<String> |
listInvalidations |
protected static org.jboss.logging.Logger |
logger |
protected Map<String,ClientModel> |
managedApplications |
protected Map<String,ClientScopeAdapter> |
managedClientScopes |
protected Map<String,GroupAdapter> |
managedGroups |
protected Map<String,RealmAdapter> |
managedRealms |
protected Map<String,RoleAdapter> |
managedRoles |
static String |
REALM_CLIENTS_QUERY_SUFFIX |
protected RealmProvider |
realmDelegate |
protected RoleProvider |
roleDelegate |
static String |
ROLES_QUERY_SUFFIX |
protected KeycloakSession |
session |
protected boolean |
setRollbackOnly |
protected long |
startupRevision |
protected boolean |
transactionActive |
| Constructor and Description |
|---|
RealmCacheSession(RealmCacheManager cache,
KeycloakSession session) |
| 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. |
RoleModel |
addClientRole(ClientModel client,
String name)
Adds a client role with given
name to the given client. |
RoleModel |
addClientRole(ClientModel client,
String id,
String name)
Adds a client role with given internal ID and
name to the given client. |
RoleModel |
addRealmRole(RealmModel realm,
String name)
Adds a realm role with given
name to the given realm. |
RoleModel |
addRealmRole(RealmModel realm,
String id,
String name)
Adds a realm role with given internal ID and
name to the given realm. |
void |
addTopLevelGroup(RealmModel realm,
GroupModel subGroup)
Removes parent group for the given group in the given realm.
|
protected ClientModel |
cacheClient(RealmModel realm,
ClientModel delegate,
Long revision) |
void |
clear() |
void |
close() |
ClientInitialAccessModel |
createClientInitialAccessModel(RealmModel realm,
int expiration,
int count) |
GroupModel |
createGroup(RealmModel realm,
String id,
String name,
GroupModel toParent)
Creates a new group with the given name, id, name and parent to the given realm.
|
RealmModel |
createRealm(String name) |
RealmModel |
createRealm(String id,
String name) |
void |
decreaseRemainingCount(RealmModel realm,
ClientInitialAccessModel clientInitialAccess) |
boolean |
deleteLocalizationText(RealmModel realm,
String locale,
String key) |
boolean |
deleteLocalizationTextsByLocale(RealmModel realm,
String locale) |
void |
evictRealmOnRemoval(RealmModel realm) |
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.
|
ClientProvider |
getClientDelegate() |
ClientInitialAccessModel |
getClientInitialAccessModel(RealmModel realm,
String id) |
RoleModel |
getClientRole(ClientModel client,
String name)
Exact search for a client role by given name.
|
Stream<RoleModel> |
getClientRolesStream(ClientModel client)
Returns all the client roles of the given client.
|
Stream<RoleModel> |
getClientRolesStream(ClientModel client,
Integer first,
Integer max)
Returns the client roles of the given client.
|
ClientScopeModel |
getClientScopeById(String id,
RealmModel realm) |
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.
|
GroupModel |
getGroupById(RealmModel realm,
String id)
Returns a group from the given realm with the corresponding id
|
GroupProvider |
getGroupDelegate() |
Stream<GroupModel> |
getGroupsByRoleStream(RealmModel realm,
RoleModel role,
Integer firstResult,
Integer maxResults)
Returns groups with the given role in the given realm.
|
Long |
getGroupsCount(RealmModel realm,
Boolean onlyTopGroups)
Returns a number of groups/top level groups (i.e.
|
Long |
getGroupsCount(RealmModel realm,
Stream<String> ids,
String search)
Returns a number of groups that contains the search string in the name
|
Long |
getGroupsCountByNameContaining(RealmModel realm,
String search)
Returns number of groups with the given string in name for the given realm.
|
Stream<GroupModel> |
getGroupsStream(RealmModel realm)
Returns groups for the given realm.
|
Stream<GroupModel> |
getGroupsStream(RealmModel realm,
Stream<String> ids,
String search,
Integer first,
Integer max)
Returns a paginated stream of groups with given ids and given search value in group names.
|
String |
getLocalizationTextsById(RealmModel realm,
String locale,
String key) |
MigrationModel |
getMigrationModel() |
RealmModel |
getRealm(String id) |
RealmModel |
getRealmByName(String name) |
RealmProvider |
getRealmDelegate() |
RoleModel |
getRealmRole(RealmModel realm,
String name)
Exact search for a role by given name.
|
Stream<RoleModel> |
getRealmRolesStream(RealmModel realm)
Returns all the realm roles of the given realm as a stream.
|
Stream<RoleModel> |
getRealmRolesStream(RealmModel realm,
Integer first,
Integer max)
Returns the realm roles of the given realm as a stream.
|
Stream<RealmModel> |
getRealmsStream() |
Stream<RealmModel> |
getRealmsWithProviderTypeStream(Class<?> type) |
RoleModel |
getRoleById(RealmModel realm,
String id)
Exact search for a role by its internal ID..
|
RoleProvider |
getRoleDelegate() |
long |
getStartupRevision() |
Stream<GroupModel> |
getTopLevelGroupsStream(RealmModel realm)
Returns all top level groups (i.e.
|
Stream<GroupModel> |
getTopLevelGroupsStream(RealmModel realm,
Integer first,
Integer max)
Returns top level groups (i.e.
|
boolean |
isInvalid(String id) |
Stream<ClientInitialAccessModel> |
listClientInitialAccessStream(RealmModel realm) |
void |
moveGroup(RealmModel realm,
GroupModel group,
GroupModel toParent)
This method is used for moving groups in group structure, for example:
making an existing child group child group of some other group,
setting a top level group (i.e.
|
void |
preRemove(RealmModel realm,
RoleModel role)
This function is called when a role is removed; this serves for removing references from groups to roles.
|
void |
registerClientInvalidation(String id,
String clientId,
String realmId) |
void |
registerClientScopeInvalidation(String id) |
void |
registerGroupInvalidation(String id) |
void |
registerRealmInvalidation(String id,
String name) |
void |
registerRoleInvalidation(String id,
String roleName,
String roleContainerId) |
boolean |
removeClient(RealmModel realm,
String id)
Removes given client from the given realm.
|
void |
removeClientInitialAccessModel(RealmModel realm,
String id) |
void |
removeClients(RealmModel realm)
Removes all clients from the given realm.
|
void |
removeExpiredClientInitialAccess() |
boolean |
removeGroup(RealmModel realm,
GroupModel group)
Removes the given group for the given realm.
|
boolean |
removeRealm(String id) |
boolean |
removeRole(RoleModel role)
Removes given realm role from the given realm.
|
void |
removeRoles(ClientModel client)
Removes all roles from the given client.
|
void |
removeRoles(RealmModel realm)
Removes all roles from the given realm.
|
protected void |
runInvalidations() |
void |
saveLocalizationText(RealmModel realm,
String locale,
String key,
String text) |
void |
saveLocalizationTexts(RealmModel realm,
String locale,
Map<String,String> localizationTexts) |
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.
|
Stream<RoleModel> |
searchForClientRolesStream(ClientModel client,
String search,
Integer first,
Integer max)
Case-insensitive search for client roles that contain the given string in their name or description.
|
Stream<GroupModel> |
searchForGroupByNameStream(RealmModel realm,
String search,
Integer first,
Integer max)
Returns groups with the given string in name for the given realm.
|
Stream<RoleModel> |
searchForRolesStream(RealmModel realm,
String search,
Integer first,
Integer max)
Case-insensitive search for roles that contain the given string in their name or description.
|
boolean |
updateLocalizationText(RealmModel realm,
String locale,
String key,
String text) |
protected ClientModel |
validateCache(RealmModel realm,
CachedClient cached) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddClientRole, addClientRole, createGroup, createGroup, createGroup, getAlwaysDisplayInConsoleClients, getClientByClientId, getClientById, getClientRole, getClientRoles, getClientRoles, getClients, getClients, getGroupById, getGroups, getGroupsByRole, getRealmRoles, getRealmRoles, getRealms, getRealmsWithProviderType, getRoleById, getTopLevelGroups, getTopLevelGroups, listClientInitialAccess, removeClient, removeRole, searchClientsByClientId, searchForClientRoles, searchForGroupByName, searchForRolesgetGroupsStream, getGroupsStreamprotected static final org.jboss.logging.Logger logger
public static final String REALM_CLIENTS_QUERY_SUFFIX
public static final String ROLES_QUERY_SUFFIX
protected RealmCacheManager cache
protected KeycloakSession session
protected RealmProvider realmDelegate
protected ClientProvider clientDelegate
protected GroupProvider groupDelegate
protected RoleProvider roleDelegate
protected boolean transactionActive
protected boolean setRollbackOnly
protected Map<String,RealmAdapter> managedRealms
protected Map<String,ClientModel> managedApplications
protected Map<String,ClientScopeAdapter> managedClientScopes
protected Map<String,RoleAdapter> managedRoles
protected Map<String,GroupAdapter> managedGroups
protected Set<InvalidationEvent> invalidationEvents
protected boolean clearAll
protected final long startupRevision
public RealmCacheSession(RealmCacheManager cache, KeycloakSession session)
public long getStartupRevision()
public boolean isInvalid(String id)
public void clear()
clear in interface CacheRealmProviderpublic MigrationModel getMigrationModel()
getMigrationModel in interface RealmProviderpublic RealmProvider getRealmDelegate()
getRealmDelegate in interface CacheRealmProviderpublic ClientProvider getClientDelegate()
public RoleProvider getRoleDelegate()
public GroupProvider getGroupDelegate()
public void registerRealmInvalidation(String id, String name)
registerRealmInvalidation in interface CacheRealmProviderpublic void registerClientInvalidation(String id, String clientId, String realmId)
registerClientInvalidation in interface CacheRealmProviderpublic void registerClientScopeInvalidation(String id)
registerClientScopeInvalidation in interface CacheRealmProviderpublic void registerRoleInvalidation(String id, String roleName, String roleContainerId)
registerRoleInvalidation in interface CacheRealmProviderpublic void registerGroupInvalidation(String id)
registerGroupInvalidation in interface CacheRealmProviderprotected void runInvalidations()
public RealmModel createRealm(String name)
createRealm in interface RealmProviderpublic RealmModel createRealm(String id, String name)
createRealm in interface RealmProviderpublic RealmModel getRealm(String id)
getRealm in interface RealmProviderpublic RealmModel getRealmByName(String name)
getRealmByName in interface RealmProviderpublic Stream<RealmModel> getRealmsWithProviderTypeStream(Class<?> type)
getRealmsWithProviderTypeStream in interface RealmProviderpublic Stream<RealmModel> getRealmsStream()
getRealmsStream in interface RealmProviderpublic boolean removeRealm(String id)
removeRealm in interface RealmProviderpublic void evictRealmOnRemoval(RealmModel realm)
public ClientModel addClient(RealmModel realm, String clientId)
ClientProviderclientId to the given realm.
The internal ID of the client will be created automatically.addClient in interface ClientProvideraddClient in interface RealmProviderrealm - 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)
ClientProviderclientId to the given realm.addClient in interface ClientProvideraddClient in interface RealmProviderrealm - 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)
ClientProvidergetClientsStream in interface ClientProviderrealm - 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)
ClientProvidergetClientsStream(realm, null, null).getClientsStream in interface ClientProviderrealm - Realm.null.public Stream<ClientModel> getAlwaysDisplayInConsoleClientsStream(RealmModel realm)
ClientProvidergetAlwaysDisplayInConsoleClientsStream in interface ClientProviderrealm - Realm owning the clients.null.public void removeClients(RealmModel realm)
ClientProviderremoveClients in interface ClientProviderrealm - Realm.public boolean removeClient(RealmModel realm, String id)
ClientProviderremoveClient in interface ClientProviderrealm - Realm.id - Internal ID of the clienttrue if the client existed and has been removed, false otherwise.public RoleModel addRealmRole(RealmModel realm, String name)
RoleProvidername to the given realm.
The internal ID of the role will be created automatically.addRealmRole in interface RealmProvideraddRealmRole in interface RoleProviderrealm - Realm owning this role.name - String name of the role.public RoleModel addRealmRole(RealmModel realm, String id, String name)
RoleProvidername to the given realm.addRealmRole in interface RealmProvideraddRealmRole in interface RoleProviderrealm - Realm owning this role.id - Internal ID of the role or null if one is to be created by the underlying storename - String name of the role.public Stream<RoleModel> getRealmRolesStream(RealmModel realm)
RoleProvidergetRealmRolesStream(realm, null, null).getRealmRolesStream in interface RoleProviderrealm - Realm.null.public Stream<RoleModel> getClientRolesStream(ClientModel client)
RoleProvidergetClientRoles(client, null, null).getClientRolesStream in interface RoleProviderclient - Client.null.public Stream<RoleModel> getRealmRolesStream(RealmModel realm, Integer first, Integer max)
RoleProvidergetRealmRolesStream in interface RoleProviderrealm - Realm.first - First result to return. Ignored if negative or null.max - Maximum number of results to return. Ignored if negative or null.null.public Stream<RoleModel> getClientRolesStream(ClientModel client, Integer first, Integer max)
RoleProvidergetClientRolesStream in interface RoleProviderclient - Client.first - First result to return. Ignored if negative or null.max - Maximum number of results to return. Ignored if negative or null.null.public Stream<RoleModel> searchForClientRolesStream(ClientModel client, String search, Integer first, Integer max)
RoleLookupProvidersearchForClientRolesStream in interface RoleLookupProviderclient - Client.search - String to search by role's name or description.first - First result to return. Ignored if negative or null.max - Maximum number of results to return. Ignored if negative or null.null.public Stream<RoleModel> searchForRolesStream(RealmModel realm, String search, Integer first, Integer max)
RoleLookupProvidersearchForRolesStream in interface RoleLookupProviderrealm - Realm.search - Searched substring of the role's name or description.first - First result to return. Ignored if negative or null.max - Maximum number of results to return. Ignored if negative or null.null.public RoleModel addClientRole(ClientModel client, String name)
RoleProvidername to the given client.
The internal ID of the role will be created automatically.addClientRole in interface RoleProviderclient - Client owning this role.name - String name of the role.public RoleModel addClientRole(ClientModel client, String id, String name)
RoleProvidername to the given client.addClientRole in interface RoleProviderclient - Client owning this role.id - Internal ID of the client role or null if one is to be created by the underlying store.name - String name of the role.public RoleModel getRealmRole(RealmModel realm, String name)
RoleLookupProvidergetRealmRole in interface RealmProvidergetRealmRole in interface RoleLookupProviderrealm - Realm.name - String name of the role.null if no role is found.public RoleModel getClientRole(ClientModel client, String name)
RoleLookupProvidergetClientRole in interface RoleLookupProviderclient - Client.name - String name of the role.null if no role is found.public boolean removeRole(RoleModel role)
RoleProviderremoveRole in interface RoleProviderrole - Role to be removed.true if the role existed and has been removed, false otherwise.public void removeRoles(RealmModel realm)
RoleProviderremoveRoles in interface RoleProviderrealm - Realm.public void removeRoles(ClientModel client)
RoleProviderremoveRoles in interface RoleProviderclient - Client.public RoleModel getRoleById(RealmModel realm, String id)
RoleLookupProvidergetRoleById in interface RoleLookupProviderrealm - Realm.id - Internal ID of the role.public GroupModel getGroupById(RealmModel realm, String id)
GroupLookupProvidergetGroupById in interface RealmProvidergetGroupById in interface GroupLookupProviderrealm - Realm.id - Id.public void moveGroup(RealmModel realm, GroupModel group, GroupModel toParent)
GroupProvidermoveGroup in interface GroupProvidermoveGroup in interface RealmProviderrealm - Realm owning this group.group - Group to update.toParent - New parent group, or null if we are moving the group to top level group.public Stream<GroupModel> getGroupsStream(RealmModel realm)
GroupProvidergetGroupsStream in interface GroupProviderrealm - Realm.public Stream<GroupModel> getGroupsStream(RealmModel realm, Stream<String> ids, String search, Integer first, Integer max)
GroupProvidergetGroupsStream in interface GroupProviderrealm - Realm.ids - List of ids.search - Case insensitive string which will be searched for. Ignored if null.first - Index of the first result to return. Ignored if negative or null.max - Maximum number of results to return. Ignored if negative or null.public Long getGroupsCount(RealmModel realm, Stream<String> ids, String search)
GroupProvidergetGroupsCount in interface GroupProviderrealm - Realm.ids - List of ids.search - Case insensitive string which will be searched for. Ignored if null.public Long getGroupsCount(RealmModel realm, Boolean onlyTopGroups)
GroupProvidergetGroupsCount in interface GroupProvidergetGroupsCount in interface RealmProviderrealm - Realm.onlyTopGroups - When true the function returns a count of top level groups only.public long getClientsCount(RealmModel realm)
ClientProvidergetClientsCount in interface ClientProvidergetClientsCount in interface RealmProviderrealm - Realm.public Long getGroupsCountByNameContaining(RealmModel realm, String search)
GroupProvidergetGroupsCountByNameContaining in interface GroupProvidergetGroupsCountByNameContaining in interface RealmProviderrealm - Realm.search - Case insensitive string which will be searched for.public Stream<GroupModel> getGroupsByRoleStream(RealmModel realm, RoleModel role, Integer firstResult, Integer maxResults)
GroupProvidergetGroupsByRoleStream in interface GroupProviderrealm - Realm.role - Role.firstResult - First result to return. Ignored if negative or null.maxResults - Maximum number of results to return. Ignored if negative or null.public Stream<GroupModel> getTopLevelGroupsStream(RealmModel realm)
GroupProvidergetTopLevelGroupsStream in interface GroupProviderrealm - Realm.public Stream<GroupModel> getTopLevelGroupsStream(RealmModel realm, Integer first, Integer max)
GroupProvidergetTopLevelGroupsStream in interface GroupProviderrealm - Realm.first - First result to return. Ignored if negative or null.max - Maximum number of results to return. Ignored if negative or null.public Stream<GroupModel> searchForGroupByNameStream(RealmModel realm, String search, Integer first, Integer max)
GroupLookupProvidersearchForGroupByNameStream in interface GroupLookupProviderrealm - Realm.search - Case sensitive searched string.first - First result to return. Ignored if negative or null.max - Maximum number of results to return. Ignored if negative or null.public boolean removeGroup(RealmModel realm, GroupModel group)
GroupProviderremoveGroup in interface GroupProviderremoveGroup in interface RealmProviderrealm - Realm.group - Group.public GroupModel createGroup(RealmModel realm, String id, String name, GroupModel toParent)
GroupProvidercreateGroup in interface GroupProvidercreateGroup in interface RealmProviderrealm - Realm.id - Id, will be generated if null.name - Name.toParent - Parent group, or null if the group is top level grouppublic void addTopLevelGroup(RealmModel realm, GroupModel subGroup)
GroupProvideraddTopLevelGroup in interface GroupProvideraddTopLevelGroup in interface RealmProviderrealm - Realm.subGroup - Group.public void preRemove(RealmModel realm, RoleModel role)
GroupProviderpreRemove in interface GroupProviderrealm - Realm.role - Role which will be removed.public ClientModel getClientById(RealmModel realm, String id)
ClientLookupProvidergetClientById in interface ClientLookupProviderrealm - Realm to limit the search.id - Internal IDnull if no client is found.protected ClientModel cacheClient(RealmModel realm, ClientModel delegate, Long revision)
protected ClientModel validateCache(RealmModel realm, CachedClient cached)
public Stream<ClientModel> searchClientsByClientIdStream(RealmModel realm, String clientId, Integer firstResult, Integer maxResults)
ClientLookupProvidersearchClientsByClientIdStream in interface ClientLookupProviderrealm - 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.public ClientModel getClientByClientId(RealmModel realm, String clientId)
ClientLookupProvidergetClientByClientId in interface ClientLookupProviderrealm - 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 ClientScopeModel getClientScopeById(String id, RealmModel realm)
getClientScopeById in interface RealmProviderpublic ClientInitialAccessModel createClientInitialAccessModel(RealmModel realm, int expiration, int count)
createClientInitialAccessModel in interface RealmProviderpublic ClientInitialAccessModel getClientInitialAccessModel(RealmModel realm, String id)
getClientInitialAccessModel in interface RealmProviderpublic void removeClientInitialAccessModel(RealmModel realm, String id)
removeClientInitialAccessModel in interface RealmProviderpublic Stream<ClientInitialAccessModel> listClientInitialAccessStream(RealmModel realm)
listClientInitialAccessStream in interface RealmProviderpublic void removeExpiredClientInitialAccess()
removeExpiredClientInitialAccess in interface RealmProviderpublic void decreaseRemainingCount(RealmModel realm, ClientInitialAccessModel clientInitialAccess)
decreaseRemainingCount in interface RealmProviderpublic void saveLocalizationText(RealmModel realm, String locale, String key, String text)
saveLocalizationText in interface RealmProviderpublic void saveLocalizationTexts(RealmModel realm, String locale, Map<String,String> localizationTexts)
saveLocalizationTexts in interface RealmProviderpublic boolean updateLocalizationText(RealmModel realm, String locale, String key, String text)
updateLocalizationText in interface RealmProviderpublic boolean deleteLocalizationTextsByLocale(RealmModel realm, String locale)
deleteLocalizationTextsByLocale in interface RealmProviderpublic boolean deleteLocalizationText(RealmModel realm, String locale, String key)
deleteLocalizationText in interface RealmProviderpublic String getLocalizationTextsById(RealmModel realm, String locale, String key)
getLocalizationTextsById in interface RealmProviderCopyright © 2021 JBoss by Red Hat. All rights reserved.