/** * This file Copyright (c) 2003-2008 Magnolia International * Ltd. (http://www.magnolia.info). All rights reserved. * * * This file is dual-licensed under both the Magnolia * Network Agreement and the GNU General Public License. * You may elect to use one or the other of these licenses. * * This file is distributed in the hope that it will be * useful, but AS-IS and WITHOUT ANY WARRANTY; without even the * implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE, TITLE, or NONINFRINGEMENT. * Redistribution, except as permitted by whichever of the GPL * or MNA you select, is prohibited. * * 1. For the GPL license (GPL), you can redistribute and/or * modify this file under the terms of the GNU General * Public License, Version 3, as published by the Free Software * Foundation. You should have received a copy of the GNU * General Public License, Version 3 along with this program; * if not, write to the Free Software Foundation, Inc., 51 * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * 2. For the Magnolia Network Agreement (MNA), this file * and the accompanying materials are made available under the * terms of the MNA which accompanies this distribution, and * is available at http://www.magnolia.info/mna.html * * Any modifications to this file must keep this entire header * intact. * */ package info.magnolia.cms.security.auth.callback; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * This ClientCallback class enables you to display a standard cms based webpage * instead of the Freemarker Magnolia login form. It can be used in combination * with the {@link CompositeCallback} class. Simply set the "class" attribute of * the pattern delegate to this class and provide the following two additional * attributes: * * IMPORTANT: Make sure you give the anonymous user read permissions on * the login page you specified. * @author Will Scheidegger - fastforward.ch */ public class WebFormClientCallback extends FormClientCallback { private static final Logger log = LoggerFactory.getLogger(WebFormClientCallback.class); /** * Overrides doCallback from info.magnolia.cms.security.auth.callback.FormClientCallback * in order to display a standard cms-based page instead of the Freemarker * login form. * Attention: The anoymous user must have read permission * on the specified page. * @param request * @param response */ public void doCallback(HttpServletRequest request, HttpServletResponse response) { log.debug("Login attempt!"); try { //MgnlContext.setAttribute(); String targetURI = request.getRequestURI(); log.debug("URI called: " + targetURI); String loginURI = request.getContextPath() + getLoginForm(); log.debug("login form URI: " + loginURI); loginURI += "?ol=" + targetURI; request.setAttribute("redirectPath", loginURI); response.sendRedirect(loginURI); } catch (Throwable t) { log.error("exception while writing login template", t); } } }