Package org.keycloak.storage
Class RoleStorageManager
java.lang.Object
org.keycloak.storage.RoleStorageManager
- All Implemented Interfaces:
- RoleProvider,- Provider,- RoleLookupProvider
- 
Field SummaryFields
- 
Constructor SummaryConstructorsConstructorDescriptionRoleStorageManager(KeycloakSession session, long roleStorageProviderTimeout) 
- 
Method SummaryModifier and TypeMethodDescriptionaddClientRole(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.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.voidclose()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.static <T> Stream<T>getEnabledStorageProviders(KeycloakSession session, RealmModel realm, Class<T> type) getRealmRole(RealmModel realm, String name) Exact search for a role by given name.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.static RoleStorageProvidergetStorageProvider(KeycloakSession session, RealmModel realm, String componentId) static RoleStorageProvidergetStorageProviderInstance(KeycloakSession session, RoleStorageProviderModel model, RoleStorageProviderFactory factory) static RoleStorageProviderModelgetStorageProviderModel(RealmModel realm, String componentId) static <T> Stream<T>getStorageProviders(KeycloakSession session, RealmModel realm, Class<T> type) static <T> Stream<RoleStorageProviderModel>getStorageProviders(RealmModel realm, KeycloakSession session, Class<T> type) static booleanisStorageProviderEnabled(RealmModel realm, String providerId) 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.searchForClientRolesStream(ClientModel client, String search, Integer first, Integer max) Obtaining roles from an external role storage is time-bounded.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)).searchForRolesStream(RealmModel realm, String search, Integer first, Integer max) Obtaining roles from an external role storage is time-bounded.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.keycloak.models.RoleProvidergetRealmRolesStream
- 
Field Details- 
session
 
- 
- 
Constructor Details- 
RoleStorageManager
 
- 
- 
Method Details- 
isStorageProviderEnabled
- 
getStorageProviderModelpublic static RoleStorageProviderModel getStorageProviderModel(RealmModel realm, String componentId) 
- 
getStorageProviderpublic static RoleStorageProvider getStorageProvider(KeycloakSession session, RealmModel realm, String componentId) 
- 
getStorageProviderspublic static <T> Stream<RoleStorageProviderModel> getStorageProviders(RealmModel realm, KeycloakSession session, Class<T> type) 
- 
getStorageProviderInstancepublic static RoleStorageProvider getStorageProviderInstance(KeycloakSession session, RoleStorageProviderModel model, RoleStorageProviderFactory factory) 
- 
getStorageProviderspublic static <T> Stream<T> getStorageProviders(KeycloakSession session, RealmModel realm, Class<T> type) 
- 
getEnabledStorageProviderspublic static <T> Stream<T> getEnabledStorageProviders(KeycloakSession session, RealmModel realm, Class<T> type) 
- 
addRealmRoleDescription 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 interface- RoleProvider
- Parameters:
- realm- Realm owning this role.
- name- String name of the role.
- Returns:
- Model of the created role.
 
- 
addRealmRoleDescription copied from interface:RoleProviderAdds a realm role with given internal ID andnameto the given realm.- Specified by:
- addRealmRolein interface- RoleProvider
- Parameters:
- realm- Realm owning this role.
- id- Internal ID of the role or- nullif one is to be created by the underlying store
- name- String name of the role.
- Returns:
- Model of the created client.
 
- 
getRealmRoleDescription copied from interface:RoleLookupProviderExact search for a role by given name.- Specified by:
- getRealmRolein interface- RoleLookupProvider
- Parameters:
- realm- Realm.
- name- String name of the role.
- Returns:
- Model of the role, or nullif no role is found.
 
- 
getRoleByIdDescription copied from interface:RoleLookupProviderExact search for a role by its internal ID..- Specified by:
- getRoleByIdin interface- RoleLookupProvider
- Parameters:
- realm- Realm.
- id- Internal ID of the role.
- Returns:
- Model of the role.
 
- 
getRealmRolesStreamDescription copied from interface:RoleProviderReturns the realm roles of the given realm as a stream.- Specified by:
- getRealmRolesStreamin interface- RoleProvider
- Parameters:
- realm- Realm.
- first- First result to return. Ignored if negative or- null.
- max- Maximum number of results to return. Ignored if negative or- null.
- Returns:
- Stream of the roles. Never returns null.
 
- 
getRolesStreampublic 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 interface- RoleProvider
- Parameters:
- realm- Realm. Cannot be- null.
- ids- Stream of ids. Returns empty- Streamwhen- null.
- search- Case-insensitive string to search by role's name or description. 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.
- Returns:
- Stream of desired roles. Never returns null.
 
- 
searchForRolesStreampublic Stream<RoleModel> searchForRolesStream(RealmModel realm, String search, Integer first, Integer max) Obtaining roles from an external role storage is time-bounded. In case the external role storage isn't available at least roles from a local storage are returned. For this purpose theorg.keycloak.services.DefaultKeycloakSessionFactory#getRoleStorageProviderTimeout()property is used. Default value is 3000 milliseconds and it's configurable. Seeorg.keycloak.services.DefaultKeycloakSessionFactoryfor details.- Specified by:
- searchForRolesStreamin interface- RoleLookupProvider
- Parameters:
- realm- 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.
- Returns:
- Stream of the realm roles their name or description contains given search string. 
 Never returns null.
 
- 
removeRoleDescription copied from interface:RoleProviderRemoves given realm role from the given realm.- Specified by:
- removeRolein interface- RoleProvider
- Parameters:
- role- Role to be removed.
- Returns:
- trueif the role existed and has been removed,- falseotherwise.
 
- 
removeRolesDescription copied from interface:RoleProviderRemoves all roles from the given realm.- Specified by:
- removeRolesin interface- RoleProvider
- Parameters:
- realm- Realm.
 
- 
removeRolesDescription copied from interface:RoleProviderRemoves all roles from the given client.- Specified by:
- removeRolesin interface- RoleProvider
- Parameters:
- client- Client.
 
- 
addClientRoleDescription 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 interface- RoleProvider
- Parameters:
- client- Client owning this role.
- name- String name of the role.
- Returns:
- Model of the created role.
 
- 
addClientRoleDescription copied from interface:RoleProviderAdds a client role with given internal ID andnameto the given client.- Specified by:
- addClientRolein interface- RoleProvider
- Parameters:
- client- Client owning this role.
- id- Internal ID of the client role or- nullif one is to be created by the underlying store.
- name- String name of the role.
- Returns:
- Model of the created role.
 
- 
getClientRoleDescription copied from interface:RoleLookupProviderExact search for a client role by given name.- Specified by:
- getClientRolein interface- RoleLookupProvider
- Parameters:
- client- Client.
- name- String name of the role.
- Returns:
- Model of the role, or nullif no role is found.
 
- 
getClientRolesStreamDescription copied from interface:RoleProviderReturns all the client roles of the given client. Effectively the same as the callgetClientRoles(client, null, null).- Specified by:
- getClientRolesStreamin interface- RoleProvider
- Parameters:
- client- Client.
- Returns:
- Stream of the roles. Never returns null.
 
- 
getClientRolesStreamDescription copied from interface:RoleProviderReturns the client roles of the given client.- Specified by:
- getClientRolesStreamin interface- RoleProvider
- Parameters:
- client- Client.
- first- First result to return. Ignored if negative or- null.
- max- Maximum number of results to return. Ignored if negative or- null.
- Returns:
- Stream of the roles. Never returns null.
 
- 
searchForClientRolesStreampublic Stream<RoleModel> searchForClientRolesStream(ClientModel client, String search, Integer first, Integer max) Obtaining roles from an external role storage is time-bounded. In case the external role storage isn't available at least roles from a local storage are returned. For this purpose theorg.keycloak.services.DefaultKeycloakSessionFactory#getRoleStorageProviderTimeout()} property is used. Default value is 3000 milliseconds and it's configurable. Seeorg.keycloak.services.DefaultKeycloakSessionFactoryfor details.- Specified by:
- searchForClientRolesStreamin interface- RoleLookupProvider
- Parameters:
- client- 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.
- Returns:
- Stream of the client roles their name or description contains given search string. 
 Never returns null.
 
- 
searchForClientRolesStreampublic 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 interface- RoleLookupProvider
- Parameters:
- realm- Realm.
- ids- Stream of ids to include in search. Ignored when- null. Returns empty- Streamwhen empty.
- search- String to search by role's name or client's public identifier.
- first- First result to return. Ignored if negative or- null.
- max- Maximum number of results to return. Ignored if negative or- null.
- Returns:
- Stream of the client roles where role name or client public identifier contains given search string.
 Never returns null.
 
- 
searchForClientRolesStreampublic 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 interface- RoleLookupProvider
- 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 or- null.
- first- First result to return. Ignored if negative or- null.
- max- Maximum number of results to return. Ignored if negative or- null.
- Returns:
- Stream of the client roles where role name or client's public identifier contains given search string.
 Never returns null.
 
- 
closepublic void close()
 
-