1 package org.apache.turbine.modules.actions;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.turbine.util.RunData;
23 import org.apache.velocity.context.Context;
24
25 /***
26 * VelocitySecure action.
27 *
28 * Always performs a Security Check that you've defined before
29 * executing the doBuildtemplate(). You should extend this class and
30 * add the specific security check needed. If you have a number of
31 * screens that need to perform the same check, you could make a base
32 * screen by extending this class and implementing the isAuthorized().
33 * Then each action that needs to perform the same check could extend
34 * your base action.
35 *
36 * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
37 * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
38 * @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
39 * @version $Id: VelocitySecureAction.java 534527 2007-05-02 16:10:59Z tv $
40 */
41 public abstract class VelocitySecureAction extends VelocityAction
42 {
43 /***
44 * Implement this to add information to the context.
45 *
46 * @param data Turbine information.
47 * @param context Context for web pages.
48 * @throws Exception a generic exception.
49 */
50 public abstract void doPerform(RunData data, Context context)
51 throws Exception;
52
53 /***
54 * This method overrides the method in WebMacroSiteAction to
55 * perform a security check first.
56 *
57 * @param data Turbine information.
58 * @throws Exception a generic exception.
59 */
60 protected void perform(RunData data) throws Exception
61 {
62 if (isAuthorized(data))
63 {
64 super.perform(data);
65 }
66 }
67
68 /***
69 * Implement this method to perform the security check needed.
70 * You should set the template in this method that you want the
71 * user to be sent to if they're unauthorized.
72 *
73 * @param data Turbine information.
74 * @return True if the user is authorized to access the screen.
75 * @throws Exception a generic exception.
76 */
77 protected abstract boolean isAuthorized(RunData data)
78 throws Exception;
79 }