Package org.keycloak.models.jpa
Class GroupAdapter
java.lang.Object
org.keycloak.models.jpa.GroupAdapter
- All Implemented Interfaces:
GroupModel
,JpaModel<GroupEntity>
,RoleMapperModel
- Version:
- $Revision: 1 $
- Author:
- Bill Burke
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.keycloak.models.GroupModel
GroupModel.GroupCreatedEvent, GroupModel.GroupEvent, GroupModel.GroupMemberJoinEvent, GroupModel.GroupMemberLeaveEvent, GroupModel.GroupPathChangeEvent, GroupModel.GroupRemovedEvent, GroupModel.GroupUpdatedEvent, GroupModel.Type
-
Field Summary
Modifier and TypeFieldDescriptionprotected jakarta.persistence.EntityManager
protected GroupEntity
protected RealmModel
protected final KeycloakSession
Fields inherited from interface org.keycloak.models.GroupModel
COMPARE_BY_NAME
-
Constructor Summary
ConstructorDescriptionGroupAdapter
(KeycloakSession session, RealmModel realm, jakarta.persistence.EntityManager em, GroupEntity group) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addChild
(GroupModel subGroup) Automatically calls setParent() on the subGroupvoid
deleteRoleMapping
(RoleModel role) Removes the given role mapping from this object.boolean
boolean
getAttributeStream
(String name) Returns group attributes that match the given name as a stream.Returns stream of client roles that are directly set to this object for the given client.getFirstAttribute
(String name) protected jakarta.persistence.TypedQuery<GroupRoleMappingEntity>
getId()
getName()
Returns stream of realm roles that are directly set to this object.Returns stream of all role (both realm all client) that are directly set to this object.Returns the number of groups contained beneath this group.Returns all sub groups for the parent group as a stream.getSubGroupsStream
(String search, Boolean exact, Integer firstResult, Integer maxResults) Returns all subgroups for the parent group matching the search as a stream, paginated.getType()
void
Grants the given role to this object.int
hashCode()
boolean
Returnstrue
if this object is directly or indirectly assigned the given role,false
otherwise.void
removeAttribute
(String name) void
removeChild
(GroupModel subGroup) Automatically calls setParent() on the subGroupvoid
setAttribute
(String name, List<String> values) void
void
setParent
(GroupModel parent) You must also call addChild on the parent group, addChild on RealmModel if there is no parent groupvoid
setSingleAttribute
(String name, String value) Set single value of specified attribute.static GroupEntity
toEntity
(GroupModel model, jakarta.persistence.EntityManager em) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.keycloak.models.GroupModel
getSubGroupsStream, getSubGroupsStream
Methods inherited from interface org.keycloak.models.RoleMapperModel
hasDirectRole
-
Field Details
-
session
-
group
-
em
protected jakarta.persistence.EntityManager em -
realm
-
-
Constructor Details
-
GroupAdapter
public GroupAdapter(KeycloakSession session, RealmModel realm, jakarta.persistence.EntityManager em, GroupEntity group)
-
-
Method Details
-
getEntity
- Specified by:
getEntity
in interfaceJpaModel<GroupEntity>
-
getId
- Specified by:
getId
in interfaceGroupModel
-
getName
- Specified by:
getName
in interfaceGroupModel
-
setName
- Specified by:
setName
in interfaceGroupModel
-
getParent
- Specified by:
getParent
in interfaceGroupModel
-
getParentId
- Specified by:
getParentId
in interfaceGroupModel
-
toEntity
-
setParent
Description copied from interface:GroupModel
You must also call addChild on the parent group, addChild on RealmModel if there is no parent group- Specified by:
setParent
in interfaceGroupModel
-
addChild
Description copied from interface:GroupModel
Automatically calls setParent() on the subGroup- Specified by:
addChild
in interfaceGroupModel
-
removeChild
Description copied from interface:GroupModel
Automatically calls setParent() on the subGroup- Specified by:
removeChild
in interfaceGroupModel
-
getSubGroupsStream
Description copied from interface:GroupModel
Returns all sub groups for the parent group as a stream. The stream is sorted by the group name.- Specified by:
getSubGroupsStream
in interfaceGroupModel
- Returns:
- Stream of
GroupModel
. Never returnsnull
.
-
getSubGroupsStream
public Stream<GroupModel> getSubGroupsStream(String search, Boolean exact, Integer firstResult, Integer maxResults) Description copied from interface:GroupModel
Returns all subgroups for the parent group matching the search as a stream, paginated. Stream is sorted by the group name.- Specified by:
getSubGroupsStream
in interfaceGroupModel
- Parameters:
search
- search string. If empty ornull
all subgroups are returned.exact
- toggles fuzzy searchingfirstResult
- First result to return. Ignored if negative ornull
.maxResults
- Maximum number of results to return. Ignored if negative ornull
.- Returns:
- Stream of
GroupModel
. Never returnsnull
.
-
getSubGroupsCount
Description copied from interface:GroupModel
Returns the number of groups contained beneath this group.- Specified by:
getSubGroupsCount
in interfaceGroupModel
- Returns:
- The number of groups beneath this group. Never returns
null
.
-
setSingleAttribute
Description copied from interface:GroupModel
Set single value of specified attribute. Remove all other existing values- Specified by:
setSingleAttribute
in interfaceGroupModel
-
setAttribute
- Specified by:
setAttribute
in interfaceGroupModel
-
removeAttribute
- Specified by:
removeAttribute
in interfaceGroupModel
-
getFirstAttribute
- Specified by:
getFirstAttribute
in interfaceGroupModel
- Returns:
- null if there is not any value of specified attribute or first value otherwise. Don't throw exception if there are more values of the attribute
-
getAttributeStream
Description copied from interface:GroupModel
Returns group attributes that match the given name as a stream.- Specified by:
getAttributeStream
in interfaceGroupModel
- Parameters:
name
-String
Name of the attribute to be used as a filter.- Returns:
- Stream of all attribute values or empty stream if there are not any values. Never return
null
.
-
getAttributes
- Specified by:
getAttributes
in interfaceGroupModel
-
hasRole
Description copied from interface:RoleMapperModel
Returnstrue
if this object is directly or indirectly assigned the given role,false
otherwise.For example,
true
is returned for hasRole(R) if:- R is directly assigned to this object
- R is indirectly assigned to this object via composites
- R is not assigned to this object but this object belongs to a group G which is assigned the role R
- R is not assigned to this object but this object belongs to a group G, and G belongs to group H which is assigned the role R
- Specified by:
hasRole
in interfaceRoleMapperModel
- Returns:
- see description
- See Also:
-
getGroupRoleMappingEntityTypedQuery
protected jakarta.persistence.TypedQuery<GroupRoleMappingEntity> getGroupRoleMappingEntityTypedQuery(RoleModel role) -
grantRole
Description copied from interface:RoleMapperModel
Grants the given role to this object.- Specified by:
grantRole
in interfaceRoleMapperModel
-
getRealmRoleMappingsStream
Description copied from interface:RoleMapperModel
Returns stream of realm roles that are directly set to this object.- Specified by:
getRealmRoleMappingsStream
in interfaceRoleMapperModel
- Returns:
- Stream of
RoleModel
. Never returnsnull
.
-
getRoleMappingsStream
Description copied from interface:RoleMapperModel
Returns stream of all role (both realm all client) that are directly set to this object.- Specified by:
getRoleMappingsStream
in interfaceRoleMapperModel
- Returns:
- Stream of
RoleModel
. Never returnsnull
.
-
deleteRoleMapping
Description copied from interface:RoleMapperModel
Removes the given role mapping from this object.- Specified by:
deleteRoleMapping
in interfaceRoleMapperModel
- Parameters:
role
- Role to remove
-
getClientRoleMappingsStream
Description copied from interface:RoleMapperModel
Returns stream of client roles that are directly set to this object for the given client.- Specified by:
getClientRoleMappingsStream
in interfaceRoleMapperModel
- Parameters:
app
-ClientModel
Client to get the roles for.- Returns:
- Stream of
RoleModel
. Never returnsnull
.
-
getType
- Specified by:
getType
in interfaceGroupModel
-
equals
-
hashCode
public int hashCode() -
escapeSlashesInGroupPath
public boolean escapeSlashesInGroupPath()- Specified by:
escapeSlashesInGroupPath
in interfaceGroupModel
-