2 * Copyright [2006] [University Corporation for Advanced Internet Development, Inc.]
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package edu.internet2.middleware.shibboleth.idp.profile;
21 import javax.servlet.ServletException;
22 import javax.servlet.http.HttpServletRequest;
23 import javax.servlet.http.HttpServletResponse;
25 import org.springframework.web.servlet.HttpServletBean;
27 import edu.internet2.middleware.shibboleth.common.profile.AbstractProfileHandler;
30 * Servlet responsible for dispatching incoming requests to the appropriate {@link AbstractProfileHandler}.
32 public class ProfileRequestDispatcher extends HttpServletBean {
34 /** Registered profile handlers. */
35 private Map<String, AbstractProfileHandler> profileHandlers;
38 * Gets the profile handlers currently registered.
40 * @return profile handlers currently registered
42 public Map<String, AbstractProfileHandler> getProfileHandlers() {
43 return profileHandlers;
47 * Sets all the profile handlers to use.
49 * @param handlers the profile handlers to use
51 public void setProfileHandlers(Map<String, AbstractProfileHandler> handlers) {
52 profileHandlers = handlers;
56 public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException {
57 String path = request.getPathInfo();
58 AbstractProfileHandler handler = profileHandlers.get(path);
60 if (handler != null) {
61 ShibbolethProfileRequest profileReq = new ShibbolethProfileRequest(request);
62 ShibbolethProfileResponse profileResp = new ShibbolethProfileResponse(response);
63 handler.processRequest(profileReq, profileResp);
66 // TODO handle case where there is no registered profile