mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 15:35:49 +01:00
use default type of user manager for default authentication
This commit is contained in:
@@ -57,7 +57,7 @@ import sonia.scm.security.EncryptionHandler;
|
|||||||
import sonia.scm.user.UserListener;
|
import sonia.scm.user.UserListener;
|
||||||
import sonia.scm.web.security.AuthenticationHandler;
|
import sonia.scm.web.security.AuthenticationHandler;
|
||||||
import sonia.scm.web.security.AuthenticationListener;
|
import sonia.scm.web.security.AuthenticationListener;
|
||||||
import sonia.scm.web.security.XmlAuthenticationHandler;
|
import sonia.scm.web.security.DefaultAuthenticationHandler;
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
@@ -134,7 +134,7 @@ public class BindingExtensionProcessor implements ExtensionProcessor
|
|||||||
Multibinder<RepositoryRequestListener> repositoryRequestListenerBinder =
|
Multibinder<RepositoryRequestListener> repositoryRequestListenerBinder =
|
||||||
Multibinder.newSetBinder(binder, RepositoryRequestListener.class);
|
Multibinder.newSetBinder(binder, RepositoryRequestListener.class);
|
||||||
|
|
||||||
authenticators.addBinding().to(XmlAuthenticationHandler.class);
|
authenticators.addBinding().to(DefaultAuthenticationHandler.class);
|
||||||
|
|
||||||
for (Class extensionClass : extensions)
|
for (Class extensionClass : extensions)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -58,18 +58,15 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
* @author Sebastian Sdorra
|
* @author Sebastian Sdorra
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class XmlAuthenticationHandler implements AuthenticationHandler
|
public class DefaultAuthenticationHandler implements AuthenticationHandler
|
||||||
{
|
{
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
public static final String NAME_DIRECTORY = "users";
|
public static final String NAME_DIRECTORY = "users";
|
||||||
|
|
||||||
/** Field description */
|
|
||||||
public static final String TYPE = "xml";
|
|
||||||
|
|
||||||
/** the logger for XmlAuthenticationHandler */
|
/** the logger for XmlAuthenticationHandler */
|
||||||
private static final Logger logger =
|
private static final Logger logger =
|
||||||
LoggerFactory.getLogger(XmlAuthenticationHandler.class);
|
LoggerFactory.getLogger(DefaultAuthenticationHandler.class);
|
||||||
|
|
||||||
//~--- constructors ---------------------------------------------------------
|
//~--- constructors ---------------------------------------------------------
|
||||||
|
|
||||||
@@ -81,8 +78,8 @@ public class XmlAuthenticationHandler implements AuthenticationHandler
|
|||||||
* @param encryptionHandler
|
* @param encryptionHandler
|
||||||
*/
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
public XmlAuthenticationHandler(UserManager userManager,
|
public DefaultAuthenticationHandler(UserManager userManager,
|
||||||
EncryptionHandler encryptionHandler)
|
EncryptionHandler encryptionHandler)
|
||||||
{
|
{
|
||||||
this.userManager = userManager;
|
this.userManager = userManager;
|
||||||
this.encryptionHandler = encryptionHandler;
|
this.encryptionHandler = encryptionHandler;
|
||||||
@@ -110,7 +107,7 @@ public class XmlAuthenticationHandler implements AuthenticationHandler
|
|||||||
|
|
||||||
if (user != null)
|
if (user != null)
|
||||||
{
|
{
|
||||||
if (TYPE.equals(user.getType()))
|
if (userManager.getDefaultType().equals(user.getType()))
|
||||||
{
|
{
|
||||||
result = authenticate(user, username, password);
|
result = authenticate(user, username, password);
|
||||||
}
|
}
|
||||||
@@ -118,7 +115,8 @@ public class XmlAuthenticationHandler implements AuthenticationHandler
|
|||||||
{
|
{
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
{
|
{
|
||||||
logger.debug("{} is not an xml user", username);
|
logger.debug("{} is not an {} user", username,
|
||||||
|
userManager.getDefaultType());
|
||||||
}
|
}
|
||||||
|
|
||||||
result = AuthenticationResult.NOT_FOUND;
|
result = AuthenticationResult.NOT_FOUND;
|
||||||
@@ -174,7 +172,7 @@ public class XmlAuthenticationHandler implements AuthenticationHandler
|
|||||||
@Override
|
@Override
|
||||||
public String getType()
|
public String getType()
|
||||||
{
|
{
|
||||||
return TYPE;
|
return userManager.getDefaultType();
|
||||||
}
|
}
|
||||||
|
|
||||||
//~--- methods --------------------------------------------------------------
|
//~--- methods --------------------------------------------------------------
|
||||||
@@ -67,7 +67,7 @@ import sonia.scm.user.xml.XmlUserDAO;
|
|||||||
*
|
*
|
||||||
* @author Sebastian Sdorra
|
* @author Sebastian Sdorra
|
||||||
*/
|
*/
|
||||||
public class XmlAuthenticationHandlerTest extends AbstractTestBase
|
public class DefaultAuthenticationHandlerTest extends AbstractTestBase
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -148,7 +148,7 @@ public class XmlAuthenticationHandlerTest extends AbstractTestBase
|
|||||||
|
|
||||||
userManager.init(contextProvider);
|
userManager.init(contextProvider);
|
||||||
userManager.create(slarti);
|
userManager.create(slarti);
|
||||||
handler = new XmlAuthenticationHandler(userManager, enc);
|
handler = new DefaultAuthenticationHandler(userManager, enc);
|
||||||
handler.init(contextProvider);
|
handler.init(contextProvider);
|
||||||
request = MockUtil.getHttpServletRequest();
|
request = MockUtil.getHttpServletRequest();
|
||||||
reponse = MockUtil.getHttpServletResponse();
|
reponse = MockUtil.getHttpServletResponse();
|
||||||
@@ -169,7 +169,7 @@ public class XmlAuthenticationHandlerTest extends AbstractTestBase
|
|||||||
//~--- fields ---------------------------------------------------------------
|
//~--- fields ---------------------------------------------------------------
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
private XmlAuthenticationHandler handler;
|
private DefaultAuthenticationHandler handler;
|
||||||
|
|
||||||
/** Field description */
|
/** Field description */
|
||||||
private HttpServletResponse reponse;
|
private HttpServletResponse reponse;
|
||||||
Reference in New Issue
Block a user