Package org.keycloak.models.jpa
Class JpaRealmProvider
java.lang.Object
org.keycloak.models.jpa.JpaRealmProvider
- All Implemented Interfaces:
ClientProvider,ClientScopeProvider,DeploymentStateProvider,GroupProvider,RealmProvider,RoleProvider,Provider,ClientLookupProvider,ClientScopeLookupProvider,GroupLookupProvider,RoleLookupProvider
public class JpaRealmProvider
extends Object
implements RealmProvider, ClientProvider, ClientScopeProvider, GroupProvider, RoleProvider, DeploymentStateProvider
- Version:
- $Revision: 1 $
- Author:
- Bill Burke
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected jakarta.persistence.EntityManagerprotected static final org.jboss.logging.LoggerFields inherited from interface org.keycloak.models.GroupProvider
DEFAULT_ESCAPE_SLASHES -
Constructor Summary
ConstructorsConstructorDescriptionJpaRealmProvider(KeycloakSession session, jakarta.persistence.EntityManager em, Set<String> clientSearchableAttributes, Set<String> groupSearchableAttributes) -
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.addClientRole(ClientModel client, String name) Adds a client role with givennameto the given client.addClientRole(ClientModel client, String id, String name) Adds a client role with given internal ID andnameto the given client.addClientScope(RealmModel realm, String id, String name) Creates new client scope with given internal ID andnameto 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.addRealmRole(RealmModel realm, String name) Adds a realm role with givennameto the given realm.addRealmRole(RealmModel realm, String id, String name) Adds a realm role with given internal ID andnameto the given realm.voidaddTopLevelGroup(RealmModel realm, GroupModel subGroup) Removes parent group for the given group in the given realm.voidclose()createGroup(RealmModel realm, String id, GroupModel.Type type, String name, GroupModel toParent) Creates a new group with the given name, id, name and parent to the given realm.createRealm(String name) Creates new realm with the given name.createRealm(String id, String name) Created new realm with given ID and name.booleandeleteLocalizationText(RealmModel realm, String locale, String key) booleandeleteLocalizationTextsByLocale(RealmModel realm, String locale) 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.getClientRole(ClientModel client, String name) Exact search for a client role by given name.getClientRolesStream(ClientModel client, Integer first, Integer max) Returns the client roles of the given client.getClientScopeById(RealmModel realm, String id) Exact search for a client scope by its internal ID..getClientScopes(RealmModel realm, ClientModel client, boolean defaultScope) Return all default scopes (ifdefaultScopeistrue) or all optional scopes (ifdefaultScopeisfalse) linked with the clientgetClientScopesByAttributes(RealmModel realm, Map<String, String> searchMap, boolean useOr) This method filters clientScopes by specific attributes.getClientScopesByProtocol(RealmModel realm, String protocol) Must retrieve all client scopes of the given realm that are use the given protocol.getClientScopesStream(RealmModel realm) Returns all the client scopes of the given realm as a stream.longgetClientsCount(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.getGroupById(RealmModel realm, String id) Returns a group from the given realm with the corresponding idgetGroupByName(RealmModel realm, GroupModel parent, String name) Returns a group from the given realm with the corresponding name and parentgetGroupsByRoleStream(RealmModel realm, RoleModel role, Integer firstResult, Integer maxResults) Returns groups with the given role in the given realm.getGroupsCount(RealmModel realm, Boolean onlyTopGroups) Returns a number of groups/top level groups (i.e.getGroupsCount(RealmModel realm, Stream<String> ids, String search) Returns a number of groups that contains the search string in the namegetGroupsCountByNameContaining(RealmModel realm, String search) Returns the number of top level groups containing groups with the given string in name for the given realm.getGroupsStream(RealmModel realm) Returns groups for the given realm.getGroupsStream(RealmModel realm, Stream<String> ids) Returns a stream of groups with given ids.getGroupsStream(RealmModel realm, Stream<String> ids, Integer first, Integer max) Returns a paginated stream of groups with given ids.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.getLocalizationTextsById(RealmModel realm, String locale, String key) Exact search for a realm by its internal ID.getRealmByName(String name) Exact search for a realm by its name.getRealmRole(RealmModel realm, String name) Exact search for a role by given name.getRealmRolesStream(RealmModel realm) Returns all the realm roles of the given realm as a stream.getRealmRolesStream(RealmModel realm, Integer first, Integer max) Returns the realm roles of the given realm as a stream.Returns realms as a stream.getRealmsStream(String search) Returns realms as a stream filtered by search.getRealmsWithProviderTypeStream(Class<?> providerType) Returns stream of realms which has component with the given provider type.getRoleById(RealmModel realm, String id) Exact search for a role by its internal ID..getRolesStream(jakarta.persistence.TypedQuery<RoleEntity> query, RealmModel realm, Integer first, Integer max) getRolesStream(RealmModel realm, Stream<String> ids, String search, Integer first, Integer max) Returns a paginated stream of roles with given ids and given search value in role names.getTopLevelGroupsStream(RealmModel realm, String search, Boolean exact, Integer firstResult, Integer maxResults) Returns top level groups (i.e.voidmoveGroup(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.voidpreRemove(RealmModel realm) Called when a realm is removed.voidpreRemove(RealmModel realm, RoleModel role) booleanremoveClient(RealmModel realm, String id) Removes given client from the given realm.voidremoveClients(RealmModel realm) Removes all clients from the given realm.booleanremoveClientScope(RealmModel realm, String id) Removes client scope from the given realm.voidremoveClientScope(RealmModel realm, ClientModel client, ClientScopeModel clientScope) Unassign clientScope from the client.voidremoveClientScopes(RealmModel realm) Removes all client scopes from the given realm.voidRemoves all expired client initial accesses from all realms.booleanremoveGroup(RealmModel realm, GroupModel group) Removes the given group for the given realm.booleanremoveRealm(String id) Removes realm with the given id.booleanremoveRole(RoleModel role) Removes given realm role from the given realm.voidremoveRoles(ClientModel client) Removes all roles from the given client.voidremoveRoles(RealmModel realm) Removes all roles from the given realm.roleRemovedEvent(RoleModel role) voidsaveLocalizationText(RealmModel realm, String locale, String key, String text) voidsaveLocalizationTexts(RealmModel realm, String locale, Map<String, String> localizationTexts) 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.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.searchForClientRolesStream(RealmModel realm, String search, Stream<String> excludedIds, Integer first, Integer max) Case-insensitive search for client roles that contain the given string in their name or their client's public identifier (clientId - (client_idin OIDC orentityIDin SAML)).searchForClientRolesStream(RealmModel realm, Stream<String> ids, String search, Integer first, Integer max) Case-insensitive search for client roles that contain the given string in its name or their client's public identifier (clientId - (client_idin OIDC orentityIDin SAML)).searchForGroupByNameStream(RealmModel realm, String search, Boolean exact, Integer first, Integer max) Returns the group hierarchy with the given string in name for the given realm.searchForRoles(jakarta.persistence.TypedQuery<RoleEntity> query, RealmModel realm, String search, Integer first, Integer max) searchForRolesStream(RealmModel realm, String search, Integer first, Integer max) Case-insensitive search for roles that contain the given string in their name or description.searchGroupsByAttributes(RealmModel realm, Map<String, String> attributes, Integer firstResult, Integer maxResults) Returns the groups filtered by attribute names and attribute values for the given realm.booleanupdateLocalizationText(RealmModel realm, String locale, String key, String text) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.keycloak.models.ClientScopeProvider
addClientScopeMethods inherited from interface org.keycloak.storage.group.GroupLookupProvider
searchForGroupByNameStreamMethods inherited from interface org.keycloak.models.GroupProvider
createGroup, createGroup, createGroup, createGroup, getTopLevelGroupsStream, getTopLevelGroupsStreamMethods inherited from interface org.keycloak.models.RealmProvider
createClientInitialAccessModel, decreaseRemainingCount, getClientInitialAccessModel, listClientInitialAccessStream, removeClientInitialAccessModelMethods inherited from interface org.keycloak.models.RoleProvider
getClientRolesStream
-
Field Details
-
logger
protected static final org.jboss.logging.Logger logger -
em
protected jakarta.persistence.EntityManager em
-
-
Constructor Details
-
JpaRealmProvider
public JpaRealmProvider(KeycloakSession session, jakarta.persistence.EntityManager em, Set<String> clientSearchableAttributes, Set<String> groupSearchableAttributes)
-
-
Method Details
-
getMigrationModel
- Specified by:
getMigrationModelin interfaceDeploymentStateProvider
-
createRealm
Description copied from interface:RealmProviderCreates new realm with the given name. The internal ID will be generated automatically.- Specified by:
createRealmin interfaceRealmProvider- Parameters:
name- String name of the realm- Returns:
- Model of the created realm.
-
createRealm
Description copied from interface:RealmProviderCreated new realm with given ID and name.- Specified by:
createRealmin interfaceRealmProvider- Parameters:
id- Internal ID of the realm ornullif one is to be created by the underlying store. If the store expects the ID to have a certain format (for exampleUUID) and the supplied ID doesn't follow the expected format, the store may replace theidwith a new one at its own discretion.name- String name of the realm- Returns:
- Model of the created realm.
-
getRealm
Description copied from interface:RealmProviderExact search for a realm by its internal ID.- Specified by:
getRealmin interfaceRealmProvider- Parameters:
id- Internal ID of the realm.- Returns:
- Model of the realm
-
getRealmsWithProviderTypeStream
Description copied from interface:RealmProviderReturns stream of realms which has component with the given provider type.- Specified by:
getRealmsWithProviderTypeStreamin interfaceRealmProvider- Parameters:
providerType-Class<?>Type of the provider.- Returns:
- Stream of
RealmModel. Never returnsnull.
-
getRealmsStream
Description copied from interface:RealmProviderReturns realms as a stream.- Specified by:
getRealmsStreamin interfaceRealmProvider- Returns:
- Stream of
RealmModel. Never returnsnull.
-
getRealmsStream
Description copied from interface:RealmProviderReturns realms as a stream filtered by search.- Specified by:
getRealmsStreamin interfaceRealmProvider- Parameters:
search- String to search for in realm names- Returns:
- Stream of
RealmModel. Never returnsnull.
-
getRealmByName
Description copied from interface:RealmProviderExact search for a realm by its name.- Specified by:
getRealmByNamein interfaceRealmProvider- Parameters:
name- String name of the realm- Returns:
- Model of the realm
-
removeRealm
Description copied from interface:RealmProviderRemoves realm with the given id.- Specified by:
removeRealmin interfaceRealmProvider- Parameters:
id- of realm.- Returns:
trueif the realm was successfully removed.
-
close
public void close() -
addRealmRole
Description copied from interface:RoleProviderAdds a realm role with givennameto the given realm. The internal ID of the role will be created automatically.- Specified by:
addRealmRolein interfaceRoleProvider- Parameters:
realm- Realm owning this role.name- String name of the role.- Returns:
- Model of the created role.
-
addRealmRole
Description copied from interface:RoleProviderAdds a realm role with given internal ID andnameto the given realm.- Specified by:
addRealmRolein interfaceRoleProvider- Parameters:
realm- Realm owning this role.id- Internal ID of the role ornullif one is to be created by the underlying storename- String name of the role.- Returns:
- Model of the created client.
-
getRealmRole
Description copied from interface:RoleLookupProviderExact search for a role by given name.- Specified by:
getRealmRolein interfaceRoleLookupProvider- Parameters:
realm- Realm.name- String name of the role.- Returns:
- Model of the role, or
nullif no role is found.
-
addClientRole
Description copied from interface:RoleProviderAdds a client role with givennameto the given client. The internal ID of the role will be created automatically.- Specified by:
addClientRolein interfaceRoleProvider- Parameters:
client- Client owning this role.name- String name of the role.- Returns:
- Model of the created role.
-
addClientRole
Description copied from interface:RoleProviderAdds a client role with given internal ID andnameto the given client.- Specified by:
addClientRolein interfaceRoleProvider- Parameters:
client- Client owning this role.id- Internal ID of the client role ornullif one is to be created by the underlying store.name- String name of the role.- Returns:
- Model of the created role.
-
getRealmRolesStream
Description copied from interface:RoleProviderReturns all the realm roles of the given realm as a stream. Effectively the same as the callgetRealmRolesStream(realm, null, null).- Specified by:
getRealmRolesStreamin interfaceRoleProvider- Parameters:
realm- Realm.- Returns:
- Stream of the roles. Never returns
null.
-
getClientRole
Description copied from interface:RoleLookupProviderExact search for a client role by given name.- Specified by:
getClientRolein interfaceRoleLookupProvider- Parameters:
client- Client.name- String name of the role.- Returns:
- Model of the role, or
nullif no role is found.
-
getAllRedirectUrisOfEnabledClients
Description copied from interface:ClientProviderReturns a map of (rootUrl, {validRedirectUris}) for all enabled clients.- Specified by:
getAllRedirectUrisOfEnabledClientsin interfaceClientProvider- Returns:
-
getRealmRolesStream
Description copied from interface:RoleProviderReturns the realm roles of the given realm as a stream.- Specified by:
getRealmRolesStreamin interfaceRoleProvider- Parameters:
realm- Realm.first- First result to return. Ignored if negative ornull.max- Maximum number of results to return. Ignored if negative ornull.- Returns:
- Stream of the roles. Never returns
null.
-
getRolesStream
public Stream<RoleModel> getRolesStream(RealmModel realm, Stream<String> ids, String search, Integer first, Integer max) Description copied from interface:RoleProviderReturns a paginated stream of roles with given ids and given search value in role names.- Specified by:
getRolesStreamin interfaceRoleProvider- Parameters:
realm- Realm. Cannot benull.ids- Stream of ids. Returns emptyStreamwhennull.search- Case-insensitive string to search by role's name or description. Ignored ifnull.first- Index of the first result to return. Ignored if negative ornull.max- Maximum number of results to return. Ignored if negative ornull.- Returns:
- Stream of desired roles. Never returns
null.
-
searchForClientRolesStream
public Stream<RoleModel> searchForClientRolesStream(RealmModel realm, Stream<String> ids, String search, Integer first, Integer max) Description copied from interface:RoleLookupProviderCase-insensitive search for client roles that contain the given string in its name or their client's public identifier (clientId - (client_idin OIDC orentityIDin SAML)).- Specified by:
searchForClientRolesStreamin interfaceRoleLookupProvider- Parameters:
realm- Realm.ids- Stream of ids to include in search. Ignored whennull. Returns emptyStreamwhen empty.search- String to search by role's name or client's public identifier.first- First result to return. Ignored if negative ornull.max- Maximum number of results to return. Ignored if negative ornull.- Returns:
- Stream of the client roles where role name or client public identifier contains given search string.
Never returns
null.
-
searchForClientRolesStream
public Stream<RoleModel> searchForClientRolesStream(RealmModel realm, String search, Stream<String> excludedIds, Integer first, Integer max) Description copied from interface:RoleLookupProviderCase-insensitive search for client roles that contain the given string in their name or their client's public identifier (clientId - (client_idin OIDC orentityIDin SAML)).- Specified by:
searchForClientRolesStreamin interfaceRoleLookupProvider- Parameters:
realm- Realm.search- String to search by role's name or client's public identifier.excludedIds- Stream of ids to exclude. Ignored if empty ornull.first- First result to return. Ignored if negative ornull.max- Maximum number of results to return. Ignored if negative ornull.- Returns:
- Stream of the client roles where role name or client's public identifier contains given search string.
Never returns
null.
-
getClientRolesStream
Description copied from interface:RoleProviderReturns the client roles of the given client.- Specified by:
getClientRolesStreamin interfaceRoleProvider- Parameters:
client- Client.first- First result to return. Ignored if negative ornull.max- Maximum number of results to return. Ignored if negative ornull.- Returns:
- Stream of the roles. Never returns
null.
-
getRolesStream
protected Stream<RoleModel> getRolesStream(jakarta.persistence.TypedQuery<RoleEntity> query, RealmModel realm, Integer first, Integer max) -
searchForClientRolesStream
public Stream<RoleModel> searchForClientRolesStream(ClientModel client, String search, Integer first, Integer max) Description copied from interface:RoleLookupProviderCase-insensitive search for client roles that contain the given string in their name or description.- Specified by:
searchForClientRolesStreamin interfaceRoleLookupProvider- Parameters:
client- Client.search- String to search by role's name or description.first- First result to return. Ignored if negative ornull.max- Maximum number of results to return. Ignored if negative ornull.- Returns:
- Stream of the client roles their name or description contains given search string.
Never returns
null.
-
searchForRolesStream
public Stream<RoleModel> searchForRolesStream(RealmModel realm, String search, Integer first, Integer max) Description copied from interface:RoleLookupProviderCase-insensitive search for roles that contain the given string in their name or description.- Specified by:
searchForRolesStreamin interfaceRoleLookupProvider- Parameters:
realm- Realm.search- Searched substring of the role's name or description.first- First result to return. Ignored if negative ornull.max- Maximum number of results to return. Ignored if negative ornull.- Returns:
- Stream of the realm roles their name or description contains given search string.
Never returns
null.
-
searchForRoles
protected Stream<RoleModel> searchForRoles(jakarta.persistence.TypedQuery<RoleEntity> query, RealmModel realm, String search, Integer first, Integer max) -
removeRole
Description copied from interface:RoleProviderRemoves given realm role from the given realm.- Specified by:
removeRolein interfaceRoleProvider- Parameters:
role- Role to be removed.- Returns:
trueif the role existed and has been removed,falseotherwise.
-
roleRemovedEvent
-
removeRoles
Description copied from interface:RoleProviderRemoves all roles from the given realm.- Specified by:
removeRolesin interfaceRoleProvider- Parameters:
realm- Realm.
-
removeRoles
Description copied from interface:RoleProviderRemoves all roles from the given client.- Specified by:
removeRolesin interfaceRoleProvider- Parameters:
client- Client.
-
getRoleById
Description copied from interface:RoleLookupProviderExact search for a role by its internal ID..- Specified by:
getRoleByIdin interfaceRoleLookupProvider- Parameters:
realm- Realm.id- Internal ID of the role.- Returns:
- Model of the role.
-
getGroupById
Description copied from interface:GroupLookupProviderReturns a group from the given realm with the corresponding id- Specified by:
getGroupByIdin interfaceGroupLookupProvider- Parameters:
realm- Realm.id- Id.- Returns:
- GroupModel with the corresponding id.
-
getGroupByName
Description copied from interface:GroupLookupProviderReturns a group from the given realm with the corresponding name and parent- Specified by:
getGroupByNamein interfaceGroupLookupProvider- Parameters:
realm- Realm.parent- parent Group. Ifnulltop level groups are searchedname- name.- Returns:
- GroupModel with the corresponding name.
-
moveGroup
Description copied from interface:GroupProviderThis 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. group without parent group) child of some group,
- making a child group top level group (i.e. removing its parent group).
- Specified by:
moveGroupin interfaceGroupProvider- Parameters:
realm- Realm owning this group.group- Group to update.toParent- New parent group, ornullif we are moving the group to top level group.
-
getGroupsStream
Description copied from interface:GroupProviderReturns groups for the given realm.- Specified by:
getGroupsStreamin interfaceGroupProvider- Parameters:
realm- Realm.- Returns:
- Stream of groups in the Realm.
-
getGroupsStream
public Stream<GroupModel> getGroupsStream(RealmModel realm, Stream<String> ids, String search, Integer first, Integer max) Description copied from interface:GroupProviderReturns a paginated stream of groups with given ids and given search value in group names.- Specified by:
getGroupsStreamin interfaceGroupProvider- Parameters:
realm- Realm.ids- Stream 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 ornull.max- Maximum number of results to return. Ignored if negative ornull.- Returns:
- Stream of desired groups. Never returns
null.
-
getGroupsStream
public Stream<GroupModel> getGroupsStream(RealmModel realm, Stream<String> ids, Integer first, Integer max) Description copied from interface:GroupProviderReturns a paginated stream of groups with given ids. Effectively the same asgetGroupsStream(realm, ids, null, first, max).- Specified by:
getGroupsStreamin interfaceGroupProvider- Parameters:
realm- Realm.ids- Stream of ids.first- Index of the first result to return. Ignored if negative ornull.max- Maximum number of results to return. Ignored if negative ornull.- Returns:
- Stream of GroupModels with the specified ids
-
getGroupsStream
Description copied from interface:GroupProviderReturns a stream of groups with given ids. Effectively the same asgetGroupsStream(realm, ids, null, null, null).- Specified by:
getGroupsStreamin interfaceGroupProvider- Parameters:
realm- Realm.ids- Stream of ids.- Returns:
- Stream of GroupModels with the specified ids
-
getGroupsCount
Description copied from interface:GroupProviderReturns a number of groups that contains the search string in the name- Specified by:
getGroupsCountin interfaceGroupProvider- Parameters:
realm- Realm.ids- List of ids.search- Case insensitive string which will be searched for. Ignored if null.- Returns:
- Number of groups.
-
getGroupsCount
Description copied from interface:GroupProviderReturns a number of groups/top level groups (i.e. groups without parent group) for the given realm.- Specified by:
getGroupsCountin interfaceGroupProvider- Parameters:
realm- Realm.onlyTopGroups- When true the function returns a count of top level groups only.- Returns:
- Number of groups/top level groups.
-
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.
-
getGroupsCountByNameContaining
Description copied from interface:GroupProviderReturns the number of top level groups containing groups with the given string in name for the given realm.- Specified by:
getGroupsCountByNameContainingin interfaceGroupProvider- Parameters:
realm- Realm.search- Case insensitive string which will be searched for.- Returns:
- Number of groups with the given string in its name.
-
getGroupsByRoleStream
public Stream<GroupModel> getGroupsByRoleStream(RealmModel realm, RoleModel role, Integer firstResult, Integer maxResults) Description copied from interface:GroupProviderReturns groups with the given role in the given realm.- Specified by:
getGroupsByRoleStreamin interfaceGroupProvider- Parameters:
realm- Realm.role- Role.firstResult- First result to return. Ignored if negative ornull.maxResults- Maximum number of results to return. Ignored if negative ornull.- Returns:
- Stream of groups with the given role. Never returns
null.
-
getTopLevelGroupsStream
public Stream<GroupModel> getTopLevelGroupsStream(RealmModel realm, String search, Boolean exact, Integer firstResult, Integer maxResults) Description copied from interface:GroupProviderReturns top level groups (i.e. groups without parent group) for the given realm.- Specified by:
getTopLevelGroupsStreamin interfaceGroupProvider- Parameters:
realm- Realm.search- The name that should be matchedfirstResult- First result to return. Ignored if negative ornull.maxResults- Maximum number of results to return. Ignored if negative ornull.- Returns:
- Stream of top level groups in the realm. Never returns
null.
-
removeGroup
Description copied from interface:GroupProviderRemoves the given group for the given realm.- Specified by:
removeGroupin interfaceGroupProvider- Parameters:
realm- Realm.group- Group.- Returns:
- true if the group was removed, false if group doesn't exist or doesn't belong to the given realm
-
createGroup
public GroupModel createGroup(RealmModel realm, String id, GroupModel.Type type, String name, GroupModel toParent) Description copied from interface:GroupProviderCreates a new group with the given name, id, name and parent to the given realm.- Specified by:
createGroupin interfaceGroupProvider- Parameters:
realm- Realm.id- Id, will be generated ifnull.type- the group type. if not set, defaults toGroupModel.Type.REALMname- Name.toParent- Parent group, ornullif the group is top level group- Returns:
- Model of the created group
-
addTopLevelGroup
Description copied from interface:GroupProviderRemoves parent group for the given group in the given realm.- Specified by:
addTopLevelGroupin interfaceGroupProvider- Parameters:
realm- Realm.subGroup- Group.
-
preRemove
-
preRemove
Description copied from interface:GroupProviderCalled when a realm is removed. Should remove all groups that belong to the realm.- Specified by:
preRemovein interfaceGroupProvider- Parameters:
realm- a reference to the realm
-
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
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.
-
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.
-
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.
-
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
-
removeClients
Description copied from interface:ClientProviderRemoves all clients from the given realm.- Specified by:
removeClientsin interfaceClientProvider- Parameters:
realm- Realm.
-
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.
-
getClientScopeById
Description copied from interface:ClientScopeLookupProviderExact search for a client scope by its internal ID..- Specified by:
getClientScopeByIdin interfaceClientScopeLookupProvider- Parameters:
realm- Realm.id- Internal ID of the role.- Returns:
- Model of the client scope.
-
getClientScopesStream
Description copied from interface:ClientScopeProviderReturns all the client scopes of the given realm as a stream.- Specified by:
getClientScopesStreamin interfaceClientScopeProvider- Parameters:
realm- Realm.- Returns:
- Stream of the client scopes. Never returns
null.
-
addClientScope
Description copied from interface:ClientScopeProviderCreates new client scope with given internal ID andnameto the given realm. Spaces innamewill be replaced by underscore so that scope name can be used as value of scope parameter.- Specified by:
addClientScopein interfaceClientScopeProvider- Parameters:
realm- Realm owning this client scope.id- Internal ID of the client scope ornullif one is to be created by the underlying storename- String name of the client scope.- Returns:
- Model of the created client scope.
-
removeClientScope
Description copied from interface:ClientScopeProviderRemoves client scope from the given realm.- Specified by:
removeClientScopein interfaceClientScopeProvider- Parameters:
realm- Realm.id- Internal ID of the client scope- Returns:
trueif the client scope existed and has been removed,falseotherwise.
-
removeClientScopes
Description copied from interface:ClientScopeProviderRemoves all client scopes from the given realm.- Specified by:
removeClientScopesin interfaceClientScopeProvider- Parameters:
realm- Realm.
-
getClientScopesByProtocol
Description copied from interface:ClientScopeProviderMust retrieve all client scopes of the given realm that are use the given protocol.- Specified by:
getClientScopesByProtocolin interfaceClientScopeProvider- Parameters:
realm- the realm to retrieve the client scopes from.protocol- the protocol expected from the clientScope
-
getClientScopesByAttributes
public Stream<ClientScopeModel> getClientScopesByAttributes(RealmModel realm, Map<String, String> searchMap, boolean useOr) This method filters clientScopes by specific attributes. To do this, it will generate the sql-statement dynamically based on the given search-parameters.
This method prevents SQL-Injections by adding dynamic parameters into the SQL-statement and resolves them later by using the JPA query functionquery.setParameter(dynamicParamName, actualValue).
Here is an example of a generated statement:SELECT distinct C FROM ClientScopeEntity C inner join ClientScopeAttributeEntity CA0 on C.id = CA0.clientScope.id and CA0.name = :a3e8d01932c104f0ab79441d34884bada WHERE C.realmId = :realmId and CA0.value = :acedd0bedc7264a2fb524a37814f7aaa1- Specified by:
getClientScopesByAttributesin interfaceClientScopeProvider- Parameters:
realm- Realm.searchMap- a key-value map that holds the attribute names and values to search for.useOr- If the search-params should be combined with or-expressions or and-expressions- Returns:
- a stream of clientScopes matching the given criteria
-
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
-
getClientScopes
public Map<String,ClientScopeModel> getClientScopes(RealmModel realm, ClientModel client, boolean defaultScope) 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- ClientdefaultScope- 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).
-
searchForGroupByNameStream
public Stream<GroupModel> searchForGroupByNameStream(RealmModel realm, String search, Boolean exact, Integer first, Integer max) Description copied from interface:GroupLookupProviderReturns the group hierarchy with the given string in name for the given realm. For a matching group node the parent group is fetched by id (with all children) and added to the result stream. This is done until the group node does not have a parent (root group)- Specified by:
searchForGroupByNameStreamin interfaceGroupLookupProvider- Parameters:
realm- Realm.search- Case sensitive searched string.exact- Boolean which defines whether search param should be matched exactly.first- First result to return. Ignored if negative ornull.max- Maximum number of results to return. Ignored if negative ornull.- Returns:
- Stream of root groups that have the given string in their name themself or a group in their child-collection has.
The returned hierarchy contains siblings that do not necessarily have a matching name. Never returns
null.
-
searchGroupsByAttributes
public Stream<GroupModel> searchGroupsByAttributes(RealmModel realm, Map<String, String> attributes, Integer firstResult, Integer maxResults) Description copied from interface:GroupLookupProviderReturns the groups filtered by attribute names and attribute values for the given realm.- Specified by:
searchGroupsByAttributesin interfaceGroupLookupProvider- Parameters:
realm- Realm.attributes- name-value pairs that are compared to group attributes.firstResult- First result to return. Ignored if negative ornull.maxResults- Maximum number of results to return. Ignored if negative ornull.- Returns:
- Stream of groups with attributes matching all searched attributes. Never returns
null.
-
removeExpiredClientInitialAccess
public void removeExpiredClientInitialAccess()Description copied from interface:RealmProviderRemoves all expired client initial accesses from all realms.- Specified by:
removeExpiredClientInitialAccessin interfaceRealmProvider
-
updateLocalizationText
- Specified by:
updateLocalizationTextin interfaceRealmProvider
-
saveLocalizationText
- Specified by:
saveLocalizationTextin interfaceRealmProvider
-
saveLocalizationTexts
public void saveLocalizationTexts(RealmModel realm, String locale, Map<String, String> localizationTexts) - Specified by:
saveLocalizationTextsin interfaceRealmProvider
-
deleteLocalizationTextsByLocale
- Specified by:
deleteLocalizationTextsByLocalein interfaceRealmProvider
-
getLocalizationTextsById
- Specified by:
getLocalizationTextsByIdin interfaceRealmProvider
-
deleteLocalizationText
- Specified by:
deleteLocalizationTextin interfaceRealmProvider
-
getClientSearchableAttributes
-