Search in sources :

Example 11 with AuthorizationConfiguration

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

the class CugConfigurationOsgiTest method testCugExcludeAnyPrincipal.

@Test
public void testCugExcludeAnyPrincipal() {
    context.registerInjectActivateService(cugExclude, ImmutableMap.of("principalNames", new String[] { EXCLUDED_PRINCIPAL_NAME }));
    context.registerInjectActivateService(cugConfiguration, PROPERTIES);
    AuthorizationConfiguration config = context.getService(AuthorizationConfiguration.class);
    PermissionProvider permissionProvider = config.getPermissionProvider(root, wspName, ImmutableSet.of(new PrincipalImpl(ANY_PRINCIPAL_NAME)));
    assertTrue(permissionProvider instanceof CugPermissionProvider);
}
Also used : AuthorizationConfiguration(org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration) EmptyPermissionProvider(org.apache.jackrabbit.oak.spi.security.authorization.permission.EmptyPermissionProvider) PermissionProvider(org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider) PrincipalImpl(org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 12 with AuthorizationConfiguration

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

the class CugConfigurationOsgiTest method testNoSupportedPaths.

@Test
public void testNoSupportedPaths() {
    context.registerInjectActivateService(cugExclude, ImmutableMap.of("principalNames", new String[] { ANY_PRINCIPAL_NAME }));
    context.registerInjectActivateService(cugConfiguration, ImmutableMap.of(CugConstants.PARAM_CUG_ENABLED, true, CugConstants.PARAM_CUG_SUPPORTED_PATHS, new String[0]));
    AuthorizationConfiguration config = context.getService(AuthorizationConfiguration.class);
    PermissionProvider permissionProvider = config.getPermissionProvider(root, wspName, ImmutableSet.of(new PrincipalImpl(ANY_PRINCIPAL_NAME)));
    assertSame(EmptyPermissionProvider.getInstance(), permissionProvider);
}
Also used : AuthorizationConfiguration(org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration) EmptyPermissionProvider(org.apache.jackrabbit.oak.spi.security.authorization.permission.EmptyPermissionProvider) PermissionProvider(org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider) PrincipalImpl(org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 13 with AuthorizationConfiguration

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

the class CugConfigurationOsgiTest method testCugExcludeExcludedPrincipal.

@Test
public void testCugExcludeExcludedPrincipal() {
    context.registerInjectActivateService(cugExclude, ImmutableMap.of("principalNames", new String[] { EXCLUDED_PRINCIPAL_NAME }));
    context.registerInjectActivateService(cugConfiguration, PROPERTIES);
    AuthorizationConfiguration config = context.getService(AuthorizationConfiguration.class);
    PermissionProvider permissionProvider = config.getPermissionProvider(root, wspName, ImmutableSet.of(new PrincipalImpl(EXCLUDED_PRINCIPAL_NAME)));
    assertSame(EmptyPermissionProvider.getInstance(), permissionProvider);
}
Also used : AuthorizationConfiguration(org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration) EmptyPermissionProvider(org.apache.jackrabbit.oak.spi.security.authorization.permission.EmptyPermissionProvider) PermissionProvider(org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider) PrincipalImpl(org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 14 with AuthorizationConfiguration

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

the class CompositeAuthorizationTest method newTestSecurityProvider.

private static SecurityProvider newTestSecurityProvider(int cnt) {
    SecurityProvider delegate = SecurityProviderBuilder.newBuilder().build();
    AuthorizationConfiguration authorizationConfiguration = delegate.getConfiguration(AuthorizationConfiguration.class);
    if (!(authorizationConfiguration instanceof CompositeAuthorizationConfiguration)) {
        throw new IllegalStateException();
    } else {
        CompositeAuthorizationConfiguration composite = (CompositeAuthorizationConfiguration) authorizationConfiguration;
        final AuthorizationConfiguration defConfig = checkNotNull(composite.getDefaultConfig());
        for (int i = 0; i < cnt; i++) {
            composite.addConfiguration(new TmpAuthorizationConfig(defConfig));
        }
        composite.addConfiguration(defConfig);
    }
    return delegate;
}
Also used : CompositeAuthorizationConfiguration(org.apache.jackrabbit.oak.security.authorization.composite.CompositeAuthorizationConfiguration) AuthorizationConfiguration(org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration) SecurityProvider(org.apache.jackrabbit.oak.spi.security.SecurityProvider) CompositeAuthorizationConfiguration(org.apache.jackrabbit.oak.security.authorization.composite.CompositeAuthorizationConfiguration)

Example 15 with AuthorizationConfiguration

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

the class AccessControlImporter 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");
    }
    if (!(session instanceof JackrabbitSession)) {
        return false;
    }
    try {
        AuthorizationConfiguration config = securityProvider.getConfiguration(AuthorizationConfiguration.class);
        importBehavior = Util.getImportBehavior(config);
        if (isWorkspaceImport) {
            acMgr = config.getAccessControlManager(root, namePathMapper);
            PrincipalConfiguration pConfig = securityProvider.getConfiguration(PrincipalConfiguration.class);
            principalManager = pConfig.getPrincipalManager(root, namePathMapper);
        } else {
            acMgr = session.getAccessControlManager();
            principalManager = ((JackrabbitSession) session).getPrincipalManager();
        }
        ntMgr = ReadOnlyNodeTypeManager.getInstance(root, namePathMapper);
        initialized = true;
    } catch (RepositoryException e) {
        log.warn("Error while initializing access control 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) JackrabbitSession(org.apache.jackrabbit.api.JackrabbitSession)

Aggregations

AuthorizationConfiguration (org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration)24 Test (org.junit.Test)11 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)10 PermissionProvider (org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider)8 CompositeAuthorizationConfiguration (org.apache.jackrabbit.oak.security.authorization.composite.CompositeAuthorizationConfiguration)6 SecurityProvider (org.apache.jackrabbit.oak.spi.security.SecurityProvider)6 EmptyPermissionProvider (org.apache.jackrabbit.oak.spi.security.authorization.permission.EmptyPermissionProvider)6 PrincipalImpl (org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl)5 Principal (java.security.Principal)3 Tree (org.apache.jackrabbit.oak.api.Tree)3 AuthorizationConfigurationImpl (org.apache.jackrabbit.oak.security.authorization.AuthorizationConfigurationImpl)3 Field (java.lang.reflect.Field)2 OpenAuthorizationConfiguration (org.apache.jackrabbit.oak.spi.security.authorization.OpenAuthorizationConfiguration)2 AggregatedPermissionProvider (org.apache.jackrabbit.oak.spi.security.authorization.permission.AggregatedPermissionProvider)2 RestrictionProvider (org.apache.jackrabbit.oak.spi.security.authorization.restriction.RestrictionProvider)2 ArrayList (java.util.ArrayList)1 Nonnull (javax.annotation.Nonnull)1 RepositoryException (javax.jcr.RepositoryException)1 AccessControlManager (javax.jcr.security.AccessControlManager)1 AccessControlPolicy (javax.jcr.security.AccessControlPolicy)1