X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.security.core%2Fsrc%2Forg%2Fargeo%2Fsecurity%2FSecurityUtils.java;h=8c6715446a96ec78cff35bd0176f3584ffadab69;hb=6e7769555f6ee64159bbdb5780e34957d6d8895e;hp=e5b8ae79cacc9019fcb8cc717e275ca6f4b55c84;hpb=10ed6557c631d5feee8541badd0c9f16a9e791c6;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.security.core/src/org/argeo/security/SecurityUtils.java b/org.argeo.security.core/src/org/argeo/security/SecurityUtils.java index e5b8ae79c..8c6715446 100644 --- a/org.argeo.security.core/src/org/argeo/security/SecurityUtils.java +++ b/org.argeo.security.core/src/org/argeo/security/SecurityUtils.java @@ -16,21 +16,32 @@ package org.argeo.security; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.UUID; -import org.springframework.security.Authentication; -import org.springframework.security.GrantedAuthority; -import org.springframework.security.context.SecurityContext; -import org.springframework.security.context.SecurityContextHolder; -import org.springframework.security.providers.anonymous.AnonymousAuthenticationToken; +import org.springframework.security.authentication.AnonymousAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.context.SecurityContext; +import org.springframework.security.core.context.SecurityContextHolder; /** Static utilities */ -public class SecurityUtils { +public final class SecurityUtils { + private final static String systemKey = UUID.randomUUID().toString(); private SecurityUtils() { } + /** + * @return a String which is guaranteed to be unique between and constant + * within a Java static context (typically a VM launch) + */ + public final static String getStaticKey() { + return systemKey; + } + /** Whether the current thread has the admin role */ public static boolean hasCurrentThreadAuthority(String authority) { SecurityContext securityContext = SecurityContextHolder.getContext(); @@ -89,7 +100,7 @@ public class SecurityUtils { * read-only list of strings, for portability and integration */ public static List authoritiesToStringList( - GrantedAuthority[] authorities) { + Collection authorities) { List lst = new ArrayList(); for (GrantedAuthority ga : authorities) lst.add(ga.getAuthority());