Do not return a Principal object to the authentication engine if no remote user was...
authorlajoie <lajoie@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Sun, 10 Jul 2011 11:50:17 +0000 (11:50 +0000)
committerlajoie <lajoie@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Sun, 10 Jul 2011 11:50:17 +0000 (11:50 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/branches/REL_2@3046 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

doc/RELEASE-NOTES.txt
src/main/java/edu/internet2/middleware/shibboleth/idp/authn/provider/RemoteUserAuthServlet.java

index 052cf94..4bed227 100644 (file)
@@ -1,5 +1,6 @@
 Changes in Release 2.3.1
 =============================================
+[SIDP-490] - REMOTE_USER handler not detecting empty value
 [SIDP-491] - Stylesheet link in login.jsp is not inside the head tag
 [SIDP-494] - login.config sample needs updating
 [SIDP-497] - Queries should return the same NameID supplied by the caller
index a441898..26a5ff8 100644 (file)
@@ -24,6 +24,7 @@ import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.opensaml.xml.util.DatatypeHelper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -43,10 +44,14 @@ public class RemoteUserAuthServlet extends HttpServlet {
     /** {@inheritDoc} */
     protected void service(HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws ServletException,
             IOException {
-        String principalName = httpRequest.getRemoteUser();
+        String principalName = DatatypeHelper.safeTrimOrNullString(httpRequest.getRemoteUser());
+        if(principalName != null){
+            log.debug("Remote user identified as {} returning control back to authentication engine", principalName);
+            httpRequest.setAttribute(LoginHandler.PRINCIPAL_KEY, new UsernamePrincipal(principalName));
+        }else{
+            log.debug("No remote user information was present in the request");
+        }
 
-        log.debug("Remote user identified as {} returning control back to authentication engine", principalName);
-        httpRequest.setAttribute(LoginHandler.PRINCIPAL_KEY, new UsernamePrincipal(principalName));
         AuthenticationEngine.returnToAuthenticationEngine(httpRequest, httpResponse);
     }
 }
\ No newline at end of file