keycloak
静的公開メンバ関数 | 全メンバ一覧
org.keycloak.models.utils.RoleUtils クラス
org.keycloak.models.utils.RoleUtils 連携図
Collaboration graph

静的公開メンバ関数

static boolean isMember (Set< GroupModel > groups, GroupModel targetGroup)
 
static boolean hasRole (Set< RoleModel > roles, RoleModel targetRole)
 
static boolean hasRoleFromGroup (GroupModel group, RoleModel targetRole, boolean checkParentGroup)
 
static boolean hasRoleFromGroup (Iterable< GroupModel > groups, RoleModel targetRole, boolean checkParentGroup)
 
static Stream< RoleModelexpandCompositeRolesStream (RoleModel role)
 

詳解

著者
Stian Thorgersen

関数詳解

◆ expandCompositeRolesStream()

static Stream<RoleModel> org.keycloak.models.utils.RoleUtils.expandCompositeRolesStream ( RoleModel  role)
inlinestatic

Recursively expands composite roles into their composite.

引数
role
戻り値
Stream of containing all of the composite roles and their components.
110  {
111  Stream.Builder<RoleModel> sb = Stream.builder();
112  Set<RoleModel> roles = new HashSet<>();
113 
114  Deque<RoleModel> stack = new ArrayDeque<>();
115  stack.add(role);
116 
117  while (! stack.isEmpty()) {
118  RoleModel current = stack.pop();
119  sb.add(current);
120 
121  if (current.isComposite()) {
122  current.getComposites().stream()
123  .filter(r -> ! roles.contains(r))
124  .forEach(r -> {
125  roles.add(r);
126  stack.add(r);
127  });
128  }
129  }
130 
131  return sb.build();
132  }

◆ hasRole()

static boolean org.keycloak.models.utils.RoleUtils.hasRole ( Set< RoleModel roles,
RoleModel  targetRole 
)
inlinestatic
引数
roles
targetRole
戻り値
true if targetRole is in roles (directly or indirectly via composite role)
59  {
60  if (roles.contains(targetRole)) return true;
61 
62  for (RoleModel mapping : roles) {
63  if (mapping.hasRole(targetRole)) return true;
64  }
65  return false;
66  }

◆ hasRoleFromGroup() [1/2]

static boolean org.keycloak.models.utils.RoleUtils.hasRoleFromGroup ( GroupModel  group,
RoleModel  targetRole,
boolean  checkParentGroup 
)
inlinestatic

Checks whether the

targetRole

is contained in the given group or its parents (if requested)

引数
groupGroup to check role for
targetRole
checkParentGroupWhen
true
, also parent group is recursively checked for role
戻り値
true if targetRole is in roles (directly or indirectly via composite role)
76  {
77  if (group.hasRole(targetRole))
78  return true;
79 
80  if (checkParentGroup) {
81  GroupModel parent = group.getParent();
82  return parent != null && hasRoleFromGroup(parent, targetRole, true);
83  }
84 
85  return false;
86  }
static boolean hasRoleFromGroup(GroupModel group, RoleModel targetRole, boolean checkParentGroup)
Definition: RoleUtils.java:76

◆ hasRoleFromGroup() [2/2]

static boolean org.keycloak.models.utils.RoleUtils.hasRoleFromGroup ( Iterable< GroupModel groups,
RoleModel  targetRole,
boolean  checkParentGroup 
)
inlinestatic

Checks whether the

targetRole

is contained in any of the

groups

or their parents (if requested)

引数
groups
targetRole
checkParentGroupWhen
true
, also parent group is recursively checked for role
戻り値
true if targetRole is in roles (directly or indirectly via composite role)
96  {
97  if (groups == null) {
98  return false;
99  }
100 
101  return StreamSupport.stream(groups.spliterator(), false)
102  .anyMatch(group -> hasRoleFromGroup(group, targetRole, checkParentGroup));
103  }
static boolean hasRoleFromGroup(GroupModel group, RoleModel targetRole, boolean checkParentGroup)
Definition: RoleUtils.java:76

◆ isMember()

static boolean org.keycloak.models.utils.RoleUtils.isMember ( Set< GroupModel groups,
GroupModel  targetGroup 
)
inlinestatic
引数
groups
targetGroup
戻り値
true if targetGroup is in groups (directly or indirectly via parent child relationship)
41  {
42  if (groups.contains(targetGroup)) return true;
43 
44  for (GroupModel mapping : groups) {
45  GroupModel child = mapping;
46  while(child.getParent() != null) {
47  if (child.getParent().equals(targetGroup)) return true;
48  child = child.getParent();
49  }
50  }
51  return false;
52  }

このクラス詳解は次のファイルから抽出されました: