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

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


        }
    }

    public void testSingleToMultiValued() throws Exception {
        AuthorizableImpl user = (AuthorizableImpl) getTestUser(superuser);
        UserManager uMgr = getUserManager(superuser);
        try {
            Value v = superuser.getValueFactory().createValue("anyValue");
            user.setProperty("someProp", v);
            if (!uMgr.isAutoSave()) {
                superuser.save();
            }
            Value[] vs = new Value[] {v, v};
            user.setProperty("someProp", vs);
            if (!uMgr.isAutoSave()) {
                superuser.save();
            }
        } finally {
            if (user.removeProperty("someProp") && !uMgr.isAutoSave()) {
                superuser.save();
            }
        }
    }
View Full Code Here


        }
    }

    public void testMultiValuedToSingle() throws Exception {
        AuthorizableImpl user = (AuthorizableImpl) getTestUser(superuser);
        UserManager uMgr = getUserManager(superuser);
        try {
            Value v = superuser.getValueFactory().createValue("anyValue");
            Value[] vs = new Value[] {v, v};
            user.setProperty("someProp", vs);
            if (!uMgr.isAutoSave()) {
                superuser.save();
            }
            user.setProperty("someProp", v);
            if (!uMgr.isAutoSave()) {
                superuser.save();
            }
        } finally {
            if (user.removeProperty("someProp") && !uMgr.isAutoSave()) {
                superuser.save();
            }
        }
    }
View Full Code Here

        try {
            // admin/anonymous/administrators must be present
            String adminId = ((UserPerWorkspaceSecurityManager) secMgr).adminId;
            assertEquals(adminId, s.getUserID());

            UserManager umgr = ((JackrabbitSession) s).getUserManager();
            assertNotNull(umgr.getAuthorizable(adminId));
            assertNotNull(umgr.getAuthorizable(((UserPerWorkspaceSecurityManager) secMgr).anonymousId));
            assertNotNull(umgr.getAuthorizable(SecurityConstants.ADMINISTRATORS_NAME));

        } finally {
            s.logout();
        }
    }
View Full Code Here

        }
    }

    public void testSystemUsersAreSaved() throws Exception {
        String adminId = ((UserPerWorkspaceSecurityManager) secMgr).adminId;
        UserManager umgr = ((JackrabbitSession) superuser).getUserManager();
        Principal p = umgr.getAuthorizable(adminId).getPrincipal();

        if (p instanceof ItemBasedPrincipal) {
            Item item = superuser.getItem(((ItemBasedPrincipal) p).getPath());
            assertFalse(item.isNew());
            assertFalse(item.isModified());
View Full Code Here

            // other users created in the default workspace...
            u = ((JackrabbitSession) superuser).getUserManager().createUser("testUser", "testUser");
            superuser.save();

            // ... must not be present in the alternate-workspace
            UserManager umgr = ((JackrabbitSession) s).getUserManager();
            assertNull(umgr.getAuthorizable("testUser"));

            try {
                Session us = getHelper().getRepository().login(new SimpleCredentials("testUser", "testUser".toCharArray()), altWsp);
                us.logout();
                fail("testUser must not be able to login to a workspace without this user.");
View Full Code Here

        String altWsp = getAlternativeWorkspaceName();
        if (altWsp == null) {
            throw new NotExecutableException();
        }

        UserManager uMgr = ((JackrabbitSession) superuser).getUserManager();

        Session s = getHelper().getSuperuserSession(altWsp);
        User u = null;
        try {
            // other users created in the default workspace...
            u = uMgr.createUser("testUser", "testUser");
            superuser.save();

            String userPath = null;
            if (u.getPrincipal() instanceof ItemBasedPrincipal) {
                userPath = ((ItemBasedPrincipal) u.getPrincipal()).getPath();
                assertTrue(superuser.nodeExists(userPath));
            } else {
                throw new NotExecutableException();
            }

            // ... must not be present in the alternate-workspace
            UserManager umgr = ((JackrabbitSession) s).getUserManager();
            assertNull(umgr.getAuthorizable("testUser"));
            assertFalse(s.nodeExists(userPath));

            String clonePath = userPath;
            String parentPath = Text.getRelativeParent(clonePath, 1);
            while (!s.nodeExists(parentPath)) {
                clonePath = parentPath;
                parentPath = Text.getRelativeParent(parentPath, 1);
            }

            // clone the user into the second workspace
            s.getWorkspace().clone(superuser.getWorkspace().getName(), clonePath, clonePath, true);

            // ... now the user must be visible
            assertNotNull(umgr.getAuthorizable("testUser"));
            if (userPath != null) {
                assertTrue(s.nodeExists(userPath));               
            }
            // ... and able to login to that workspace
            Session us = getHelper().getRepository().login(new SimpleCredentials("testUser", "testUser".toCharArray()), altWsp);
View Full Code Here

        String altWsp = getAlternativeWorkspaceName();
        if (altWsp == null) {
            throw new NotExecutableException();
        }

        UserManager uMgr = ((JackrabbitSession) superuser).getUserManager();

        Session s = getHelper().getSuperuserSession(altWsp);
        User u = null;
        try {
            // other users created in the default workspace...
            u = uMgr.createUser("testUser", "testUser");
            superuser.save();

            String userPath = null;
            if (u.getPrincipal() instanceof ItemBasedPrincipal) {
                userPath = ((ItemBasedPrincipal) u.getPrincipal()).getPath();
                assertTrue(superuser.nodeExists(userPath));
            } else {
                throw new NotExecutableException();
            }

            // ... must not be present in the alternate-workspace
            UserManager umgr = ((JackrabbitSession) s).getUserManager();
            assertNull(umgr.getAuthorizable("testUser"));
            assertFalse(s.nodeExists(userPath));

            User u2 = umgr.createUser("testUser", "testUser");
            s.save();
            assertTrue(s.nodeExists(userPath));

            Value value = superuser.getValueFactory().createValue("anyValue");
            u.setProperty(propertyName1, value);
View Full Code Here

            throw new NotExecutableException("SessionImpl expected.");
        }

        sImpl = (SessionImpl) superuser;

        UserManager umgr = sImpl.getUserManager();
        if (umgr.isAutoSave()) {
            try {
                umgr.autoSave(false);
            } catch (RepositoryException e) {
                // user manager cannot have the autosave behavior changed
                // -> test not executable
                throw new NotExecutableException("Expected user manager that can have its autosave behavior changed to false.");
            }
View Full Code Here

            superuser.logout();
            throw new NotExecutableException();
        }

        try {
            UserManager uMgr = getUserManager(superuser);
            // create the testUser
            uid = "testUser" + UUID.randomUUID();
            creds = new SimpleCredentials(uid, uid.toCharArray());

            testUser = uMgr.createUser(uid, uid);
            if (!uMgr.isAutoSave()) {
                superuser.save();
            }
        } catch (Exception e) {
            superuser.logout();
            throw e;
View Full Code Here

    }

    public void testCleanup() throws RepositoryException, NotExecutableException {
        Session s = getHelper().getSuperuserSession();
        try {
            UserManager umgr = getUserManager(s);
            s.logout();

            // after logging out the session, the user manager must have been
            // released as well and it's underlying session must not be available
            // any more -> accessing users must fail.
            try {
                umgr.getAuthorizable("any userid");
                fail("After having logged out the original session, the user manager must not be live any more.");
            } catch (RepositoryException e) {
                // success
            }
        } finally {
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.