Package org.keycloak.models.utils
Class RoleUtils
java.lang.Object
org.keycloak.models.utils.RoleUtils
- Author:
- Stian Thorgersen
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionexpandCompositeRoles
(Set<RoleModel> roles) static boolean
static boolean
static boolean
hasRoleFromGroup
(Stream<GroupModel> groups, RoleModel targetRole, boolean checkParentGroup) Checks whether thetargetRole
is contained in any of thegroups
or their parents (if requested)static boolean
hasRoleFromGroup
(GroupModel group, RoleModel targetRole, boolean checkParentGroup) Checks whether thetargetRole
is contained in the given group or its parents (if requested)static boolean
isClientRole
(RoleModel r, ClientModel c) static boolean
isDirectMember
(Stream<GroupModel> groups, GroupModel targetGroup) static boolean
isMember
(Stream<GroupModel> groups, GroupModel targetGroup) static boolean
static boolean
isRealmRole
(RoleModel r, RealmModel realm)
-
Constructor Details
-
RoleUtils
public RoleUtils()
-
-
Method Details
-
isMember
- Parameters:
groups
-targetGroup
-- Returns:
- true if targetGroup is in groups (directly or indirectly via parent child relationship)
-
isDirectMember
- Parameters:
groups
-targetGroup
-- Returns:
- true if targetGroup is in groups directly
-
hasRole
- Parameters:
roles
-targetRole
-- Returns:
- true if targetRole is in roles (directly or indirectly via composite role)
-
hasRole
- Parameters:
roles
-targetRole
-- Returns:
- true if targetRole is in roles (directly or indirectly via composite role)
-
hasRoleFromGroup
public static boolean hasRoleFromGroup(GroupModel group, RoleModel targetRole, boolean checkParentGroup) Checks whether thetargetRole
is contained in the given group or its parents (if requested)- Parameters:
group
- Group to check role fortargetRole
-checkParentGroup
- Whentrue
, also parent group is recursively checked for role- Returns:
- true if targetRole is in roles (directly or indirectly via composite role)
-
hasRoleFromGroup
public static boolean hasRoleFromGroup(Stream<GroupModel> groups, RoleModel targetRole, boolean checkParentGroup) Checks whether thetargetRole
is contained in any of thegroups
or their parents (if requested)- Parameters:
groups
-targetRole
-checkParentGroup
- Whentrue
, also parent group is recursively checked for role- Returns:
- true if targetRole is in roles (directly or indirectly via composite role)
-
expandCompositeRoles
- Parameters:
roles
-- Returns:
- new set with composite roles expanded
-
expandCompositeRolesStream
- Parameters:
roles
-- Returns:
- stream with composite roles expanded
-
getDeepUserRoleMappings
- Parameters:
user
-- Returns:
- all user role mappings including all groups of user. Composite roles will be expanded
-
isRealmRole
-
isRealmRole
-
isClientRole
-