public Map<String, String> getSettingsAsKeyValuePair() { Map<String, String> settingsAsKeyValuePair = new HashMap<>(); for (ConfigurationProperty configurationProperty : settingsMap) { settingsAsKeyValuePair.put(configurationProperty.getConfigKeyName(), configurationProperty.getValue()); } return settingsAsKeyValuePair; }
public Map<String, String> getConfigurationAsMap(boolean addSecureFields) { Map<String, String> configurationMap = new LinkedHashMap<>(); for (ConfigurationProperty currentConfiguration : this) { if (addSecureFields || !currentConfiguration.isSecure()) { configurationMap.put(currentConfiguration.getConfigKeyName(), currentConfiguration.getValue()); } } return configurationMap; }
public Map<String, Map<String, String>> configAsMap() { Map<String, Map<String, String>> configMap = new HashMap<>(); for (ConfigurationProperty property : configuration) { Map<String, String> mapValue = new HashMap<>(); mapValue.put(VALUE_KEY, property.getValue()); if (!property.errors().isEmpty()) { mapValue.put(ERRORS_KEY, StringUtils.join(property.errors().getAll(), ", ")); } configMap.put(property.getConfigKeyName(), mapValue); } return configMap; }
public void addConfigurations(PluginInfo pluginInfo, List<ConfigurationProperty> configurationProperties) { settingsMap.clear(); ConfigurationPropertyBuilder builder = new ConfigurationPropertyBuilder(); for (ConfigurationProperty property : configurationProperties) { ConfigurationProperty configurationProperty = builder.create(property.getConfigKeyName(), property.getConfigValue(), property.getEncryptedValue(), pluginInfo.isSecure(property.getConfigKeyName())); settingsMap.add(configurationProperty); } }
public Map<String, Map<String, String>> getConfigAsMap() { Map<String, Map<String, String>> configMap = new HashMap<>(); for (ConfigurationProperty property : configuration) { Map<String, String> mapValue = new HashMap<>(); mapValue.put(VALUE_KEY, property.getValue()); if (!property.errors().isEmpty()) { mapValue.put(ERRORS_KEY, StringUtils.join(property.errors().getAll(), ", ")); } configMap.put(property.getConfigKeyName(), mapValue); } return configMap; }
@PostConstruct public void applyPluginMetadata() { if (taskPreference() != null) { for (ConfigurationProperty configurationProperty : configuration) { if (isValidPluginConfiguration(configurationProperty.getConfigKeyName())) { Boolean isSecure = pluginConfigurationFor(configurationProperty.getConfigKeyName()).getOption(Property.SECURE); configurationProperty.handleSecureValueConfiguration(isSecure); } } } }
public void populateErrorMessageFor(String settingsKey, String errorMessage) { hasErrors = true; for (ConfigurationProperty configurationProperty : settingsMap) { if (configurationProperty.getConfigKeyName().equals(settingsKey)) { configurationProperty.addError(settingsKey, errorMessage); break; } } if (getErrorFor(settingsKey) == null) { addError(settingsKey, errorMessage); } }
@PostConstruct public void encryptSecureConfigurations() { if (hasPluginInfo()) { for (ConfigurationProperty configuration : this) { configuration.handleSecureValueConfiguration(isSecure(configuration.getConfigKeyName())); } } }
public static List<CRConfigurationProperty> getCrConfigurations(Configuration configuration) { List<CRConfigurationProperty> config = new ArrayList<>(); for (ConfigurationProperty prop : configuration) { String configKeyName = prop.getConfigKeyName(); if (!prop.isSecure()) config.add(new CRConfigurationProperty(configKeyName, prop.getValue(), null)); else { CRConfigurationProperty crProp = new CRConfigurationProperty(configKeyName, null, prop.getEncryptedValue()); config.add(crProp); } } return config; }
public void addConfigurations(List<ConfigurationProperty> configurations) { ConfigurationPropertyBuilder builder = new ConfigurationPropertyBuilder(); for (ConfigurationProperty property : configurations) { add(builder.create(property.getConfigKeyName(), property.getConfigValue(), property.getEncryptedValue(), isSecure(property.getConfigKeyName()))); } }
public void addConfigurations(List<ConfigurationProperty> configurations) { ConfigurationPropertyBuilder builder = new ConfigurationPropertyBuilder(); for (ConfigurationProperty property : configurations) { if(isValidPluginConfiguration(property.getConfigKeyName())) { configuration.add(builder.create(property.getConfigKeyName(), property.getConfigValue(), property.getEncryptedValue(), pluginConfigurationFor(property.getConfigKeyName()).getOption(Property.SECURE))); } else { configuration.add(property); } } }
public List<String> getErrorFor(String settingsKey) { for (ConfigurationProperty configurationProperty : settingsMap) { if (configurationProperty.getConfigKeyName().equals(settingsKey)) { return configurationProperty.errors().getAllOn(settingsKey); } } return errors().getAllOn(settingsKey); }
public void addConfigurations(List<ConfigurationProperty> configurations) { ConfigurationPropertyBuilder builder = new ConfigurationPropertyBuilder(); for (ConfigurationProperty property : configurations) { add(builder.create(property.getConfigKeyName(), property.getConfigValue(), null, false)); } }
public PluginSettingsConfiguration toPluginSettingsConfiguration() { PluginSettingsConfiguration configuration = new PluginSettingsConfiguration(); for (ConfigurationProperty configurationProperty : settingsMap) { configuration.add(new PluginSettingsProperty(configurationProperty.getConfigKeyName(), configurationProperty.getValue())); } return configuration; }
private void encryptSecureConfigurations(ArtifactStore artifactStore) { if (artifactStore != null && hasPluginInfo(artifactStore)) { for (ConfigurationProperty configuration : getConfiguration()) { configuration.handleSecureValueConfiguration(isSecure(configuration.getConfigKeyName(), artifactStore)); } } }
public void addConfigurations(List<ConfigurationProperty> configurations) { ConfigurationPropertyBuilder builder = new ConfigurationPropertyBuilder(); for (ConfigurationProperty property : configurations) { RepositoryConfiguration repositoryMetadata = RepositoryMetadataStore.getInstance().getRepositoryMetadata(pluginConfiguration.getId()); if (isValidPluginConfiguration(property.getConfigKeyName(), repositoryMetadata)) { configuration.add(builder.create(property.getConfigKeyName(), property.getConfigValue(), property.getEncryptedValue(), repositoryPropertyFor(property.getConfigKeyName(), repositoryMetadata).getOption(Property.SECURE))); } else { configuration.add(property); } } }
public void addConfigurations(List<ConfigurationProperty> configurations) { ConfigurationPropertyBuilder builder = new ConfigurationPropertyBuilder(); for (ConfigurationProperty property : configurations) { SCMConfigurations scmConfigurations = SCMMetadataStore.getInstance().getConfigurationMetadata(getPluginId()); if (isValidPluginConfiguration(property.getConfigKeyName(), scmConfigurations)) { configuration.add(builder.create(property.getConfigKeyName(), property.getConfigValue(), property.getEncryptedValue(), scmConfigurationFor(property.getConfigKeyName(), scmConfigurations).getOption(SCMConfiguration.SECURE))); } else { configuration.add(property); } } }
@Test public void shouldCreateConfigurationPropertyWithEncyrptedValueForSecureProperty() { Property key = new Property("key"); key.with(Property.SECURE, true); ConfigurationProperty property = new ConfigurationPropertyBuilder().create("key", null, "enc_value", true); assertThat(property.getConfigKeyName(), is("key")); assertThat(property.getEncryptedValue(), is("enc_value")); assertNull(property.getConfigurationValue()); }
@Test public void shouldCreateWithEncyrptedValueForOnlyPlainTextInputForSecureProperty() throws Exception { Property key = new Property("key"); key.with(Property.SECURE, true); ConfigurationProperty property = new ConfigurationPropertyBuilder().create("key", "value", null, true); assertThat(property.getConfigKeyName(), is("key")); assertThat(property.getEncryptedValue(), is(new GoCipher().encrypt("value"))); assertNull(property.getConfigurationValue()); }
@Test public void shouldCreatePropertyInAbsenceOfPlainAndEncryptedTextInputForSecureProperty() throws Exception { Property key = new Property("key"); key.with(Property.SECURE, true); ConfigurationProperty property = new ConfigurationPropertyBuilder().create("key", null, null, true); assertThat(property.errors().size(), is(0)); assertThat(property.getConfigKeyName(), is("key")); assertNull(property.getEncryptedConfigurationValue()); assertNull(property.getConfigurationValue()); }