    001package org.apache.turbine.modules.actions;
    002
    003/*
    004 * Licensed to the Apache Software Foundation (ASF) under one
    005 * or more contributor license agreements.  See the NOTICE file
    006 * distributed with this work for additional information
    007 * regarding copyright ownership.  The ASF licenses this file
    008 * to you under the Apache License, Version 2.0 (the
    009 * "License"); you may not use this file except in compliance
    010 * with the License.  You may obtain a copy of the License at
    011 *
    012 *   http://www.apache.org/licenses/LICENSE-2.0
    013 *
    014 * Unless required by applicable law or agreed to in writing,
    015 * software distributed under the License is distributed on an
    016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    017 * KIND, either express or implied.  See the License for the
    018 * specific language governing permissions and limitations
    019 * under the License.
    020 */
    021
    022
    023import org.apache.turbine.pipeline.PipelineData;
    024import org.apache.turbine.util.RunData;
    025
    026/**
    027 * VelocitySecure action.
    028 *
    029 * Always performs a Security Check that you've defined before
    030 * executing the doPerform().  You should extend this class and
    031 * add the specific security check needed.  If you have a number of
    032 * actions that need to perform the same check, you could make a base
    033 * action by extending this class and implementing the isAuthorized().
    034 * Then each action that needs to perform the same check could extend
    035 * your base action.
    036 *
    037 * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
    038 * @deprecated Use VelocitySecureAction directly
    039 */
    040@Deprecated
    041public abstract class LegacyVelocitySecureAction extends LegacyVelocityAction
    042{
    043    /**
    044     * This method overrides the method in VelocityAction to
    045     * perform a security check first.
    046     *
    047     * @param pipelineData Turbine information.
    048     * @throws Exception a generic exception.
    049     */
    050    @Override
    051    protected void perform(PipelineData pipelineData) throws Exception
    052    {
    053        if (isAuthorized(getRunData(pipelineData)))
    054        {
    055            super.perform(pipelineData);
    056        }
    057    }
    058
    059    /**
    060     * Implement this method to perform the security check needed.
    061     * You should set the template in this method that you want the
    062     * user to be sent to if they're unauthorized.
    063     *
    064     * @param data Turbine information.
    065     * @return True if the user is authorized to access the screen.
    066     * @throws Exception a generic exception.
    067     */
    068    protected abstract boolean isAuthorized(RunData data) throws Exception;
    069}