Search in sources :

Example 41 with ConfigurationParameters

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

the class CustomLoginModule method initialize.

@Override
public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState, Map<String, ?> options) {
    if (options != null) {
        ConfigurationParameters opts = ConfigurationParameters.of(options);
        config = (config == null) ? opts : ConfigurationParameters.of(config, opts);
    }
// EXERCISE
}
Also used : ConfigurationParameters(org.apache.jackrabbit.oak.spi.security.ConfigurationParameters)

Example 42 with ConfigurationParameters

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

the class CustomExternalIdentityProvider method activate.

//----------------------------------------------------< SCR integration >---
@SuppressWarnings("UnusedDeclaration")
@Activate
public void activate(Map<String, Object> properties) {
    ConfigurationParameters config = ConfigurationParameters.of(properties);
    for (String entry : config.getConfigValue("externalidentities", Collections.<String>emptySet())) {
        String[] strs = Text.explode(entry, ',', false);
        String uid = strs[0].trim();
        Set<String> declaredGroups = new HashSet<String>();
        if (strs.length > 1) {
            for (int i = 1; i < strs.length; i++) {
                groupIds.add(strs[i]);
                declaredGroups.add(strs[i]);
            }
        }
        userGroupMap.put(uid, declaredGroups);
    }
    log.info("activated IDP: " + getName());
}
Also used : ConfigurationParameters(org.apache.jackrabbit.oak.spi.security.ConfigurationParameters) HashSet(java.util.HashSet) Activate(org.apache.felix.scr.annotations.Activate)

Example 43 with ConfigurationParameters

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

the class ImportIgnoreTest method before.

@Before
public void before() throws Exception {
    String importBehavior = getImportBehavior();
    SecurityProvider securityProvider;
    if (importBehavior != null) {
        Map<String, String> params = new HashMap<String, String>();
        params.put(ProtectedItemImporter.PARAM_IMPORT_BEHAVIOR, getImportBehavior());
        ConfigurationParameters config = ConfigurationParameters.of(AuthorizationConfiguration.NAME, ConfigurationParameters.of(params));
        securityProvider = new SecurityProviderImpl(config);
    } else {
        securityProvider = new SecurityProviderImpl();
    }
    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()));
    target = adminSession.getRootNode().addNode("nodeName1");
    target.addMixin("rep:AccessControllable");
    adminSession.save();
}
Also used : SimpleCredentials(javax.jcr.SimpleCredentials) HashMap(java.util.HashMap) QueryEngineSettings(org.apache.jackrabbit.oak.query.QueryEngineSettings) SecurityProvider(org.apache.jackrabbit.oak.spi.security.SecurityProvider) Jcr(org.apache.jackrabbit.oak.jcr.Jcr) SecurityProviderImpl(org.apache.jackrabbit.oak.security.SecurityProviderImpl) ConfigurationParameters(org.apache.jackrabbit.oak.spi.security.ConfigurationParameters) Before(org.junit.Before)

Example 44 with ConfigurationParameters

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

the class AbstractImportTest method before.

@Before
public void before() throws Exception {
    ConfigurationParameters config = getConfigurationParameters();
    if (config != null) {
        securityProvider = new SecurityProviderImpl(config);
    } else {
        securityProvider = new SecurityProviderImpl();
    }
    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()));
    if (!(adminSession instanceof JackrabbitSession)) {
        throw new NotExecutableException();
    }
    userMgr = ((JackrabbitSession) adminSession).getUserManager();
    preTestAuthorizables.clear();
    Iterator<Authorizable> iter = userMgr.findAuthorizables("rep:principalName", null);
    while (iter.hasNext()) {
        String id = iter.next().getID();
        preTestAuthorizables.add(id);
    }
    // make sure the target node for group-import exists
    Authorizable administrators = userMgr.getAuthorizable(ADMINISTRATORS);
    if (userMgr.getAuthorizable(ADMINISTRATORS) == null) {
        userMgr.createGroup(new PrincipalImpl(ADMINISTRATORS));
    } else if (!administrators.isGroup()) {
        throw new NotExecutableException("Expected " + administrators.getID() + " to be a group.");
    }
    adminSession.save();
}
Also used : SimpleCredentials(javax.jcr.SimpleCredentials) NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) QueryEngineSettings(org.apache.jackrabbit.oak.query.QueryEngineSettings) Jcr(org.apache.jackrabbit.oak.jcr.Jcr) Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) SecurityProviderImpl(org.apache.jackrabbit.oak.security.SecurityProviderImpl) ConfigurationParameters(org.apache.jackrabbit.oak.spi.security.ConfigurationParameters) JackrabbitSession(org.apache.jackrabbit.api.JackrabbitSession) PrincipalImpl(org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl) 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