Added option to indirect username from different header
authorcantor <cantor@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Mon, 12 Aug 2002 16:11:33 +0000 (16:11 +0000)
committercantor <cantor@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Mon, 12 Aug 2002 16:11:33 +0000 (16:11 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@265 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

src/edu/internet2/middleware/shibboleth/hs/HandleServlet.java

index 1fc4750..5c3227d 100644 (file)
@@ -62,6 +62,7 @@ public class HandleServlet extends HttpServlet {
 
     private HandleRepositoryFactory hrf;
     private long ticketExp; 
+    private String username=null;
     private HandleServiceSAML hsSAML;
     private String rep;
     private static Logger log = Logger.getLogger(HandleServlet.class.getName());; 
@@ -75,12 +76,10 @@ public class HandleServlet extends HttpServlet {
 
        getInitParams();
        log.info("HS: Loading init params");
-       System.err.println("HS: initializing");
 
        try {
            edu.internet2.middleware.eduPerson.Init.init();
-           InputStream is = sctx.getResourceAsStream
-               (getInitParameter("KSpath"));
+           InputStream is = sctx.getResourceAsStream(getInitParameter("KSpath"));
            hsSAML = new HandleServiceSAML( getInitParameter("domain"), 
                                            getInitParameter("AAurl"),
                                            getInitParameter("HSname"),
@@ -130,6 +129,8 @@ public class HandleServlet extends HttpServlet {
        }
        ticketExp = Long.parseLong(ticket);
 
+       username=getInitParameter("username");
+
        if ( getInitParameter("domain") == null || 
             getInitParameter("domain").equals("")) {
            throw new ServletException("Cannot find host domain in init parameters");
@@ -184,7 +185,10 @@ public class HandleServlet extends HttpServlet {
            req.setAttribute("shire", req.getParameter("shire"));
            req.setAttribute("target", req.getParameter("target"));
 
-           he = new HandleEntry(req.getRemoteUser(), req.getAuthType(), ticketExp);
+           he = new HandleEntry(
+               (username==null || username.equalsIgnoreCase("REMOTE_USER")) ? req.getRemoteUser() : req.getHeader(username),
+               req.getAuthType(),
+               ticketExp );
            log.info("Issued Handle (" + he.getHandle() + ") to (" + he.getUsername() + ")");
            hrf.insertHandleEntry( he );