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

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


        // first try to retrieve an authorizable corresponding to
        // a non-group principal. the first one present is used
        // to determine the userID.
        try {
            UserManager umgr = getSystemUserManager(workspaceName);
            for (Principal p : subject.getPrincipals()) {
                if (!(p instanceof Group)) {
                    Authorizable authorz = umgr.getAuthorizable(p);
                    if (authorz != null && !authorz.isGroup()) {
                        uid = authorz.getID();
                        break;
                    }
                }
View Full Code Here


        public PrincipalManager getPrincipalManager() throws AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException {
            return null;
        }

        public UserManager getUserManager() throws AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException {
            return new UserManager() {

                public Authorizable getAuthorizable(String id) throws RepositoryException {
                    return null;
                }
View Full Code Here

        }
        assertTrue(isUserAdmin);
    }

    public void testCreateUser() throws RepositoryException, NotExecutableException {
        UserManager umgr = getUserManager(otherSession);
        UserImpl u = null;
        // create a new user -> must succeed.
        try {
            Principal p = getTestPrincipal();
            u = (UserImpl) umgr.createUser(p.getName(), buildPassword(p));
            save(otherSession);
        } finally {
            if (u != null) {
                u.remove();
                save(otherSession);
View Full Code Here

            }
        }
    }

    public void testCreateUserWithIntermediatePath() throws RepositoryException, NotExecutableException {
        UserManager umgr = getUserManager(otherSession);
        UserImpl u = null;

        // create a new user with intermediate-path
        // -> must succeed and user must be created
        // -> intermediate path must be part of the nodes path
        Principal p = getTestPrincipal();
        String usersPath = ((UserManagerImpl) umgr).getUsersPath();
        Map<String, String> m = new HashMap<String, String>();
        m.put("/some/intermediate/path", usersPath + "/some/intermediate/path/" + p.getName());
        m.put("some/intermediate/path", usersPath + "/some/intermediate/path/" + p.getName());
        m.put("/", usersPath + "/" + p.getName());
        m.put("", usersPath + "/" + p.getName());
        m.put(usersPath + "/some/intermediate/path", usersPath + "/some/intermediate/path/" + p.getName());

        for (String intermediatePath : m.keySet()) {
            try {
                u = (UserImpl) umgr.createUser(p.getName(), buildPassword(p), p, intermediatePath);
                save(otherSession);

                String expPath = m.get(intermediatePath);
                assertEquals(expPath, u.getNode().getPath());
            } finally {
View Full Code Here

            }
        }
    }

    public void testCreateNestedUsers() throws NotExecutableException, RepositoryException {
        UserManager umgr = getUserManager(otherSession);
        UserImpl u = null;

        String invalidIntermediatePath = ((UserImpl) umgr.getAuthorizable(otherUID)).getNode().getPath();
        try {
            Principal p = getTestPrincipal();
            u = (UserImpl) umgr.createUser(p.getName(), buildPassword(p), p, invalidIntermediatePath);
            save(otherSession);

            fail("An attempt to create a user below an existing user must fail.");
        } catch (RepositoryException e) {
            // success
View Full Code Here

            }
        }
    }

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

        Authorizable himself = umgr.getAuthorizable(otherUID);
        try {
            himself.remove();
            save(otherSession);

            fail("A UserAdministrator should not be allowed to remove himself.");
View Full Code Here

     *
     * @throws RepositoryException
     * @throws NotExecutableException
     */
    public void testRemoveAnotherUser() throws RepositoryException, NotExecutableException {
        UserManager umgr = getUserManager(otherSession);

        Authorizable user = umgr.getAuthorizable(uID);
        user.remove();
        save(otherSession);
    }
View Full Code Here

        user.remove();
        save(otherSession);
    }

    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));
View Full Code Here

            throw new NotExecutableException("Cannot execute test. OtherP can already impersonate UID-user.");
        }
    }

    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 " +
View Full Code Here

TOP

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

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.