Package org.apache.jackrabbit.api.security.user

Examples of org.apache.jackrabbit.api.security.user.User


        assertFalse(folder.hasProperty("jcr:created"));
    }

    public void testEditor() throws NotExecutableException, RepositoryException {
        User u = null;
        try {
            UserManager uMgr = getUserManager(superuser);
            u = uMgr.createUser("t", "t");
            Principal p = u.getPrincipal();

            JackrabbitAccessControlManager acMgr = (JackrabbitAccessControlManager) getAccessControlManager(superuser);
            JackrabbitAccessControlPolicy[] acls = acMgr.getApplicablePolicies(p);

            assertEquals(1, acls.length);
            assertTrue(acls[0] instanceof ACLTemplate);

            // access again
            acls = acMgr.getApplicablePolicies(p);

            assertEquals(1, acls.length);           
            assertEquals(1, acMgr.getApplicablePolicies(acls[0].getPath()).getSize());

            assertEquals(0, acMgr.getPolicies(p).length);
            assertEquals(0, acMgr.getPolicies(acls[0].getPath()).length);

            acMgr.setPolicy(acls[0].getPath(), acls[0]);

            assertEquals(0, acMgr.getApplicablePolicies(p).length);
            assertEquals(1, acMgr.getPolicies(p).length);
            assertEquals(1, acMgr.getPolicies(acls[0].getPath()).length);
        } finally {
            superuser.refresh(false);
            if (u != null) {
                u.remove();
            }
        }
    }
View Full Code Here


            }
        }
    }

    public void testEditor2() throws NotExecutableException, RepositoryException {
        User u = null;
        User u2 = null;

        try {
            UserManager uMgr = getUserManager(superuser);

            u = uMgr.createUser("t", "t");
            u2 = uMgr.createUser("tt", "tt", new TestPrincipal("tt"), "t/tt");

            Principal p = u.getPrincipal();
            Principal p2 = u2.getPrincipal();

            if (p instanceof ItemBasedPrincipal && p2 instanceof ItemBasedPrincipal &&
                    Text.isDescendant(((ItemBasedPrincipal) p).getPath(), ((ItemBasedPrincipal) p2).getPath())) {

                JackrabbitAccessControlManager acMgr = (JackrabbitAccessControlManager) getAccessControlManager(superuser);

                JackrabbitAccessControlPolicy[] acls = acMgr.getApplicablePolicies(p2);
                acMgr.setPolicy(acls[0].getPath(), acls[0]);

                acls = acMgr.getApplicablePolicies(p);
                String path = acls[0].getPath();

                Node n = superuser.getNode(path);
                assertEquals("rep:PrincipalAccessControl", n.getPrimaryNodeType().getName());
            } else {
                throw new NotExecutableException();
            }
        } finally {
            superuser.refresh(false);
            if (u2 != null) u2.remove();
            if (u != null) u.remove();
     }

    }
View Full Code Here

        try {
            NodeImpl userNode = (NodeImpl) nodeCreator.createUserNode(userID, intermediatePath);
            setPrincipal(userNode, principal);
            setPassword(userNode, password, true);

            User user = createUser(userNode);
            onCreate(user, password);
            if (isAutoSave()) {
                session.save();
            }
View Full Code Here

     *
     * @return The admin user.
     * @throws RepositoryException If an error occurs.
     */
    private User createAdmin() throws RepositoryException {
        User admin;
        try {
            admin = createUser(adminId, adminId);
            if (!isAutoSave()) {
                session.save();
            }
View Full Code Here

            throw new IllegalArgumentException();
        }
        if (!Text.isDescendant(USERS_PATH, userNode.getPath())) {
            throw new IllegalArgumentException("User has to be within the User Path");
        }
        User user = doCreateUser(userNode);
        idPathMap.put(user.getID(), userNode.getPath());
        return user;
    }
View Full Code Here

                // yet present (detected eventual circular membership).
                if (members.add(group) && includeIndirect) {
                    members.addAll(((GroupImpl) group).getMembers(true));
                }
            } else if (n.isNodeType(NT_REP_USER)) {
                User user = userManager.createUser(n);
                members.add(user);
            } else {
                // weak-ref property 'rep:groups' that doesn't reside under an
                // authorizable node -> doesn't represent a member of this group.
                log.debug("Undefined reference to group '" + getID() + "' -> Not included in member set.");
View Full Code Here

        }
        return userId;
    }

    public void testCreateNodesDirectly() throws NotExecutableException, RepositoryException {
        User u = getTestUser(superuser);
        if (u instanceof UserImpl) {
            throw new NotExecutableException();
        }

        NodeImpl n = ((UserImpl)u).getNode();
View Full Code Here


    public void testRemoveUserRemovesTree() throws RepositoryException {
        // create 2 new users. the second as child of the first.
        Principal p = getTestPrincipal();
        User u = userMgr.createUser(p.getName(), buildPassword(p));
        String uID = u.getID();
        p = getTestPrincipal();
        User u2 = userMgr.createUser(p.getName(), buildPassword(p), p, ((UserImpl)u).getNode().getPath());
        String u2ID = u2.getID();

        // removing the first user must also remove the child-users.
        u.remove();

        // make sure both users are gone
View Full Code Here

        assertNull(userMgr.getAuthorizable(u2ID));
    }

    public void testPrincipalNameEqualsUserID() throws RepositoryException {
        Principal p = getTestPrincipal();
        User u = null;
        try {
            u = userMgr.createUser(p.getName(), buildPassword(p));

            String msg = "Implementation specific: User.getID() must return the userID pass to createUser.";
            assertEquals(msg, u.getID(), p.getName());
        } finally {
            if (u != null) {
                u.remove();
            }
        }
    }
View Full Code Here

        }
    }

    public void testUserIDFromSession() throws RepositoryException {
        Principal p = getTestPrincipal();
        User u = null;
        Session uSession = null;
        try {
            String uid = p.getName();
            String pw = buildPassword(p);
            u = userMgr.createUser(uid, pw);

            uSession = superuser.getRepository().login(new SimpleCredentials(uid, pw.toCharArray()));
            assertEquals(u.getID(), uSession.getUserID());
        } finally {
            if (uSession != null) {
                uSession.logout();
            }
            if (u != null) {
                u.remove();
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.api.security.user.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.