Package org.keycloak.models.map.group
Class MapGroupAdapter
- java.lang.Object
-
- org.keycloak.models.map.group.AbstractGroupModel<MapGroupEntity>
-
- org.keycloak.models.map.group.MapGroupAdapter
-
- All Implemented Interfaces:
GroupModel,RoleMapperModel
public abstract class MapGroupAdapter extends AbstractGroupModel<MapGroupEntity>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.keycloak.models.GroupModel
GroupModel.GroupPathChangeEvent, GroupModel.GroupRemovedEvent, GroupModel.SearchableFields, GroupModel.Streams
-
-
Field Summary
-
Fields inherited from class org.keycloak.models.map.group.AbstractGroupModel
entity, realm, session
-
Fields inherited from interface org.keycloak.models.GroupModel
COMPARE_BY_NAME
-
-
Constructor Summary
Constructors Constructor Description MapGroupAdapter(KeycloakSession session, RealmModel realm, MapGroupEntity entity)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChild(GroupModel subGroup)Automatically calls setParent() on the subGroupvoiddeleteRoleMapping(RoleModel role)Removes the given role mapping from this object.Map<String,List<String>>getAttributes()Stream<String>getAttributeStream(String name)Returns group attributes that match the given name as a stream.Stream<RoleModel>getClientRoleMappingsStream(ClientModel app)Returns stream of client roles that are directly set to this object for the given client.StringgetFirstAttribute(String name)StringgetId()StringgetName()GroupModelgetParent()StringgetParentId()Stream<RoleModel>getRealmRoleMappingsStream()Returns stream of realm roles that are directly set to this object.Stream<RoleModel>getRoleMappingsStream()Returns stream of all role (both realm all client) that are directly set to this object.voidgrantRole(RoleModel role)Grants the given role to this object.booleanhasDirectRole(RoleModel role)Returnstrue, if this object is directly assigned the given role.booleanhasRole(RoleModel role)Returnstrueif 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)voidsetName(String name)voidsetParent(GroupModel group)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.-
Methods inherited from class org.keycloak.models.map.group.AbstractGroupModel
equals, hashCode
-
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
-
-
-
-
Constructor Detail
-
MapGroupAdapter
public MapGroupAdapter(KeycloakSession session, RealmModel realm, MapGroupEntity entity)
-
-
Method Detail
-
getId
public String getId()
-
getName
public String getName()
-
setName
public void setName(String name)
-
setSingleAttribute
public void setSingleAttribute(String name, String value)
Description copied from interface:GroupModelSet single value of specified attribute. Remove all other existing values
-
removeAttribute
public void removeAttribute(String name)
-
getFirstAttribute
public String getFirstAttribute(String name)
- 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:GroupModelReturns group attributes that match the given name as a stream.- 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.
-
getParent
public GroupModel getParent()
-
getParentId
public String getParentId()
-
setParent
public void setParent(GroupModel group)
Description copied from interface:GroupModelYou must also call addChild on the parent group, addChild on RealmModel if there is no parent group
-
addChild
public void addChild(GroupModel subGroup)
Description copied from interface:GroupModelAutomatically calls setParent() on the subGroup
-
removeChild
public void removeChild(GroupModel subGroup)
Description copied from interface:GroupModelAutomatically calls setParent() on the subGroup
-
getRealmRoleMappingsStream
public Stream<RoleModel> getRealmRoleMappingsStream()
Description copied from interface:RoleMapperModelReturns stream of realm roles that are directly set to this object.- Returns:
- Stream of
RoleModel. Never returnsnull.
-
getClientRoleMappingsStream
public Stream<RoleModel> getClientRoleMappingsStream(ClientModel app)
Description copied from interface:RoleMapperModelReturns stream of client roles that are directly set to this object for the given client.- Parameters:
app-ClientModelClient to get the roles for.- Returns:
- Stream of
RoleModel. Never returnsnull.
-
hasDirectRole
public boolean hasDirectRole(RoleModel role)
Description copied from interface:RoleMapperModelReturnstrue, if this object is directly assigned the given role.- Parameters:
role- the role- Returns:
- see description
- See Also:
if you want to check whether this object is directly or indirectly assigned to a role
-
hasRole
public boolean hasRole(RoleModel role)
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
- Returns:
- see description
- See Also:
if you want to check if this object is directly assigned to a role
-
grantRole
public void grantRole(RoleModel role)
Description copied from interface:RoleMapperModelGrants the given role to this object.
-
getRoleMappingsStream
public Stream<RoleModel> getRoleMappingsStream()
Description copied from interface:RoleMapperModelReturns stream of all role (both realm all client) that are directly set to this object.- Returns:
- Stream of
RoleModel. Never returnsnull.
-
deleteRoleMapping
public void deleteRoleMapping(RoleModel role)
Description copied from interface:RoleMapperModelRemoves the given role mapping from this object.- Parameters:
role- Role to remove
-
-