]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - security/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/internal/CurrentUser.java
Introduce OSAuthentication
[lgpl/argeo-commons.git] / security / plugins / org.argeo.security.ui / src / main / java / org / argeo / security / ui / internal / CurrentUser.java
index 1abdc15646dc6453045762147f3ad503458f36fe..ed50d1e3ccd521d864d5e1ac77a8ee5b4a6bdc82 100644 (file)
@@ -23,11 +23,16 @@ public class CurrentUser {
        }
 
        public final static Set<String> roles() {
-               Principal principal = getSubject().getPrincipals().iterator().next();
-               Authentication authentication = (Authentication) principal;
                Set<String> roles = Collections.synchronizedSet(new HashSet<String>());
-               for (GrantedAuthority ga : authentication.getAuthorities()) {
-                       roles.add(ga.getAuthority());
+
+               Set<Authentication> authens = getSubject().getPrincipals(
+                               Authentication.class);
+               if (authens != null && !authens.isEmpty()) {
+                       Principal principal = authens.iterator().next();
+                       Authentication authentication = (Authentication) principal;
+                       for (GrantedAuthority ga : authentication.getAuthorities()) {
+                               roles.add(ga.getAuthority());
+                       }
                }
                return Collections.unmodifiableSet(roles);
        }