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

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


            Authorizable himself = uMgr.getAuthorizable(uID);
            Impersonation impers = ((User) himself).getImpersonation();

            assertFalse(impers.allows(buildSubject(p)));
            assertTrue(impers.grantImpersonation(p));
            assertTrue(impers.allows(buildSubject(p)));
            assertTrue(impers.revokeImpersonation(p));
            assertFalse(impers.allows(buildSubject(p)));

        } finally {
View Full Code Here


            Authorizable child = uMgr.getAuthorizable(childID);

            Impersonation impers = ((User) child).getImpersonation();
            Principal himselfP = uMgr.getAuthorizable(uID).getPrincipal();
            assertFalse(impers.allows(buildSubject(himselfP)));
            impers.grantImpersonation(himselfP);
            fail("A non-administrator user should not be allowed modify Impersonation of a child user.");
        } catch (AccessDeniedException e) {
            // success
        }
View Full Code Here

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

        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

            List<String> nonExisting = new ArrayList<String>();
            for (String principalName : toAdd) {
                Principal principal = (principals.containsKey(principalName)) ?
                        principals.get(principalName) :
                        new PrincipalImpl(principalName);
                if (!imp.grantImpersonation(principal)) {
                    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

            List<String> nonExisting = new ArrayList<String>();
            for (String principalName : toAdd) {
                Principal principal = (principals.containsKey(principalName)) ?
                        principals.get(principalName) :
                        new PrincipalImpl(principalName);
                if (!imp.grantImpersonation(principal)) {
                    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

            List<String> nonExisting = new ArrayList<String>();
            for (String principalName : toAdd) {
                Principal principal = (principals.containsKey(principalName)) ?
                        principals.get(principalName) :
                        new PrincipalImpl(principalName);
                if (!imp.grantImpersonation(principal)) {
                    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

        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

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.