    001package 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
    024import java.io.IOException;
    025
    026import org.apache.commons.configuration.Configuration;
    027import org.apache.turbine.TurbineConstants;
    028import org.apache.turbine.annotation.TurbineConfiguration;
    029import org.apache.turbine.annotation.TurbineLoader;
    030import org.apache.turbine.modules.Action;
    031import org.apache.turbine.modules.ActionLoader;
    032import org.apache.turbine.util.TurbineException;
    033
    034/**
    035 * Implements the action portion of the "Turbine classic" processing
    036 * pipeline (from the Turbine 2.x series).
    037 *
    038 * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>\
    039 * @author <a href="mailto:peter@courcoux.biz">Peter Courcoux</a>
    040 * @version $Id: DefaultSessionValidationValve.java 1706239 2015-10-01 13:18:35Z tv $
    041 */
    042public class DefaultSessionValidationValve
    043    extends AbstractValve
    044{
    045    /** Injected loader instance */
    046    @TurbineLoader( Action.class )
    047    private ActionLoader actionLoader;
    048
    049    /** Injected configuration instance */
    050    @TurbineConfiguration
    051    private Configuration config;
    052
    053    /**
    054     * @see org.apache.turbine.pipeline.Valve#invoke(PipelineData, ValveContext)
    055     */
    056    @Override
    057    public void invoke(PipelineData pipelineData, ValveContext context)
    058        throws IOException, TurbineException
    059    {
    060        try
    061        {
    062            // This is where the validation of the Session information
    063            // is performed if the user has not logged in yet, then
    064            // the screen is set to be Login. This also handles the
    065            // case of not having a screen defined by also setting the
    066            // screen to Login. If you want people to go to another
    067            // screen other than Login, you need to change that within
    068            // TurbineResources.properties...screen.homepage; or, you
    069            // can specify your own SessionValidator action.
    070            actionLoader.exec(pipelineData, config.getString(
    071                            TurbineConstants.ACTION_SESSION_VALIDATOR_KEY,
    072                            TurbineConstants.ACTION_SESSION_VALIDATOR_DEFAULT));
    073        }
    074        catch (Exception e)
    075        {
    076            throw new TurbineException(e);
    077        }
    078
    079        // Pass control to the next Valve in the Pipeline
    080        context.invokeNext(pipelineData);
    081    }
    082}