|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.owasp.esapi.AccessController
Reference implementation of the IAccessController interface. This reference implementation uses a simple model for specifying a set of access control rules. Many organizations will want to create their own implementation of the methods provided in the IAccessController interface.
This reference implementation uses a simple scheme for specifying the rules. The first step is to create a namespace for the resources being accessed. For files and URL's, this is easy as they already have a namespace. Be extremely careful about canonicalizing when relying on information from the user in an access ctnrol decision.
For functions, data, and services, you will have to come up with your own namespace for the resources being accessed. You might simply define a flat namespace with a list of category names. For example, you might specify 'FunctionA', 'FunctionB', and 'FunctionC'. Or you can create a richer namespace with a hierarchical structure, such as:
/functions
There is a single configuration file supporting each of the five methods in the IAccessController interface. These files are located in the ESAPI resources directory as specified when the JVM was started. The use of a default deny rule is STRONGLY recommended. The file format is as follows:
path | role,role | allow/deny | comment ------------------------------------------------------------------------------------ /banking/* | user,admin | allow | authenticated users can access /banking /admin | admin | allow | only admin role can access /admin / | any | deny | default deny ruleTo find the matching rules, this implementation follows the general approach used in Java EE when matching HTTP requests to servlets in web.xml. The four mapping rules are used in the following order:
IAccessController| Constructor Summary | |
AccessController()
|
|
| 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. |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public AccessController()
| Method Detail |
public boolean isAuthorizedForURL(java.lang.String url)
IAccessControllerESAPI.accessController().isAuthorizedForURL(request.getRequestURI().toString());
isAuthorizedForURL in interface IAccessControllerpublic boolean isAuthorizedForFunction(java.lang.String functionName)
IAccessController
isAuthorizedForFunction in interface IAccessControllerfunctionName - the function name
public boolean isAuthorizedForData(java.lang.String key)
IAccessController
isAuthorizedForData in interface IAccessControllerkey - the key
public boolean isAuthorizedForFile(java.lang.String filepath)
IAccessController
isAuthorizedForFile in interface IAccessControllerfilepath - the filepath
public boolean isAuthorizedForService(java.lang.String serviceName)
IAccessController
isAuthorizedForService in interface IAccessControllerserviceName - the service name
public void assertAuthorizedForURL(java.lang.String url)
throws AccessControlException
assertAuthorizedForURL in interface IAccessControllerAccessControlException
public void assertAuthorizedForFunction(java.lang.String functionName)
throws AccessControlException
assertAuthorizedForFunction in interface IAccessControllerAccessControlException
public void assertAuthorizedForData(java.lang.String key)
throws AccessControlException
assertAuthorizedForData in interface IAccessControllerAccessControlException
public void assertAuthorizedForFile(java.lang.String filepath)
throws AccessControlException
assertAuthorizedForFile in interface IAccessControllerAccessControlException
public void assertAuthorizedForService(java.lang.String serviceName)
throws AccessControlException
assertAuthorizedForService in interface IAccessControllerAccessControlException
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||