org.apache.struts.chain
Class AbstractAuthorizeAction

java.lang.Object
  extended byorg.apache.struts.chain.AbstractAuthorizeAction
All Implemented Interfaces:
org.apache.commons.chain.Command
Direct Known Subclasses:
AuthorizeAction

public abstract class AbstractAuthorizeAction
extends java.lang.Object
implements org.apache.commons.chain.Command

Determine whether the requested action is authorized for the current user. If not, abort chain processing and perferably, return an error message of some kind.

Version:
$Rev: 54933 $ $Date: 2004-10-16 18:04:52 +0100 (Sat, 16 Oct 2004) $
Author:
Don Brown

Field Summary
private  java.lang.String actionConfigKey
           
private  java.lang.String actionServletKey
           
private static org.apache.commons.logging.Log log
           
 
Constructor Summary
AbstractAuthorizeAction()
           
 
Method Summary
 boolean execute(org.apache.commons.chain.Context context)
          Determine whether the requested action is authorized for the current user.
 java.lang.String getActionConfigKey()
          Return the context attribute key under which the ActionConfig for the currently selected application action is stored.
 java.lang.String getActionServletKey()
          Return the context attribute key under which the ActionServlet for the currently selected application action is stored.
protected abstract  boolean isAuthorized(org.apache.commons.chain.Context context, java.lang.String[] roles, org.apache.struts.config.ActionConfig actionConfig)
          Determine if the action is authorized for the given roles.
 void setActionConfigKey(java.lang.String actionConfigKey)
          Set the context attribute key under which the ActionConfig for the currently selected application action is stored.
 void setActionServletKey(java.lang.String actionServletKey)
          Set the context attribute key under which the ActionServlet for the currently selected application action is stored.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

actionConfigKey

private java.lang.String actionConfigKey

actionServletKey

private java.lang.String actionServletKey

log

private static final org.apache.commons.logging.Log log
Constructor Detail

AbstractAuthorizeAction

public AbstractAuthorizeAction()
Method Detail

getActionConfigKey

public java.lang.String getActionConfigKey()

Return the context attribute key under which the ActionConfig for the currently selected application action is stored.


setActionConfigKey

public void setActionConfigKey(java.lang.String actionConfigKey)

Set the context attribute key under which the ActionConfig for the currently selected application action is stored.

Parameters:
actionConfigKey - The new context attribute key

getActionServletKey

public java.lang.String getActionServletKey()

Return the context attribute key under which the ActionServlet for the currently selected application action is stored.


setActionServletKey

public void setActionServletKey(java.lang.String actionServletKey)

Set the context attribute key under which the ActionServlet for the currently selected application action is stored.

Parameters:
actionServletKey - The new context attribute key

execute

public boolean execute(org.apache.commons.chain.Context context)
                throws java.lang.Exception

Determine whether the requested action is authorized for the current user. If not, abort chain processing and perferably, return an error message of some kind.

Specified by:
execute in interface org.apache.commons.chain.Command
Parameters:
context - The Context for the current request
Returns:
false if the user is authorized for the selected action, else true to abort processing.
Throws:
java.lang.Exception

isAuthorized

protected abstract boolean isAuthorized(org.apache.commons.chain.Context context,
                                        java.lang.String[] roles,
                                        org.apache.struts.config.ActionConfig actionConfig)
                                 throws java.lang.Exception

Determine if the action is authorized for the given roles.

Parameters:
context - The Context for the current request
roles - An array of valid roles for this request
actionConfig - The current action mapping
Returns:
true if the request is authorized, else false
Throws:
java.lang.Exception - If the action cannot be tested for authorization


Copyright ? 2003 - Apache Software Foundation