use of org.jboss.as.ejb3.context.SessionContextImpl in project wildfly by wildfly.
the class UncheckedStatelessBean method unchecked.
@PermitAll
public Set<Principal> unchecked() {
org.wildfly.security.auth.server.SecurityDomain securityDomain = org.wildfly.security.auth.server.SecurityDomain.getCurrent();
if (securityDomain != null) {
// elytron profile is enabled
final Roles roles = ((SessionContextImpl) ctx).getComponent().getIncomingRunAsIdentity().getRoles("ejb");
final HashSet<Principal> rolesSet = new HashSet<>();
if (roles != null) {
roles.forEach(role -> rolesSet.add(new NamePrincipal(role.toString())));
}
return rolesSet;
} else {
// use legacy approach
RunAsIdentity rs = (RunAsIdentity) ctx.getCallerPrincipal();
return rs.getRunAsRoles();
}
}
Aggregations