Allow login handlers to indicate which authentication method they used
authorlajoie <lajoie@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Tue, 11 Dec 2007 14:36:16 +0000 (14:36 +0000)
committerlajoie <lajoie@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Tue, 11 Dec 2007 14:36:16 +0000 (14:36 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@2492 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

src/edu/internet2/middleware/shibboleth/idp/authn/AuthenticationEngine.java
src/edu/internet2/middleware/shibboleth/idp/authn/LoginHandler.java

index c5022d2..8c7ef6b 100644 (file)
@@ -278,8 +278,13 @@ public class AuthenticationEngine extends HttpServlet {
         LOG.debug("Recording authentication and service information in Shibboleth session for principal: {}",
                 principalName);
         Subject subject = (Subject) httpRequest.getAttribute(LoginHandler.SUBJECT_KEY);
-        AuthenticationMethodInformation authnMethodInfo = new AuthenticationMethodInformationImpl(subject, loginContext
-                .getAuthenticationMethod(), new DateTime(), loginContext.getAuthenticationDuration());
+        String authnMethod = (String) httpRequest.getAttribute(LoginHandler.AUTHENTICATION_METHOD_KEY);
+        if (DatatypeHelper.isEmpty(authnMethod)) {
+            authnMethod = loginContext.getAuthenticationMethod();
+        }
+
+        AuthenticationMethodInformation authnMethodInfo = new AuthenticationMethodInformationImpl(subject, authnMethod,
+                new DateTime(), loginContext.getAuthenticationDuration());
 
         shibSession.getAuthenticationMethods().put(authnMethodInfo.getAuthenticationMethod(), authnMethodInfo);
 
index 2b08f1f..a528249 100644 (file)
@@ -36,6 +36,10 @@ import edu.internet2.middleware.shibboleth.idp.session.AuthenticationMethodInfor
  * the authentication process. This Subject is stored in the {@link AuthenticationMethodInformation}, created for this
  * authentication, in the user's session.
  * 
+ * The handler may designate the a URI representing the authentication method actually used, for example if a handler is
+ * capable of performing multiple types of authentication, by binding the URI, as a String, to a request attribute
+ * identified by {@link #AUTHENTICATION_METHOD_KEY}.
+ * 
  * The handler may also bind an error message, if an error occurred during authentication to the request attribute
  * identified by {@link LoginHandler#AUTHENTICATION_ERROR_KEY}.
  * 
@@ -55,6 +59,9 @@ public interface LoginHandler {
     /** Request attribute to which user's subject should be bound. */
     public static final String SUBJECT_KEY = "subject";
 
+    /** Request attribute to which an authentication method URI may be bound. */
+    public static final String AUTHENTICATION_METHOD_KEY = "authnMethod";
+
     /** Request attribute to which an error message may be bound. */
     public static final String AUTHENTICATION_ERROR_KEY = "authnError";