View Javadoc

    1   package org.apache.turbine.modules.screens;
    2
    3   /*
    4    * Licensed to the Apache Software Foundation (ASF) under one
    5    * or more contributor license agreements.  See the NOTICE file
    6    * distributed with this work for additional information
    7    * regarding copyright ownership.  The ASF licenses this file
    8    * to you under the Apache License, Version 2.0 (the
    9    * "License"); you may not use this file except in compliance
    10   * with the License.  You may obtain a copy of the License at
    11   *
    12   *   http://www.apache.org/licenses/LICENSE-2.0
    13   *
    14   * Unless required by applicable law or agreed to in writing,
    15   * software distributed under the License is distributed on an
    16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    17   * KIND, either express or implied.  See the License for the
    18   * specific language governing permissions and limitations
    19   * under the License.
    20   */
    21
    22
    23  import org.apache.turbine.pipeline.PipelineData;
    24  import org.apache.turbine.services.velocity.TurbineVelocity;
    25  import org.apache.turbine.util.RunData;
    26  import org.apache.velocity.context.Context;
    27
    28  /**
    29   * Support Turbine 2 screens
    30   *
    31   * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
    32   * @deprecated Use VelocitySecureScreen directly
    33   */
    34  @Deprecated
    35  public abstract class LegacyVelocitySecureScreen
    36          extends LegacyVelocityScreen
    37  {
    38      /**
    39       * Implement this to add information to the context.
    40       *
    41       * @param data Turbine information.
    42       * @param context Context for web pages.
    43       * @exception Exception, a generic exception.
    44       */
    45      @Override
    46      protected abstract void doBuildTemplate(RunData data, Context context)
    47              throws Exception;
    48
    49      /**
    50       * This method overrides the method in VelocityScreen to
    51       * perform a security check first.
    52       *
    53       * @param pipelineData Turbine information.
    54       * @exception Exception, a generic exception.
    55       */
    56      @Override
    57      protected void doBuildTemplate(PipelineData pipelineData)
    58          throws Exception
    59      {
    60          if (isAuthorized(getRunData(pipelineData)))
    61          {
    62              doBuildTemplate(getRunData(pipelineData), TurbineVelocity.getContext(pipelineData));
    63          }
    64      }
    65
    66      /**
    67       * Implement this method to perform the security check needed.
    68       * You should set the template in this method that you want the
    69       * user to be sent to if they're unauthorized.  See the
    70       * VelocitySecurityCheck utility.
    71       *
    72       * @param data Turbine information.
    73       * @return True if the user is authorized to access the screen.
    74       * @exception Exception, a generic exception.
    75       */
    76      protected abstract boolean isAuthorized(RunData data)
    77              throws Exception;
    78  }