Search in sources :

Example 66 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 67 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 68 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 69 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)

Example 70 with Authorizable

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

the class UserQueryManager method findAuthorizables.

@Nonnull
private Iterator<Authorizable> findAuthorizables(@Nonnull String statement, long limit, long offset, @Nullable AuthorizableType type) throws RepositoryException {
    try {
        Result query = root.getQueryEngine().executeQuery(statement, javax.jcr.query.Query.XPATH, limit, offset, NO_BINDINGS, namePathMapper.getSessionLocalMappings());
        Iterable<? extends ResultRow> resultRows = query.getRows();
        Iterator<Authorizable> authorizables = Iterators.transform(resultRows.iterator(), new ResultRowToAuthorizable(userManager, root, type));
        return Iterators.filter(authorizables, new UniqueResultPredicate());
    } catch (ParseException e) {
        log.warn("Invalid user query: " + statement, e);
        throw new RepositoryException(e);
    }
}
Also used : Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) RepositoryException(javax.jcr.RepositoryException) ParseException(java.text.ParseException) Result(org.apache.jackrabbit.oak.api.Result) Nonnull(javax.annotation.Nonnull)

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