|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.owasp.esapi.reference.FileBasedAccessController
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:
AccessController| Constructor Summary | |
FileBasedAccessController()
|
|
| Method Summary | |
void |
assertAuthorizedForData(java.lang.String key)
Checks if an account is authorized to access the referenced data. |
void |
assertAuthorizedForFile(java.lang.String filepath)
Checks if an account is authorized to access the referenced file. |
void |
assertAuthorizedForFunction(java.lang.String functionName)
Checks if an account is authorized to access the referenced function. |
void |
assertAuthorizedForService(java.lang.String serviceName)
Checks if an account is authorized to access the referenced service. |
void |
assertAuthorizedForURL(java.lang.String url)
Checks if an account is authorized to access the referenced 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 FileBasedAccessController()
| Method Detail |
public boolean isAuthorizedForURL(java.lang.String url)
AccessControllerESAPI.accessController().isAuthorizedForURL(request.getRequestURI().toString());
isAuthorizedForURL in interface AccessControllerpublic boolean isAuthorizedForFunction(java.lang.String functionName)
AccessController
isAuthorizedForFunction in interface AccessControllerfunctionName - the function name
public boolean isAuthorizedForData(java.lang.String key)
AccessController
isAuthorizedForData in interface AccessControllerkey - the key
public boolean isAuthorizedForFile(java.lang.String filepath)
AccessController
isAuthorizedForFile in interface AccessControllerfilepath - the filepath
Encoder.canonicalize(String)public boolean isAuthorizedForService(java.lang.String serviceName)
AccessController
isAuthorizedForService in interface AccessControllerserviceName - the service name
public void assertAuthorizedForURL(java.lang.String url)
throws AccessControlException
AccessControllerESAPI.accessController().assertAuthorizedForURL(request.getRequestURI().toString());
assertAuthorizedForURL in interface AccessControllerurl - the url as returned by request.getRequestURI().toString()
AccessControlException - if access is not permitted
public void assertAuthorizedForFunction(java.lang.String functionName)
throws AccessControlException
AccessController
assertAuthorizedForFunction in interface AccessControllerfunctionName - the function name
AccessControlException - if access is not permitted
public void assertAuthorizedForData(java.lang.String key)
throws AccessControlException
AccessController
assertAuthorizedForData in interface AccessControllerkey - the key
AccessControlException - is access is not permitted
public void assertAuthorizedForFile(java.lang.String filepath)
throws AccessControlException
AccessController
assertAuthorizedForFile in interface AccessControllerfilepath - the filepath
AccessControlException - is access is not permittedEncoder.canonicalize(String)
public void assertAuthorizedForService(java.lang.String serviceName)
throws AccessControlException
AccessController
assertAuthorizedForService in interface AccessControllerserviceName - the service name
AccessControlException
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||