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

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


    }

    @Test
    public void createWithoutPrincipalName() throws Exception {
        try {
            User user = getUserManager(root).createUser("withoutPrincipalName", "pw");
            Tree tree = root.getTree(userPath);
            tree.removeProperty(REP_PRINCIPAL_NAME);
            root.commit();

            fail("creating user with invalid jcr:uuid should fail");
View Full Code Here


    }

    @Test
    public void createWithInvalidUUID() throws Exception {
        try {
            User user = getUserManager(root).createUser("withInvalidUUID", "pw");
            Tree tree = root.getTree(userPath);
            tree.setProperty(JcrConstants.JCR_UUID, UUID.randomUUID().toString());
            root.commit();

            fail("creating user with invalid jcr:uuid should fail");
View Full Code Here

    }

    @Test
    public void testAccessControlActionForUser() throws Exception {
        UserManager userMgr = getUserManager(root);
        User u = null;
        try {
            String uid = "actionTestUser";
            u = userMgr.createUser(uid, uid);
            root.commit();

            assertAcAction(u, PrivilegeConstants.JCR_ALL);
        } finally {
            root.refresh();
            if (u != null) {
                u.remove();
            }
            root.commit();
        }
    }
View Full Code Here

    @Test
    public void testUserLogin() throws Exception {
        UserManager userManager = getUserManager(root);
        ContentSession cs = null;
        User user = null;
        try {
            user = userManager.createUser("test", "pw");
            root.commit();

            cs = login(new SimpleCredentials("test", "pw".toCharArray()));
            AuthInfo authInfo = cs.getAuthInfo();
            assertEquals("test", authInfo.getUserID());
        } finally {
            if (user != null) {
                user.remove();
                root.commit();
            }
            if (cs != null) {
                cs.close();
            }
View Full Code Here

    @Test
    public void testSelfImpersonation() throws Exception {
        UserManager userManager = getUserManager(root);
        ContentSession cs = null;
        User user = null;
        try {
            user = userManager.createUser("test", "pw");
            root.commit();

            SimpleCredentials sc = new SimpleCredentials("test", "pw".toCharArray());
            cs = login(sc);

            AuthInfo authInfo = cs.getAuthInfo();
            assertEquals("test", authInfo.getUserID());

            cs.close();

            sc = new SimpleCredentials("test", new char[0]);
            ImpersonationCredentials ic = new ImpersonationCredentials(sc, authInfo);
            cs = login(ic);

            authInfo = cs.getAuthInfo();
            assertEquals("test", authInfo.getUserID());
        } finally {
            if (user != null) {
                user.remove();
                root.commit();
            }
            if (cs != null) {
                cs.close();
            }
View Full Code Here

    @Test
    public void testInvalidImpersonation() throws Exception {
        UserManager userManager = getUserManager(root);
        ContentSession cs = null;
        User user = null;
        try {
            user = userManager.createUser("test", "pw");
            root.commit();

            SimpleCredentials sc = new SimpleCredentials("test", "pw".toCharArray());
            cs = login(sc);

            AuthInfo authInfo = cs.getAuthInfo();
            assertEquals("test", authInfo.getUserID());

            cs.close();
            cs = null;

            ConfigurationParameters config = securityProvider.getConfiguration(UserConfiguration.class).getParameters();
            String adminId = UserUtil.getAdminId(config);
            sc = new SimpleCredentials(adminId, new char[0]);
            ImpersonationCredentials ic = new ImpersonationCredentials(sc, authInfo);

            try {
                cs = login(ic);
                fail("User 'test' should not be allowed to impersonate " + adminId);
            } catch (LoginException e) {
                // success
            }
        } finally {
            if (user != null) {
                user.remove();
                root.commit();
            }
            if (cs != null) {
                cs.close();
            }
View Full Code Here

    @Test
    public void testAdminUser() throws Exception {
        Authorizable a = userMgr.getAuthorizable(UserUtil.getAdminId(config));
        assertFalse(a.isGroup());

        User admin = (User) a;
        assertTrue(admin.isAdmin());
        assertTrue(admin.getPrincipal() instanceof AdminPrincipal);
        assertTrue(admin.getPrincipal() instanceof TreeBasedPrincipal);
        assertEquals(admin.getID(), admin.getPrincipal().getName());
    }
View Full Code Here

    @Test
    public void testAnonymous() throws Exception {
        Authorizable a = userMgr.getAuthorizable(UserUtil.getAnonymousId(config));
        assertFalse(a.isGroup());

        User anonymous = (User) a;
        assertFalse(anonymous.isAdmin());
        assertFalse(anonymous.getPrincipal() instanceof AdminPrincipal);
        assertTrue(anonymous.getPrincipal() instanceof TreeBasedPrincipal);
        assertEquals(anonymous.getID(), anonymous.getPrincipal().getName());
    }
View Full Code Here

        Root testRoot = getTestRoot();
        testRoot.refresh();

        UserManager testUserMgr = getUserConfiguration().getUserManager(testRoot, NamePathMapper.DEFAULT);
        try {
            User u = testUserMgr.createUser("a", "b");
            testRoot.commit();

            u.changePassword("c");
            testRoot.commit();

            u.remove();
            testRoot.commit();
        } finally {
            root.refresh();
            Authorizable user = getUserManager(root).getAuthorizable("a");
            if (user != null) {
View Full Code Here

        Authorizable authrz = userManager.getAuthorizable(principal);
        if (authrz == null || authrz.isGroup()) {
            return false;
        }
        Subject impersSubject = getImpersonatorSubject(credentials);
        User user = (User) authrz;
        if (user.getImpersonation().allows(impersSubject)) {
            return true;
        } else {
            throw new FailedLoginException("attempt to impersonate denied for " + principal.getName());
        }
    }
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.