diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/authenticate/Authenticator.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/authenticate/Authenticator.java index 28755fc73..7fe8165eb 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/authenticate/Authenticator.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/authenticate/Authenticator.java @@ -14,6 +14,8 @@ import javax.servlet.http.HttpServletRequest; import org.apache.commons.codec.binary.Hex; import edu.cornell.mannlib.vedit.beans.LoginStatusBean.AuthenticationSource; +import edu.cornell.mannlib.vitro.webapp.auth.identifier.ActiveIdentifierBundleFactories; +import edu.cornell.mannlib.vitro.webapp.auth.identifier.IdentifierBundle; import edu.cornell.mannlib.vitro.webapp.beans.UserAccount; /** @@ -57,14 +59,19 @@ public abstract class Authenticator { ServletContext ctx = request.getSession().getServletContext(); Object attribute = ctx.getAttribute(FACTORY_ATTRIBUTE_NAME); if (!(attribute instanceof AuthenticatorFactory)) { - attribute = new BasicAuthenticator.Factory(); - ctx.setAttribute(FACTORY_ATTRIBUTE_NAME, attribute); + setAuthenticatorFactory(new BasicAuthenticator.Factory(), ctx); + attribute = ctx.getAttribute(FACTORY_ATTRIBUTE_NAME); } AuthenticatorFactory factory = (AuthenticatorFactory) attribute; return factory.getInstance(request); } + public static void setAuthenticatorFactory(AuthenticatorFactory factory, + ServletContext ctx) { + ctx.setAttribute(FACTORY_ATTRIBUTE_NAME, factory); + } + // ---------------------------------------------------------------------- // The interface. // ---------------------------------------------------------------------- @@ -200,6 +207,16 @@ public abstract class Authenticator { } } + /** + * Get the IDs that would be created for this userAccount, if this user were + * to log in. + */ + public static IdentifierBundle getIdsForUserAccount(HttpServletRequest req, + UserAccount userAccount) { + return ActiveIdentifierBundleFactories.getUserIdentifierBundle(req, + userAccount); + } + // ---------------------------------------------------------------------- // Exceptions // ---------------------------------------------------------------------- diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/authenticate/BasicAuthenticator.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/authenticate/BasicAuthenticator.java index 3e3aa3d97..39787c8ef 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/authenticate/BasicAuthenticator.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/authenticate/BasicAuthenticator.java @@ -312,4 +312,9 @@ public class BasicAuthenticator extends Authenticator { return wadf; } + @Override + public String toString() { + return "BasicAuthenticator[" + request + "]"; + } + }