Search in sources :

Example 1 with SystemUserPrincipal

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

the class CugConfigurationTest method testExcludedPrincipals.

@Test
public void testExcludedPrincipals() {
    ConfigurationParameters params = ConfigurationParameters.of(CugConstants.PARAM_CUG_ENABLED, true, CugConstants.PARAM_CUG_SUPPORTED_PATHS, "/content");
    CugConfiguration cc = createConfiguration(params);
    List<Principal> excluded = ImmutableList.of(SystemPrincipal.INSTANCE, new AdminPrincipal() {

        @Override
        public String getName() {
            return "admin";
        }
    }, new SystemUserPrincipal() {

        @Override
        public String getName() {
            return "systemUser";
        }
    });
    for (Principal p : excluded) {
        Set<Principal> principals = ImmutableSet.of(p, EveryonePrincipal.getInstance());
        PermissionProvider pp = cc.getPermissionProvider(root, "default", principals);
        assertSame(EmptyPermissionProvider.getInstance(), pp);
    }
}
Also used : AdminPrincipal(org.apache.jackrabbit.oak.spi.security.principal.AdminPrincipal) SystemUserPrincipal(org.apache.jackrabbit.oak.spi.security.principal.SystemUserPrincipal) EmptyPermissionProvider(org.apache.jackrabbit.oak.spi.security.authorization.permission.EmptyPermissionProvider) PermissionProvider(org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider) ConfigurationParameters(org.apache.jackrabbit.oak.spi.security.ConfigurationParameters) AdminPrincipal(org.apache.jackrabbit.oak.spi.security.principal.AdminPrincipal) EveryonePrincipal(org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal) SystemPrincipal(org.apache.jackrabbit.oak.spi.security.principal.SystemPrincipal) SystemUserPrincipal(org.apache.jackrabbit.oak.spi.security.principal.SystemUserPrincipal) Principal(java.security.Principal) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 2 with SystemUserPrincipal

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

the class SystemUserImplTest method testGetPrincipal.

@Test
public void testGetPrincipal() throws Exception {
    User user = createUser(null);
    assertTrue(user.getPrincipal() instanceof SystemUserPrincipal);
}
Also used : SystemUserPrincipal(org.apache.jackrabbit.oak.spi.security.principal.SystemUserPrincipal) User(org.apache.jackrabbit.api.security.user.User) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 3 with SystemUserPrincipal

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

the class CugExcludeDefaultTest method testMixedPrincipals.

@Test
public void testMixedPrincipals() {
    Set<Principal> principals = new HashSet<Principal>();
    principals.add(new PrincipalImpl("test"));
    principals.add(new SystemUserPrincipal() {

        @Override
        public String getName() {
            return "test";
        }
    });
    assertTrue(exclude.isExcluded(principals));
}
Also used : SystemUserPrincipal(org.apache.jackrabbit.oak.spi.security.principal.SystemUserPrincipal) 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) PrincipalImpl(org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 4 with SystemUserPrincipal

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

the class CugExcludeDefaultTest method testSystemUserPrincipal.

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

        @Override
        public String getName() {
            return "test";
        }
    });
    assertTrue(exclude.isExcluded(principals));
}
Also used : SystemUserPrincipal(org.apache.jackrabbit.oak.spi.security.principal.SystemUserPrincipal) 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 5 with SystemUserPrincipal

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

the class AbstractPrincipalProviderTest method testSystemUserPrincipal.

@Test
public void testSystemUserPrincipal() throws Exception {
    User user = getUserManager(root).createSystemUser("testSystemUser" + UUID.randomUUID(), null);
    root.commit();
    try {
        Principal principal = principalProvider.getPrincipal(user.getPrincipal().getName());
        assertNotNull(principal);
        assertTrue(principal instanceof SystemUserPrincipal);
    } finally {
        user.remove();
        root.commit();
    }
}
Also used : SystemUserPrincipal(org.apache.jackrabbit.oak.spi.security.principal.SystemUserPrincipal) User(org.apache.jackrabbit.api.security.user.User) 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)

Aggregations

SystemUserPrincipal (org.apache.jackrabbit.oak.spi.security.principal.SystemUserPrincipal)5 Test (org.junit.Test)5 Principal (java.security.Principal)4 AdminPrincipal (org.apache.jackrabbit.oak.spi.security.principal.AdminPrincipal)4 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)3 SystemPrincipal (org.apache.jackrabbit.oak.spi.security.principal.SystemPrincipal)3 ItemBasedPrincipal (org.apache.jackrabbit.api.security.principal.ItemBasedPrincipal)2 User (org.apache.jackrabbit.api.security.user.User)2 EveryonePrincipal (org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal)2 HashSet (java.util.HashSet)1 ConfigurationParameters (org.apache.jackrabbit.oak.spi.security.ConfigurationParameters)1 EmptyPermissionProvider (org.apache.jackrabbit.oak.spi.security.authorization.permission.EmptyPermissionProvider)1 PermissionProvider (org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider)1 PrincipalImpl (org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl)1