jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1455449 - /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/Permissions.java
Date Tue, 12 Mar 2013 08:58:27 GMT
Author: angela
Date: Tue Mar 12 08:58:27 2013
New Revision: 1455449

URL: http://svn.apache.org/r1455449
Log:
OAK-527: permissions (wip)

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/Permissions.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/Permissions.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/Permissions.java?rev=1455449&r1=1455448&r2=1455449&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/Permissions.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/authorization/Permissions.java
Tue Mar 12 08:58:27 2013
@@ -103,8 +103,7 @@ public final class Permissions {
             | USER_MANAGEMENT
     );
 
-    private static final Map<Long, String> PERMISSION_NAMES = new LinkedHashMap<Long,
String>();
-
+    public static final Map<Long, String> PERMISSION_NAMES = new LinkedHashMap<Long,
String>();
     static {
         PERMISSION_NAMES.put(ALL, "ALL");
         PERMISSION_NAMES.put(READ, "READ");
@@ -161,6 +160,23 @@ public final class Permissions {
         return (permissions & permissionsToTest) == permissionsToTest;
     }
 
+     /**
+      * Returns those bits from {@code permissions} that are not present in
+      * the {@code otherPermissions}, i.e. subtracts the other permissions
+      * from permissions.<br>
+      * If the specified {@code otherPermissions} do not intersect with
+      * {@code permissions},  {@code permissions} are returned.<br>
+      * If {@code permissions} is included in {@code otherPermissions},
+      * {@link #NO_PERMISSION} is returned.
+      *
+      * @param permissions
+      * @param otherPermissions
+      * @return the differences of the 2 permissions or {@link #NO_PERMISSION}.
+      */
+    public static long diff(long permissions, long otherPermissions) {
+        return permissions & ~otherPermissions;
+    }
+
     public static long getPermissions(String jcrActions, TreeLocation location) {
         Set<String> actions = new HashSet<String>(Arrays.asList(jcrActions.split(",")));
         int permissions = 0;



Mime
View raw message