public class SecurityCheck extends Object
SecurityCheck mycheck = new SecurityCheck(data, "Unauthorized to do this!", "WrongPermission"); if (!mycheck.hasPermission("add_user"); return;
Constructor and Description |
---|
SecurityCheck(RunData data,
String message,
String failedScreen)
Constructor.
|
SecurityCheck(RunData data,
String message,
String failedScreen,
boolean initialize)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
String |
getFailScreen()
Get the screen that should be displayed.
|
String |
getMessage()
Get the message that should be displayed.
|
boolean |
hasPermission(org.apache.fulcrum.security.entity.Permission permission)
Does the user have this permission?
|
boolean |
hasPermission(String permission)
Does the user have this permission?
|
boolean |
hasRole(org.apache.fulcrum.security.entity.Role role)
Does the user have this role?
|
boolean |
hasRole(String role)
Does the user have this role?
|
public SecurityCheck(RunData data, String message, String failedScreen)
data
- A Turbine RunData object.message
- The message to display upon failure.failedScreen
- The screen to redirect to upon failure.public SecurityCheck(RunData data, String message, String failedScreen, boolean initialize)
data
- A Turbine RunData object.message
- The message to display upon failure.failedScreen
- The screen to redirect to upon failure.initialize
- if a non-existing Permission or Role should be created.public boolean hasRole(org.apache.fulcrum.security.entity.Role role) throws Exception
role
- A Role.Exception
- a generic exception.public boolean hasRole(String role) throws Exception
role
- A String.Exception
- a generic exception.public boolean hasPermission(org.apache.fulcrum.security.entity.Permission permission) throws Exception
permission
- A Permission.Exception
- a generic exception.public boolean hasPermission(String permission) throws Exception
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 SecurityService is granted the
permission.permission
- A String.Exception
- a generic exception.public String getMessage()
public String getFailScreen()
Copyright © 2000–2019 The Apache Software Foundation. All rights reserved.