| java.lang.Object org.apache.turbine.util.SecurityCheck
SecurityCheck | public class SecurityCheck (Code) | | Utility for doing security checks in Screens and Actions.
Sample usage:
SecurityCheck mycheck =
new SecurityCheck(data, "Unauthorized to do this!", "WrongPermission");
if (!mycheck.hasPermission("add_user");
return;
author: Dave Bryson author: Jürgen Hoffmann version: $Id: SecurityCheck.java 534527 2007-05-02 16:10:59Z tv $ |
Method Summary | |
public String | getFailScreen() Get the screen that should be displayed. | public String | getMessage() Get the message that should be displayed. | public boolean | hasPermission(Permission permission) Does the user have this permission?
Parameters: permission - A Permission. | public boolean | hasPermission(String permission) Does the user have this permission? If initialze is set to true
The permission will be created and granted to the first available Role of
the user, that the SecurityCheck is running against.
If the User has no Roles, the first Role via TurbineSecurity is granted the
permission.
Parameters: permission - A String. | public boolean | hasRole(Role role) Does the user have this role?
Parameters: role - A Role. | public boolean | hasRole(String role) Does the user have this role?
Parameters: role - A String. |
SecurityCheck | public SecurityCheck(RunData data, String message, String failedScreen)(Code) | | Constructor.
Parameters: data - A Turbine RunData object. Parameters: message - The message to display upon failure. Parameters: failedScreen - The screen to redirect to upon failure. |
SecurityCheck | public SecurityCheck(RunData data, String message, String failedScreen, boolean initialize)(Code) | | Constructor.
Parameters: data - A Turbine RunData object. Parameters: message - The message to display upon failure. Parameters: failedScreen - The screen to redirect to upon failure. Parameters: initialize - if a non-existing Permission or Role should be created. |
getFailScreen | public String getFailScreen()(Code) | | Get the screen that should be displayed. This is initialized in the
constructor.
A String. |
getMessage | public String getMessage()(Code) | | Get the message that should be displayed. This is initialized in the
constructor.
A String. |
hasPermission | public boolean hasPermission(Permission permission) throws Exception(Code) | | Does the user have this permission?
Parameters: permission - A Permission. True if the user has this permission. exception: Exception - ,a generic exception. |
hasPermission | public boolean hasPermission(String permission) throws Exception(Code) | | Does the user have this permission? If initialze is set to true
The permission will be created and granted to the first available Role of
the user, that the SecurityCheck is running against.
If the User has no Roles, the first Role via TurbineSecurity is granted the
permission.
Parameters: permission - A String. True if the user has this permission. exception: Exception - ,a generic exception. |
hasRole | public boolean hasRole(Role role) throws Exception(Code) | | Does the user have this role?
Parameters: role - A Role. True if the user has this role. exception: Exception - ,a generic exception. |
hasRole | public boolean hasRole(String role) throws Exception(Code) | | Does the user have this role?
Parameters: role - A String. True if the user has this role. exception: Exception - ,a generic exception. |
|
|