    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.turbine.TurbineConstants;
    027import org.apache.turbine.annotation.TurbineConfiguration;
    028import org.apache.turbine.annotation.TurbineLoader;
    029import org.apache.turbine.modules.Action;
    030import org.apache.turbine.modules.ActionLoader;
    031import 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 1725011 2016-01-16 17:38:47Z tv $
    040 */
    041public class DefaultSessionValidationValve
    042    extends AbstractValve
    043{
    044    /** Injected loader instance */
    045    @TurbineLoader( Action.class )
    046    private ActionLoader actionLoader;
    047
    048    @TurbineConfiguration( TurbineConstants.ACTION_SESSION_VALIDATOR_KEY )
    049    private String actionSessionValidator = TurbineConstants.ACTION_SESSION_VALIDATOR_DEFAULT;
    050
    051    /**
    052     * @see org.apache.turbine.pipeline.Valve#invoke(PipelineData, ValveContext)
    053     */
    054    @Override
    055    public void invoke(PipelineData pipelineData, ValveContext context)
    056        throws IOException, TurbineException
    057    {
    058        try
    059        {
    060            // This is where the validation of the Session information
    061            // is performed if the user has not logged in yet, then
    062            // the screen is set to be Login. This also handles the
    063            // case of not having a screen defined by also setting the
    064            // screen to Login. If you want people to go to another
    065            // screen other than Login, you need to change that within
    066            // TurbineResources.properties...screen.homepage; or, you
    067            // can specify your own SessionValidator action.
    068            actionLoader.exec(pipelineData, actionSessionValidator);
    069        }
    070        catch (Exception e)
    071        {
    072            throw new TurbineException(e);
    073        }
    074
    075        // Pass control to the next Valve in the Pipeline
    076        context.invokeNext(pipelineData);
    077    }
    078}