@NotNull @Override public Boolean perform() throws RepositoryException { return impersonationDelegate.revokeImpersonation(principal); } });
@NotNull @Override public Boolean perform() throws RepositoryException { return impersonationDelegate.revokeImpersonation(principal); } });
@Nonnull @Override public Boolean perform() throws RepositoryException { return impersonationDelegate.revokeImpersonation(principal); } });
@Override public boolean revokeImpersonation(Principal principal) throws RepositoryException { try { return dlg.revokeImpersonation(principal); } finally { getMgr().autosave(); } }
@Override public boolean revokeImpersonation(Principal principal) throws RepositoryException { try { return dlg.revokeImpersonation(principal); } finally { getMgr().autosave(); } }
@Override public boolean revokeImpersonation(Principal principal) throws RepositoryException { try { return dlg.revokeImpersonation(principal); } finally { getMgr().autosave(); } }
public void testRevokeImpersonatingForOneself() throws RepositoryException { Principal main = newUser.getPrincipal(); assertFalse(impersonation.revokeImpersonation(main)); }
public void testCannotRevokeImpersonationForAdministrator() throws RepositoryException, NotExecutableException { User admin = getTestUser(superuser); assertFalse(impersonation.revokeImpersonation(admin.getPrincipal())); }
public void testGrantImpersonatingForOneself() throws RepositoryException { Principal main = newUser.getPrincipal(); try { assertFalse(impersonation.grantImpersonation(main)); } finally { impersonation.revokeImpersonation(main); } }
public void testGrantImpersonationUnknownUser() throws RepositoryException, NotExecutableException { Principal test = getTestPrincipal(); try { assertFalse("Granting impersonation to an unknown principal should not be successful.", impersonation.grantImpersonation(test)); } finally { impersonation.revokeImpersonation(test); save(superuser); } }
@Test public void testImpersonation() throws RepositoryException, NotExecutableException { Principal user2Principal = user2.getPrincipal(); 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)); assertTrue(impers.revokeImpersonation(user2Principal)); assertFalse(impers.revokeImpersonation(user2Principal)); superuser.save(); assertFalse(impers.allows(subject)); }
public void testCannotGrantImpersonationForAdministrator() throws RepositoryException, NotExecutableException { User admin = getTestUser(superuser); try { assertFalse(impersonation.grantImpersonation(admin.getPrincipal())); } finally { impersonation.revokeImpersonation(admin.getPrincipal()); } }
public void testGrantImpersonationToGroupPrincipal() throws RepositoryException, NotExecutableException { Session s = getHelper().getReadOnlySession(); try { Principal group = getTestGroup(s).getPrincipal(); try { assertFalse("Granting impersonation to a Group should not be successful.", impersonation.grantImpersonation(group)); } finally { impersonation.revokeImpersonation(group); save(superuser); } } finally { s.logout(); } }
public void testGrantImpersonation() throws RepositoryException, NotExecutableException { User u = null; Principal test = getTestPrincipal(); try { u = userMgr.createUser(test.getName(), buildPassword(test)); save(superuser); assertTrue("Admin should be allowed to edit impersonation and grant to another test-user.", impersonation.grantImpersonation(test)); } finally { impersonation.revokeImpersonation(test); if (u != null) { u.remove(); } save(superuser); } }
public void testRevokeImpersonation() throws RepositoryException, NotExecutableException { User u = null; Principal test = getTestPrincipal(); try { u = userMgr.createUser(test.getName(), buildPassword(test)); save(superuser); impersonation.grantImpersonation(test); save(superuser); assertTrue(impersonation.revokeImpersonation(test)); } finally { if (u != null) { u.remove(); } } }
public void testAdminPrincipalAsImpersonator() throws RepositoryException, NotExecutableException { Principal adminPrincipal = new AdminPrincipal() { @Override public String getName() { return "some-admin-name"; } }; // 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))); } }
@Test public void testRevokeImpCnt() throws Exception { User user = getTestUser(); Principal p2 = getUserManager(root).createUser("tmpUser", null).getPrincipal(); user.getImpersonation().revokeImpersonation(p2); assertEquals(0, cntAction.onDisabledCnt); assertEquals(0, cntAction.onGrantImpCnt); assertEquals(1, cntAction.onRevokeImpCnt); }
public void testSystemPrincipalAsImpersonator() throws RepositoryException { Principal systemPrincipal = new SystemPrincipal(); 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))); } }
@Test 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()); }
public void testModifyOwnImpersonation() throws RepositoryException, NotExecutableException { User u = (User) uMgr.getAuthorizable(uID); if (!uSession.hasPermission(((UserImpl) u).getNode().getPath(), "set_property")) { 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))); }