|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
The IAccessController interface defines a set of methods that can be used in a wide variety of applications to enforce access control. In most applications, access control must be performed in multiple different locations across the various applicaton layers. This class provides access control for URLs, business functions, data, services, and files.
The implementation of this interface will need to access some sort of user information repository to determine what roles or permissions are assigned to the accountName passed into the various methods. In addition, the implementation will also need information about the resources that are being accessed. Using the user information and the resource information, the implementation should return an access control decision.
Implementers are encouraged to build on existing access control mechanisms, such as methods like isUserInRole() or hasPrivilege(). While powerful, these methods can be confusing, as users may be in multiple roles or possess multiple overlapping privileges. These methods encourage the use of complex boolean tests throughout the code. The point of this interface is to centralize access control logic so that it is easy to use and easy to verify.
if ( ESAPI.accessController().isAuthorizedForFunction( BUSINESS_FUNCTION ) ) {
... access is allowed
} else {
... attack in progress
}
Note that in the user interface layer, access control checks can be used to control whether particular controls are
rendered or not. These checks are supposed to fail when an unauthorized user is logged in, and do not represent
attacks. Remember that regardless of how the user interface appears, an attacker can attempt to invoke any business
function or access any data in your application. Therefore, access control checks in the user interface should be
repeated in both the business logic and data layers.
<% if ( ESAPI.accessController().isAuthorizedForFunction( ADMIN_FUNCTION ) ) { %>
<a href="/doAdminFunction">ADMIN</a>
<% } else { %>
<a href="/doNormalFunction">NORMAL</a>
<% } %>
| Method Summary | |
void |
assertAuthorizedForData(java.lang.String key)
|
void |
assertAuthorizedForFile(java.lang.String filepath)
|
void |
assertAuthorizedForFunction(java.lang.String functionName)
|
void |
assertAuthorizedForService(java.lang.String serviceName)
|
void |
assertAuthorizedForURL(java.lang.String url)
|
boolean |
isAuthorizedForData(java.lang.String key)
Checks if an account is authorized to access the referenced data. |
boolean |
isAuthorizedForFile(java.lang.String filepath)
Checks if an account is authorized to access the referenced file. |
boolean |
isAuthorizedForFunction(java.lang.String functionName)
Checks if an account is authorized to access the referenced function. |
boolean |
isAuthorizedForService(java.lang.String serviceName)
Checks if an account is authorized to access the referenced service. |
boolean |
isAuthorizedForURL(java.lang.String url)
Checks if an account is authorized to access the referenced URL. |
| Method Detail |
public boolean isAuthorizedForURL(java.lang.String url)
ESAPI.accessController().isAuthorizedForURL(request.getRequestURI().toString());
public boolean isAuthorizedForFunction(java.lang.String functionName)
functionName - the function name
public boolean isAuthorizedForData(java.lang.String key)
key - the key
public boolean isAuthorizedForFile(java.lang.String filepath)
filepath - the filepath
public boolean isAuthorizedForService(java.lang.String serviceName)
serviceName - the service name
public void assertAuthorizedForURL(java.lang.String url)
throws AccessControlException
AccessControlException
public void assertAuthorizedForFunction(java.lang.String functionName)
throws AccessControlException
AccessControlException
public void assertAuthorizedForData(java.lang.String key)
throws AccessControlException
AccessControlException
public void assertAuthorizedForFile(java.lang.String filepath)
throws AccessControlException
AccessControlException
public void assertAuthorizedForService(java.lang.String serviceName)
throws AccessControlException
AccessControlException
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||