Search in sources :

Example 21 with PrincipalImpl

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

the class L3_UserVsPrincipalTest method testLookup.

@Test
public void testLookup() throws RepositoryException {
    Map<String, Object[]> resultMap = ImmutableMap.of(testId, new Object[] { null, null, null }, testPrincipal.getName(), new Object[] { null, null, null }, testGroupId, new Object[] { null, null }, testGroupPrincipal.getName(), new Object[] { null, null });
    for (String key : resultMap.keySet()) {
        Object[] result = resultMap.get(key);
        // lookup principal by "ID"
        Principal expectedP = (Principal) result[0];
        Principal principal = principalManager.getPrincipal(key);
        assertEquals(expectedP, principal);
        // lookup authorizable by "principal"
        Principal p = new PrincipalImpl(key);
        Authorizable a = getUserManager(root).getAuthorizable(p);
        if (a != null) {
            assertEquals(expectedP, a.getPrincipal());
        }
        // lookup Authorizable by "ID"
        Authorizable expectedA = (Authorizable) result[1];
        a = getUserManager(root).getAuthorizable(key);
        assertEquals(expectedA, a);
    }
}
Also used : Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) Principal(java.security.Principal) PrincipalImpl(org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test) L2_AuthInfoTest(org.apache.jackrabbit.oak.exercise.security.authentication.L2_AuthInfoTest)

Example 22 with PrincipalImpl

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

the class RandomAuthorizableNodeNameTest method testCreateGroupWithPath.

@Test
public void testCreateGroupWithPath() throws Exception {
    Group group = getUserManager(root).createGroup(id, new PrincipalImpl(id), "a/b");
    root.commit();
    assertNodeName(group, "a/b");
}
Also used : Group(org.apache.jackrabbit.api.security.user.Group) PrincipalImpl(org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 23 with PrincipalImpl

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

the class CugExcludeDefaultTest method testPrincipals.

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

        @Override
        public String getPath() {
            return "/path";
        }

        @Override
        public String getName() {
            return "test";
        }
    });
    assertFalse(exclude.isExcluded(principals));
    for (Principal p : principals) {
        assertFalse(exclude.isExcluded(ImmutableSet.of(p)));
    }
}
Also used : ItemBasedPrincipal(org.apache.jackrabbit.api.security.principal.ItemBasedPrincipal) 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 24 with PrincipalImpl

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

the class CugExcludeImplTest method testExcludeAnother.

@Test
public void testExcludeAnother() {
    Map<String, Object> m = ImmutableMap.<String, Object>of("principalNames", principalNames);
    activate(m);
    assertFalse(exclude.isExcluded(ImmutableSet.<Principal>of(new PrincipalImpl("another"))));
}
Also used : Principal(java.security.Principal) PrincipalImpl(org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl) Test(org.junit.Test)

Example 25 with PrincipalImpl

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

the class CugExcludeImplTest method testExcludeTest.

@Test
public void testExcludeTest() {
    Map<String, Object> m = ImmutableMap.<String, Object>of("principalNames", principalNames);
    activate(m);
    Set<Principal> all = new HashSet<Principal>();
    for (String name : principalNames) {
        Principal p = new PrincipalImpl(name);
        assertTrue(exclude.isExcluded(ImmutableSet.of(p)));
        all.add(p);
        assertTrue(exclude.isExcluded(all));
    }
}
Also used : Principal(java.security.Principal) PrincipalImpl(org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

PrincipalImpl (org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl)96 Test (org.junit.Test)66 Principal (java.security.Principal)40 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)24 Group (org.apache.jackrabbit.api.security.user.Group)22 User (org.apache.jackrabbit.api.security.user.User)20 EveryonePrincipal (org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal)20 UserManager (org.apache.jackrabbit.api.security.user.UserManager)16 Authorizable (org.apache.jackrabbit.api.security.user.Authorizable)15 JackrabbitSession (org.apache.jackrabbit.api.JackrabbitSession)12 GroupPrincipal (org.apache.jackrabbit.api.security.principal.GroupPrincipal)11 Session (javax.jcr.Session)9 SimpleCredentials (javax.jcr.SimpleCredentials)7 ContentSession (org.apache.jackrabbit.oak.api.ContentSession)6 ExternalUser (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser)6 CugPolicy (org.apache.jackrabbit.oak.spi.security.authorization.cug.CugPolicy)6 HashSet (java.util.HashSet)5 ExternalGroup (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup)5 AuthorizationConfiguration (org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration)5 EmptyPermissionProvider (org.apache.jackrabbit.oak.spi.security.authorization.permission.EmptyPermissionProvider)5