NIHVIVO-1207 Add authenticationSource field to LoginStatusBean, so we can tell whether the user logged in via internal or external credentials.

This commit is contained in:
jeb228 2010-11-23 19:20:59 +00:00
parent 61d95dbf5c
commit 1365f0a665
7 changed files with 57 additions and 24 deletions

View file

@ -12,6 +12,7 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import edu.cornell.mannlib.vedit.beans.LoginStatusBean;
import edu.cornell.mannlib.vedit.beans.LoginStatusBean.AuthenticationSource;
import edu.cornell.mannlib.vitro.webapp.beans.User;
import edu.cornell.mannlib.vitro.webapp.controller.edit.Authenticate;
@ -138,12 +139,13 @@ public class AuthenticatorStub extends Authenticator {
}
@Override
public void recordLoginAgainstUserAccount(String username) {
public void recordLoginAgainstUserAccount(String username,
AuthenticationSource authSource) {
recordedLogins.add(username);
User user = getUserByUsername(username);
LoginStatusBean lsb = new LoginStatusBean(user.getURI(), username,
parseUserSecurityLevel(user.getRoleURI()));
parseUserSecurityLevel(user.getRoleURI()), authSource);
LoginStatusBean.setBean(request.getSession(), lsb);
}
@ -177,7 +179,7 @@ public class AuthenticatorStub extends Authenticator {
@Override
public void recordLoginWithoutUserAccount(String username,
String individualUri) {
String individualUri, AuthenticationSource authSource) {
throw new RuntimeException(
"AuthenticatorStub.recordLoginWithoutUserAccount() not implemented.");
}

View file

@ -24,11 +24,11 @@ import stubs.javax.servlet.http.HttpServletRequestStub;
import stubs.javax.servlet.http.HttpServletResponseStub;
import stubs.javax.servlet.http.HttpSessionStub;
import edu.cornell.mannlib.vedit.beans.LoginStatusBean;
import edu.cornell.mannlib.vedit.beans.LoginStatusBean.AuthenticationSource;
import edu.cornell.mannlib.vitro.testing.AbstractTestClass;
import edu.cornell.mannlib.vitro.webapp.beans.User;
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
import edu.cornell.mannlib.vitro.webapp.controller.authenticate.AuthenticatorStub;
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
import edu.cornell.mannlib.vitro.webapp.controller.login.LoginProcessBean;
import edu.cornell.mannlib.vitro.webapp.controller.login.LoginProcessBean.State;
@ -56,7 +56,8 @@ public class AuthenticateTest extends AbstractTestClass {
private static final String URL_SELF_EDITOR_PAGE = "/individual?uri=selfEditorURI";
private static final LoginStatusBean LOGIN_STATUS_DBA = new LoginStatusBean(
USER_DBA_URI, USER_DBA_NAME, LoginStatusBean.DBA);
USER_DBA_URI, USER_DBA_NAME, LoginStatusBean.DBA,
AuthenticationSource.INTERNAL);
private AuthenticatorStub authenticator;
private ServletContextStub servletContext;
@ -91,7 +92,7 @@ public class AuthenticateTest extends AbstractTestClass {
auth = new Authenticate();
auth.init(servletConfig);
}
private User createNewDbaUser() {