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);
}
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);
}
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);
}
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;
}
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;
}
Aggregations