Very basic request distpatching functionality
authorlajoie <lajoie@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Wed, 24 Jan 2007 15:31:48 +0000 (15:31 +0000)
committerlajoie <lajoie@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Wed, 24 Jan 2007 15:31:48 +0000 (15:31 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@2128 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

src/edu/internet2/middleware/shibboleth/idp/profile/ProfileRequestDispatcher.java

index 78468f0..dae6fd1 100644 (file)
  */
 package edu.internet2.middleware.shibboleth.idp.profile;
 
+import java.util.Map;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
 import org.springframework.web.servlet.HttpServletBean;
 
+import edu.internet2.middleware.shibboleth.common.profile.ProfileHandler;
+
 /**
  * Servlet responsible for dispatching incoming requests to the appropriate {@link ProfileHandler}.
  */
 public class ProfileRequestDispatcher extends HttpServletBean {
 
+    /** Serial version UID. */
+    private static final long serialVersionUID = -8899576775507240060L;
+
+    /** Registered profile handlers. */
+    private Map<String, ProfileHandler> profileHandlers;
+    
+    /**
+     * Gets the profile handlers currently registered.
+     * 
+     * @return profile handlers currently registered
+     */
+    public Map<String, ProfileHandler> getProfileHandlers(){
+        return profileHandlers;
+    }
+    
+    /**
+     * Sets all the profile handlers to use.
+     * 
+     * @param handlers the profile handlers to use
+     */
+    public void setProfileHandlers(Map<String, ProfileHandler> handlers){
+        profileHandlers = handlers;
+    }
+    
+    /** {@inheritDoc} */
+    public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException{
+        String path = request.getPathInfo();
+        ProfileHandler handler = profileHandlers.get(path);
+        
+        if(handler != null){
+            handler.processRequest(request, response);
+        }
+        
+        // TODO handle case where there is no registered profile
+    }
 }
\ No newline at end of file