/** * @see <a href="https://issues.apache.org/jira/browse/JCR-2931">JCR-2931</a> */ public void testAdminImpersonatingOneself() throws RepositoryException, NotExecutableException { User admin = getTestUser(superuser); Subject subject = createSubject(admin); assertTrue(admin.getImpersonation().allows(subject)); }
public void testGrantImpersonatingForOneself() throws RepositoryException { Principal main = newUser.getPrincipal(); try { assertFalse(impersonation.grantImpersonation(main)); } finally { impersonation.revokeImpersonation(main); } }
public void testGetAuthorizableById() throws RepositoryException, NotExecutableException { Authorizable auth = null; for (Principal principal : getPrincipalSetFromSession(superuser)) { Principal p = principal; auth = userMgr.getAuthorizable(p); if (auth != null) { Authorizable authByID = userMgr.getAuthorizable(auth.getID()); assertEquals("Equal ID expected", auth.getID(), authByID.getID()); } } }
@Override protected void setUp() throws Exception { super.setUp(); Principal test = getTestPrincipal(); String pw = buildPassword(test); newUser = userMgr.createUser(test.getName(), pw); save(superuser); impersonation = newUser.getImpersonation(); }
private User createUser(String uid, String pw, Principal p, String iPath) throws RepositoryException, NotExecutableException { User u = userMgr.createUser(uid, pw, p, iPath); save(superuser); return u; }
public void testGetNotExistingProperty() throws RepositoryException, NotExecutableException { Authorizable auth = getTestUser(superuser); String hint = "Fullname"; String propName = hint; int i = 0; while (auth.hasProperty(propName)) { propName = hint + i; i++; } assertNull(auth.getProperty(propName)); assertFalse(auth.hasProperty(propName)); }
private Group createGroup(Principal p) throws RepositoryException, NotExecutableException { Group gr = userMgr.createGroup(p); save(superuser); return gr; }
private Group createGroup(Principal p) throws RepositoryException, NotExecutableException { Group gr = userMgr.createGroup(p); save(superuser); return gr; }
public void testRemoveNotExistingProperty() throws RepositoryException, NotExecutableException { Authorizable auth = getTestUser(superuser); String hint = "Fullname"; String propName = hint; int i = 0; while (auth.hasProperty(propName)) { propName = hint + i; i++; } assertFalse(auth.removeProperty(propName)); save(superuser); }
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); } }
private boolean removeMember(Group gr, Authorizable member) throws RepositoryException, NotExecutableException { boolean removed = gr.removeMember(member); save(superuser); return removed; }
public void testUserHasCredentials() throws RepositoryException, NotExecutableException { User user = getTestUser(superuser); Credentials creds = user.getCredentials(); assertTrue(creds != null); }
public void testUnknownCannotImpersonate() throws RepositoryException { Principal test = getTestPrincipal(); Subject subject = createSubject(test); assertFalse("An unknown principal should not be allowed to impersonate.", impersonation.allows(subject)); }
public void testCannotGrantImpersonationForAdministrator() throws RepositoryException, NotExecutableException { User admin = getTestUser(superuser); try { assertFalse(impersonation.grantImpersonation(admin.getPrincipal())); } finally { impersonation.revokeImpersonation(admin.getPrincipal()); } }
private User createUser(String uid, String pw) throws RepositoryException, NotExecutableException { User u = userMgr.createUser(uid, pw); save(superuser); return u; }
private Group createGroup(Principal p, String iPath) throws RepositoryException, NotExecutableException { Group gr = userMgr.createGroup(p, iPath); save(superuser); return gr; }
public void testAdministratorCanImpersonate() throws RepositoryException, NotExecutableException { User admin = getTestUser(superuser); Subject subject = createSubject(admin); assertTrue(impersonation.allows(subject)); }
public void testCannotRevokeImpersonationForAdministrator() throws RepositoryException, NotExecutableException { User admin = getTestUser(superuser); assertFalse(impersonation.revokeImpersonation(admin.getPrincipal())); }