Package org.keycloak.models.map.role
Class MapRoleProvider
java.lang.Object
org.keycloak.models.map.role.MapRoleProvider
- All Implemented Interfaces:
RoleProvider
,Provider
,RoleLookupProvider
-
Constructor Summary
ConstructorDescriptionMapRoleProvider
(KeycloakSession session, MapStorage<MapRoleEntity, RoleModel> roleStore) -
Method Summary
Modifier and TypeMethodDescriptionaddClientRole
(ClientModel client, String id, String name) Adds a client role with given internal ID andname
to the given client.addRealmRole
(RealmModel realm, String id, String name) Adds a realm role with given internal ID andname
to the given realm.void
close()
getClientRole
(ClientModel client, String name) Exact search for a client role by given name.getClientRolesStream
(ClientModel client) Returns all the client roles of the given client.getClientRolesStream
(ClientModel client, Integer first, Integer max) Returns the client roles of the given client.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.getRoleById
(RealmModel realm, String id) Exact search for a role by its internal ID..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.void
preRemove
(RealmModel realm) void
preRemove
(RealmModel realm, RoleModel role) 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.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.searchForRolesStream
(RealmModel realm, String search, Integer first, Integer max) Case-insensitive search for roles that contain the given string in their name or description.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.keycloak.models.RoleProvider
addClientRole, addRealmRole
-
Constructor Details
-
MapRoleProvider
-
-
Method Details
-
addRealmRole
Description copied from interface:RoleProvider
Adds a realm role with given internal ID andname
to the given realm.- Specified by:
addRealmRole
in interfaceRoleProvider
- Parameters:
realm
- Realm owning this role.id
- Internal ID of the role ornull
if one is to be created by the underlying storename
- String name of the role.- Returns:
- Model of the created client.
-
getRealmRolesStream
Description copied from interface:RoleProvider
Returns the realm roles of the given realm as a stream.- Specified by:
getRealmRolesStream
in 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:RoleProvider
Returns a paginated stream of roles with given ids and given search value in role names.- Specified by:
getRolesStream
in interfaceRoleProvider
- Parameters:
realm
- Realm. Cannot benull
.ids
- Stream of ids. Returns emptyStream
whennull
.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
.
-
getRealmRolesStream
Description copied from interface:RoleProvider
Returns all the realm roles of the given realm as a stream. Effectively the same as the callgetRealmRolesStream(realm, null, null)
.- Specified by:
getRealmRolesStream
in interfaceRoleProvider
- Parameters:
realm
- Realm.- Returns:
- Stream of the roles. Never returns
null
.
-
addClientRole
Description copied from interface:RoleProvider
Adds a client role with given internal ID andname
to the given client.- Specified by:
addClientRole
in interfaceRoleProvider
- Parameters:
client
- Client owning this role.id
- Internal ID of the client role ornull
if one is to be created by the underlying store.name
- String name of the role.- Returns:
- Model of the created role.
-
getClientRolesStream
Description copied from interface:RoleProvider
Returns the client roles of the given client.- Specified by:
getClientRolesStream
in 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
.
-
getClientRolesStream
Description copied from interface:RoleProvider
Returns all the client roles of the given client. Effectively the same as the callgetClientRoles(client, null, null)
.- Specified by:
getClientRolesStream
in interfaceRoleProvider
- Parameters:
client
- Client.- Returns:
- Stream of the roles. Never returns
null
.
-
removeRole
Description copied from interface:RoleProvider
Removes given realm role from the given realm.- Specified by:
removeRole
in interfaceRoleProvider
- Parameters:
role
- Role to be removed.- Returns:
true
if the role existed and has been removed,false
otherwise.
-
removeRoles
Description copied from interface:RoleProvider
Removes all roles from the given realm.- Specified by:
removeRoles
in interfaceRoleProvider
- Parameters:
realm
- Realm.
-
removeRoles
Description copied from interface:RoleProvider
Removes all roles from the given client.- Specified by:
removeRoles
in interfaceRoleProvider
- Parameters:
client
- Client.
-
getRealmRole
Description copied from interface:RoleLookupProvider
Exact search for a role by given name.- Specified by:
getRealmRole
in interfaceRoleLookupProvider
- Parameters:
realm
- Realm.name
- String name of the role.- Returns:
- Model of the role, or
null
if no role is found.
-
getClientRole
Description copied from interface:RoleLookupProvider
Exact search for a client role by given name.- Specified by:
getClientRole
in interfaceRoleLookupProvider
- Parameters:
client
- Client.name
- String name of the role.- Returns:
- Model of the role, or
null
if no role is found.
-
getRoleById
Description copied from interface:RoleLookupProvider
Exact search for a role by its internal ID..- Specified by:
getRoleById
in interfaceRoleLookupProvider
- Parameters:
realm
- Realm.id
- Internal ID of the role.- Returns:
- Model of the role.
-
searchForRolesStream
public Stream<RoleModel> searchForRolesStream(RealmModel realm, String search, Integer first, Integer max) Description copied from interface:RoleLookupProvider
Case-insensitive search for roles that contain the given string in their name or description.- Specified by:
searchForRolesStream
in 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
.
-
searchForClientRolesStream
public Stream<RoleModel> searchForClientRolesStream(ClientModel client, String search, Integer first, Integer max) Description copied from interface:RoleLookupProvider
Case-insensitive search for client roles that contain the given string in their name or description.- Specified by:
searchForClientRolesStream
in 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
.
-
preRemove
-
preRemove
-
close
public void close()
-