Class GroupAdapter

java.lang.Object
org.keycloak.models.cache.infinispan.GroupAdapter
All Implemented Interfaces:
GroupModel, RoleMapperModel

public class GroupAdapter extends Object implements GroupModel
Version:
$Revision: 1 $
Author:
Bill Burke
  • Field Details

    • cached

      protected final CachedGroup cached
    • cacheSession

      protected final RealmCacheSession cacheSession
    • keycloakSession

      protected final KeycloakSession keycloakSession
    • realm

      protected final RealmModel realm
    • updated

      protected volatile GroupModel updated
    • invalidated

      protected volatile boolean invalidated
  • Constructor Details

  • Method Details

    • getDelegateForUpdate

      protected void getDelegateForUpdate()
    • invalidate

      public void invalidate()
    • isUpdated

      protected boolean isUpdated()
    • equals

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

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

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

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

      public void setName(String name)
      Specified by:
      setName in interface GroupModel
    • 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
    • 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.
    • 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.
    • hasDirectRole

      public boolean hasDirectRole(RoleModel role)
      Description copied from interface: RoleMapperModel
      Returns true, if this object is directly assigned the given role.
      Specified by:
      hasDirectRole in interface RoleMapperModel
      Parameters:
      role - the role
      Returns:
      see description
      See Also:
    • 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:
    • grantRole

      public void grantRole(RoleModel role)
      Description copied from interface: RoleMapperModel
      Grants the given role to this object.
      Specified by:
      grantRole in interface RoleMapperModel
    • 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
    • getParent

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

      public String getParentId()
      Specified by:
      getParentId 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, Integer firstResult, Integer maxResults)
      Description copied from interface: GroupModel
      Returns all sub groups for the parent group matching the fuzzy search as a stream, paginated. Stream is sorted by the group name.
      Specified by:
      getSubGroupsStream in interface GroupModel
      Parameters:
      search - searched string. If empty or null all subgroups are returned.
      Returns:
      Stream of GroupModel. Never returns null.
    • getSubGroupsStream

      public Stream<GroupModel> getSubGroupsStream(Integer firstResult, Integer maxResults)
      Description copied from interface: GroupModel
      Returns all sub groups for the parent group as a stream, paginated.
      Specified by:
      getSubGroupsStream in interface GroupModel
      Parameters:
      firstResult - First result to return. Ignored if negative or null.
      maxResults - Maximum number of results to return. Ignored if negative or null.
      Returns:
    • 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.
    • setParent

      public void setParent(GroupModel group)
      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
    • escapeSlashesInGroupPath

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