AbstractAuthorizeAction (Struts 1.3.10 API)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help

PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.struts.chain.commands
Class AbstractAuthorizeAction

    java.lang.Object
      org.apache.struts.chain.commands.ActionCommandBase
          org.apache.struts.chain.commands.AbstractAuthorizeAction

All Implemented Interfaces:
  org.apache.commons.chain.Command, ActionCommand

Direct Known Subclasses:
  AuthorizeAction

    public abstract class AbstractAuthorizeAction

extends ActionCommandBase

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: 481115 $ $Date: 2005-11-12 13:01:44 -0500 (Sat, 12 Nov 2005) $

Field Summary

Fields inherited from interface org.apache.commons.chain.Command
`CONTINUE_PROCESSING, PROCESSING_COMPLETE`

Constructor Summary
`AbstractAuthorizeAction()`

Method Summary
`boolean` | `execute(ActionContext actionCtx)` Determine whether the requested action is authorized for the current user.
`protected abstract String` | `getErrorMessage(ActionContext context, ActionConfig actionConfig)` Retrieve error message from context.
`protected boolean` | `isAuthorizationRequired(ActionConfig actionConfig)` Must authorization rules be consulted? The base implementation returns `true` if the given `ActionConfig` has one or more roles defined.
`protected abstract boolean` | `isAuthorized(ActionContext context, String[] roles, ActionConfig actionConfig)` Determine if the action is authorized for the given roles.

Methods inherited from class org.apache.struts.chain.commands.ActionCommandBase
`execute`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### AbstractAuthorizeAction

    public AbstractAuthorizeAction()

Method Detail

### execute

    public boolean execute(ActionContext actionCtx)
                    throws 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 `ActionCommand`
  Specified by:
    `execute` in class `ActionCommandBase`
  Parameters:
    `actionCtx` - The `Context` for the current request
  Returns:
    `false` if the user is authorized for the selected action, else `true` to abort processing.
  Throws:
    `UnauthorizedActionException` - if authorization fails or if an error is encountered in the course of performing the authorization.
    `Exception` - On any error

### isAuthorizationRequired

    protected boolean isAuthorizationRequired(ActionConfig actionConfig)

  Must authorization rules be consulted? The base implementation returns `true` if the given `ActionConfig` has one or more roles defined.

  Parameters:
    `actionConfig` - the current ActionConfig object
  Returns:
    true if the `isAuthorized` method should be consulted.

### isAuthorized

    protected abstract boolean isAuthorized(ActionContext context,
                                            String[] roles,
                                            ActionConfig actionConfig)
                                     throws 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:
    `UnauthorizedActionException` - If the logic determines that the request is not authorized but does not wish to rely upon the default mechanism reporting the error.
    `Exception` - If the action cannot be tested for authorization

### getErrorMessage

    protected abstract String getErrorMessage(ActionContext context,
                                              ActionConfig actionConfig)

  Retrieve error message from context.

  Parameters:
    `context` - The `Context` for the current request
    `actionConfig` - The current action mapping
  Returns:
    error message

Overview | Package | Class | Use | Tree | Deprecated | Index | Help

PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.