Search in sources :

Example 36 with OpenSecurityProvider

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

the class MutableRootTest method before.

@Before
public void before() {
    SecurityProvider sp = new OpenSecurityProvider() {

        @Nonnull
        @Override
        public <T> T getConfiguration(@Nonnull Class<T> configClass) {
            if (AuthorizationConfiguration.class == configClass) {
                return (T) new OpenAuthorizationConfiguration() {

                    @Nonnull
                    @Override
                    public PermissionProvider getPermissionProvider(@Nonnull Root root, @Nonnull String workspaceName, @Nonnull Set<Principal> principals) {
                        return permissionProvider;
                    }
                };
            } else {
                return super.getConfiguration(configClass);
            }
        }
    };
    ContentSessionImpl cs = Mockito.mock(ContentSessionImpl.class);
    when(cs.toString()).thenReturn("contentSession");
    when(cs.getAuthInfo()).thenReturn(AuthInfoImpl.EMPTY);
    when(cs.getWorkspaceName()).thenReturn("default");
    root = new MutableRoot(store, new EmptyHook(), "default", new Subject(), sp, null, null, cs);
}
Also used : Root(org.apache.jackrabbit.oak.api.Root) Nonnull(javax.annotation.Nonnull) PermissionProvider(org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) Subject(javax.security.auth.Subject) OpenAuthorizationConfiguration(org.apache.jackrabbit.oak.spi.security.authorization.OpenAuthorizationConfiguration) SecurityProvider(org.apache.jackrabbit.oak.spi.security.SecurityProvider) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) EmptyHook(org.apache.jackrabbit.oak.spi.commit.EmptyHook) Principal(java.security.Principal) Before(org.junit.Before)

Example 37 with OpenSecurityProvider

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

the class DefaultConflictHandlerTheirsTest method setUp.

@Before
public void setUp() throws CommitFailedException {
    ContentSession session = new Oak().with(new OpenSecurityProvider()).with(DefaultConflictHandler.THEIRS).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 38 with OpenSecurityProvider

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

the class PropertyIndexQueryTest method testInvalidNamespace.

@Ignore("OAK-1517")
@Test
public void testInvalidNamespace() throws Exception {
    new Oak().with(new InitialContent()).with(new OpenSecurityProvider()).with(new PropertyIndexEditorProvider()).with(new RepositoryInitializer() {

        @Override
        public void initialize(@Nonnull NodeBuilder builder) {
            createIndexDefinition(builder.child(INDEX_DEFINITIONS_NAME), "foo", true, false, ImmutableSet.of("illegal:namespaceProperty"), null);
        }
    }).createContentRepository();
    fail("creating an index definition with an illegal namespace should fail.");
}
Also used : InitialContent(org.apache.jackrabbit.oak.InitialContent) Nonnull(javax.annotation.Nonnull) Oak(org.apache.jackrabbit.oak.Oak) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) RepositoryInitializer(org.apache.jackrabbit.oak.spi.lifecycle.RepositoryInitializer) NodeBuilder(org.apache.jackrabbit.oak.spi.state.NodeBuilder) Ignore(org.junit.Ignore) Test(org.junit.Test) AbstractQueryTest(org.apache.jackrabbit.oak.query.AbstractQueryTest)

Example 39 with OpenSecurityProvider

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

the class PrivilegeDefinitionReaderTest method testMissingPermissionRoot.

@Test
public void testMissingPermissionRoot() throws Exception {
    ContentRepository repo = new Oak().with(new OpenSecurityProvider()).createContentRepository();
    Root tmpRoot = repo.login(null, null).getLatestRoot();
    try {
        PrivilegeDefinitionReader reader = new PrivilegeDefinitionReader(tmpRoot);
        assertNull(reader.readDefinition(JCR_READ));
    } 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) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 40 with OpenSecurityProvider

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

the class UserProviderTest method setUp.

@Before
public void setUp() throws Exception {
    root = new Oak().with(new OpenSecurityProvider()).with(new InitialContent()).with(new PropertyIndexEditorProvider()).createRoot();
    defaultConfig = ConfigurationParameters.EMPTY;
    defaultUserPath = defaultConfig.getConfigValue(UserConstants.PARAM_USER_PATH, UserConstants.DEFAULT_USER_PATH);
    defaultGroupPath = defaultConfig.getConfigValue(UserConstants.PARAM_GROUP_PATH, UserConstants.DEFAULT_GROUP_PATH);
    customOptions = new HashMap<String, Object>();
    customOptions.put(UserConstants.PARAM_GROUP_PATH, customGroupPath);
    customOptions.put(UserConstants.PARAM_USER_PATH, customUserPath);
}
Also used : InitialContent(org.apache.jackrabbit.oak.InitialContent) Oak(org.apache.jackrabbit.oak.Oak) OpenSecurityProvider(org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider) PropertyIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider) Before(org.junit.Before)

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