mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 08:25:44 +01:00
remove unnecessary provider
This commit is contained in:
@@ -36,7 +36,6 @@ package sonia.scm.web.security;
|
|||||||
//~--- non-JDK imports --------------------------------------------------------
|
//~--- non-JDK imports --------------------------------------------------------
|
||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provider;
|
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -86,22 +85,25 @@ public class ChainAuthenticatonManager extends AbstractAuthenticationManager
|
|||||||
* @param encryptionHandler
|
* @param encryptionHandler
|
||||||
* @param cacheManager
|
* @param cacheManager
|
||||||
* @param authenticationListenerProvider
|
* @param authenticationListenerProvider
|
||||||
|
* @param authenticationListeners
|
||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
public ChainAuthenticatonManager(
|
public ChainAuthenticatonManager(
|
||||||
Set<AuthenticationHandler> authenticationHandlerSet,
|
Set<AuthenticationHandler> authenticationHandlerSet,
|
||||||
EncryptionHandler encryptionHandler, CacheManager cacheManager,
|
EncryptionHandler encryptionHandler, CacheManager cacheManager,
|
||||||
Provider<Set<AuthenticationListener>> authenticationListenerProvider)
|
Set<AuthenticationListener> authenticationListeners)
|
||||||
{
|
{
|
||||||
AssertUtil.assertIsNotEmpty(authenticationHandlerSet);
|
AssertUtil.assertIsNotEmpty(authenticationHandlerSet);
|
||||||
AssertUtil.assertIsNotNull(cacheManager);
|
AssertUtil.assertIsNotNull(cacheManager);
|
||||||
this.authenticationHandlerSet = authenticationHandlerSet;
|
this.authenticationHandlerSet = authenticationHandlerSet;
|
||||||
this.encryptionHandler = encryptionHandler;
|
this.encryptionHandler = encryptionHandler;
|
||||||
this.authenticationListenerProvider = authenticationListenerProvider;
|
|
||||||
this.cache = cacheManager.getCache(String.class,
|
this.cache = cacheManager.getCache(String.class,
|
||||||
AuthenticationCacheValue.class, CACHE_NAME);
|
AuthenticationCacheValue.class, CACHE_NAME);
|
||||||
|
|
||||||
// addListeners(authenticationListeners);
|
if (Util.isNotEmpty(authenticationListeners))
|
||||||
|
{
|
||||||
|
addListeners(authenticationListeners);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//~--- methods --------------------------------------------------------------
|
//~--- methods --------------------------------------------------------------
|
||||||
@@ -189,14 +191,6 @@ public class ChainAuthenticatonManager extends AbstractAuthenticationManager
|
|||||||
|
|
||||||
authenticator.init(context);
|
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 */
|
/** Field description */
|
||||||
private Set<AuthenticationHandler> authenticationHandlerSet;
|
private Set<AuthenticationHandler> authenticationHandlerSet;
|
||||||
|
|
||||||
/** Field description */
|
|
||||||
private Provider<Set<AuthenticationListener>> authenticationListenerProvider;
|
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
private Cache<String, AuthenticationCacheValue> cache;
|
private Cache<String, AuthenticationCacheValue> cache;
|
||||||
|
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ import static org.mockito.Mockito.*;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -109,7 +110,7 @@ public class ChainAuthenticationManagerTest extends AbstractTestBase
|
|||||||
assertUserEquals(trillian, result.getUser());
|
assertUserEquals(trillian, result.getUser());
|
||||||
assertEquals("trilliansType", result.getUser().getType());
|
assertEquals("trilliansType", result.getUser().getType());
|
||||||
result = manager.authenticate(request, response, perfect.getName(),
|
result = manager.authenticate(request, response, perfect.getName(),
|
||||||
"perfect123");
|
"perfect123");
|
||||||
assertNotNull(perfect);
|
assertNotNull(perfect);
|
||||||
assertUserEquals(perfect, result.getUser());
|
assertUserEquals(perfect, result.getUser());
|
||||||
assertEquals("perfectsType", result.getUser().getType());
|
assertEquals("perfectsType", result.getUser().getType());
|
||||||
@@ -133,16 +134,10 @@ public class ChainAuthenticationManagerTest extends AbstractTestBase
|
|||||||
trillian = UserTestData.createTrillian();
|
trillian = UserTestData.createTrillian();
|
||||||
trillian.setPassword("trillian123");
|
trillian.setPassword("trillian123");
|
||||||
handlerSet.add(new SingleUserAuthenticaionHandler("trilliansType",
|
handlerSet.add(new SingleUserAuthenticaionHandler("trilliansType",
|
||||||
trillian));
|
trillian));
|
||||||
|
|
||||||
Provider<Set<AuthenticationListener>> listenerProvider =
|
|
||||||
mock(Provider.class);
|
|
||||||
|
|
||||||
when(listenerProvider.get()).thenReturn(
|
|
||||||
new HashSet<AuthenticationListener>());
|
|
||||||
manager = new ChainAuthenticatonManager(handlerSet,
|
manager = new ChainAuthenticatonManager(handlerSet,
|
||||||
new MessageDigestEncryptionHandler(), cacheManager,
|
new MessageDigestEncryptionHandler(), cacheManager,
|
||||||
listenerProvider);
|
Collections.EMPTY_SET);
|
||||||
manager.init(contextProvider);
|
manager.init(contextProvider);
|
||||||
request = MockUtil.getHttpServletRequest();
|
request = MockUtil.getHttpServletRequest();
|
||||||
response = MockUtil.getHttpServletResponse();
|
response = MockUtil.getHttpServletResponse();
|
||||||
@@ -184,7 +179,7 @@ public class ChainAuthenticationManagerTest extends AbstractTestBase
|
|||||||
* @author Sebastian Sdorra
|
* @author Sebastian Sdorra
|
||||||
*/
|
*/
|
||||||
private static class SingleUserAuthenticaionHandler
|
private static class SingleUserAuthenticaionHandler
|
||||||
implements AuthenticationHandler
|
implements AuthenticationHandler
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -215,7 +210,7 @@ public class ChainAuthenticationManagerTest extends AbstractTestBase
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public AuthenticationResult authenticate(HttpServletRequest request,
|
public AuthenticationResult authenticate(HttpServletRequest request,
|
||||||
HttpServletResponse response, String username, String password)
|
HttpServletResponse response, String username, String password)
|
||||||
{
|
{
|
||||||
AuthenticationResult result = null;
|
AuthenticationResult result = null;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user