]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - org.argeo.security.core/src/org/argeo/security/NodeAuthenticationToken.java
Fix issue with propagating user removal.
[lgpl/argeo-commons.git] / org.argeo.security.core / src / org / argeo / security / NodeAuthenticationToken.java
index 1870675d81cf9075fb5e496f7b059c4dc14f24fe..600811d75e09720199cf00a86f4f0b05680e82ed 100644 (file)
  */
 package org.argeo.security;
 
-import org.springframework.security.GrantedAuthority;
-import org.springframework.security.providers.UsernamePasswordAuthenticationToken;
+import java.util.Collection;
+
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
+import org.springframework.security.core.GrantedAuthority;
 
 /** Credentials required for the authentication to a node. */
 public class NodeAuthenticationToken extends
@@ -39,7 +41,7 @@ public class NodeAuthenticationToken extends
 
        /** Authenticated constructor */
        public NodeAuthenticationToken(NodeAuthenticationToken sat,
-                       GrantedAuthority[] authorities) {
+                       Collection<? extends GrantedAuthority> authorities) {
                super(sat.getPrincipal(), sat.getCredentials(), authorities);
                this.url = sat.getUrl();
        }
@@ -51,4 +53,17 @@ public class NodeAuthenticationToken extends
        public Boolean isRemote() {
                return url != null;
        }
+
+       public String toString() {
+               String username = getName();
+               StringBuilder buf = new StringBuilder("groups=");
+               for (GrantedAuthority ga : getAuthorities()) {
+                       if (!ga.getAuthority().equals(username)) {
+                               buf.append(ga.getAuthority());
+                               buf.append(',');
+                       }
+               }
+               buf.deleteCharAt(buf.length() - 1);
+               return "uid=" + getName() + " " + buf.toString();
+       }
 }