Package org.keycloak.models
Interface RoleProvider
-
- All Superinterfaces:
Provider
,RoleLookupProvider
- All Known Subinterfaces:
CacheRealmProvider
,RealmProvider
- All Known Implementing Classes:
JpaRealmProvider
,MapRealmProvider
,MapRoleProvider
,RealmCacheSession
,RoleStorageManager
public interface RoleProvider extends Provider, RoleLookupProvider
Provider of the role records.- Author:
- vramik
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default RoleModel
addClientRole(ClientModel client, String name)
Adds a client role with givenname
to the given client.RoleModel
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.RoleModel
addRealmRole(RealmModel realm, String id, String name)
Adds a realm role with given internal ID andname
to the given realm.default 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.default 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<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.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 Detail
-
addRealmRole
default RoleModel addRealmRole(RealmModel realm, String name)
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
RoleModel addRealmRole(RealmModel realm, String id, String name)
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
default Stream<RoleModel> getRealmRolesStream(RealmModel realm)
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
Stream<RoleModel> getRealmRolesStream(RealmModel realm, Integer first, Integer max)
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
boolean removeRole(RoleModel role)
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
void removeRoles(RealmModel realm)
Removes all roles from the given realm.- Parameters:
realm
- Realm.
-
addClientRole
default RoleModel addClientRole(ClientModel client, String name)
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
RoleModel addClientRole(ClientModel client, String id, String name)
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
default Stream<RoleModel> getClientRolesStream(ClientModel client)
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
Stream<RoleModel> getClientRolesStream(ClientModel client, Integer first, Integer max)
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
void removeRoles(ClientModel client)
Removes all roles from the given client.- Parameters:
client
- Client.
-
-