Search in sources :

Example 16 with ConfigurationParameters

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

the class UserInitializerTest method testAnonymousConfiguration.

/**
     * @since OAK 1.0 The anonymous user is optional.
     */
@Test
public void testAnonymousConfiguration() throws Exception {
    Map<String, Object> userParams = new HashMap();
    userParams.put(UserConstants.PARAM_ANONYMOUS_ID, "");
    ConfigurationParameters params = ConfigurationParameters.of(UserConfiguration.NAME, ConfigurationParameters.of(userParams));
    SecurityProvider sp = new SecurityProviderImpl(params);
    final ContentRepository repo = new Oak().with(new InitialContent()).with(new PropertyIndexEditorProvider()).with(new PropertyIndexProvider()).with(new TypeEditorProvider()).with(sp).createContentRepository();
    ContentSession cs = Subject.doAs(SystemSubject.INSTANCE, new PrivilegedExceptionAction<ContentSession>() {

        @Override
        public ContentSession run() throws Exception {
            return repo.login(null, null);
        }
    });
    try {
        Root root = cs.getLatestRoot();
        UserConfiguration uc = sp.getConfiguration(UserConfiguration.class);
        UserManager umgr = uc.getUserManager(root, NamePathMapper.DEFAULT);
        Authorizable anonymous = umgr.getAuthorizable(UserConstants.DEFAULT_ANONYMOUS_ID);
        assertNull(anonymous);
    } finally {
        cs.close();
    }
    // login as admin should fail
    ContentSession anonymousSession = null;
    try {
        anonymousSession = repo.login(new GuestCredentials(), null);
        fail();
    } catch (LoginException e) {
    //success
    } finally {
        if (anonymousSession != null) {
            anonymousSession.close();
        }
    }
}
Also used : Root(org.apache.jackrabbit.oak.api.Root) HashMap(java.util.HashMap) PropertyIndexEditorProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider) ConfigurationParameters(org.apache.jackrabbit.oak.spi.security.ConfigurationParameters) LoginException(javax.security.auth.login.LoginException) InitialContent(org.apache.jackrabbit.oak.InitialContent) PropertyIndexProvider(org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexProvider) TypeEditorProvider(org.apache.jackrabbit.oak.plugins.nodetype.TypeEditorProvider) UserManager(org.apache.jackrabbit.api.security.user.UserManager) SecurityProvider(org.apache.jackrabbit.oak.spi.security.SecurityProvider) ContentRepository(org.apache.jackrabbit.oak.api.ContentRepository) Oak(org.apache.jackrabbit.oak.Oak) ContentSession(org.apache.jackrabbit.oak.api.ContentSession) Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) LoginException(javax.security.auth.login.LoginException) SecurityProviderImpl(org.apache.jackrabbit.oak.security.SecurityProviderImpl) GuestCredentials(javax.jcr.GuestCredentials) UserConfiguration(org.apache.jackrabbit.oak.spi.security.user.UserConfiguration) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 17 with ConfigurationParameters

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

the class QueryUtilTest method testGetSearchRoot.

@Test
public void testGetSearchRoot() {
    ConfigurationParameters params = ConfigurationParameters.of(UserConstants.PARAM_USER_PATH, "/configured/user/path", UserConstants.PARAM_GROUP_PATH, "/configured/group/path");
    Map<AuthorizableType, String> paths = ImmutableMap.of(AuthorizableType.USER, "/configured/user/path", AuthorizableType.GROUP, "/configured/group/path", AuthorizableType.AUTHORIZABLE, "/configured");
    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 18 with ConfigurationParameters

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

the class QueryUtilTest method testGetSearchRootGroupPathParentOfUser.

@Test
public void testGetSearchRootGroupPathParentOfUser() {
    ConfigurationParameters params = ConfigurationParameters.of(UserConstants.PARAM_USER_PATH, "/configured/groups/users", UserConstants.PARAM_GROUP_PATH, "/configured/groups");
    Map<AuthorizableType, String> paths = ImmutableMap.of(AuthorizableType.USER, "/configured/groups/users", AuthorizableType.GROUP, "/configured/groups", AuthorizableType.AUTHORIZABLE, "/configured/groups");
    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 19 with ConfigurationParameters

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

the class LdapIdentityProvider method activate.

//----------------------------------------------------< SCR integration >---
@SuppressWarnings("UnusedDeclaration")
@Activate
private void activate(Map<String, Object> properties) {
    ConfigurationParameters cfg = ConfigurationParameters.of(properties);
    config = LdapProviderConfig.of(cfg);
    init();
}
Also used : ConfigurationParameters(org.apache.jackrabbit.oak.spi.security.ConfigurationParameters) Activate(org.apache.felix.scr.annotations.Activate)

Example 20 with ConfigurationParameters

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

the class CugImportBaseTest method before.

@Before
public void before() throws Exception {
    ConfigurationParameters config = getConfigurationParameters();
    SecurityProvider securityProvider = new CugSecurityProvider(config);
    QueryEngineSettings queryEngineSettings = new QueryEngineSettings();
    queryEngineSettings.setFailTraversal(true);
    Jcr jcr = new Jcr();
    jcr.with(securityProvider);
    jcr.with(queryEngineSettings);
    repo = jcr.createRepository();
    adminSession = repo.login(new SimpleCredentials(UserConstants.DEFAULT_ADMIN_ID, UserConstants.DEFAULT_ADMIN_ID.toCharArray()));
    adminSession.getRootNode().addNode(TEST_NODE_NAME, NodeTypeConstants.NT_OAK_UNSTRUCTURED);
    adminSession.save();
}
Also used : SimpleCredentials(javax.jcr.SimpleCredentials) QueryEngineSettings(org.apache.jackrabbit.oak.query.QueryEngineSettings) SecurityProvider(org.apache.jackrabbit.oak.spi.security.SecurityProvider) Jcr(org.apache.jackrabbit.oak.jcr.Jcr) ConfigurationParameters(org.apache.jackrabbit.oak.spi.security.ConfigurationParameters) Before(org.junit.Before)

Aggregations

ConfigurationParameters (org.apache.jackrabbit.oak.spi.security.ConfigurationParameters)44 Test (org.junit.Test)24 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)11 SimpleCredentials (javax.jcr.SimpleCredentials)6 SecurityProvider (org.apache.jackrabbit.oak.spi.security.SecurityProvider)6 Activate (org.apache.felix.scr.annotations.Activate)4 Tree (org.apache.jackrabbit.oak.api.Tree)4 SecurityProviderImpl (org.apache.jackrabbit.oak.security.SecurityProviderImpl)4 AuthorizableType (org.apache.jackrabbit.oak.spi.security.user.AuthorizableType)4 UserConfiguration (org.apache.jackrabbit.oak.spi.security.user.UserConfiguration)4 Before (org.junit.Before)4 HashMap (java.util.HashMap)3 Nonnull (javax.annotation.Nonnull)3 LoginException (javax.security.auth.login.LoginException)3 Authorizable (org.apache.jackrabbit.api.security.user.Authorizable)3 UserManager (org.apache.jackrabbit.api.security.user.UserManager)3 ContentSession (org.apache.jackrabbit.oak.api.ContentSession)3 Root (org.apache.jackrabbit.oak.api.Root)3 Jcr (org.apache.jackrabbit.oak.jcr.Jcr)3 PropertyIndexProvider (org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexProvider)3