jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1433969 [2/2] - in /jackrabbit/oak/trunk/oak-core/src: main/java/org/apache/jackrabbit/oak/security/authorization/ main/java/org/apache/jackrabbit/oak/security/authorization/restriction/ main/java/org/apache/jackrabbit/oak/spi/security/aut...
Date Wed, 16 Jan 2013 14:59:02 GMT
Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/ACETest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/ACETest.java?rev=1433969&r1=1433968&r2=1433969&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/ACETest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/ACETest.java
Wed Jan 16 14:59:01 2013
@@ -32,9 +32,8 @@ import javax.jcr.security.Privilege;
 import org.apache.jackrabbit.api.security.JackrabbitAccessControlEntry;
 import org.apache.jackrabbit.api.security.authorization.PrivilegeManager;
 import org.apache.jackrabbit.commons.jackrabbit.authorization.AccessControlUtils;
-import org.apache.jackrabbit.oak.api.Root;
+import org.apache.jackrabbit.oak.AbstractSecurityTest;
 import org.apache.jackrabbit.oak.namepath.NamePathMapper;
-import org.apache.jackrabbit.oak.security.AbstractSecurityTest;
 import org.apache.jackrabbit.oak.security.authorization.AccessControlManagerImpl;
 import org.apache.jackrabbit.oak.security.privilege.PrivilegeConstants;
 import org.junit.Before;
@@ -57,6 +56,7 @@ public class ACETest extends AbstractSec
     private AccessControlManager acMgr;
     private PrivilegeManager privMgr;
 
+    @Override
     @Before
     public void before() throws Exception {
         super.before();
@@ -65,7 +65,6 @@ public class ACETest extends AbstractSec
                 return "TestPrincipal";
             }
         };
-        Root root = adminSession.getLatestRoot();
         // TODO
         //acMgr = securityProvider.getAccessControlConfiguration().getAccessControlManager(root,
NamePathMapper.DEFAULT);
         acMgr = new AccessControlManagerImpl(root, NamePathMapper.DEFAULT, getSecurityProvider());

Added: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/AbstractAccessControlListTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/AbstractAccessControlListTest.java?rev=1433969&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/AbstractAccessControlListTest.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/AbstractAccessControlListTest.java
Wed Jan 16 14:59:01 2013
@@ -0,0 +1,201 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.spi.security.authorization;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.jcr.RepositoryException;
+import javax.jcr.security.Privilege;
+
+import com.google.common.collect.Lists;
+import org.apache.jackrabbit.api.security.JackrabbitAccessControlEntry;
+import org.apache.jackrabbit.api.security.authorization.PrivilegeManager;
+import org.apache.jackrabbit.oak.AbstractSecurityTest;
+import org.apache.jackrabbit.oak.namepath.GlobalNameMapper;
+import org.apache.jackrabbit.oak.namepath.LocalNameMapper;
+import org.apache.jackrabbit.oak.namepath.NameMapper;
+import org.apache.jackrabbit.oak.namepath.NamePathMapper;
+import org.apache.jackrabbit.oak.namepath.NamePathMapperImpl;
+import org.apache.jackrabbit.oak.security.principal.PrincipalImpl;
+import org.apache.jackrabbit.oak.security.privilege.PrivilegeConstants;
+import org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionDefinition;
+import org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * AbstractAccessControlListTest... TODO
+ */
+public abstract class AbstractAccessControlListTest extends AbstractSecurityTest {
+
+    private final String testPath = "/testPath";
+    private PrivilegeManager privMgr;
+    private RestrictionProvider restrictionProvider;
+
+    @Override
+    @Before
+    public void before() throws Exception {
+        super.before();
+
+        privMgr = getSecurityProvider().getPrivilegeConfiguration().getPrivilegeManager(root,
namePathMapper);
+        restrictionProvider = getSecurityProvider().getAccessControlConfiguration().getRestrictionProvider(namePathMapper);
+    }
+
+    protected String getTestPath() {
+        return testPath;
+    }
+
+    protected PrivilegeManager getPrivilegeManager() {
+        return privMgr;
+    }
+
+    protected RestrictionProvider getRestrictionProvider() {
+        return restrictionProvider;
+    }
+
+    protected AbstractAccessControlList createACL(List<JackrabbitAccessControlEntry>
entries) {
+        return createACL(getTestPath(), entries);
+    }
+
+    protected AbstractAccessControlList createACL(String jcrPath, List<JackrabbitAccessControlEntry>
entries) {
+        return createACL(jcrPath, entries, namePathMapper);
+    }
+
+    protected abstract AbstractAccessControlList createACL(String jcrPath,
+                                                           List<JackrabbitAccessControlEntry>
entries,
+                                                           NamePathMapper namePathMapper);
+
+    protected List<JackrabbitAccessControlEntry> createTestEntries(int size) throws
RepositoryException {
+        if (size == 0) {
+            return Collections.emptyList();
+        } else {
+            List<JackrabbitAccessControlEntry> entries = new ArrayList<JackrabbitAccessControlEntry>(size);
+            for (int i = 0; i < size; i++) {
+                entries.add(new ACE(
+                        new PrincipalImpl("testPrincipal"+i),
+                        new Privilege[] {getPrivilegeManager().getPrivilege(PrivilegeConstants.JCR_READ)},
+                        true, null));
+            }
+            return entries;
+        }
+    }
+
+    @Test
+    public void testGetPath() {
+        NameMapper nameMapper = new GlobalNameMapper() {
+            @Override
+            protected Map<String, String> getNamespaceMap() {
+                return Collections.singletonMap("jr", "http://jackrabbit.apache.org");
+            }
+        };
+        NamePathMapper npMapper = new NamePathMapperImpl(nameMapper);
+
+        // map of jcr-path to standard jcr-path
+        Map<String, String> paths = new HashMap<String, String>();
+        paths.put(null, null);
+        paths.put(getTestPath(), getTestPath());
+        paths.put("/", "/");
+        paths.put("/jr:testPath", "/jr:testPath");
+        paths.put("/{http://jackrabbit.apache.org}testPath", "/jr:testPath");
+
+        for (String path : paths.keySet()) {
+            AbstractAccessControlList acl = createACL(path, Collections.<JackrabbitAccessControlEntry>emptyList(),
npMapper);
+            assertEquals(paths.get(path), acl.getPath());
+        }
+    }
+
+    @Test
+    public void testGetOakPath() {
+        NameMapper nameMapper = new LocalNameMapper(Collections.singletonMap("my", "http://jackrabbit.apache.org"))
{
+            @Override
+            protected Map<String, String> getNamespaceMap() {
+                return Collections.singletonMap("jr", "http://jackrabbit.apache.org");
+            }
+        };
+        NamePathMapper npMapper = new NamePathMapperImpl(nameMapper);
+
+        // map of jcr-path to oak path
+        Map<String, String> paths = new HashMap<String, String>();
+        paths.put(null, null);
+        paths.put(getTestPath(), getTestPath());
+        paths.put("/", "/");
+        paths.put("/my:testPath", "/jr:testPath");
+        paths.put("/{http://jackrabbit.apache.org}testPath", "/jr:testPath");
+
+        // test if oak-path is properly set.
+        for (String path : paths.keySet()) {
+            AbstractAccessControlList acl = createACL(path, Collections.<JackrabbitAccessControlEntry>emptyList(),
npMapper);
+            assertEquals(paths.get(path), acl.getOakPath());
+        }
+    }
+
+    @Test
+    public void testGetEntries() {
+        AbstractAccessControlList acl = createACL(Collections.<JackrabbitAccessControlEntry>emptyList());
+
+
+    }
+
+    @Test
+    public void testGetAccessControlEntries() {
+
+    }
+
+    @Test
+    public void testSize() throws RepositoryException {
+        AbstractAccessControlList acl = createACL(createTestEntries(0));
+        assertEquals(0, acl.size());
+
+        acl = createACL(createTestEntries(3));
+        assertEquals(3, acl.size());
+    }
+
+    @Test
+    public void testIsEmpty() throws RepositoryException {
+        AbstractAccessControlList acl = createACL(createTestEntries(0));
+        assertTrue(acl.isEmpty());
+
+        acl = createACL(createTestEntries(3));
+        assertFalse(acl.isEmpty());
+    }
+
+    @Test
+    public void testGetRestrictionNames() throws RepositoryException {
+        AbstractAccessControlList acl = createACL(createTestEntries(0));
+        List<String> names = Lists.newArrayList(acl.getRestrictionNames());
+        for (RestrictionDefinition def : getRestrictionProvider().getSupportedRestrictions(getTestPath()))
{
+            assertTrue(names.remove(def.getJcrName()));
+        }
+        assertTrue(names.isEmpty());
+    }
+
+    @Test
+    public void testGetRestrictionType() throws RepositoryException {
+        AbstractAccessControlList acl = createACL(createTestEntries(0));
+        for (RestrictionDefinition def : getRestrictionProvider().getSupportedRestrictions(getTestPath()))
{
+            int reqType = acl.getRestrictionType(def.getJcrName());
+            assertEquals(def.getRequiredType(), reqType);
+        }
+    }
+}
\ No newline at end of file

Added: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/AllPermissionsTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/AllPermissionsTest.java?rev=1433969&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/AllPermissionsTest.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/AllPermissionsTest.java
Wed Jan 16 14:59:01 2013
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.spi.security.authorization;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.jackrabbit.oak.AbstractSecurityTest;
+import org.apache.jackrabbit.oak.api.PropertyState;
+import org.apache.jackrabbit.oak.api.Tree;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Test {@code AllPermissions}.
+ */
+public class AllPermissionsTest extends AbstractSecurityTest {
+
+    private final CompiledPermissions all = AllPermissions.getInstance();
+
+    private List<String> paths = new ArrayList<String>();
+
+    @Override
+    @Before
+    public void before() throws Exception {
+        super.before();
+
+        paths.add("/");
+        // TODO
+    }
+
+    @Test
+    public void testCanRead() {
+        for (String path : paths) {
+            Tree tree = root.getTree(path);
+            assertNotNull(tree);
+
+            assertTrue(all.canRead(tree));
+            for (PropertyState prop : tree.getProperties()) {
+                assertTrue(all.canRead(tree, prop));
+            }
+            for (Tree child : tree.getChildren()) {
+                assertTrue(all.canRead(child));
+            }
+        }
+    }
+
+    @Test
+    public void testIsGranted() {
+        assertTrue(all.isGranted(Permissions.ALL));
+
+        for (String path : paths) {
+            Tree tree = root.getTree(path);
+            assertNotNull(tree);
+
+            assertTrue(all.isGranted(tree, Permissions.ALL));
+            for (PropertyState prop : tree.getProperties()) {
+                assertTrue(all.isGranted(tree, prop, Permissions.ALL));
+            }
+            for (Tree child : tree.getChildren()) {
+                assertTrue(all.isGranted(child, Permissions.ALL));
+            }
+        }
+    }
+
+    @Test
+    public void testSame() {
+        assertSame(all, AllPermissions.getInstance());
+    }
+}
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/ImmutableACLTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/ImmutableACLTest.java?rev=1433969&r1=1433968&r2=1433969&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/ImmutableACLTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/ImmutableACLTest.java
Wed Jan 16 14:59:01 2013
@@ -20,8 +20,6 @@ import java.security.Principal;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
-import java.util.Map;
-import javax.annotation.Nonnull;
 import javax.jcr.Value;
 import javax.jcr.security.AccessControlEntry;
 import javax.jcr.security.AccessControlException;
@@ -29,10 +27,7 @@ import javax.jcr.security.Privilege;
 
 import org.apache.jackrabbit.api.security.JackrabbitAccessControlEntry;
 import org.apache.jackrabbit.api.security.JackrabbitAccessControlList;
-import org.apache.jackrabbit.api.security.authorization.PrivilegeManager;
-import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.namepath.NamePathMapper;
-import org.apache.jackrabbit.oak.security.AbstractSecurityTest;
 import org.apache.jackrabbit.oak.security.principal.PrincipalImpl;
 import org.apache.jackrabbit.oak.security.privilege.PrivilegeConstants;
 import org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider;
@@ -47,38 +42,27 @@ import static org.junit.Assert.fail;
 /**
  * ImmutableACLTest... TODO
  */
-public class ImmutableACLTest extends AbstractSecurityTest {
+public class ImmutableACLTest extends AbstractAccessControlListTest {
 
-    private PrivilegeManager privMgr;
-    private RestrictionProvider restrictionProvider;
-
-    private String testPath = "/testPath";
     private Principal testPrincipal;
     private Privilege[] testPrivileges;
 
+    @Override
     @Before
     public void before() throws Exception {
         super.before();
 
-        Root root = adminSession.getLatestRoot();
-        NamePathMapper npMapper = NamePathMapper.DEFAULT;
-
-        privMgr = getSecurityProvider().getPrivilegeConfiguration().getPrivilegeManager(root,
npMapper);
-        restrictionProvider = getSecurityProvider().getAccessControlConfiguration().getRestrictionProvider(npMapper);
-
         testPrincipal = new PrincipalImpl("testPrincipal");
         testPrivileges = new Privilege[] {
-                privMgr.getPrivilege(PrivilegeConstants.JCR_READ),
-                privMgr.getPrivilege(PrivilegeConstants.JCR_ADD_CHILD_NODES)
+                getPrivilegeManager().getPrivilege(PrivilegeConstants.JCR_READ),
+                getPrivilegeManager().getPrivilege(PrivilegeConstants.JCR_ADD_CHILD_NODES)
         };
     }
 
-    private ImmutableACL createACL(List<JackrabbitAccessControlEntry> entries) {
-        return createACL(entries, testPath);
-    }
-
-    private ImmutableACL createACL(List<JackrabbitAccessControlEntry> entries, String
path) {
-        return new ImmutableACL(path, entries, restrictionProvider);
+    @Override
+    protected ImmutableACL createACL(String jcrPath, List<JackrabbitAccessControlEntry>
entries, NamePathMapper namePathMapper) {
+        String oakPath = (jcrPath == null) ? null : namePathMapper.getOakPathKeepIndex(jcrPath);
+        return new ImmutableACL(oakPath, entries, getRestrictionProvider(), namePathMapper);
     }
 
     private void assertImmutable(JackrabbitAccessControlList acl) throws Exception {
@@ -136,22 +120,22 @@ public class ImmutableACLTest extends Ab
     public void testImmutable() throws Exception {
         List<JackrabbitAccessControlEntry> entries = new ArrayList<JackrabbitAccessControlEntry>();
         entries.add(new ACE(testPrincipal, testPrivileges, true, null));
-        entries.add(new ACE(testPrincipal, new Privilege[] {privMgr.getPrivilege(PrivilegeConstants.JCR_LIFECYCLE_MANAGEMENT)},
false, null));
+        entries.add(new ACE(testPrincipal, new Privilege[] {getPrivilegeManager().getPrivilege(PrivilegeConstants.JCR_LIFECYCLE_MANAGEMENT)},
false, null));
 
-        ImmutableACL acl = createACL(entries);
+        JackrabbitAccessControlList acl = createACL(entries);
         assertFalse(acl.isEmpty());
         assertEquals(2, acl.size());
-        assertEquals(testPath, acl.getPath());
+        assertEquals(getTestPath(), acl.getPath());
         assertImmutable(acl);
     }
 
     @Test
     public void testEmptyIsImmutable() throws Exception {
-        ImmutableACL acl = createACL(Collections.<JackrabbitAccessControlEntry>emptyList());
+        JackrabbitAccessControlList acl = createACL(Collections.<JackrabbitAccessControlEntry>emptyList());
 
         assertTrue(acl.isEmpty());
         assertEquals(0, acl.size());
-        assertEquals(testPath, acl.getPath());
+        assertEquals(getTestPath(), acl.getPath());
         assertImmutable(acl);
     }
 
@@ -165,68 +149,15 @@ public class ImmutableACLTest extends Ab
         assertEquals(empty, createACL(Collections.<JackrabbitAccessControlEntry>emptyList()));
         assertEquals(acl, createACL(entries));
 
+        String testPath = getTestPath();
+        RestrictionProvider restrictionProvider = getRestrictionProvider();
+
         assertFalse(empty.equals(acl));
         assertFalse(acl.equals(empty));
-        assertFalse(acl.equals(createACL(entries, "/anotherPath")));
-        assertFalse(acl.equals(new TestACL("/anotherPath", entries)));
-        assertFalse(acl.equals(new TestACL("/anotherPath", Collections.<JackrabbitAccessControlEntry>emptyList())));
-        assertFalse(acl.equals(new TestACL(testPath, entries)));
-        assertFalse(empty.equals(new TestACL(testPath, Collections.<JackrabbitAccessControlEntry>emptyList())));
-    }
-
-    /**
-     * Another JackrabbitAccessControlList
-     */
-    private final class TestACL extends AbstractAccessControlList {
-
-        private List<JackrabbitAccessControlEntry> entries = new ArrayList<JackrabbitAccessControlEntry>();
-
-        public TestACL(String jcrPath, List<JackrabbitAccessControlEntry> entries)
{
-            super(jcrPath);
-            this.entries.addAll(entries);
-        }
-
-        @Override
-        public boolean isEmpty() {
-            return entries.isEmpty();
-        }
-
-        @Override
-        public int size() {
-            return entries.size();
-        }
-
-        @Override
-        public boolean addEntry(Principal principal, Privilege[] privileges,
-                                boolean isAllow, Map<String, Value> restrictions) {
-            throw new UnsupportedOperationException();
-        }
-
-        @Override
-        public void orderBefore(AccessControlEntry srcEntry, AccessControlEntry destEntry)
{
-            throw new UnsupportedOperationException();
-        }
-
-        @Override
-        public AccessControlEntry[] getAccessControlEntries() {
-            return entries.toArray(new AccessControlEntry[entries.size()]);
-        }
-
-        @Override
-        public void removeAccessControlEntry(AccessControlEntry ace) {
-            throw new UnsupportedOperationException();
-        }
-
-        @Nonnull
-        @Override
-        public List<JackrabbitAccessControlEntry> getEntries() {
-            return entries;
-        }
-
-        @Nonnull
-        @Override
-        public RestrictionProvider getRestrictionProvider() {
-            return restrictionProvider;
-        }
+        assertFalse(acl.equals(createACL("/anotherPath", entries)));
+        assertFalse(acl.equals(new TestACL("/anotherPath", entries, restrictionProvider)));
+        assertFalse(acl.equals(new TestACL("/anotherPath", Collections.<JackrabbitAccessControlEntry>emptyList(),
restrictionProvider)));
+        assertFalse(acl.equals(new TestACL(testPath, entries, restrictionProvider)));
+        assertFalse(empty.equals(new TestACL(testPath, Collections.<JackrabbitAccessControlEntry>emptyList(),
restrictionProvider)));
     }
 }
\ No newline at end of file

Added: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/TestACL.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/TestACL.java?rev=1433969&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/TestACL.java
(added)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/TestACL.java
Wed Jan 16 14:59:01 2013
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.oak.spi.security.authorization;
+
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import javax.annotation.Nonnull;
+import javax.jcr.Value;
+import javax.jcr.security.AccessControlEntry;
+import javax.jcr.security.Privilege;
+
+import org.apache.jackrabbit.api.security.JackrabbitAccessControlEntry;
+import org.apache.jackrabbit.oak.namepath.NamePathMapper;
+import org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider;
+
+/**
+ * TestACL... TODO
+ */
+public final class TestACL extends AbstractAccessControlList {
+
+    private final List<JackrabbitAccessControlEntry> entries = new ArrayList<JackrabbitAccessControlEntry>();
+    private final RestrictionProvider restrictionProvider;
+
+    public TestACL(String jcrPath, List<JackrabbitAccessControlEntry> entries,
+                   RestrictionProvider restrictionProvider) {
+        super(jcrPath, NamePathMapper.DEFAULT);
+        this.entries.addAll(entries);
+        this.restrictionProvider = restrictionProvider;
+    }
+
+    @Override
+    public boolean isEmpty() {
+        return entries.isEmpty();
+    }
+
+    @Override
+    public int size() {
+        return entries.size();
+    }
+
+    @Override
+    public boolean addEntry(Principal principal, Privilege[] privileges,
+                            boolean isAllow, Map<String, Value> restrictions) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void orderBefore(AccessControlEntry srcEntry, AccessControlEntry destEntry) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public AccessControlEntry[] getAccessControlEntries() {
+        return entries.toArray(new AccessControlEntry[entries.size()]);
+    }
+
+    @Override
+    public void removeAccessControlEntry(AccessControlEntry ace) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Nonnull
+    @Override
+    public List<JackrabbitAccessControlEntry> getEntries() {
+        return entries;
+    }
+
+    @Nonnull
+    @Override
+    public RestrictionProvider getRestrictionProvider() {
+        return restrictionProvider;
+    }
+}
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/principal/EveryonePrincipalTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/principal/EveryonePrincipalTest.java?rev=1433969&r1=1433968&r2=1433969&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/principal/EveryonePrincipalTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/principal/EveryonePrincipalTest.java
Wed Jan 16 14:59:01 2013
@@ -20,7 +20,6 @@ import java.security.Principal;
 import java.util.Enumeration;
 
 import org.apache.jackrabbit.api.security.principal.JackrabbitPrincipal;
-import org.apache.jackrabbit.oak.security.AbstractSecurityTest;
 import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
@@ -28,7 +27,7 @@ import static org.junit.Assert.assertFal
 import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertTrue;
 
-public class EveryonePrincipalTest extends AbstractSecurityTest {
+public class EveryonePrincipalTest  {
 
     private final Principal everyone = EveryonePrincipal.getInstance();
 

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/user/action/PasswordValidationActionTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/user/action/PasswordValidationActionTest.java?rev=1433969&r1=1433968&r2=1433969&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/user/action/PasswordValidationActionTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/user/action/PasswordValidationActionTest.java
Wed Jan 16 14:59:01 2013
@@ -24,11 +24,10 @@ import javax.jcr.RepositoryException;
 import javax.jcr.nodetype.ConstraintViolationException;
 
 import org.apache.jackrabbit.api.security.user.User;
-import org.apache.jackrabbit.api.security.user.UserManager;
+import org.apache.jackrabbit.oak.AbstractSecurityTest;
 import org.apache.jackrabbit.oak.api.Root;
 import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.namepath.NamePathMapper;
-import org.apache.jackrabbit.oak.security.AbstractSecurityTest;
 import org.apache.jackrabbit.oak.security.SecurityProviderImpl;
 import org.apache.jackrabbit.oak.security.user.UserConfigurationImpl;
 import org.apache.jackrabbit.oak.spi.security.ConfigurationParameters;
@@ -50,20 +49,14 @@ public class PasswordValidationActionTes
     private PasswordValidationAction pwAction = new PasswordValidationAction();
     private TestAction testAction = new TestAction();
 
-    private Root root;
-    private UserManager userManager;
     private User user;
-
     private User testUser;
 
     @Before
     public void before() throws Exception {
         super.before();
 
-        root = adminSession.getLatestRoot();
-
-        userManager = getSecurityProvider().getUserConfiguration().getUserManager(root, NamePathMapper.DEFAULT);
-        user = (User) userManager.getAuthorizable(adminSession.getAuthInfo().getUserID());
+        user = (User) getUserManager().getAuthorizable(adminSession.getAuthInfo().getUserID());
 
         testAction.reset();
         pwAction.setConstraint("^.*(?=.{8,})(?=.*[a-z])(?=.*[A-Z]).*");
@@ -90,7 +83,7 @@ public class PasswordValidationActionTes
 
     @Test
     public void testActionIsCalled() throws Exception {
-        testUser = userManager.createUser("testUser", "testUser12345");
+        testUser = getUserManager().createUser("testUser", "testUser12345");
         root.commit();
         assertEquals(1, testAction.onCreateCalled);
 
@@ -134,7 +127,7 @@ public class PasswordValidationActionTes
     @Test
     public void testPasswordValidationActionOnCreate() throws Exception {
         String hashed = PasswordUtility.buildPasswordHash("DWkej32H");
-        testUser = userManager.createUser("testuser", hashed);
+        testUser = getUserManager().createUser("testuser", hashed);
         root.commit();
 
         String pwValue = root.getTree(testUser.getPath()).getProperty(UserConstants.REP_PASSWORD).getValue(Type.STRING);
@@ -144,7 +137,7 @@ public class PasswordValidationActionTes
 
     @Test
     public void testPasswordValidationActionOnChange() throws Exception {
-        testUser = userManager.createUser("testuser", "testPw123456");
+        testUser = getUserManager().createUser("testuser", "testPw123456");
         root.commit();
         try {
             pwAction.setConstraint("abc");



Mime
View raw message