Search in sources :

Example 26 with Authorizable

use of org.apache.jackrabbit.api.security.user.Authorizable in project jackrabbit-oak by apache.

the class PrincipalProviderAutoMembershipTest method testGetGroupPrincipals.

@Test
public void testGetGroupPrincipals() throws Exception {
    Set<Principal> expected = getExpectedGroupPrincipals(USER_ID);
    Authorizable user = getUserManager(root).getAuthorizable(USER_ID);
    Set<java.security.acl.Group> result = principalProvider.getGroupMembership(user.getPrincipal());
    assertTrue(result.contains(autoMembershipGroup.getPrincipal()));
    assertEquals(expected, result);
}
Also used : Group(org.apache.jackrabbit.api.security.user.Group) Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) Principal(java.security.Principal) Test(org.junit.Test)

Example 27 with Authorizable

use of org.apache.jackrabbit.api.security.user.Authorizable in project jackrabbit-oak by apache.

the class ExternalGroupPrincipalProviderTest method testGetGroupMembershipExternalUser2.

@Test
public void testGetGroupMembershipExternalUser2() throws Exception {
    Authorizable user = getUserManager(root).getAuthorizable(USER_ID);
    assertNotNull(user);
    Set<Principal> expected = getExpectedGroupPrincipals(USER_ID);
    // same as in test before even if the principal is not a tree-based-principal
    Set<? extends Principal> principals = principalProvider.getGroupMembership(new PrincipalImpl(user.getPrincipal().getName()));
    assertEquals(expected, principals);
}
Also used : Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) Principal(java.security.Principal) PrincipalImpl(org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl) Test(org.junit.Test)

Example 28 with Authorizable

use of org.apache.jackrabbit.api.security.user.Authorizable in project jackrabbit-oak by apache.

the class ExternalGroupPrincipalProviderTest method testGetGroupMembershipExternalGroup.

@Test
public void testGetGroupMembershipExternalGroup() throws Exception {
    Authorizable group = getUserManager(root).getAuthorizable("secondGroup");
    assertNotNull(group);
    Set<? extends Principal> principals = principalProvider.getGroupMembership(group.getPrincipal());
    assertTrue(principals.isEmpty());
    // same if the principal is not marked as 'java.security.acl.Group' and not tree-based-principal
    principals = principalProvider.getGroupMembership(new PrincipalImpl(group.getPrincipal().getName()));
    assertTrue(principals.isEmpty());
}
Also used : Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) PrincipalImpl(org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl) Test(org.junit.Test)

Example 29 with Authorizable

use of org.apache.jackrabbit.api.security.user.Authorizable in project jackrabbit-oak by apache.

the class ExternalGroupPrincipalProviderTest method testGetGroupMembershipDefaultSync.

@Test
public void testGetGroupMembershipDefaultSync() throws Exception {
    // synchronized by default sync-context => no 'dynamic' group principals
    Authorizable user = getUserManager(root).getAuthorizable(TestIdentityProvider.ID_SECOND_USER);
    assertNotNull(user);
    Set<? extends Principal> principals = principalProvider.getGroupMembership(user.getPrincipal());
    assertTrue(principals.isEmpty());
}
Also used : Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) Test(org.junit.Test)

Example 30 with Authorizable

use of org.apache.jackrabbit.api.security.user.Authorizable in project jackrabbit-oak by apache.

the class ExternalGroupPrincipalProviderTest method testGetGroupMembershipDefaultSync2.

@Test
public void testGetGroupMembershipDefaultSync2() throws Exception {
    // synchronized by default sync-context => no 'dynamic' group principals
    Authorizable user = getUserManager(root).getAuthorizable(TestIdentityProvider.ID_SECOND_USER);
    assertNotNull(user);
    // same as in test before even if the principal is not a tree-based-principal
    Set<? extends Principal> principals = principalProvider.getGroupMembership(new PrincipalImpl(user.getPrincipal().getName()));
    assertTrue(principals.isEmpty());
}
Also used : Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) PrincipalImpl(org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl) Test(org.junit.Test)

Aggregations

Authorizable (org.apache.jackrabbit.api.security.user.Authorizable)466 Test (org.junit.Test)254 User (org.apache.jackrabbit.api.security.user.User)104 Group (org.apache.jackrabbit.api.security.user.Group)101 UserManager (org.apache.jackrabbit.api.security.user.UserManager)93 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)64 Principal (java.security.Principal)58 Node (javax.jcr.Node)55 RepositoryException (javax.jcr.RepositoryException)55 Query (org.apache.jackrabbit.api.security.user.Query)50 Session (javax.jcr.Session)49 JackrabbitSession (org.apache.jackrabbit.api.JackrabbitSession)45 Value (javax.jcr.Value)29 NodeImpl (org.apache.jackrabbit.core.NodeImpl)29 AbstractExternalAuthTest (org.apache.jackrabbit.oak.spi.security.authentication.external.AbstractExternalAuthTest)28 ExternalUser (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser)24 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)24 SimpleCredentials (javax.jcr.SimpleCredentials)21 HashMap (java.util.HashMap)18 QueryBuilder (org.apache.jackrabbit.api.security.user.QueryBuilder)16