added AuthenticationListener

This commit is contained in:
Sebastian Sdorra
2011-01-07 11:57:15 +01:00
parent c65539265d
commit 4a490499f9
6 changed files with 221 additions and 3 deletions

View File

@@ -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>();

View File

@@ -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;
}

View File

@@ -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;