use of java.util.Dictionary in project ddf by codice.
the class ConfigureTestCommons method configureEnforceValidityErrorsAndWarnings.
public static void configureEnforceValidityErrorsAndWarnings(String enforceErrors, String enforceWarnings, AdminConfig configAdmin) throws IOException {
Configuration config = configAdmin.getConfiguration(METACARD_VALIDATITY_MARKER_PLUGIN_SERVICE_PID, null);
Dictionary properties = new Hashtable<>();
properties.put("enforceErrors", enforceErrors);
properties.put("enforceWarnings", enforceWarnings);
config.update(properties);
}
use of java.util.Dictionary in project ddf by codice.
the class ConfigureTestCommons method configureMetacardValidityFilterPlugin.
public static void configureMetacardValidityFilterPlugin(List<String> securityAttributeMappings, AdminConfig configAdmin) throws IOException {
Configuration config = configAdmin.getConfiguration(METACARD_VALIDATITY_FILTER_PLUGIN_SERVICE_PID, null);
Dictionary properties = new Hashtable<>();
properties.put("attributeMap", securityAttributeMappings);
config.update(properties);
}
use of java.util.Dictionary in project ddf by codice.
the class TestSecurity method beforeTest.
@BeforeExam
public void beforeTest() throws Exception {
try {
waitForSystemReady();
Configuration config = getAdminConfig().getConfiguration("org.codice.ddf.admin.config.policy.AdminConfigPolicy");
config.setBundleLocation("mvn:ddf.admin.core/admin-core-configpolicy/" + System.getProperty("ddf.version"));
Dictionary properties = new Hashtable<>();
List<String> featurePolicies = new ArrayList<>();
featurePolicies.addAll(Arrays.asList(getDefaultRequiredApps()));
featurePolicies.addAll(FEATURES_TO_FILTER);
featurePolicies.replaceAll(featureName -> featureName + "=\"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/role=admin\"");
List<String> servicePolicies = new ArrayList<>();
servicePolicies.addAll(SERVICES_TO_FILTER);
servicePolicies.replaceAll(serviceName -> serviceName + "=\"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/role=admin\"");
properties.put("featurePolicies", featurePolicies.stream().toArray(String[]::new));
properties.put("servicePolicies", servicePolicies.stream().toArray(String[]::new));
config.update(properties);
} catch (Exception e) {
LoggingUtils.failWithThrowableStacktrace(e, "Failed in @BeforeExam: ");
}
}
use of java.util.Dictionary in project ddf by codice.
the class TestSecurity method testAccessGroupsGuest.
@Test
public void testAccessGroupsGuest() throws Exception {
List attr = ImmutableList.of("security.access-groups=http://schemas.xmlsoap.org/ws/2005/05/identity/claims/role");
Dictionary authZProperties = configureAuthZRealm(attr, getAdminConfig());
Dictionary metacardAttributeSecurityFilterProperties = null;
String url = null;
try {
String testData = IOUtils.toString(IOUtils.toInputStream(getFileContent(XML_RECORD_RESOURCE_PATH + "/accessGroupTokenMetacard.xml")));
testData = testData.replace(ACCESS_GROUP_REPLACE_TOKEN, "guest");
String id = CatalogTestCommons.ingest(testData, MediaType.TEXT_XML);
metacardAttributeSecurityFilterProperties = configureMetacardAttributeSecurityFiltering(attr, ImmutableList.of(""), getAdminConfig());
url = SERVICE_ROOT.getUrl() + "/catalog/query?q=" + id + "&src=local";
configureRestForGuest(SDK_SOAP_CONTEXT);
waitForSecurityHandlers(url);
getSecurityPolicy().waitForGuestAuthReady(url);
//anon guest
String response = getGuestRestResponseAsString(url);
assertThat(response, containsString("Lady Liberty"));
//configure for basic
configureRestForBasic(SDK_SOAP_CONTEXT);
waitForSecurityHandlers(url);
getSecurityPolicy().waitForBasicAuthReady(url);
//user with permissions gets results
response = getBasicRestResponseAsString(url, A_USER, USER_PASSWORD);
assertThat(response, containsString("Lady Liberty"));
//user without permissions gets results
response = getBasicRestResponseAsString(url, B_USER, USER_PASSWORD);
assertThat(response, containsString("Lady Liberty"));
} finally {
configureAuthZRealm(authZProperties, getAdminConfig());
if (metacardAttributeSecurityFilterProperties != null) {
configureMetacardAttributeSecurityFiltering(metacardAttributeSecurityFilterProperties, getAdminConfig());
}
configureRestForGuest(SDK_SOAP_CONTEXT);
getSecurityPolicy().waitForGuestAuthReady(url);
//metacard will be deleted in @After
}
}
use of java.util.Dictionary in project ddf by codice.
the class ConfigurationAdminExt method addConfigurationData.
private void addConfigurationData(Map<String, Object> service, Configuration[] configs) {
for (Configuration config : configs) {
// ignore configuration object if it is invalid
final String pid = config.getPid();
if (!isAllowedPid(pid)) {
continue;
}
Map<String, Object> configData = new HashMap<String, Object>();
configData.put(MAP_ENTRY_ID, pid);
String fpid = config.getFactoryPid();
if (fpid != null) {
configData.put(MAP_ENTRY_FPID, fpid);
}
// insert an entry for the PID
try {
ObjectClassDefinition ocd = getObjectClassDefinition(config);
if (ocd != null) {
configData.put(MAP_ENTRY_NAME, ocd.getName());
} else {
// no object class definition, use plain PID
configData.put(MAP_ENTRY_NAME, pid);
}
} catch (IllegalArgumentException t) {
// Catch exception thrown by getObjectClassDefinition so other configurations
// are displayed
// no object class definition, use plain PID
configData.put(MAP_ENTRY_NAME, pid);
}
final Bundle bundle = getBoundBundle(config);
if (null != bundle) {
configData.put(MAP_ENTRY_BUNDLE, bundle.getBundleId());
configData.put(MAP_ENTRY_BUNDLE_NAME, getName(bundle));
configData.put(MAP_ENTRY_BUNDLE_LOCATION, bundle.getLocation());
}
Map<String, Object> propertiesTable = new HashMap<String, Object>();
Dictionary<String, Object> properties = config.getProperties();
if (properties != null) {
Enumeration<String> keys = properties.keys();
while (keys.hasMoreElements()) {
String key = keys.nextElement();
propertiesTable.put(key, properties.get(key));
}
}
// If the configuration property is a password, set its value to "password" so that
// the real password value will be hidden.
List<HashMap<String, Object>> metatypeList = (List<HashMap<String, Object>>) service.get("metatype");
metatypeList.stream().filter(metatype -> AttributeDefinition.PASSWORD == (Integer) metatype.get("type")).forEach(metatype -> {
String passwordProperty = (String) metatype.get("id");
propertiesTable.put(passwordProperty, "password");
});
configData.put(MAP_ENTRY_PROPERTIES, propertiesTable);
Map<String, Object> pluginDataMap = getConfigurationPluginData(configData.get(MAP_ENTRY_ID).toString(), Collections.unmodifiableMap(configData));
if (pluginDataMap != null && !pluginDataMap.isEmpty()) {
configData.putAll(pluginDataMap);
}
List<Map<String, Object>> configurations = null;
if (service.containsKey(ENABLED_CONFIGURATION)) {
configurations = (List<Map<String, Object>>) service.get(ENABLED_CONFIGURATION);
} else if (service.containsKey(DISABLED_CONFIGURATION)) {
configurations = (List<Map<String, Object>>) service.get(DISABLED_CONFIGURATION);
} else {
configurations = new ArrayList<Map<String, Object>>();
}
configurations.add(configData);
if (((String) configData.get(MAP_ENTRY_ID)).contains(DISABLED_SERVICE_ID)) {
configData.put(ENABLED, false);
} else {
configData.put(ENABLED, true);
}
service.put(ENABLED_CONFIGURATION, configurations);
}
}
Aggregations