Skip to content

Commit

Permalink
JCR-2931 : Compatibility issue if admin impersonates admin session
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/jackrabbit/trunk@1085070 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
anchela committed Mar 24, 2011
1 parent e25b054 commit 9f2fac4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,7 @@ public boolean allows(Subject subject) throws RepositoryException {
continue;
}
Authorizable a = userManager.getAuthorizable(p);
if (user.equals(a)) {
allows = false;
break;
} else if (a != null && userManager.isAdminId(a.getID())) {
if (a != null && userManager.isAdminId(a.getID())) {
allows = true;
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,15 @@ public void testImpersonatingOneself() throws RepositoryException {
assertFalse(impersonation.allows(subject));
}

/**
* @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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,11 @@ public void testAdminPrincipalAsImpersonator() throws RepositoryException, NotEx
assertTrue(impersonation.allows(buildSubject(adminPrincipal)));

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

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

public void testSystemPrincipalAsImpersonator() throws RepositoryException {
Expand Down

0 comments on commit 9f2fac4

Please sign in to comment.