Search in sources :

Example 6 with AuthorizableType

use of org.apache.jackrabbit.oak.spi.security.user.AuthorizableType in project jackrabbit-oak by apache.

the class ResultRowToAuthorizable method getAuthorizable.

//------------------------------------------------------------< private >---
@CheckForNull
private Authorizable getAuthorizable(@CheckForNull ResultRow row) {
    Authorizable authorizable = null;
    if (row != null) {
        String resultPath = row.getValue(QueryImpl.JCR_PATH).getValue(Type.STRING);
        try {
            Tree tree = root.getTree(resultPath);
            AuthorizableType type = UserUtil.getType(tree);
            while (tree.exists() && !tree.isRoot() && type == null) {
                tree = tree.getParent();
                type = UserUtil.getType(tree);
            }
            if (tree.exists() && (targetType == null || targetType == type)) {
                authorizable = userManager.getAuthorizable(tree);
            }
        } catch (RepositoryException e) {
            log.debug("Failed to access authorizable " + resultPath);
        }
    }
    return authorizable;
}
Also used : Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) Tree(org.apache.jackrabbit.oak.api.Tree) RepositoryException(javax.jcr.RepositoryException) AuthorizableType(org.apache.jackrabbit.oak.spi.security.user.AuthorizableType) CheckForNull(javax.annotation.CheckForNull)

Example 7 with AuthorizableType

use of org.apache.jackrabbit.oak.spi.security.user.AuthorizableType in project jackrabbit-oak by apache.

the class QueryUtilTest method testGetSearchRootUserPathParentOfGroup.

@Test
public void testGetSearchRootUserPathParentOfGroup() {
    ConfigurationParameters params = ConfigurationParameters.of(UserConstants.PARAM_USER_PATH, "/configured/users", UserConstants.PARAM_GROUP_PATH, "/configured/users/groups");
    Map<AuthorizableType, String> paths = ImmutableMap.of(AuthorizableType.USER, "/configured/users", AuthorizableType.GROUP, "/configured/users/groups", AuthorizableType.AUTHORIZABLE, "/configured/users");
    assertSearchRoot(paths, params);
}
Also used : ConfigurationParameters(org.apache.jackrabbit.oak.spi.security.ConfigurationParameters) AuthorizableType(org.apache.jackrabbit.oak.spi.security.user.AuthorizableType) Test(org.junit.Test)

Example 8 with AuthorizableType

use of org.apache.jackrabbit.oak.spi.security.user.AuthorizableType in project jackrabbit-oak by apache.

the class QueryUtilTest method assertSearchRoot.

private static void assertSearchRoot(@Nonnull Map<AuthorizableType, String> mapping, @Nonnull ConfigurationParameters params) {
    for (AuthorizableType type : mapping.keySet()) {
        String expected = QueryConstants.SEARCH_ROOT_PATH + mapping.get(type);
        assertEquals(expected, QueryUtil.getSearchRoot(type, params));
    }
}
Also used : AuthorizableType(org.apache.jackrabbit.oak.spi.security.user.AuthorizableType)

Example 9 with AuthorizableType

use of org.apache.jackrabbit.oak.spi.security.user.AuthorizableType in project jackrabbit-oak by apache.

the class QueryUtilTest method testGetSearchRootNoCommonAncestor.

@Test
public void testGetSearchRootNoCommonAncestor() {
    ConfigurationParameters params = ConfigurationParameters.of(UserConstants.PARAM_USER_PATH, "/users", UserConstants.PARAM_GROUP_PATH, "/groups");
    Map<AuthorizableType, String> paths = ImmutableMap.of(AuthorizableType.USER, "/users", AuthorizableType.GROUP, "/groups", AuthorizableType.AUTHORIZABLE, "/");
    assertSearchRoot(paths, params);
}
Also used : ConfigurationParameters(org.apache.jackrabbit.oak.spi.security.ConfigurationParameters) AuthorizableType(org.apache.jackrabbit.oak.spi.security.user.AuthorizableType) Test(org.junit.Test)

Example 10 with AuthorizableType

use of org.apache.jackrabbit.oak.spi.security.user.AuthorizableType in project jackrabbit-oak by apache.

the class UserUtilTest method testGetTypeFromTree.

@Test
public void testGetTypeFromTree() {
    Map<String, AuthorizableType> test = ImmutableMap.of(UserConstants.NT_REP_GROUP, AuthorizableType.GROUP, UserConstants.NT_REP_USER, AuthorizableType.USER, UserConstants.NT_REP_SYSTEM_USER, AuthorizableType.USER);
    for (String ntName : test.keySet()) {
        AuthorizableType expected = test.get(ntName);
        assertEquals(ntName, expected, UserUtil.getType(createTree(ntName)));
    }
}
Also used : AuthorizableType(org.apache.jackrabbit.oak.spi.security.user.AuthorizableType) Test(org.junit.Test)

Aggregations

AuthorizableType (org.apache.jackrabbit.oak.spi.security.user.AuthorizableType)10 Test (org.junit.Test)6 ConfigurationParameters (org.apache.jackrabbit.oak.spi.security.ConfigurationParameters)4 Authorizable (org.apache.jackrabbit.api.security.user.Authorizable)2 Tree (org.apache.jackrabbit.oak.api.Tree)2 Principal (java.security.Principal)1 ParseException (java.text.ParseException)1 CheckForNull (javax.annotation.CheckForNull)1 Nonnull (javax.annotation.Nonnull)1 RepositoryException (javax.jcr.RepositoryException)1 Group (org.apache.jackrabbit.api.security.user.Group)1 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)1 Result (org.apache.jackrabbit.oak.api.Result)1 EveryonePrincipal (org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal)1 SystemPrincipal (org.apache.jackrabbit.oak.spi.security.principal.SystemPrincipal)1