package org.openecomp.appc.configuration;
-
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
/**
* Construct the configuration object.
*/
- public DefaultConfiguration() {
+ DefaultConfiguration() {
// do nothing
}
*/
@SuppressWarnings("nls")
private static String decrypt(String value) {
- if (value != null) {
- if (value.startsWith(EncryptionTool.ENCRYPTED_VALUE_PREFIX)) {
- try {
- return EncryptionTool.getInstance().decrypt(value);
- } catch (Exception e) {
- StringBuilder out = new StringBuilder();
- for (Provider p : Security.getProviders()) {
- for (Service s : p.getServices()) {
- String algo = s.getAlgorithm();
- out.append(String.format("\n==Found Algorithm [ %s ] in provider [ %s ] and service [ %s ]",
- algo, p.getName(), s.getClassName()));
- }
+ if (value != null && value.startsWith(EncryptionTool.ENCRYPTED_VALUE_PREFIX)) {
+ try {
+ return EncryptionTool.getInstance().decrypt(value);
+ } catch (Exception e) {
+ StringBuilder out = new StringBuilder();
+ for (Provider p : Security.getProviders()) {
+ for (Service s : p.getServices()) {
+ String algo = s.getAlgorithm();
+ out.append(String.format("\n==Found Algorithm [ %s ] in provider [ %s ] and service [ %s ]",
+ algo, p.getName(), s.getClassName()));
}
- logger.debug(out.toString());
- logger.warn(String.format("Could not decrypt the configuration value [%s]", value), e);
}
+ logger.debug(out.toString());
+ logger.warn(String.format("Could not decrypt the configuration value [%s]", value), e);
}
}
return value;
// template = decrypt(template); DH: Do not assign values to parameters, bad form! Also, Sonar complains
// bitterly
- StringBuffer buffer = new StringBuffer(decrypt(template));
+ StringBuilder builder = new StringBuilder(decrypt(template));
Pattern pattern = Pattern.compile("\\$\\{([^\\}]+)\\}");
- Matcher matcher = pattern.matcher(buffer);
+ Matcher matcher = pattern.matcher(builder);
while (matcher.find()) {
String variable = matcher.group(1);
String value = properties.getProperty(variable);
if (value == null) {
value = "";
}
- buffer.replace(matcher.start(), matcher.end(), value);
+ builder.replace(matcher.start(), matcher.end(), value);
matcher.reset();
}
- return buffer.toString().trim();
+ return builder.toString().trim();
}
/**
*/
@Override
public int hashCode() {
- return (properties == null ? 0 : properties.hashCode());
+ return properties == null ? 0 : properties.hashCode();
}
/**
try {
properties.load(is);
} catch (IOException e) {
- e.printStackTrace();
+ logger.warn("setProperties with inputStream got exception", e);
}
}
@SuppressWarnings("nls")
@Override
public String toString() {
- return String.format("Configuration: %d properties, keys:[%s]", properties.size(), properties.keySet()
- .toString());
+ return String.format("Configuration: %d properties, keys:[%s]",
+ properties.size(), properties.keySet().toString());
}
/**