Commits

Sebastian Sdorra committed 5dc9c3e

remove unnecessary provider

Comments (0)

Files changed (2)

scm-webapp/src/main/java/sonia/scm/web/security/ChainAuthenticatonManager.java

 //~--- non-JDK imports --------------------------------------------------------
 
 import com.google.inject.Inject;
-import com.google.inject.Provider;
 import com.google.inject.Singleton;
 
 import org.slf4j.Logger;
    * @param encryptionHandler
    * @param cacheManager
    * @param authenticationListenerProvider
+   * @param authenticationListeners
    */
   @Inject
   public ChainAuthenticatonManager(
     Set<AuthenticationHandler> authenticationHandlerSet,
     EncryptionHandler encryptionHandler, CacheManager cacheManager,
-    Provider<Set<AuthenticationListener>> authenticationListenerProvider)
+    Set<AuthenticationListener> authenticationListeners)
   {
     AssertUtil.assertIsNotEmpty(authenticationHandlerSet);
     AssertUtil.assertIsNotNull(cacheManager);
     this.authenticationHandlerSet = authenticationHandlerSet;
     this.encryptionHandler = encryptionHandler;
-    this.authenticationListenerProvider = authenticationListenerProvider;
     this.cache = cacheManager.getCache(String.class,
       AuthenticationCacheValue.class, CACHE_NAME);
 
-    // addListeners(authenticationListeners);
+    if (Util.isNotEmpty(authenticationListeners))
+    {
+      addListeners(authenticationListeners);
+    }
   }
 
   //~--- methods --------------------------------------------------------------
 
       authenticator.init(context);
     }
-
-    Set<AuthenticationListener> listeners =
-      authenticationListenerProvider.get();
-
-    if (Util.isNotEmpty(listeners))
-    {
-      addListeners(listeners);
-    }
   }
 
   /**
   private Set<AuthenticationHandler> authenticationHandlerSet;
 
   /** Field description */
-  private Provider<Set<AuthenticationListener>> authenticationListenerProvider;
-
-  /** Field description */
   private Cache<String, AuthenticationCacheValue> cache;
 
   /** Field description */

scm-webapp/src/test/java/sonia/scm/web/security/ChainAuthenticationManagerTest.java

 
 import java.io.IOException;
 
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
 
     assertUserEquals(trillian, result.getUser());
     assertEquals("trilliansType", result.getUser().getType());
     result = manager.authenticate(request, response, perfect.getName(),
-                                  "perfect123");
+      "perfect123");
     assertNotNull(perfect);
     assertUserEquals(perfect, result.getUser());
     assertEquals("perfectsType", result.getUser().getType());
     trillian = UserTestData.createTrillian();
     trillian.setPassword("trillian123");
     handlerSet.add(new SingleUserAuthenticaionHandler("trilliansType",
-            trillian));
-
-    Provider<Set<AuthenticationListener>> listenerProvider =
-      mock(Provider.class);
-
-    when(listenerProvider.get()).thenReturn(
-        new HashSet<AuthenticationListener>());
+      trillian));
     manager = new ChainAuthenticatonManager(handlerSet,
-            new MessageDigestEncryptionHandler(), cacheManager,
-            listenerProvider);
+      new MessageDigestEncryptionHandler(), cacheManager,
+      Collections.EMPTY_SET);
     manager.init(contextProvider);
     request = MockUtil.getHttpServletRequest();
     response = MockUtil.getHttpServletResponse();
    * @author         Sebastian Sdorra
    */
   private static class SingleUserAuthenticaionHandler
-          implements AuthenticationHandler
+    implements AuthenticationHandler
   {
 
     /**
      */
     @Override
     public AuthenticationResult authenticate(HttpServletRequest request,
-            HttpServletResponse response, String username, String password)
+      HttpServletResponse response, String username, String password)
     {
       AuthenticationResult result = null;