use of com.thinkbiganalytics.security.SimplePrincipal in project kylo by Teradata.
the class SecurityContextUtil method getCurrentPrincipals.
public static Set<Principal> getCurrentPrincipals() {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
Set<Principal> principals = new HashSet<>();
if (auth != null) {
for (GrantedAuthority grant : auth.getAuthorities()) {
if (grant instanceof JaasGrantedAuthority) {
JaasGrantedAuthority jaasGrant = (JaasGrantedAuthority) grant;
principals.add(jaasGrant.getPrincipal());
} else {
String authority = grant.getAuthority();
if (authority != null) {
principals.add(new SimplePrincipal(authority));
}
}
}
principals.add(new UsernamePrincipal(auth.getName()));
} else {
principals.add(new AnonymousPrincipal());
}
return principals;
}
Aggregations