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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.keycloak.models.GroupModel
GroupModel.GroupPathChangeEvent, GroupModel.GroupRemovedEvent, GroupModel.SearchableFields, GroupModel.Streams
-
-
Field Summary
Fields Modifier and Type Field Description protected CachedGroup
cached
protected RealmCacheSession
cacheSession
protected boolean
invalidated
protected KeycloakSession
keycloakSession
protected RealmModel
realm
protected GroupModel
updated
-
Fields inherited from interface org.keycloak.models.GroupModel
COMPARE_BY_NAME
-
-
Constructor Summary
Constructors Constructor Description GroupAdapter(CachedGroup cached, RealmCacheSession cacheSession, KeycloakSession keycloakSession, RealmModel realm)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addChild(GroupModel subGroup)
Automatically calls setParent() on the subGroupvoid
deleteRoleMapping(RoleModel role)
Removes the given role mapping from this object.boolean
equals(Object o)
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.protected void
getDelegateForUpdate()
String
getFirstAttribute(String name)
String
getId()
String
getName()
GroupModel
getParent()
String
getParentId()
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.Stream<GroupModel>
getSubGroupsStream()
Returns all sub groups for the parent group as a stream.void
grantRole(RoleModel role)
Grants the given role to this object.boolean
hasDirectRole(RoleModel role)
Returnstrue
, if this object is directly assigned the given role.int
hashCode()
boolean
hasRole(RoleModel role)
Returnstrue
if this object is directly or indirectly assigned the given role,false
otherwise.void
invalidate()
protected boolean
isUpdated()
void
removeAttribute(String name)
void
removeChild(GroupModel subGroup)
Automatically calls setParent() on the subGroupvoid
setAttribute(String name, List<String> values)
void
setName(String name)
void
setParent(GroupModel group)
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.
-
-
-
Field Detail
-
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 Detail
-
GroupAdapter
public GroupAdapter(CachedGroup cached, RealmCacheSession cacheSession, KeycloakSession keycloakSession, RealmModel realm)
-
-
Method Detail
-
getDelegateForUpdate
protected void getDelegateForUpdate()
-
invalidate
public void invalidate()
-
isUpdated
protected boolean isUpdated()
-
getId
public String getId()
- Specified by:
getId
in interfaceGroupModel
-
getName
public String getName()
- Specified by:
getName
in interfaceGroupModel
-
setName
public void setName(String name)
- Specified by:
setName
in interfaceGroupModel
-
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 interfaceGroupModel
-
setAttribute
public void setAttribute(String name, List<String> values)
- Specified by:
setAttribute
in interfaceGroupModel
-
removeAttribute
public void removeAttribute(String name)
- Specified by:
removeAttribute
in interfaceGroupModel
-
getFirstAttribute
public String getFirstAttribute(String name)
- 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
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 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
public Map<String,List<String>> getAttributes()
- Specified by:
getAttributes
in interfaceGroupModel
-
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 interfaceRoleMapperModel
- Returns:
- Stream of
RoleModel
. Never returnsnull
.
-
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 interfaceRoleMapperModel
- Parameters:
app
-ClientModel
Client to get the roles for.- Returns:
- Stream of
RoleModel
. Never returnsnull
.
-
hasDirectRole
public boolean hasDirectRole(RoleModel role)
Description copied from interface:RoleMapperModel
Returnstrue
, if this object is directly assigned the given role.- Specified by:
hasDirectRole
in interfaceRoleMapperModel
- 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: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:
if you want to check if this object is directly assigned to a role
-
grantRole
public void grantRole(RoleModel role)
Description copied from interface:RoleMapperModel
Grants the given role to this object.- Specified by:
grantRole
in interfaceRoleMapperModel
-
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 interfaceRoleMapperModel
- Returns:
- Stream of
RoleModel
. Never returnsnull
.
-
deleteRoleMapping
public void deleteRoleMapping(RoleModel role)
Description copied from interface:RoleMapperModel
Removes the given role mapping from this object.- Specified by:
deleteRoleMapping
in interfaceRoleMapperModel
- Parameters:
role
- Role to remove
-
getParent
public GroupModel getParent()
- Specified by:
getParent
in interfaceGroupModel
-
getParentId
public String getParentId()
- Specified by:
getParentId
in interfaceGroupModel
-
getSubGroupsStream
public Stream<GroupModel> getSubGroupsStream()
Description copied from interface:GroupModel
Returns all sub groups for the parent group as a stream.- Specified by:
getSubGroupsStream
in interfaceGroupModel
- Returns:
- Stream of
GroupModel
. Never returnsnull
.
-
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 interfaceGroupModel
-
addChild
public void addChild(GroupModel subGroup)
Description copied from interface:GroupModel
Automatically calls setParent() on the subGroup- Specified by:
addChild
in interfaceGroupModel
-
removeChild
public void removeChild(GroupModel subGroup)
Description copied from interface:GroupModel
Automatically calls setParent() on the subGroup- Specified by:
removeChild
in interfaceGroupModel
-
-