keycloak
静的公開メンバ関数 | 静的限定公開メンバ関数 | 全メンバ一覧
org.keycloak.adapters.wildfly.SecurityInfoHelper クラス
org.keycloak.adapters.wildfly.SecurityInfoHelper 連携図
Collaboration graph

静的公開メンバ関数

static void propagateSessionInfo (KeycloakAccount account)
 

静的限定公開メンバ関数

static Principal getPrincipal (Subject subject)
 
static Group createGroup (String name, Set< Principal > principals)
 
static Group [] getRoleSets (Collection< String > roleSet)
 

詳解

著者
Bill Burke
バージョン
Revision
1

関数詳解

◆ createGroup()

static Group org.keycloak.adapters.wildfly.SecurityInfoHelper.createGroup ( String  name,
Set< Principal >  principals 
)
inlinestaticprotected
104  {
105  Group roles = null;
106  Iterator<Principal> iter = principals.iterator();
107  while (iter.hasNext()) {
108  Object next = iter.next();
109  if (!(next instanceof Group))
110  continue;
111  Group grp = (Group) next;
112  if (grp.getName().equals(name)) {
113  roles = grp;
114  break;
115  }
116  }
117  // If we did not find a group create one
118  if (roles == null) {
119  roles = new SimpleGroup(name);
120  principals.add(roles);
121  }
122  return roles;
123  }

◆ getPrincipal()

static Principal org.keycloak.adapters.wildfly.SecurityInfoHelper.getPrincipal ( Subject  subject)
inlinestaticprotected

Get the Principal given the authenticated Subject. Currently the first subject that is not of type

Group

is considered or the single subject inside the CallerPrincipal group.

引数
subject
戻り値
the authenticated subject
80  {
81  Principal principal = null;
82  Principal callerPrincipal = null;
83  if (subject != null) {
84  Set<Principal> principals = subject.getPrincipals();
85  if (principals != null && !principals.isEmpty()) {
86  for (Principal p : principals) {
87  if (!(p instanceof Group) && principal == null) {
88  principal = p;
89  }
90  if (p instanceof Group) {
91  Group g = Group.class.cast(p);
92  if (g.getName().equals(SecurityConstants.CALLER_PRINCIPAL_GROUP) && callerPrincipal == null) {
93  Enumeration<? extends Principal> e = g.members();
94  if (e.hasMoreElements())
95  callerPrincipal = e.nextElement();
96  }
97  }
98  }
99  }
100  }
101  return callerPrincipal == null ? principal : callerPrincipal;
102  }

◆ getRoleSets()

static Group [] org.keycloak.adapters.wildfly.SecurityInfoHelper.getRoleSets ( Collection< String >  roleSet)
inlinestaticprotected
125  {
126  SimpleGroup roles = new SimpleGroup("Roles");
127  Group[] roleSets = {roles};
128  for (String role : roleSet) {
129  roles.addMember(new SimplePrincipal(role));
130  }
131  return roleSets;
132  }

◆ propagateSessionInfo()

static void org.keycloak.adapters.wildfly.SecurityInfoHelper.propagateSessionInfo ( KeycloakAccount  account)
inlinestatic
40  {
41  Subject subject = new Subject();
42  Set<Principal> principals = subject.getPrincipals();
43  principals.add(account.getPrincipal());
44  Group[] roleSets = getRoleSets(account.getRoles());
45  for (int g = 0; g < roleSets.length; g++) {
46  Group group = roleSets[g];
47  String name = group.getName();
48  Group subjectGroup = createGroup(name, principals);
49  if (subjectGroup instanceof NestableGroup) {
50  /* A NestableGroup only allows Groups to be added to it so we
51  need to add a SimpleGroup to subjectRoles to contain the roles
52  */
53  SimpleGroup tmp = new SimpleGroup("Roles");
54  subjectGroup.addMember(tmp);
55  subjectGroup = tmp;
56  }
57  // Copy the group members to the Subject group
58  Enumeration<? extends Principal> members = group.members();
59  while (members.hasMoreElements()) {
60  Principal role = (Principal) members.nextElement();
61  subjectGroup.addMember(role);
62  }
63  }
64  // add the CallerPrincipal group if none has been added in getRoleSets
65  Group callerGroup = new SimpleGroup(SecurityConstants.CALLER_PRINCIPAL_GROUP);
66  callerGroup.addMember(account.getPrincipal());
67  principals.add(callerGroup);
68  org.jboss.security.SecurityContext sc = SecurityContextAssociation.getSecurityContext();
69  Principal userPrincipal = getPrincipal(subject);
70  sc.getUtil().createSubjectInfo(userPrincipal, account, subject);
71  }
static Group [] getRoleSets(Collection< String > roleSet)
Definition: SecurityInfoHelper.java:125
static Principal getPrincipal(Subject subject)
Definition: SecurityInfoHelper.java:80
static Group createGroup(String name, Set< Principal > principals)
Definition: SecurityInfoHelper.java:104

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