Search in sources :

Example 1 with ConfigurationParameters

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

the class ConfigurationInitializerTest method testInitBaseConfiguration.

@Test
public void testInitBaseConfiguration() {
    TestConfiguration sc = new TestConfiguration();
    SecurityConfiguration afterInit = ConfigurationInitializer.initializeConfiguration(sp, sc);
    assertSame(sc, afterInit);
    // verify securityprovider
    assertSame(sp, sc.getSecurityProvider());
    // verify params
    ConfigurationParameters parameters = afterInit.getParameters();
    assertTrue(parameters.containsKey("key"));
    assertTrue(parameters.containsKey("key2"));
    assertEquals("initialValue", parameters.get("key"));
    assertEquals("initialValue", parameters.get("key2"));
}
Also used : SecurityConfiguration(org.apache.jackrabbit.oak.spi.security.SecurityConfiguration) ConfigurationParameters(org.apache.jackrabbit.oak.spi.security.ConfigurationParameters) Test(org.junit.Test)

Example 2 with ConfigurationParameters

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

the class ValidatorNoProtectionTest method before.

@Override
public void before() throws Exception {
    super.before();
    ConfigurationParameters params = ConfigurationParameters.of(externalPrincipalConfiguration.getParameters(), ConfigurationParameters.of(ExternalIdentityConstants.PARAM_PROTECT_EXTERNAL_IDS, false));
    externalPrincipalConfiguration.setParameters(params);
}
Also used : ConfigurationParameters(org.apache.jackrabbit.oak.spi.security.ConfigurationParameters)

Example 3 with ConfigurationParameters

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

the class CugConfiguration method getPermissionProvider.

@Nonnull
@Override
public PermissionProvider getPermissionProvider(@Nonnull Root root, @Nonnull String workspaceName, @Nonnull Set<Principal> principals) {
    ConfigurationParameters params = getParameters();
    boolean enabled = params.getConfigValue(CugConstants.PARAM_CUG_ENABLED, false);
    if (!enabled || supportedPaths.isEmpty() || getExclude().isExcluded(principals)) {
        return EmptyPermissionProvider.getInstance();
    } else {
        return new CugPermissionProvider(root, workspaceName, principals, supportedPaths, getSecurityProvider().getConfiguration(AuthorizationConfiguration.class).getContext());
    }
}
Also used : ConfigurationParameters(org.apache.jackrabbit.oak.spi.security.ConfigurationParameters) Nonnull(javax.annotation.Nonnull)

Example 4 with ConfigurationParameters

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

the class CugImporter method init.

//----------------------------------------------< ProtectedItemImporter >---
@Override
public boolean init(@Nonnull Session session, @Nonnull Root root, @Nonnull NamePathMapper namePathMapper, boolean isWorkspaceImport, int uuidBehavior, @Nonnull ReferenceChangeTracker referenceTracker, @Nonnull SecurityProvider securityProvider) {
    if (initialized) {
        throw new IllegalStateException("Already initialized");
    }
    try {
        ConfigurationParameters config = securityProvider.getConfiguration(AuthorizationConfiguration.class).getParameters();
        supportedPaths = CugUtil.getSupportedPaths(config, mountInfoProvider);
        importBehavior = CugUtil.getImportBehavior(config);
        if (isWorkspaceImport) {
            PrincipalConfiguration pConfig = securityProvider.getConfiguration(PrincipalConfiguration.class);
            principalManager = pConfig.getPrincipalManager(root, namePathMapper);
        } else {
            principalManager = ((JackrabbitSession) session).getPrincipalManager();
        }
        initialized = true;
    } catch (RepositoryException e) {
        log.warn("Error while initializing cug importer", e);
    }
    return initialized;
}
Also used : AuthorizationConfiguration(org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration) PrincipalConfiguration(org.apache.jackrabbit.oak.spi.security.principal.PrincipalConfiguration) RepositoryException(javax.jcr.RepositoryException) ConfigurationParameters(org.apache.jackrabbit.oak.spi.security.ConfigurationParameters)

Example 5 with ConfigurationParameters

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

the class CugConfigurationTest method testExcludedPrincipals.

@Test
public void testExcludedPrincipals() {
    ConfigurationParameters params = ConfigurationParameters.of(CugConstants.PARAM_CUG_ENABLED, true, CugConstants.PARAM_CUG_SUPPORTED_PATHS, "/content");
    CugConfiguration cc = createConfiguration(params);
    List<Principal> excluded = ImmutableList.of(SystemPrincipal.INSTANCE, new AdminPrincipal() {

        @Override
        public String getName() {
            return "admin";
        }
    }, new SystemUserPrincipal() {

        @Override
        public String getName() {
            return "systemUser";
        }
    });
    for (Principal p : excluded) {
        Set<Principal> principals = ImmutableSet.of(p, EveryonePrincipal.getInstance());
        PermissionProvider pp = cc.getPermissionProvider(root, "default", principals);
        assertSame(EmptyPermissionProvider.getInstance(), pp);
    }
}
Also used : AdminPrincipal(org.apache.jackrabbit.oak.spi.security.principal.AdminPrincipal) SystemUserPrincipal(org.apache.jackrabbit.oak.spi.security.principal.SystemUserPrincipal) EmptyPermissionProvider(org.apache.jackrabbit.oak.spi.security.authorization.permission.EmptyPermissionProvider) PermissionProvider(org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider) ConfigurationParameters(org.apache.jackrabbit.oak.spi.security.ConfigurationParameters) AdminPrincipal(org.apache.jackrabbit.oak.spi.security.principal.AdminPrincipal) EveryonePrincipal(org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal) SystemPrincipal(org.apache.jackrabbit.oak.spi.security.principal.SystemPrincipal) SystemUserPrincipal(org.apache.jackrabbit.oak.spi.security.principal.SystemUserPrincipal) Principal(java.security.Principal) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

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