001package org.apache.turbine.modules.screens;
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.services.velocity.TurbineVelocity;
025import org.apache.turbine.util.RunData;
026import org.apache.velocity.context.Context;
027
028/**
029 * Support Turbine 2 screens
030 *
031 * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
032 * @deprecated Use VelocitySecureScreen directly
033 */
034@Deprecated
035public abstract class LegacyVelocitySecureScreen
036        extends LegacyVelocityScreen
037{
038    /**
039     * Implement this to add information to the context.
040     *
041     * @param data Turbine information.
042     * @param context Context for web pages.
043     * @exception Exception, a generic exception.
044     */
045    @Override
046    protected abstract void doBuildTemplate(RunData data, Context context)
047            throws Exception;
048
049    /**
050     * This method overrides the method in VelocityScreen to
051     * perform a security check first.
052     *
053     * @param pipelineData Turbine information.
054     * @exception Exception, a generic exception.
055     */
056    @Override
057    protected void doBuildTemplate(PipelineData pipelineData)
058        throws Exception
059    {
060        if (isAuthorized(getRunData(pipelineData)))
061        {
062            doBuildTemplate(getRunData(pipelineData), TurbineVelocity.getContext(pipelineData));
063        }
064    }
065
066    /**
067     * Implement this method to perform the security check needed.
068     * You should set the template in this method that you want the
069     * user to be sent to if they're unauthorized.  See the
070     * VelocitySecurityCheck utility.
071     *
072     * @param data Turbine information.
073     * @return True if the user is authorized to access the screen.
074     * @exception Exception, a generic exception.
075     */
076    protected abstract boolean isAuthorized(RunData data)
077            throws Exception;
078}