Class GroupAdapter

java.lang.Object
org.keycloak.models.jpa.GroupAdapter
All Implemented Interfaces:
GroupModel, JpaModel<GroupEntity>, Model, RoleMapperModel

public class GroupAdapter extends Object implements GroupModel, JpaModel<GroupEntity>
Version:
$Revision: 1 $
Author:
Bill Burke
  • Field Details

  • Constructor Details

  • Method Details

    • getEntity

      public GroupEntity getEntity()
      Specified by:
      getEntity in interface JpaModel<GroupEntity>
    • getId

      public String getId()
      Description copied from interface: Model

      Returns the unique identifier of this model. The identifier is generated by the persistence layer and is not supposed to be manually set. It is used internally to identify the model and should not be confused with any user-facing identifier, such as a username or email.

      The identifier is immutable and should not be changed after the model is created.

      Specified by:
      getId in interface GroupModel
      Specified by:
      getId in interface Model
      Returns:
      the unique identifier of this model, not null
    • getName

      public String getName()
      Specified by:
      getName in interface GroupModel
    • setName

      public void setName(String name)
      Specified by:
      setName in interface GroupModel
    • getDescription

      public String getDescription()
      Specified by:
      getDescription in interface GroupModel
    • setDescription

      public void setDescription(String description)
      Specified by:
      setDescription in interface GroupModel
    • getCreatedTimestamp

      public Long getCreatedTimestamp()
      Description copied from interface: GroupModel
      Get timestamp of group creation. May be null for groups created before this feature introduction.
      Specified by:
      getCreatedTimestamp in interface GroupModel
    • setCreatedTimestamp

      public void setCreatedTimestamp(Long timestamp)
      Specified by:
      setCreatedTimestamp in interface GroupModel
    • getLastModifiedTimestamp

      public Long getLastModifiedTimestamp()
      Description copied from interface: GroupModel
      Get timestamp of last group modification. May be null for groups that have not been modified since this feature was introduced.
      Specified by:
      getLastModifiedTimestamp in interface GroupModel
    • setLastModifiedTimestamp

      public void setLastModifiedTimestamp(Long timestamp)
      Specified by:
      setLastModifiedTimestamp in interface GroupModel
    • getParent

      public GroupModel getParent()
      Specified by:
      getParent in interface GroupModel
    • getParentId

      public String getParentId()
      Specified by:
      getParentId in interface GroupModel
    • toEntity

      public static GroupEntity toEntity(GroupModel model, jakarta.persistence.EntityManager em)
    • setParent

      public void setParent(GroupModel parent)
      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 interface GroupModel
    • addChild

      public void addChild(GroupModel subGroup)
      Description copied from interface: GroupModel
      Automatically calls setParent() on the subGroup
      Specified by:
      addChild in interface GroupModel
    • removeChild

      public void removeChild(GroupModel subGroup)
      Description copied from interface: GroupModel
      Automatically calls setParent() on the subGroup
      Specified by:
      removeChild in interface GroupModel
    • getSubGroupsStream

      public Stream<GroupModel> 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 interface GroupModel
      Returns:
      Stream of GroupModel. Never returns null.
    • 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 interface GroupModel
      Parameters:
      search - search string. If empty or null all subgroups are returned.
      exact - toggles fuzzy searching
      firstResult - First result to return. Ignored if negative or null.
      maxResults - Maximum number of results to return. Ignored if negative or null.
      Returns:
      Stream of GroupModel. Never returns null.
    • getSubGroupsCount

      public Long getSubGroupsCount()
      Description copied from interface: GroupModel
      Returns the number of groups contained beneath this group.
      Specified by:
      getSubGroupsCount in interface GroupModel
      Returns:
      The number of groups beneath this group. Never returns null.
    • setSingleAttribute

      public void setSingleAttribute(String name, String value)
      Description copied from interface: GroupModel
      Set single value of specified attribute. Remove all other existing values
      Specified by:
      setSingleAttribute in interface GroupModel
    • setAttribute

      public void setAttribute(String name, List<String> values)
      Specified by:
      setAttribute in interface GroupModel
    • removeAttribute

      public void removeAttribute(String name)
      Specified by:
      removeAttribute in interface GroupModel
    • getFirstAttribute

      public String getFirstAttribute(String name)
      Specified by:
      getFirstAttribute in interface GroupModel
      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

      public Stream<String> getAttributeStream(String name)
      Description copied from interface: GroupModel
      Returns group attributes that match the given name as a stream.
      Specified by:
      getAttributeStream in interface GroupModel
      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

      public Map<String,List<String>> getAttributes()
      Specified by:
      getAttributes in interface GroupModel
    • hasRole

      public boolean hasRole(RoleModel role)
      Description copied from interface: RoleMapperModel
      Returns true 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 interface RoleMapperModel
      Returns:
      see description
      See Also:
    • getGroupRoleMappingEntityTypedQuery

      protected jakarta.persistence.TypedQuery<GroupRoleMappingEntity> getGroupRoleMappingEntityTypedQuery(RoleModel role)
    • grantRole

      public void grantRole(RoleModel role)
      Description copied from interface: RoleMapperModel
      Grants the given role to this object.
      Specified by:
      grantRole in interface RoleMapperModel
    • getRealmRoleMappingsStream

      public Stream<RoleModel> getRealmRoleMappingsStream()
      Description copied from interface: RoleMapperModel
      Returns stream of realm roles that are directly set to this object.
      Specified by:
      getRealmRoleMappingsStream in interface RoleMapperModel
      Returns:
      Stream of RoleModel. Never returns null.
    • getRoleMappingsStream

      public Stream<RoleModel> 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 interface RoleMapperModel
      Returns:
      Stream of RoleModel. Never returns null.
    • deleteRoleMapping

      public void deleteRoleMapping(RoleModel role)
      Description copied from interface: RoleMapperModel
      Removes the given role mapping from this object.
      Specified by:
      deleteRoleMapping in interface RoleMapperModel
      Parameters:
      role - Role to remove
    • getClientRoleMappingsStream

      public Stream<RoleModel> getClientRoleMappingsStream(ClientModel app)
      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 interface RoleMapperModel
      Parameters:
      app - ClientModel Client to get the roles for.
      Returns:
      Stream of RoleModel. Never returns null.
    • getType

      public GroupModel.Type getType()
      Specified by:
      getType in interface GroupModel
    • getOrganization

      public OrganizationModel getOrganization()
      Specified by:
      getOrganization in interface GroupModel
      Returns:
      Organization this group belongs to, or null if the group is of GroupModel.Type.REALM.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • escapeSlashesInGroupPath

      public boolean escapeSlashesInGroupPath()
      Specified by:
      escapeSlashesInGroupPath in interface GroupModel