Search in sources :

Example 6 with ValueFactoryImpl

use of org.apache.jackrabbit.oak.plugins.value.jcr.ValueFactoryImpl in project jackrabbit-oak by apache.

the class ExternalLoginModule method validateUser.

/**
     * Initiates synchronization of a possible remove user
     * @param id the user id
     */
private void validateUser(@Nonnull String id) throws SyncException {
    SyncContext context = null;
    try {
        Root root = getRoot();
        if (root == null) {
            throw new SyncException("Cannot synchronize user. root == null");
        }
        UserManager userManager = getUserManager();
        if (userManager == null) {
            throw new SyncException("Cannot synchronize user. userManager == null");
        }
        DebugTimer timer = new DebugTimer();
        context = syncHandler.createContext(idp, userManager, new ValueFactoryImpl(root, NamePathMapper.DEFAULT));
        context.sync(id);
        timer.mark("sync");
        root.commit();
        timer.mark("commit");
        debug("validateUser({}) {}", id, timer.getString());
    } catch (CommitFailedException e) {
        throw new SyncException("User synchronization failed during commit.", e);
    } finally {
        if (context != null) {
            context.close();
        }
    }
}
Also used : DebugTimer(org.apache.jackrabbit.oak.commons.DebugTimer) Root(org.apache.jackrabbit.oak.api.Root) UserManager(org.apache.jackrabbit.api.security.user.UserManager) ValueFactoryImpl(org.apache.jackrabbit.oak.plugins.value.jcr.ValueFactoryImpl) SyncException(org.apache.jackrabbit.oak.spi.security.authentication.external.SyncException) SyncContext(org.apache.jackrabbit.oak.spi.security.authentication.external.SyncContext) CommitFailedException(org.apache.jackrabbit.oak.api.CommitFailedException)

Example 7 with ValueFactoryImpl

use of org.apache.jackrabbit.oak.plugins.value.jcr.ValueFactoryImpl in project jackrabbit-oak by apache.

the class AccessControlManagerImplTest method before.

@Override
@Before
public void before() throws Exception {
    super.before();
    registerNamespace(TEST_PREFIX, TEST_URI);
    NameMapper nameMapper = new GlobalNameMapper(root);
    npMapper = new NamePathMapperImpl(nameMapper);
    acMgr = new AccessControlManagerImpl(root, npMapper, getSecurityProvider());
    NodeUtil rootNode = new NodeUtil(root.getTree("/"), getNamePathMapper());
    rootNode.addChild(testName, JcrConstants.NT_UNSTRUCTURED);
    root.commit();
    valueFactory = new ValueFactoryImpl(root, npMapper);
    testPrivileges = privilegesFromNames(PrivilegeConstants.JCR_ADD_CHILD_NODES, PrivilegeConstants.JCR_READ);
    testPrincipal = getTestUser().getPrincipal();
}
Also used : GlobalNameMapper(org.apache.jackrabbit.oak.namepath.GlobalNameMapper) NameMapper(org.apache.jackrabbit.oak.namepath.NameMapper) GlobalNameMapper(org.apache.jackrabbit.oak.namepath.GlobalNameMapper) LocalNameMapper(org.apache.jackrabbit.oak.namepath.LocalNameMapper) ValueFactoryImpl(org.apache.jackrabbit.oak.plugins.value.jcr.ValueFactoryImpl) NamePathMapperImpl(org.apache.jackrabbit.oak.namepath.NamePathMapperImpl) NodeUtil(org.apache.jackrabbit.oak.util.NodeUtil) Before(org.junit.Before)

Example 8 with ValueFactoryImpl

use of org.apache.jackrabbit.oak.plugins.value.jcr.ValueFactoryImpl in project jackrabbit-oak by apache.

the class AbstractRestrictionProviderTest method before.

@Before
public void before() throws Exception {
    valueFactory = new ValueFactoryImpl(Mockito.mock(Root.class), namePathMapper);
    globValue = valueFactory.createValue("*");
    nameValue = valueFactory.createValue("nt:file", PropertyType.NAME);
    nameValues = new Value[] { valueFactory.createValue("nt:folder", PropertyType.NAME), valueFactory.createValue("nt:file", PropertyType.NAME) };
    RestrictionDefinition glob = new RestrictionDefinitionImpl(REP_GLOB, Type.STRING, false);
    RestrictionDefinition nts = new RestrictionDefinitionImpl(REP_NT_NAMES, Type.NAMES, false);
    RestrictionDefinition mand = new RestrictionDefinitionImpl("mandatory", Type.BOOLEAN, true);
    supported = ImmutableMap.of(glob.getName(), glob, nts.getName(), nts, mand.getName(), mand);
    restrictionProvider = new AbstractRestrictionProvider(supported) {

        @Nonnull
        @Override
        public RestrictionPattern getPattern(@Nullable String oakPath, @Nonnull Tree tree) {
            throw new UnsupportedOperationException();
        }

        @Nonnull
        @Override
        public RestrictionPattern getPattern(@Nullable String oakPath, @Nonnull Set<Restriction> restrictions) {
            throw new UnsupportedOperationException();
        }
    };
}
Also used : Nonnull(javax.annotation.Nonnull) ValueFactoryImpl(org.apache.jackrabbit.oak.plugins.value.jcr.ValueFactoryImpl) Tree(org.apache.jackrabbit.oak.api.Tree) Before(org.junit.Before)

Example 9 with ValueFactoryImpl

use of org.apache.jackrabbit.oak.plugins.value.jcr.ValueFactoryImpl in project jackrabbit-oak by apache.

the class ACETest method before.

@Before
public void before() throws Exception {
    ValueFactory valueFactory = new ValueFactoryImpl(Mockito.mock(Root.class), getNamePathMapper());
    globValue = valueFactory.createValue("*");
    nameValue = valueFactory.createValue("nt:file", PropertyType.NAME);
    nameValues = new Value[] { valueFactory.createValue("nt:folder", PropertyType.NAME), valueFactory.createValue("nt:file", PropertyType.NAME) };
}
Also used : Root(org.apache.jackrabbit.oak.api.Root) ValueFactoryImpl(org.apache.jackrabbit.oak.plugins.value.jcr.ValueFactoryImpl) ValueFactory(javax.jcr.ValueFactory) Before(org.junit.Before)

Aggregations

ValueFactoryImpl (org.apache.jackrabbit.oak.plugins.value.jcr.ValueFactoryImpl)9 Root (org.apache.jackrabbit.oak.api.Root)4 UserManager (org.apache.jackrabbit.api.security.user.UserManager)3 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)3 Before (org.junit.Before)3 Tree (org.apache.jackrabbit.oak.api.Tree)2 DebugTimer (org.apache.jackrabbit.oak.commons.DebugTimer)2 SyncContext (org.apache.jackrabbit.oak.spi.security.authentication.external.SyncContext)2 SyncException (org.apache.jackrabbit.oak.spi.security.authentication.external.SyncException)2 Stopwatch (com.google.common.base.Stopwatch)1 IOException (java.io.IOException)1 Nonnull (javax.annotation.Nonnull)1 NamespaceException (javax.jcr.NamespaceException)1 RepositoryException (javax.jcr.RepositoryException)1 SimpleCredentials (javax.jcr.SimpleCredentials)1 Value (javax.jcr.Value)1 ValueFactory (javax.jcr.ValueFactory)1 NodeTypeManager (javax.jcr.nodetype.NodeTypeManager)1 AccessControlManager (javax.jcr.security.AccessControlManager)1 JackrabbitAccessControlList (org.apache.jackrabbit.api.security.JackrabbitAccessControlList)1