Examples of Impersonation


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

        save(superuser);

        try {
            Authorizable a = uMgr.getAuthorizable(user2ID);

            Impersonation impers = ((User) a).getImpersonation();
            Principal himselfP = uMgr.getAuthorizable(uID).getPrincipal();
            assertFalse(impers.allows(buildSubject(himselfP)));
            impers.grantImpersonation(himselfP);
            save(uSession);

            fail("A non-administrator user should not be allowed modify Impersonation of another user.");
        } catch (AccessDeniedException e) {
            // success
View Full Code Here

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

            throw new NotExecutableException("Users should be able to modify their properties -> Check repository config.");
        }

        Principal otherP = uMgr.getAuthorizable(otherUID).getPrincipal();

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

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

        assertTrue(impers.allows(buildSubject(otherP)));

        assertTrue(impers.revokeImpersonation(otherP));
        save(uSession);

        assertFalse(impers.allows(buildSubject(otherP)));
    }
View Full Code Here

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

        Principal adminPrincipal = new AdminPrincipal(adminId);

        // admin cannot be add/remove to set of impersonators of 'u' but is
        // always allowed to impersonate that user.
        User u = (User) userMgr.getAuthorizable(uID);
        Impersonation impersonation = u.getImpersonation();

        assertFalse(impersonation.grantImpersonation(adminPrincipal));
        assertFalse(impersonation.revokeImpersonation(adminPrincipal));
        assertTrue(impersonation.allows(buildSubject(adminPrincipal)));

        // same if the impersonation object of the admin itself is used.
        Impersonation adminImpersonation = ((User) a).getImpersonation();

        assertFalse(adminImpersonation.grantImpersonation(adminPrincipal));
        assertFalse(adminImpersonation.revokeImpersonation(adminPrincipal));
        assertTrue(impersonation.allows(buildSubject(adminPrincipal)));
    }
View Full Code Here

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

        assertNull(userMgr.getAuthorizable(systemPrincipal));

        // system cannot be add/remove to set of impersonators of 'u' nor
        // should it be allowed to impersonate a given user...
        User u = (User) userMgr.getAuthorizable(uID);
        Impersonation impersonation = u.getImpersonation();

        assertFalse(impersonation.grantImpersonation(systemPrincipal));
        assertFalse(impersonation.revokeImpersonation(systemPrincipal));
        assertFalse(impersonation.allows(buildSubject(systemPrincipal)));
    }
View Full Code Here

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

        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);

            assertTrue(uImpl.allows(buildSubject(otherP)));

            uImpl.revokeImpersonation(otherP);
            save(otherSession);
        } else {
            throw new NotExecutableException("Cannot execute test. OtherP can already impersonate UID-user.");
        }
    }
View Full Code Here

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

        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);

            assertTrue(uImpl.allows(buildSubject(otherP)));

            uImpl.revokeImpersonation(otherP);
            save(otherSession);
        } else {
            throw new NotExecutableException("Cannot execute test. OtherP can already impersonate UID-user.");
        }
    }
View Full Code Here

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

            throw new NotExecutableException("Users should be able to modify their properties -> Check repository config.");
        }

        Principal otherP = uMgr.getAuthorizable(otherUID).getPrincipal();

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

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

        assertTrue(impers.allows(buildSubject(otherP)));

        assertTrue(impers.revokeImpersonation(otherP));
        save(uSession);

        assertFalse(impers.allows(buildSubject(otherP)));
    }
View Full Code Here

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

            assertNotNull(u2);
           
            Subject subj = new Subject();
            subj.getPrincipals().add(u2.getPrincipal());

            Impersonation imp = ((User) newUser).getImpersonation();
            assertTrue(imp.allows(subj));

        } finally {
            sImpl.refresh(false);
        }
    }
View Full Code Here

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

                doImport(target, xml, UserImporter.ImportBehavior.IGNORE);
                // no exception during import: no impersonation must be granted
                // for the invalid principal name
                Authorizable a = umgr.getAuthorizable("t");
                if (!a.isGroup()) {
                    Impersonation imp = ((User)a).getImpersonation();
                    Subject s = new Subject();
                    s.getPrincipals().add(new PrincipalImpl(principalName));
                    assertFalse(imp.allows(s));
                    for (PrincipalIterator it = imp.getImpersonators(); it.hasNext();) {
                        assertFalse(principalName.equals(it.nextPrincipal().getName()));
                    }
                } else {
                    fail("Importing 't' didn't create a User.");
                }
View Full Code Here

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

    public void testImpersonationOfOtherUser() throws RepositoryException, NotExecutableException {
        UserManager umgr = getUserManager(uSession);
        Principal selfPrinc = umgr.getAuthorizable(uID).getPrincipal();

        User child = (User) umgr.getAuthorizable(getYetAnotherID());
        Impersonation impers = child.getImpersonation();
        assertFalse(impers.allows(buildSubject(selfPrinc)));
        try {
            assertFalse(impers.grantImpersonation(selfPrinc));
        } catch (AccessDeniedException e) {
            // ok.
        }
        assertFalse(impers.allows(buildSubject(selfPrinc)));

        User parent = (User) umgr.getAuthorizable(otherUID);
        impers = parent.getImpersonation();
        assertFalse(impers.allows(buildSubject(selfPrinc)));
        try {
            assertFalse(impers.grantImpersonation(selfPrinc));
        } catch (AccessDeniedException e) {
            // ok.
        }
        assertFalse(impers.allows(buildSubject(selfPrinc)));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.