remove unnecessary provider

This commit is contained in:
Sebastian Sdorra
2013-01-23 13:38:26 +01:00
parent 6d7e8341fa
commit 29a3f682a2
2 changed files with 13 additions and 27 deletions

View File

@@ -36,7 +36,6 @@ package sonia.scm.web.security;
//~--- non-JDK imports --------------------------------------------------------
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
import org.slf4j.Logger;
@@ -86,22 +85,25 @@ public class ChainAuthenticatonManager extends AbstractAuthenticationManager
* @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 --------------------------------------------------------------
@@ -189,14 +191,6 @@ public class ChainAuthenticatonManager extends AbstractAuthenticationManager
authenticator.init(context);
}
Set<AuthenticationListener> listeners =
authenticationListenerProvider.get();
if (Util.isNotEmpty(listeners))
{
addListeners(listeners);
}
}
/**
@@ -346,9 +340,6 @@ public class ChainAuthenticatonManager extends AbstractAuthenticationManager
/** Field description */
private Set<AuthenticationHandler> authenticationHandlerSet;
/** Field description */
private Provider<Set<AuthenticationListener>> authenticationListenerProvider;
/** Field description */
private Cache<String, AuthenticationCacheValue> cache;

View File

@@ -56,6 +56,7 @@ import static org.mockito.Mockito.*;
import java.io.IOException;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@@ -134,15 +135,9 @@ public class ChainAuthenticationManagerTest extends AbstractTestBase
trillian.setPassword("trillian123");
handlerSet.add(new SingleUserAuthenticaionHandler("trilliansType",
trillian));
Provider<Set<AuthenticationListener>> listenerProvider =
mock(Provider.class);
when(listenerProvider.get()).thenReturn(
new HashSet<AuthenticationListener>());
manager = new ChainAuthenticatonManager(handlerSet,
new MessageDigestEncryptionHandler(), cacheManager,
listenerProvider);
Collections.EMPTY_SET);
manager.init(contextProvider);
request = MockUtil.getHttpServletRequest();
response = MockUtil.getHttpServletResponse();