Search in sources :

Example 6 with AdminPrincipal

use of org.apache.jackrabbit.oak.spi.security.principal.AdminPrincipal in project jackrabbit-oak by apache.

the class CugExcludeDefaultTest method testAdminPrincipal.

@Test
public void testAdminPrincipal() {
    Set<Principal> principals = ImmutableSet.<Principal>of(new AdminPrincipal() {

        @Override
        public String getName() {
            return "admin";
        }
    });
    assertTrue(exclude.isExcluded(principals));
}
Also used : AdminPrincipal(org.apache.jackrabbit.oak.spi.security.principal.AdminPrincipal) SystemPrincipal(org.apache.jackrabbit.oak.spi.security.principal.SystemPrincipal) SystemUserPrincipal(org.apache.jackrabbit.oak.spi.security.principal.SystemUserPrincipal) AdminPrincipal(org.apache.jackrabbit.oak.spi.security.principal.AdminPrincipal) Principal(java.security.Principal) ItemBasedPrincipal(org.apache.jackrabbit.api.security.principal.ItemBasedPrincipal) Test(org.junit.Test)

Example 7 with AdminPrincipal

use of org.apache.jackrabbit.oak.spi.security.principal.AdminPrincipal in project jackrabbit-oak by apache.

the class AdminPrincipalsBaseTest method testAdminAuthInfoPrincipals.

@Test
public void testAdminAuthInfoPrincipals() throws Exception {
    try {
        for (Principal p : adminSession.getAuthInfo().getPrincipals()) {
            if (p instanceof AdminPrincipal) {
                boolean success = acl.addAccessControlEntry(p, privilegesFromNames(PrivilegeConstants.JCR_READ));
                assertResult(success);
            }
        }
    } catch (AccessControlException e) {
        assertException();
    }
}
Also used : AdminPrincipal(org.apache.jackrabbit.oak.spi.security.principal.AdminPrincipal) AccessControlException(javax.jcr.security.AccessControlException) SystemPrincipal(org.apache.jackrabbit.oak.spi.security.principal.SystemPrincipal) AdminPrincipal(org.apache.jackrabbit.oak.spi.security.principal.AdminPrincipal) Principal(java.security.Principal) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 8 with AdminPrincipal

use of org.apache.jackrabbit.oak.spi.security.principal.AdminPrincipal in project jackrabbit-oak by apache.

the class AbstractPrincipalProviderTest method testAdminPrincipal.

@Test
public void testAdminPrincipal() throws Exception {
    String userId = adminSession.getAuthInfo().getUserID();
    Authorizable admin = getUserManager(root).getAuthorizable(userId);
    if (admin != null && admin.getPrincipal() instanceof AdminPrincipal) {
        Principal principal = principalProvider.getPrincipal(admin.getPrincipal().getName());
        assertTrue(principal instanceof AdminPrincipal);
        Set<? extends Principal> principals = principalProvider.getPrincipals(userId);
        boolean containsAdminPrincipal = false;
        for (Principal p : principals) {
            if (p instanceof AdminPrincipal) {
                containsAdminPrincipal = true;
                break;
            }
        }
        assertTrue(containsAdminPrincipal);
    }
}
Also used : AdminPrincipal(org.apache.jackrabbit.oak.spi.security.principal.AdminPrincipal) Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) AdminPrincipal(org.apache.jackrabbit.oak.spi.security.principal.AdminPrincipal) EveryonePrincipal(org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal) SystemUserPrincipal(org.apache.jackrabbit.oak.spi.security.principal.SystemUserPrincipal) Principal(java.security.Principal) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 9 with AdminPrincipal

use of org.apache.jackrabbit.oak.spi.security.principal.AdminPrincipal in project jackrabbit-oak by apache.

the class ImpersonationImplEmptyTest method testAllowsAdminPrincipal2.

@Test
public void testAllowsAdminPrincipal2() throws Exception {
    Subject subject = new Subject(true, ImmutableSet.of(new AdminPrincipal() {

        @Override
        public String getName() {
            return "principalName";
        }
    }), ImmutableSet.of(), ImmutableSet.of());
    assertTrue(impersonation.allows(subject));
}
Also used : AdminPrincipal(org.apache.jackrabbit.oak.spi.security.principal.AdminPrincipal) Subject(javax.security.auth.Subject) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 10 with AdminPrincipal

use of org.apache.jackrabbit.oak.spi.security.principal.AdminPrincipal in project jackrabbit-oak by apache.

the class UserInitializerTest method testAnonymous.

@Test
public void testAnonymous() throws Exception {
    Authorizable a = userMgr.getAuthorizable(UserUtil.getAnonymousId(config));
    assertFalse(a.isGroup());
    User anonymous = (User) a;
    assertFalse(anonymous.isAdmin());
    assertFalse(anonymous.getPrincipal() instanceof AdminPrincipal);
    assertTrue(anonymous.getPrincipal() instanceof TreeBasedPrincipal);
    assertEquals(anonymous.getID(), anonymous.getPrincipal().getName());
}
Also used : AdminPrincipal(org.apache.jackrabbit.oak.spi.security.principal.AdminPrincipal) User(org.apache.jackrabbit.api.security.user.User) Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Aggregations

AdminPrincipal (org.apache.jackrabbit.oak.spi.security.principal.AdminPrincipal)12 Test (org.junit.Test)9 Principal (java.security.Principal)7 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)7 Authorizable (org.apache.jackrabbit.api.security.user.Authorizable)4 Subject (javax.security.auth.Subject)3 User (org.apache.jackrabbit.api.security.user.User)3 SystemPrincipal (org.apache.jackrabbit.oak.spi.security.principal.SystemPrincipal)3 SystemUserPrincipal (org.apache.jackrabbit.oak.spi.security.principal.SystemUserPrincipal)3 PrivilegedActionException (java.security.PrivilegedActionException)2 PrivilegedExceptionAction (java.security.PrivilegedExceptionAction)2 RepositoryException (javax.jcr.RepositoryException)2 Session (javax.jcr.Session)2 AccessControlException (javax.jcr.security.AccessControlException)2 Impersonation (org.apache.jackrabbit.api.security.user.Impersonation)2 AuthInfo (org.apache.jackrabbit.oak.api.AuthInfo)2 AuthInfoImpl (org.apache.jackrabbit.oak.spi.security.authentication.AuthInfoImpl)2 EveryonePrincipal (org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal)2 HashMap (java.util.HashMap)1 JackrabbitRepository (org.apache.jackrabbit.api.JackrabbitRepository)1