use of org.apache.jackrabbit.core.security.principal.AdminPrincipal in project jackrabbit by apache.
the class SessionFactory method createAdminSession.
public SessionImpl createAdminSession(String workspace) throws RepositoryException {
Principal admin = new AdminPrincipal(SecurityConstants.ADMIN_ID);
Subject subject = new Subject(true, Collections.singleton(admin), Collections.emptySet(), Collections.emptySet());
return context.getRepository().createSession(subject, workspace);
}
use of org.apache.jackrabbit.core.security.principal.AdminPrincipal in project jackrabbit by apache.
the class AdministratorTest method testGetPrincipal.
public void testGetPrincipal() throws RepositoryException {
Authorizable admin = userMgr.getAuthorizable(adminId);
assertNotNull(admin);
assertFalse(admin.isGroup());
assertTrue(admin.getPrincipal() instanceof AdminPrincipal);
}
use of org.apache.jackrabbit.core.security.principal.AdminPrincipal in project jackrabbit by apache.
the class ImpersonationImplTest method testAdminPrincipalAsImpersonator.
public void testAdminPrincipalAsImpersonator() throws RepositoryException, NotExecutableException {
String adminId = superuser.getUserID();
Authorizable a = userMgr.getAuthorizable(adminId);
if (a == null || a.isGroup() || !((User) a).isAdmin()) {
throw new NotExecutableException(adminId + " is not administators ID");
}
Principal adminPrincipal = new AdminPrincipal(adminId);
// admin cannot be add/remove to set of impersonators of 'u' but is
// always allowed to impersonate that user.
User u = (User) userMgr.getAuthorizable(uID);
Impersonation impersonation = u.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) a).getImpersonation();
assertFalse(adminImpersonation.grantImpersonation(adminPrincipal));
assertFalse(adminImpersonation.revokeImpersonation(adminPrincipal));
assertTrue(impersonation.allows(buildSubject(adminPrincipal)));
}
Aggregations