jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1538618 - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/spi/security/privilege/PrivilegeBits.java test/java/org/apache/jackrabbit/oak/spi/security/privilege/PrivilegeBitsTest.java
Date Mon, 04 Nov 2013 14:17:47 GMT
Author: angela
Date: Mon Nov  4 14:17:47 2013
New Revision: 1538618

URL: http://svn.apache.org/r1538618
Log:
OAK-64: privilege mgt

- remove unused code
- change signature of getInstance(PrivilegeBits) to allow for specifying multiple base privileges

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/privilege/PrivilegeBits.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/privilege/PrivilegeBitsTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/privilege/PrivilegeBits.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/privilege/PrivilegeBits.java?rev=1538618&r1=1538617&r2=1538618&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/privilege/PrivilegeBits.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/spi/security/privilege/PrivilegeBits.java
Mon Nov  4 14:17:47 2013
@@ -121,8 +121,12 @@ public final class PrivilegeBits impleme
      * @return a new instance of privilege bits.
      */
     @Nonnull
-    public static PrivilegeBits getInstance(@Nonnull PrivilegeBits base) {
-        return new PrivilegeBits(new ModifiableData(base.d));
+    public static PrivilegeBits getInstance(@Nonnull PrivilegeBits... base) {
+        PrivilegeBits bts = getInstance();
+        for (PrivilegeBits baseBits : base) {
+            bts.add(baseBits);
+        }
+        return bts;
     }
 
     /**
@@ -491,8 +495,6 @@ public final class PrivilegeBits impleme
 
         abstract boolean includes(Data other);
 
-        abstract boolean includes(long permissions);
-
         /**
          * Checks if all {@code otherBits} is already included in {@code bits}.
          * <p>
@@ -619,11 +621,6 @@ public final class PrivilegeBits impleme
             }
         }
 
-        @Override
-        boolean includes(long permissions) {
-            return (isSimple) ? (bits & permissions) == permissions : (bitsArr[0] &
permissions) == permissions;
-        }
-
         //---------------------------------------------------------< Object >---
         @Override
         public int hashCode() {
@@ -713,11 +710,6 @@ public final class PrivilegeBits impleme
             }
         }
 
-        @Override
-        boolean includes(long permissions) {
-            return (bits[0] & permissions) == permissions;
-        }
-
         /**
          * Add the other Data to this instance.
          *

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/privilege/PrivilegeBitsTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/privilege/PrivilegeBitsTest.java?rev=1538618&r1=1538617&r2=1538618&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/privilege/PrivilegeBitsTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/privilege/PrivilegeBitsTest.java
Mon Nov  4 14:17:47 2013
@@ -476,6 +476,21 @@ public class PrivilegeBitsTest extends A
     }
 
     @Test
+    public void testGetInstanceFromBase() {
+        PrivilegeBits pb = PrivilegeBits.getInstance(READ_NODES_PRIVILEGE_BITS);
+        pb.add(PrivilegeBits.BUILT_IN.get(PrivilegeConstants.JCR_READ_ACCESS_CONTROL));
+        pb.add(PrivilegeBits.BUILT_IN.get(PrivilegeConstants.JCR_NODE_TYPE_MANAGEMENT));
+
+        PrivilegeBits pb2 = PrivilegeBits.getInstance(READ_NODES_PRIVILEGE_BITS,
+                PrivilegeBits.BUILT_IN.get(PrivilegeConstants.JCR_READ_ACCESS_CONTROL),
+                PrivilegeBits.BUILT_IN.get(PrivilegeConstants.JCR_NODE_TYPE_MANAGEMENT));
+
+        assertNotSame(pb, pb2);
+        assertEquivalent(pb, pb2);
+        assertSame(pb.unmodifiable(), pb2.unmodifiable());
+    }
+
+    @Test
     public void testGetInstanceFromPropertyState() {
         for (long l : LONGS) {
             PropertyState property = createPropertyState(l);



Mime
View raw message