    001    package org.apache.turbine.pipeline;
    002
    003
    004    /*
    005     * Licensed to the Apache Software Foundation (ASF) under one
    006     * or more contributor license agreements.  See the NOTICE file
    007     * distributed with this work for additional information
    008     * regarding copyright ownership.  The ASF licenses this file
    009     * to you under the Apache License, Version 2.0 (the
    010     * "License"); you may not use this file except in compliance
    011     * with the License.  You may obtain a copy of the License at
    012     *
    013     *   http://www.apache.org/licenses/LICENSE-2.0
    014     *
    015     * Unless required by applicable law or agreed to in writing,
    016     * software distributed under the License is distributed on an
    017     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    018     * KIND, either express or implied.  See the License for the
    019     * specific language governing permissions and limitations
    020     * under the License.
    021     */
    022
    023
    024    import java.io.IOException;
    025
    026    import org.apache.turbine.Turbine;
    027    import org.apache.turbine.TurbineConstants;
    028    import org.apache.turbine.modules.Action;
    029    import org.apache.turbine.modules.ActionLoader;
    030    import org.apache.turbine.services.assemblerbroker.TurbineAssemblerBroker;
    031    import org.apache.turbine.util.TurbineException;
    032
    033    /**
    034     * Implements the action portion of the "Turbine classic" processing
    035     * pipeline (from the Turbine 2.x series).
    036     *
    037     * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>\
    038     * @author <a href="mailto:peter@courcoux.biz">Peter Courcoux</a>
    039     * @version $Id: DefaultSessionValidationValve.java 758254 2009-03-25 13:41:02Z tv $
    040     */
    041    public class DefaultSessionValidationValve
    042        extends AbstractValve
    043    {
    044        private ActionLoader actionLoader;
    045
    046        public DefaultSessionValidationValve()
    047            throws Exception
    048        {
    049            // empty constructor
    050        }
    051
    052        /**
    053         * Initialize this valve for use in a pipeline.
    054         *
    055         * @see org.apache.turbine.pipeline.AbstractValve#initialize()
    056         */
    057        public void initialize() throws Exception
    058        {
    059            super.initialize();
    060
    061            this.actionLoader = (ActionLoader)TurbineAssemblerBroker.getLoader(Action.NAME);
    062        }
    063
    064        /**
    065         * @see org.apache.turbine.Valve#invoke(RunData, ValveContext)
    066         */
    067        public void invoke(PipelineData pipelineData, ValveContext context)
    068            throws IOException, TurbineException
    069        {
    070            try
    071            {
    072                // This is where the validation of the Session information
    073                // is performed if the user has not logged in yet, then
    074                // the screen is set to be Login. This also handles the
    075                // case of not having a screen defined by also setting the
    076                // screen to Login. If you want people to go to another
    077                // screen other than Login, you need to change that within
    078                // TurbineResources.properties...screen.homepage; or, you
    079                // can specify your own SessionValidator action.
    080                actionLoader.exec(pipelineData,
    081                        Turbine.getConfiguration().getString(
    082                                TurbineConstants.ACTION_SESSION_VALIDATOR_KEY,
    083                                TurbineConstants.ACTION_SESSION_VALIDATOR_DEFAULT));
    084            }
    085            catch (Exception e)
    086            {
    087                throw new TurbineException(e);
    088            }
    089
    090            // Pass control to the next Valve in the Pipeline
    091            context.invokeNext(pipelineData);
    092        }
    093    }