Search in sources :

Example 31 with NotExecutableException

use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.

the class ImpersonationImplTest method testModifyOwnImpersonation.

public void testModifyOwnImpersonation() throws RepositoryException, NotExecutableException {
    User u = (User) uMgr.getAuthorizable(uID);
    if (!uSession.hasPermission(((UserImpl) u).getNode().getPath(), "set_property")) {
        throw new NotExecutableException("Users should be able to modify their properties -> Check repository config.");
    }
    Principal otherP = uMgr.getAuthorizable(otherUID).getPrincipal();
    Impersonation impers = u.getImpersonation();
    assertFalse(impers.allows(buildSubject(otherP)));
    assertTrue(impers.grantImpersonation(otherP));
    save(uSession);
    assertTrue(impers.allows(buildSubject(otherP)));
    assertTrue(impers.revokeImpersonation(otherP));
    save(uSession);
    assertFalse(impers.allows(buildSubject(otherP)));
}
Also used : Impersonation(org.apache.jackrabbit.api.security.user.Impersonation) User(org.apache.jackrabbit.api.security.user.User) NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) AdminPrincipal(org.apache.jackrabbit.core.security.principal.AdminPrincipal) SystemPrincipal(org.apache.jackrabbit.core.security.SystemPrincipal) Principal(java.security.Principal)

Example 32 with NotExecutableException

use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.

the class NodeResolverTest method createNodeResolver.

protected NodeResolver createNodeResolver(Session session) throws NotExecutableException, RepositoryException {
    if (!(session instanceof SessionImpl)) {
        throw new NotExecutableException();
    }
    NodeResolver resolver = createNodeResolver((SessionImpl) session);
    UserManager umr = ((SessionImpl) session).getUserManager();
    if (umr instanceof UserManagerImpl) {
        UserManagerImpl uImpl = (UserManagerImpl) umr;
        resolver.setSearchRoots(uImpl.getUsersPath(), uImpl.getGroupsPath());
    }
    return resolver;
}
Also used : NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) UserManager(org.apache.jackrabbit.api.security.user.UserManager) SessionImpl(org.apache.jackrabbit.core.SessionImpl)

Example 33 with NotExecutableException

use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.

the class NodeResolverTest method testFindNodesWithNonExistingSearchRoot.

public void testFindNodesWithNonExistingSearchRoot() throws NotExecutableException, RepositoryException {
    String searchRoot = nodeResolver.getSearchRoot(UserConstants.NT_REP_AUTHORIZABLE);
    if (superuser.nodeExists(searchRoot)) {
        throw new NotExecutableException();
    }
    NodeIterator result = nodeResolver.findNodes(UserConstants.P_PRINCIPAL_NAME, "anyValue", UserConstants.NT_REP_AUTHORIZABLE, true);
    assertNotNull(result);
    assertFalse(result.hasNext());
}
Also used : NodeIterator(javax.jcr.NodeIterator) NotExecutableException(org.apache.jackrabbit.test.NotExecutableException)

Example 34 with NotExecutableException

use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.

the class NodeResolverTest method testFindNodeWithNonExistingSearchRoot.

public void testFindNodeWithNonExistingSearchRoot() throws NotExecutableException, RepositoryException {
    String searchRoot = nodeResolver.getSearchRoot(UserConstants.NT_REP_AUTHORIZABLE_FOLDER);
    SessionImpl sImpl = (SessionImpl) superuser;
    if (sImpl.nodeExists(searchRoot)) {
        throw new NotExecutableException();
    }
    Node result = nodeResolver.findNode(sImpl.getQName(UserConstants.GROUP_ADMIN_GROUP_NAME), UserConstants.NT_REP_AUTHORIZABLE);
    assertNull(result);
}
Also used : NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) Node(javax.jcr.Node) SessionImpl(org.apache.jackrabbit.core.SessionImpl)

Example 35 with NotExecutableException

use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.

the class LockTest method setUpSameNameSiblings.

/**
     * Create three child nodes with identical names
     */
private Node setUpSameNameSiblings() throws RepositoryException, NotExecutableException {
    // create three lockable nodes with same name
    try {
        Node testNode = testRootNode.addNode(nodeName1, testNodeType);
        ensureMixinType(testNode, mixLockable);
        testNode = testRootNode.addNode(nodeName1, testNodeType);
        ensureMixinType(testNode, mixLockable);
        testNode = testRootNode.addNode(nodeName1, testNodeType);
        ensureMixinType(testNode, mixLockable);
        testRootNode.getSession().save();
        return testNode;
    } catch (ItemExistsException ex) {
        // repository does not seem to support same name siblings on this node type
        throw new NotExecutableException("Node type " + testNodeType + " does not support same-name-siblings");
    }
}
Also used : NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) ItemExistsException(javax.jcr.ItemExistsException) Node(javax.jcr.Node)

Aggregations

NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)381 Node (javax.jcr.Node)149 NodeType (javax.jcr.nodetype.NodeType)84 Value (javax.jcr.Value)81 RepositoryException (javax.jcr.RepositoryException)64 PropertyDefinition (javax.jcr.nodetype.PropertyDefinition)61 Session (javax.jcr.Session)59 Property (javax.jcr.Property)47 NodeDefinition (javax.jcr.nodetype.NodeDefinition)29 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)28 JackrabbitSession (org.apache.jackrabbit.api.JackrabbitSession)25 Authorizable (org.apache.jackrabbit.api.security.user.Authorizable)23 AccessControlPolicyIterator (javax.jcr.security.AccessControlPolicyIterator)22 Test (org.junit.Test)22 AccessControlPolicy (javax.jcr.security.AccessControlPolicy)21 User (org.apache.jackrabbit.api.security.user.User)19 Principal (java.security.Principal)18 NodeIterator (javax.jcr.NodeIterator)18 UserManager (org.apache.jackrabbit.api.security.user.UserManager)17 ItemExistsException (javax.jcr.ItemExistsException)16