mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 15:05:44 +01:00
create global object for the anonymous user
This commit is contained in:
@@ -35,6 +35,7 @@ package sonia.scm;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.user.User;
|
||||
import sonia.scm.util.ServiceUtil;
|
||||
|
||||
/**
|
||||
@@ -52,6 +53,14 @@ public class SCMContext
|
||||
/** Name of the anonymous user */
|
||||
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} */
|
||||
private static volatile SCMContextProvider provider;
|
||||
|
||||
|
||||
@@ -168,8 +168,7 @@ public class BasicAuthenticationFilter extends HttpFilter
|
||||
else if ((configuration != null)
|
||||
&& configuration.isAnonymousAccessEnabled())
|
||||
{
|
||||
user = new User(SCMContext.USER_ANONYMOUS, "SCM Anonymous",
|
||||
"scm-anonymous@scm-manager.com");
|
||||
user = SCMContext.ANONYMOUS;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -288,10 +288,7 @@ public class AuthenticationResource
|
||||
*/
|
||||
private ScmState createAnonymousState()
|
||||
{
|
||||
User user = new User(SCMContext.USER_ANONYMOUS, "SCM Anonymous",
|
||||
"scm-anonymous@scm-manager.com");
|
||||
|
||||
return createState(user, Collections.EMPTY_LIST);
|
||||
return createState(SCMContext.ANONYMOUS, Collections.EMPTY_LIST);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -164,8 +164,7 @@ public class SecurityFilter extends HttpFilter
|
||||
}
|
||||
else
|
||||
{
|
||||
user = new User(SCMContext.USER_ANONYMOUS, "SCM Anonymous",
|
||||
"scm-anonymous@scm-manager.com");
|
||||
user = SCMContext.ANONYMOUS;
|
||||
}
|
||||
|
||||
return user;
|
||||
|
||||
Reference in New Issue
Block a user