Search in sources :

Example 1 with OpenSecurityProvider

use of org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider in project jackrabbit-oak by apache.

the class UniquePropertyTest method testUniqueness.

@Test
public void testUniqueness() throws Exception {
    Root root = new Oak().with(new OpenSecurityProvider()).with(new PropertyIndexEditorProvider()).with(new InitialContent()).createRoot();
    NodeUtil node = new NodeUtil(root.getTree("/"));
    String uuid = UUID.randomUUID().toString();
    node.setString(JcrConstants.JCR_UUID, uuid);
    root.commit();
    NodeUtil child = new NodeUtil(root.getTree("/")).addChild("another", "rep:User");
    child.setString(JcrConstants.JCR_UUID, uuid);
    try {
        root.commit();
        fail("Duplicate jcr:uuid should be detected.");
    } catch (CommitFailedException e) {
    // expected
    }
}
Also used : InitialContent(org.apache.jackrabbit.oak.InitialContent) Root(org.apache.jackrabbit.oak.api.Root) Oak(org.apache.jackrabbit.oak.Oak) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) CommitFailedException(org.apache.jackrabbit.oak.api.CommitFailedException) NodeUtil(org.apache.jackrabbit.oak.util.NodeUtil) Test(org.junit.Test)

Example 2 with OpenSecurityProvider

use of org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider in project jackrabbit-oak by apache.

the class PrivilegeDefinitionWriterTest method testMissingPrivilegeRoot.

@Test
public void testMissingPrivilegeRoot() throws Exception {
    ContentRepository repo = new Oak().with(new OpenSecurityProvider()).createContentRepository();
    Root tmpRoot = repo.login(null, null).getLatestRoot();
    try {
        PrivilegeDefinitionWriter writer = new PrivilegeDefinitionWriter(tmpRoot);
        writer.writeDefinition(new ImmutablePrivilegeDefinition("newName", true, null));
        fail("missing privilege root");
    } catch (RepositoryException e) {
    // success
    } finally {
        tmpRoot.getContentSession().close();
    }
}
Also used : Root(org.apache.jackrabbit.oak.api.Root) ContentRepository(org.apache.jackrabbit.oak.api.ContentRepository) Oak(org.apache.jackrabbit.oak.Oak) ImmutablePrivilegeDefinition(org.apache.jackrabbit.oak.spi.security.privilege.ImmutablePrivilegeDefinition) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) RepositoryException(javax.jcr.RepositoryException) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 3 with OpenSecurityProvider

use of org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider in project jackrabbit-oak by apache.

the class RepositoryManagerTest method registerRequiredServices.

private void registerRequiredServices() {
    context.registerService(SecurityProvider.class, new OpenSecurityProvider());
    context.registerService(NodeStore.class, new MemoryNodeStore());
    context.registerService(IndexEditorProvider.class, new PropertyIndexEditorProvider(), ImmutableMap.<String, Object>of("type", "property"));
    context.registerService(IndexEditorProvider.class, new ReferenceEditorProvider(), ImmutableMap.<String, Object>of("type", "reference"));
}
Also used : ReferenceEditorProvider(org.apache.jackrabbit.oak.plugins.index.reference.ReferenceEditorProvider) MemoryNodeStore(org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) PropertyIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider)

Example 4 with OpenSecurityProvider

use of org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider in project jackrabbit-oak by apache.

the class DefaultConflictHandlerOursTest method setUp.

@Before
public void setUp() throws CommitFailedException {
    ContentSession session = new Oak().with(new OpenSecurityProvider()).with(DefaultConflictHandler.OURS).createContentSession();
    // Add test content
    Root root = session.getLatestRoot();
    Tree tree = root.getTree("/");
    tree.setProperty("a", 1);
    tree.setProperty("b", 2);
    tree.setProperty("c", 3);
    tree.addChild("x");
    tree.addChild("y");
    tree.addChild("z");
    root.commit();
    ourRoot = session.getLatestRoot();
    theirRoot = session.getLatestRoot();
}
Also used : Root(org.apache.jackrabbit.oak.api.Root) Oak(org.apache.jackrabbit.oak.Oak) ContentSession(org.apache.jackrabbit.oak.api.ContentSession) Tree(org.apache.jackrabbit.oak.api.Tree) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) Before(org.junit.Before)

Example 5 with OpenSecurityProvider

use of org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider in project jackrabbit-oak by apache.

the class OakTest method closeAsyncIndexers.

@Test
public void closeAsyncIndexers() throws Exception {
    final AtomicReference<AsyncIndexUpdate> async = new AtomicReference<AsyncIndexUpdate>();
    Whiteboard wb = new DefaultWhiteboard() {

        @Override
        public <T> Registration register(Class<T> type, T service, Map<?, ?> properties) {
            if (service instanceof AsyncIndexUpdate) {
                async.set((AsyncIndexUpdate) service);
            }
            return super.register(type, service, properties);
        }
    };
    Oak oak = new Oak().with(new OpenSecurityProvider()).with(wb).withAsyncIndexing("foo-async", 5);
    ContentRepository repo = oak.createContentRepository();
    ((Closeable) repo).close();
    assertNotNull(async.get());
    assertTrue(async.get().isClosed());
    assertNull(WhiteboardUtils.getService(wb, AsyncIndexUpdate.class));
}
Also used : DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) Closeable(java.io.Closeable) ContentRepository(org.apache.jackrabbit.oak.api.ContentRepository) AsyncIndexUpdate(org.apache.jackrabbit.oak.plugins.index.AsyncIndexUpdate) AtomicReference(java.util.concurrent.atomic.AtomicReference) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) Map(java.util.Map) Whiteboard(org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard) DefaultWhiteboard(org.apache.jackrabbit.oak.spi.whiteboard.DefaultWhiteboard) Test(org.junit.Test)

Aggregations

OpenSecurityProvider (org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider)51 Oak (org.apache.jackrabbit.oak.Oak)38 InitialContent (org.apache.jackrabbit.oak.InitialContent)25 Test (org.junit.Test)19 Root (org.apache.jackrabbit.oak.api.Root)16 Tree (org.apache.jackrabbit.oak.api.Tree)14 PropertyIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider)14 ContentRepository (org.apache.jackrabbit.oak.api.ContentRepository)12 MemoryNodeStore (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)11 Before (org.junit.Before)11 IOException (java.io.IOException)8 NodeTypeIndexProvider (org.apache.jackrabbit.oak.plugins.index.nodetype.NodeTypeIndexProvider)8 QueryIndexProvider (org.apache.jackrabbit.oak.spi.query.QueryIndexProvider)8 ContentSession (org.apache.jackrabbit.oak.api.ContentSession)7 Nonnull (javax.annotation.Nonnull)6 Closeable (java.io.Closeable)5 LuceneIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexEditorProvider)5 LuceneIndexProvider (org.apache.jackrabbit.oak.plugins.index.lucene.LuceneIndexProvider)5 Observer (org.apache.jackrabbit.oak.spi.commit.Observer)5 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)4