Search in sources :

Example 16 with TypeEditorProvider

use of org.apache.jackrabbit.oak.plugins.nodetype.TypeEditorProvider in project jackrabbit-oak by apache.

the class UserInitializerTest method testAdminConfiguration.

/**
 * @since OAK 1.0 The configuration defines if the password of the
 * admin user is being set.
 */
@Test
public void testAdminConfiguration() throws Exception {
    Map<String, Object> userParams = new HashMap();
    userParams.put(UserConstants.PARAM_ADMIN_ID, "admin");
    userParams.put(UserConstants.PARAM_OMIT_ADMIN_PW, true);
    ConfigurationParameters params = ConfigurationParameters.of(UserConfiguration.NAME, ConfigurationParameters.of(userParams));
    SecurityProvider sp = SecurityProviderBuilder.newBuilder().with(params).build();
    final ContentRepository repo = new Oak().with(new InitialContent()).with(new PropertyIndexEditorProvider()).with(new PropertyIndexProvider()).with(new TypeEditorProvider()).with(sp).createContentRepository();
    ContentSession cs = Subject.doAs(SystemSubject.INSTANCE, new PrivilegedExceptionAction<ContentSession>() {

        @Override
        public ContentSession run() throws Exception {
            return repo.login(null, null);
        }
    });
    try {
        Root root = cs.getLatestRoot();
        UserConfiguration uc = sp.getConfiguration(UserConfiguration.class);
        UserManager umgr = uc.getUserManager(root, NamePathMapper.DEFAULT);
        Authorizable adminUser = umgr.getAuthorizable("admin");
        assertNotNull(adminUser);
        Tree adminTree = root.getTree(adminUser.getPath());
        assertTrue(adminTree.exists());
        assertNull(adminTree.getProperty(UserConstants.REP_PASSWORD));
    } finally {
        cs.close();
    }
    // login as admin should fail
    ContentSession adminSession = null;
    try {
        adminSession = repo.login(new SimpleCredentials("admin", new char[0]), null);
        fail();
    } catch (LoginException e) {
    // success
    } finally {
        if (adminSession != null) {
            adminSession.close();
        }
    }
}
Also used : Root(org.apache.jackrabbit.oak.api.Root) HashMap(java.util.HashMap) PropertyIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider) ConfigurationParameters(org.apache.jackrabbit.oak.spi.security.ConfigurationParameters) LoginException(javax.security.auth.login.LoginException) InitialContent(org.apache.jackrabbit.oak.InitialContent) PropertyIndexProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexProvider) SimpleCredentials(javax.jcr.SimpleCredentials) TypeEditorProvider(org.apache.jackrabbit.oak.plugins.nodetype.TypeEditorProvider) UserManager(org.apache.jackrabbit.api.security.user.UserManager) SecurityProvider(org.apache.jackrabbit.oak.spi.security.SecurityProvider) ContentRepository(org.apache.jackrabbit.oak.api.ContentRepository) Oak(org.apache.jackrabbit.oak.Oak) ContentSession(org.apache.jackrabbit.oak.api.ContentSession) Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) Tree(org.apache.jackrabbit.oak.api.Tree) LoginException(javax.security.auth.login.LoginException) UserConfiguration(org.apache.jackrabbit.oak.spi.security.user.UserConfiguration) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 17 with TypeEditorProvider

use of org.apache.jackrabbit.oak.plugins.nodetype.TypeEditorProvider in project jackrabbit-oak by apache.

the class SynchronousPropertyIndexTest method registerTestNodTypes.

private void registerTestNodTypes() throws IOException, CommitFailedException {
    optionalEditorProvider.delegate = new TypeEditorProvider();
    NodeTypeRegistry.register(root, IOUtils.toInputStream(testNodeTypes, "utf-8"), "test nodeType");
    // Flush the changes to nodetypes
    root.commit();
}
Also used : TypeEditorProvider(org.apache.jackrabbit.oak.plugins.nodetype.TypeEditorProvider)

Aggregations

TypeEditorProvider (org.apache.jackrabbit.oak.plugins.nodetype.TypeEditorProvider)17 Oak (org.apache.jackrabbit.oak.Oak)8 InitialContent (org.apache.jackrabbit.oak.InitialContent)7 NamespaceEditorProvider (org.apache.jackrabbit.oak.plugins.name.NamespaceEditorProvider)7 Root (org.apache.jackrabbit.oak.api.Root)6 EditorHook (org.apache.jackrabbit.oak.spi.commit.EditorHook)6 Test (org.junit.Test)6 Tree (org.apache.jackrabbit.oak.api.Tree)5 PropertyIndexEditorProvider (org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider)5 CompositeEditorProvider (org.apache.jackrabbit.oak.spi.commit.CompositeEditorProvider)5 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)5 PropertyIndexProvider (org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexProvider)4 MemoryNodeStore (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeStore)4 AbstractQueryTest (org.apache.jackrabbit.oak.query.AbstractQueryTest)4 OpenSecurityProvider (org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider)4 ApplyDiff (org.apache.jackrabbit.oak.spi.state.ApplyDiff)4 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)4 NodeStore (org.apache.jackrabbit.oak.spi.state.NodeStore)4 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 IOException (java.io.IOException)3