1/*2 * Licensed to the Apache Software Foundation (ASF) under one or more3 * contributor license agreements. See the NOTICE file distributed with4 * this work for additional information regarding copyright ownership.5 * The ASF licenses this file to You under the Apache License, Version 2.06 * (the "License"); you may not use this file except in compliance with7 * the License. You may obtain a copy of the License at8 * 9 * http://www.apache.org/licenses/LICENSE-2.010 * 11 * Unless required by applicable law or agreed to in writing, software12 * distributed under the License is distributed on an "AS IS" BASIS,13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.14 * See the License for the specific language governing permissions and15 * limitations under the License.16 */17packageorg.apache.jetspeed.login.impl;
1819import java.io.IOException;
2021import javax.servlet.RequestDispatcher;
22import javax.servlet.ServletException;
2324import org.apache.commons.logging.Log;
25import org.apache.commons.logging.LogFactory;
26import org.apache.jetspeed.pipeline.PipelineException;
27import org.apache.jetspeed.pipeline.valve.AbstractValve;
28import org.apache.jetspeed.pipeline.valve.LoginViewValve;
29import org.apache.jetspeed.pipeline.valve.ValveContext;
30import org.apache.jetspeed.request.RequestContext;
3132/***33 * LoginJSPViewValveImpl34 * 35 * TODO: move this class into a new component?36 * @author <a href="mailto:shinsuke@yahoo.co.jp">Shinsuke Sugaya</a>37 * @version $Id: LoginJSPViewValve.java 186726 2004-06-05 05:13:09Z shinsuke $38 */39publicclassLoginJSPViewValveextendsAbstractValve implements LoginViewValve40 {
41privatestaticfinal Log log = LogFactory.getLog(LoginJSPViewValve.class);
4243privatestaticfinal String DEFAULT_TEMPLATE_PATH = "/WEB-INF/templates/login";
4445private String templatePath;
4647publicLoginJSPViewValve()
48 {
49 templatePath = DEFAULT_TEMPLATE_PATH;
50 }
5152publicLoginJSPViewValve(String templatePath)
53 {
54this.templatePath = templatePath;
55 }
5657/*58 * (non-Javadoc)59 * 60 * @see org.apache.jetspeed.pipeline.valve.AbstractValve#invoke(org.apache.jetspeed.request.RequestContext,61 * org.apache.jetspeed.pipeline.valve.ValveContext)62 */63publicvoid invoke(RequestContext request, ValveContext context) throws PipelineException
64 {
65 String loginTemplateFile = templatePath + "/" + request.getMediaType() + "/login.jsp";
6667try68 {
69 RequestDispatcher rd = request.getRequest().getRequestDispatcher(loginTemplateFile);
70 rd.include(request.getRequest(), request.getResponse());
71 }
72catch (ServletException e)
73 {
74 log.warn("The included login template file threw the exception.", e);
75thrownew PipelineException("The included login template file threw the exception.", e);
76 }
77catch (IOException e)
78 {
79 log.warn("I/O error occurred on the included login template file.", e);
80thrownew PipelineException("I/O error occurred on the included login template file.", e);
81 }
8283// Pass control to the next Valve in the Pipeline84 context.invokeNext(request);
85 }
8687public String toString()
88 {
89return"LoginViewValve";
90 }
91 }