Package org.keycloak.models
Interface RoleProvider
- All Superinterfaces:
Provider
,RoleLookupProvider
- All Known Subinterfaces:
CacheRealmProvider
- All Known Implementing Classes:
JpaRealmProvider
,MapRoleProvider
,RealmCacheSession
,RoleStorageManager
Provider of the role records.
- Author:
- vramik
-
Method Summary
Modifier and TypeMethodDescriptiondefault RoleModel
addClientRole
(ClientModel client, String name) Adds a client role with givenname
to the given client.addClientRole
(ClientModel client, String id, String name) Adds a client role with given internal ID andname
to the given client.default RoleModel
addRealmRole
(RealmModel realm, String name) Adds a realm role with givenname
to the given realm.addRealmRole
(RealmModel realm, String id, String name) Adds a realm role with given internal ID andname
to the given realm.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.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.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.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.Methods inherited from interface org.keycloak.storage.role.RoleLookupProvider
getClientRole, getRealmRole, getRoleById, searchForClientRolesStream, searchForRolesStream
-
Method Details
-
addRealmRole
Adds a realm role with givenname
to the given realm. The internal ID of the role will be created automatically.- Parameters:
realm
- Realm owning this role.name
- String name of the role.- Returns:
- Model of the created role.
-
addRealmRole
Adds a realm role with given internal ID andname
to the given realm.- 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.
- Throws:
IllegalArgumentException
- Ifid
does not conform the format understood by the underlying store.
-
getRealmRolesStream
Returns all the realm roles of the given realm as a stream. Effectively the same as the callgetRealmRolesStream(realm, null, null)
.- Parameters:
realm
- Realm.- Returns:
- Stream of the roles. Never returns
null
.
-
getRealmRolesStream
Returns the realm roles of the given realm as a stream.- 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
Stream<RoleModel> 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.- 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
.
-
removeRole
Removes given realm role from the given realm.- Parameters:
role
- Role to be removed.- Returns:
true
if the role existed and has been removed,false
otherwise.
-
removeRoles
Removes all roles from the given realm.- Parameters:
realm
- Realm.
-
addClientRole
Adds a client role with givenname
to the given client. The internal ID of the role will be created automatically.- Parameters:
client
- Client owning this role.name
- String name of the role.- Returns:
- Model of the created role.
-
addClientRole
Adds a client role with given internal ID andname
to the given client.- 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
Returns all the client roles of the given client. Effectively the same as the callgetClientRoles(client, null, null)
.- Parameters:
client
- Client.- Returns:
- Stream of the roles. Never returns
null
.
-
getClientRolesStream
Returns the client roles of the given client.- 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
.
-
removeRoles
Removes all roles from the given client.- Parameters:
client
- Client.
-