public Map<String, Map<String, Object>> getPropertyMetadataAndValuesAsMap() { Map<String, Map<String, Object>> configMap = new HashMap<>(); for (ConfigurationProperty property : this) { Map<String, Object> mapValue = new HashMap<>(); mapValue.put("isSecure", property.isSecure()); if (property.isSecure()) { mapValue.put(VALUE_KEY, property.getEncryptedValue()); } else { mapValue.put(VALUE_KEY, property.getConfigurationValue().getValue()); } mapValue.put("displayValue", property.getDisplayValue()); configMap.put(property.getConfigKeyName(), mapValue); } return configMap; }
@Override public List<TaskProperty> getPropertiesForDisplay() { ArrayList<TaskProperty> taskProperties = new ArrayList<>(); if (PluggableTaskConfigStore.store().hasPreferenceFor(pluginConfiguration.getId())) { TaskPreference preference = taskPreference(); List<? extends Property> propertyDefinitions = preference.getConfig().list(); for (Property propertyDefinition : propertyDefinitions) { ConfigurationProperty configuredProperty = configuration.getProperty(propertyDefinition.getKey()); if (configuredProperty == null) continue; taskProperties.add(new TaskProperty(propertyDefinition.getOption(Property.DISPLAY_NAME), configuredProperty.getDisplayValue(), configuredProperty.getConfigKeyName())); } return taskProperties; } for (ConfigurationProperty property : configuration) { taskProperties.add(new TaskProperty(property.getConfigKeyName(), property.getDisplayValue())); } return taskProperties; }
@Test public void shouldGetMaskedStringIfConfigurationPropertyIsSecure() { assertThat(new ConfigurationProperty(new ConfigurationKey("key"), new EncryptedConfigurationValue("value")).getDisplayValue(), is("****")); assertThat(new ConfigurationProperty(new ConfigurationKey("key"), new ConfigurationValue("value")).getDisplayValue(), is("value")); } }