mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 15:35:49 +01:00
added AuthenticationListener
This commit is contained in:
@@ -50,6 +50,7 @@ import sonia.scm.repository.RepositoryListener;
|
||||
import sonia.scm.security.EncryptionHandler;
|
||||
import sonia.scm.user.UserListener;
|
||||
import sonia.scm.web.security.AuthenticationHandler;
|
||||
import sonia.scm.web.security.AuthenticationListener;
|
||||
import sonia.scm.web.security.XmlAuthenticationHandler;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
@@ -162,6 +163,19 @@ public class BindingExtensionProcessor implements ExtensionProcessor
|
||||
|
||||
repositoryListeners.add(listener);
|
||||
}
|
||||
else if (AuthenticationListener.class.isAssignableFrom(extensionClass))
|
||||
{
|
||||
if (logger.isInfoEnabled())
|
||||
{
|
||||
logger.info("bind AuthenticaitonListener {}",
|
||||
extensionClass.getName());
|
||||
}
|
||||
|
||||
AuthenticationListener listener =
|
||||
(AuthenticationListener) extensionClass.newInstance();
|
||||
|
||||
authenticationListeners.add(listener);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (logger.isInfoEnabled())
|
||||
@@ -206,6 +220,17 @@ public class BindingExtensionProcessor implements ExtensionProcessor
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Set<AuthenticationListener> getAuthenticationListeners()
|
||||
{
|
||||
return authenticationListeners;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -307,6 +332,10 @@ public class BindingExtensionProcessor implements ExtensionProcessor
|
||||
private Set<RepositoryListener> repositoryListeners =
|
||||
new HashSet<RepositoryListener>();
|
||||
|
||||
/** Field description */
|
||||
private Set<AuthenticationListener> authenticationListeners =
|
||||
new HashSet<AuthenticationListener>();
|
||||
|
||||
/** Field description */
|
||||
private Set<UserListener> userListeners = new HashSet<UserListener>();
|
||||
|
||||
|
||||
@@ -144,7 +144,12 @@ public class ScmContextListener extends GuiceServletContextListener
|
||||
groupManager.init(context);
|
||||
|
||||
// init Authenticator
|
||||
injector.getInstance(AuthenticationManager.class).init(context);
|
||||
AuthenticationManager authenticationManager =
|
||||
injector.getInstance(AuthenticationManager.class);
|
||||
|
||||
authenticationManager.init(context);
|
||||
authenticationManager.addListeners(
|
||||
bindExtProcessor.getAuthenticationListeners());
|
||||
|
||||
return injector;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Singleton
|
||||
public class ChainAuthenticatonManager implements AuthenticationManager
|
||||
public class ChainAuthenticatonManager extends AbstractAuthenticationManager
|
||||
{
|
||||
|
||||
/** the logger for ChainAuthenticatonManager */
|
||||
@@ -124,6 +124,9 @@ public class ChainAuthenticatonManager implements AuthenticationManager
|
||||
{
|
||||
user = result.getUser();
|
||||
user.setType(authenticator.getType());
|
||||
|
||||
// notify authentication listeners
|
||||
fireAuthenticationEvent(request, response, user);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user