58 KeycloakAccount account =
new KeycloakAccount() {
65 public Set<String> getRoles() {
69 Subject subject =
new Subject();
70 Set<Principal> principals = subject.getPrincipals();
71 principals.add(identity);
73 for (
int g = 0; g < roleSets.length; g++) {
74 Group group = roleSets[g];
75 String name = group.getName();
77 if (subjectGroup instanceof NestableGroup) {
81 SimpleGroup tmp =
new SimpleGroup(
"Roles");
82 subjectGroup.addMember(tmp);
86 Enumeration<? extends Principal> members = group.members();
87 while (members.hasMoreElements()) {
88 Principal role = (Principal) members.nextElement();
89 subjectGroup.addMember(role);
93 Group callerGroup =
new SimpleGroup(SecurityConstants.CALLER_PRINCIPAL_GROUP);
94 callerGroup.addMember(identity);
95 principals.add(callerGroup);
96 SecurityContext sc = SecurityContextAssociation.getSecurityContext();
98 sc.getUtil().createSubjectInfo(userPrincipal, account, subject);
99 List<String> rolesAsStringList =
new ArrayList<String>();
100 rolesAsStringList.addAll(roleSet);
103 return (GenericPrincipal)
jbossWebPrincipalConstructor.newInstance(realm, userPrincipal.getName(), null, rolesAsStringList, userPrincipal, null, account, null, subject);
104 }
catch (Throwable t) {
105 throw new RuntimeException(
"Failed to create JBossGenericPrincipal", t);
Group createGroup(String name, Set< Principal > principals)
Definition: JBossWebPrincipalFactory.java:140
static Constructor jbossWebPrincipalConstructor
Definition: JBossWebPrincipalFactory.java:49
Group [] getRoleSets(Collection< String > roleSet)
Definition: JBossWebPrincipalFactory.java:161
Principal getPrincipal(Subject subject)
Definition: JBossWebPrincipalFactory.java:116