BasicSecurityContext should not throw AuthenticationException, to not break existing behavior

This commit is contained in:
Sebastian Sdorra
2012-08-29 09:27:55 +02:00
parent 0197eb6f07
commit 2ddfe06a54

View File

@@ -38,6 +38,7 @@ package sonia.scm.web.security;
import com.google.inject.Inject;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationException;
import org.apache.shiro.subject.PrincipalCollection;
import org.apache.shiro.subject.Subject;
@@ -110,12 +111,28 @@ public class BasicSecurityContext implements WebSecurityContext
public User authenticate(HttpServletRequest request,
HttpServletResponse response, String username, String password)
{
User user = null;
try
{
Subject subject = SecurityUtils.getSubject();
subject.login(new ScmAuthenticationToken(request, response, username,
password));
return subject.getPrincipals().oneByType(User.class);
user = subject.getPrincipals().oneByType(User.class);
}
catch (AuthenticationException ex)
{
if (logger.isWarnEnabled())
{
logger.warn("authentication failed", ex);
}
}
return user;
}
/**