Commits

Sebastian Sdorra committed 52becb8

create global object for the anonymous user

Comments (0)

Files changed (4)

scm-core/src/main/java/sonia/scm/SCMContext.java

 
 //~--- non-JDK imports --------------------------------------------------------
 
+import sonia.scm.user.User;
 import sonia.scm.util.ServiceUtil;
 
 /**
   /** 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;
 

scm-core/src/main/java/sonia/scm/web/filter/BasicAuthenticationFilter.java

     else if ((configuration != null)
       && configuration.isAnonymousAccessEnabled())
     {
-      user = new User(SCMContext.USER_ANONYMOUS, "SCM Anonymous",
-        "scm-anonymous@scm-manager.com");
+      user = SCMContext.ANONYMOUS;
 
     }
 

scm-webapp/src/main/java/sonia/scm/api/rest/resources/AuthenticationResource.java

    */
   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);
   }
 
   /**

scm-webapp/src/main/java/sonia/scm/filter/SecurityFilter.java

     }
     else
     {
-      user = new User(SCMContext.USER_ANONYMOUS, "SCM Anonymous",
-        "scm-anonymous@scm-manager.com");
+      user = SCMContext.ANONYMOUS;
     }
 
     return user;