[Yanel-dev] [Security API/Library] Check whether access policy exists

Michael Wechner michael.wechner at wyona.com
Fri Oct 1 14:37:51 CEST 2010


Hi

There are various cases when one has to check if a policy actually 
exists. So far one called

PolicyManager.getPolicy(PATH, false)

and it returned something, then one knew it exists, and if it returned 
null, then one knew it doesn't exist.

I don't think that's very nice, because first of all it wasn't commented 
:-(, second it's up to the implementation
that it is correctly implemented and hence is prone to errors.

Hence I would suggest to introduce a PolicyManager.existsPolicy(PATH) 
method, e.g.

Index: src/core/java/org/wyona/security/core/api/PolicyManager.java
===================================================================
--- src/core/java/org/wyona/security/core/api/PolicyManager.java    
(revision 53566)
+++ src/core/java/org/wyona/security/core/api/PolicyManager.java    
(working copy)
@@ -39,11 +39,16 @@
      * Get policy of a specific node
      * @param path Path of content, e.g. /hello/world.html
      * @param aggregate Boolean which specifies if implementation shall 
return an aggregated policy, e.g. an aggregation of the policies for /, 
/hello/ and /hello/world.html
-     * @return Policy which is associated with content path
+     * @return Policy which is associated with content path and if no 
policy exists, then return null
      */
     public Policy getPolicy(String path, boolean aggregate) throws 
AuthorizationException;
 
     /**
+     * TBD/TODO (WARNING: Backwards compatibility)
+     */
+    //public boolean existsPolicy(String path) throws 
AuthorizationException;
+
+    /**
      * Set new or modified policy
      * @param path Path of content, e.g. /hello/world.html
      * @param policy New or modified policy

WDYT?

Thanks

Michael


More information about the Yanel-development mailing list