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
FieldsModifier and TypeFieldDescriptionprotected jakarta.persistence.EntityManagerprotected GroupEntityprotected RealmModelprotected final KeycloakSessionFields inherited from interface org.keycloak.models.GroupModel
COMPARE_BY_NAME -
Constructor Summary
ConstructorsConstructorDescriptionGroupAdapter(KeycloakSession session, RealmModel realm, jakarta.persistence.EntityManager em, GroupEntity group) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChild(GroupModel subGroup) Automatically calls setParent() on the subGroupvoiddeleteRoleMapping(RoleModel role) Removes the given role mapping from this object.booleanbooleangetAttributeStream(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()voidGrants the given role to this object.inthashCode()booleanReturnstrueif this object is directly or indirectly assigned the given role,falseotherwise.voidremoveAttribute(String name) voidremoveChild(GroupModel subGroup) Automatically calls setParent() on the subGroupvoidsetAttribute(String name, List<String> values) voidsetDescription(String description) voidvoidsetParent(GroupModel parent) You must also call addChild on the parent group, addChild on RealmModel if there is no parent groupvoidsetSingleAttribute(String name, String value) Set single value of specified attribute.static GroupEntitytoEntity(GroupModel model, jakarta.persistence.EntityManager em) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.keycloak.models.GroupModel
getSubGroupsStream, getSubGroupsStreamMethods 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:
getEntityin interfaceJpaModel<GroupEntity>
-
getId
- Specified by:
getIdin interfaceGroupModel
-
getName
- Specified by:
getNamein interfaceGroupModel
-
setName
- Specified by:
setNamein interfaceGroupModel
-
getDescription
- Specified by:
getDescriptionin interfaceGroupModel
-
setDescription
- Specified by:
setDescriptionin interfaceGroupModel
-
getParent
- Specified by:
getParentin interfaceGroupModel
-
getParentId
- Specified by:
getParentIdin interfaceGroupModel
-
toEntity
-
setParent
Description copied from interface:GroupModelYou must also call addChild on the parent group, addChild on RealmModel if there is no parent group- Specified by:
setParentin interfaceGroupModel
-
addChild
Description copied from interface:GroupModelAutomatically calls setParent() on the subGroup- Specified by:
addChildin interfaceGroupModel
-
removeChild
Description copied from interface:GroupModelAutomatically calls setParent() on the subGroup- Specified by:
removeChildin interfaceGroupModel
-
getSubGroupsStream
Description copied from interface:GroupModelReturns all sub groups for the parent group as a stream. The stream is sorted by the group name.- Specified by:
getSubGroupsStreamin interfaceGroupModel- Returns:
- Stream of
GroupModel. Never returnsnull.
-
getSubGroupsStream
public Stream<GroupModel> getSubGroupsStream(String search, Boolean exact, Integer firstResult, Integer maxResults) Description copied from interface:GroupModelReturns all subgroups for the parent group matching the search as a stream, paginated. Stream is sorted by the group name.- Specified by:
getSubGroupsStreamin interfaceGroupModel- Parameters:
search- search string. If empty ornullall 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:GroupModelReturns the number of groups contained beneath this group.- Specified by:
getSubGroupsCountin interfaceGroupModel- Returns:
- The number of groups beneath this group. Never returns
null.
-
setSingleAttribute
Description copied from interface:GroupModelSet single value of specified attribute. Remove all other existing values- Specified by:
setSingleAttributein interfaceGroupModel
-
setAttribute
- Specified by:
setAttributein interfaceGroupModel
-
removeAttribute
- Specified by:
removeAttributein interfaceGroupModel
-
getFirstAttribute
- Specified by:
getFirstAttributein 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:GroupModelReturns group attributes that match the given name as a stream.- Specified by:
getAttributeStreamin interfaceGroupModel- Parameters:
name-StringName 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:
getAttributesin interfaceGroupModel
-
hasRole
Description copied from interface:RoleMapperModelReturnstrueif this object is directly or indirectly assigned the given role,falseotherwise.For example,
trueis 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:
hasRolein interfaceRoleMapperModel- Returns:
- see description
- See Also:
-
getGroupRoleMappingEntityTypedQuery
protected jakarta.persistence.TypedQuery<GroupRoleMappingEntity> getGroupRoleMappingEntityTypedQuery(RoleModel role) -
grantRole
Description copied from interface:RoleMapperModelGrants the given role to this object.- Specified by:
grantRolein interfaceRoleMapperModel
-
getRealmRoleMappingsStream
Description copied from interface:RoleMapperModelReturns stream of realm roles that are directly set to this object.- Specified by:
getRealmRoleMappingsStreamin interfaceRoleMapperModel- Returns:
- Stream of
RoleModel. Never returnsnull.
-
getRoleMappingsStream
Description copied from interface:RoleMapperModelReturns stream of all role (both realm all client) that are directly set to this object.- Specified by:
getRoleMappingsStreamin interfaceRoleMapperModel- Returns:
- Stream of
RoleModel. Never returnsnull.
-
deleteRoleMapping
Description copied from interface:RoleMapperModelRemoves the given role mapping from this object.- Specified by:
deleteRoleMappingin interfaceRoleMapperModel- Parameters:
role- Role to remove
-
getClientRoleMappingsStream
Description copied from interface:RoleMapperModelReturns stream of client roles that are directly set to this object for the given client.- Specified by:
getClientRoleMappingsStreamin interfaceRoleMapperModel- Parameters:
app-ClientModelClient to get the roles for.- Returns:
- Stream of
RoleModel. Never returnsnull.
-
getType
- Specified by:
getTypein interfaceGroupModel
-
equals
-
hashCode
public int hashCode() -
escapeSlashesInGroupPath
public boolean escapeSlashesInGroupPath()- Specified by:
escapeSlashesInGroupPathin interfaceGroupModel
-