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