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

Examples of org.apache.jackrabbit.api.security.user.Impersonation.grantImpersonation()


        assertTrue(impersonation.allows(buildSubject(adminPrincipal)));

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

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

    public void testAdminPrincipalAsImpersonator() throws RepositoryException, NotExecutableException {
View Full Code Here


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

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

    public void testImpersonation() throws Exception {
        User u = mgr.createUser("u", "u");

        Impersonation imp = u.getImpersonation();
        Principal p = mgr.getAuthorizable("anonymous").getPrincipal();
        assertTrue(imp.grantImpersonation(p));
        assertFalse(root.hasPendingChanges());

        assertTrue(imp.revokeImpersonation(p));
        assertFalse(root.hasPendingChanges());
    }
View Full Code Here

                    handleFailure("Failed to revoke impersonation for " + principalName + " on " + a);
                }
            }
            List<String> nonExisting = new ArrayList<String>();
            for (String principalName : toAdd) {
                if (!imp.grantImpersonation(new PrincipalImpl(principalName))) {
                    handleFailure("Failed to grant impersonation for " + principalName + " on " + a);
                    if (importBehavior == ImportBehavior.BESTEFFORT &&
                            getPrincipalManager().getPrincipal(principalName) == null) {
                        log.info("ImportBehavior.BESTEFFORT: Remember non-existing impersonator for special processing.");
                        nonExisting.add(principalName);
View Full Code Here

                    handleFailure("Failed to revoke impersonation for " + principalName + " on " + a);
                }
            }
            List<String> nonExisting = new ArrayList<String>();
            for (String principalName : toAdd) {
                if (!imp.grantImpersonation(new PrincipalImpl(principalName))) {
                    handleFailure("Failed to grant impersonation for " + principalName + " on " + a);
                    if (importBehavior == ImportBehavior.BESTEFFORT &&
                            getPrincipalProvider().getPrincipal(principalName) == null) {
                        log.info("ImportBehavior.BESTEFFORT: Remember non-existing impersonator for special processing.");
                        nonExisting.add(principalName);
View Full Code Here

        Subject subject = new Subject(true, Collections.singleton(user2Principal), Collections.<Object>emptySet(), Collections.<Object>emptySet());

        Impersonation impers = user.getImpersonation();
        assertFalse(impers.allows(subject));

        assertTrue(impers.grantImpersonation(user2Principal));
        assertFalse(impers.grantImpersonation(user2Principal));
        superuser.save();

        assertTrue(impers.allows(subject));
View Full Code Here

        Impersonation impers = user.getImpersonation();
        assertFalse(impers.allows(subject));

        assertTrue(impers.grantImpersonation(user2Principal));
        assertFalse(impers.grantImpersonation(user2Principal));
        superuser.save();

        assertTrue(impers.allows(subject));

        assertTrue(impers.revokeImpersonation(user2Principal));
View Full Code Here

        // admin cannot be add/remove to set of impersonators of 'u' but is
        // always allowed to impersonate that user.
        Impersonation impersonation = user.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) admin).getImpersonation();
View Full Code Here

        assertTrue(impersonation.allows(buildSubject(adminPrincipal)));

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

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

    public void testAdminPrincipalAsImpersonator() throws RepositoryException, NotExecutableException {
View Full Code Here

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

        assertFalse(impersonation.grantImpersonation(adminPrincipal));
        assertFalse(impersonation.revokeImpersonation(adminPrincipal));
        assertTrue(impersonation.allows(buildSubject(adminPrincipal)));
    }
}
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.