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

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


    }

    public void testSetSpecialProperties() throws NotExecutableException, RepositoryException {
        Value v = superuser.getValueFactory().createValue("any_value");

        User u = getTestUser(superuser);
        for (String pName : protectedUserProps) {
            try {
                u.setProperty(pName, v);
                save(superuser);
                fail("changing the '" + pName + "' property on a User should fail.");
            } catch (RepositoryException e) {
                // success
            }
View Full Code Here


            }
        }
    }

    public void testRemoveSpecialProperties() throws NotExecutableException, RepositoryException {
        User u = getTestUser(superuser);
        for (String pName : protectedUserProps) {
            try {
                u.removeProperty(pName);
                save(superuser);
                fail("removing the '" + pName + "' property on a User should fail.");
            } catch (RepositoryException e) {
                // success
            }
View Full Code Here

        String newUserId = null;
        Group newGroup = null;

        try {
            Principal uP = getTestPrincipal();
            User newUser = userMgr.createUser(uP.getName(), uP.getName());
            superuser.save();
            newUserId = newUser.getID();

            newGroup = userMgr.createGroup(getTestPrincipal());
            newGroup.addMember(newUser);
            superuser.save();

            // remove the new user that is still listed as member.
            newUser.remove();
            superuser.save();
        } finally {
            if (newUserId != null) {
                Authorizable u = userMgr.getAuthorizable(newUserId);
                if (u != null) {
View Full Code Here

    }

    protected void setupAuthorizables() throws RepositoryException {
        for (JackrabbitSession s : writeSessions) {
            UserManager userManager = s.getUserManager();
            User user = userManager.createUser(userId, userId);

            Group group = userManager.createGroup("group1");
            group.addMember(user);

            Group group2 = userManager.createGroup("group2");
View Full Code Here

            }
            return a;
        }

        private User createAdmin(String adminId, String pw) throws RepositoryException {
            User admin = createUser(adminId, pw);
            if (!isAutoSave()) {
                session.save();
            }
            log.info("... created admin user with id \'" + adminId + "\' and default pw.");
            return admin;
View Full Code Here

        // create a second user
        p = getTestPrincipal();
        String pw = buildPassword(p);
        Credentials otherCreds = buildCredentials(p.getName(), pw);
        User other = userMgr.createUser(p.getName(), pw);
        save(superuser);

        otherUID = other.getID();

        // make other user a user-administrator:
        Authorizable ua = userMgr.getAuthorizable(UserConstants.USER_ADMIN_GROUP_NAME);
        if (ua == null || !ua.isGroup()) {
            throw new NotExecutableException("Cannot execute test. No user-administrator group found.");
View Full Code Here

    public void testModifyImpersonationOfUser() throws RepositoryException, NotExecutableException {
        UserManager umgr = getUserManager(otherSession);
        Principal otherP = umgr.getAuthorizable(otherUID).getPrincipal();

        // modify impersonation of new user
        User u = null;
        try {
            Principal p = getTestPrincipal();
            u = umgr.createUser(p.getName(), buildPassword(p));
            save(otherSession);

            Impersonation impers = u.getImpersonation();
            assertFalse(impers.allows(buildSubject(otherP)));

            assertTrue(impers.grantImpersonation(otherP));
            save(otherSession);

            assertTrue(impers.allows(buildSubject(otherP)));
        } finally {
            // impersonation get removed while removing the user u.
            if (u != null) {
                u.remove();
                save(otherSession);
            }
        }

        // modify impersonation of another user
        u = (User) umgr.getAuthorizable(uID);
        Impersonation uImpl = u.getImpersonation();

        if (!uImpl.allows(buildSubject(otherP))) {
            // ... trying to modify 'impersonators of another user must succeed
            assertTrue(uImpl.grantImpersonation(otherP));
            save(otherSession);
View Full Code Here

    }

    public void testModifyGroupForHimSelf() throws RepositoryException, NotExecutableException {
        UserManager umgr = getUserManager(otherSession);

        User userHimSelf = (User) umgr.getAuthorizable(otherUID);
        Group gr = getGroupAdminGroup(umgr);
        try {
            assertFalse(gr.addMember(userHimSelf));
            // conditial save call omitted.
        } catch (RepositoryException e) {
View Full Code Here

    }

    public void testModifyGroup() throws RepositoryException, NotExecutableException {
        UserManager umgr = getUserManager(otherSession);

        User parentUser = (User) umgr.getAuthorizable(uID);
        if (parentUser == null) {
            throw new NotExecutableException();
        } else {
            Group gr = getGroupAdminGroup(umgr);
            try {
                assertFalse("A UserAdmin must not be allowed to modify group memberships", gr.addMember(parentUser));
            } catch (RepositoryException e) {
                // success
            }
        }

        Principal cp = getTestPrincipal();
        User childU = null;
        try {
            childU = umgr.createUser(cp.getName(), buildPassword(cp));
            save(otherSession);

            Group gr = getGroupAdminGroup(umgr);
            try {
                assertFalse("A UserAdmin must not be allowed to modify group " +
                        "memberships", gr.addMember(childU));
                // con-save call omitted.
            } catch (RepositoryException e) {
                // success
            }
        } finally {
            if (childU != null) {
                childU.remove();
            }
        }
    }
View Full Code Here

        try {
            NodeImpl userNode = (NodeImpl) nodeCreator.createUserNode(userID, intermediatePath);
            setPrincipal(userNode, principal);
            setProperty(userNode, P_PASSWORD, getValue(UserImpl.buildPasswordValue(password)), true);

            User user = createUser(userNode);
            if (isAutoSave()) {
                session.save();
            }

            log.debug("User created: " + userID + "; " + userNode.getPath());
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.