create global object for the anonymous user

This commit is contained in:
Sebastian Sdorra
2012-10-02 16:02:44 +02:00
parent 7463e0f16f
commit f29bb6d983
4 changed files with 12 additions and 8 deletions

View File

@@ -35,6 +35,7 @@ package sonia.scm;
//~--- non-JDK imports -------------------------------------------------------- //~--- non-JDK imports --------------------------------------------------------
import sonia.scm.user.User;
import sonia.scm.util.ServiceUtil; import sonia.scm.util.ServiceUtil;
/** /**
@@ -52,6 +53,14 @@ public class SCMContext
/** Name of the anonymous user */ /** Name of the anonymous user */
public static final String USER_ANONYMOUS = "anonymous"; public static final String USER_ANONYMOUS = "anonymous";
/**
* the anonymous user
* @since 1.21
*/
public static final User ANONYMOUS = new User(USER_ANONYMOUS,
"SCM Anonymous",
"scm-anonymous@scm-manager.com");
/** Singleton instance of {@link SCMContextProvider} */ /** Singleton instance of {@link SCMContextProvider} */
private static volatile SCMContextProvider provider; private static volatile SCMContextProvider provider;

View File

@@ -168,8 +168,7 @@ public class BasicAuthenticationFilter extends HttpFilter
else if ((configuration != null) else if ((configuration != null)
&& configuration.isAnonymousAccessEnabled()) && configuration.isAnonymousAccessEnabled())
{ {
user = new User(SCMContext.USER_ANONYMOUS, "SCM Anonymous", user = SCMContext.ANONYMOUS;
"scm-anonymous@scm-manager.com");
} }

View File

@@ -288,10 +288,7 @@ public class AuthenticationResource
*/ */
private ScmState createAnonymousState() private ScmState createAnonymousState()
{ {
User user = new User(SCMContext.USER_ANONYMOUS, "SCM Anonymous", return createState(SCMContext.ANONYMOUS, Collections.EMPTY_LIST);
"scm-anonymous@scm-manager.com");
return createState(user, Collections.EMPTY_LIST);
} }
/** /**

View File

@@ -164,8 +164,7 @@ public class SecurityFilter extends HttpFilter
} }
else else
{ {
user = new User(SCMContext.USER_ANONYMOUS, "SCM Anonymous", user = SCMContext.ANONYMOUS;
"scm-anonymous@scm-manager.com");
} }
return user; return user;