Mentions légales du service

Skip to content
Snippets Groups Projects
Commit bdf514f9 authored by Wylem Bars's avatar Wylem Bars
Browse files

IUAINFRA-52 | Fix sonar

parent 3492369e
No related branches found
No related tags found
1 merge request!2Feature/iuainfra 52
......@@ -8,22 +8,40 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
/**
* {@link AudienceSecretRetriever} used by SoapUI project to retrieve secrets.
*/
public class AudienceSecretRetrieverForSoapui implements AudienceSecretRetriever {
private static final GazelleLogger LOGGER = GazelleLoggerFactory.getInstance().getLogger(AudienceSecretRetrieverForSoapui.class);
private String propertiesFile = "/opt/simulators/audience.properties";
/**
* Default constructor for the class.
*/
public AudienceSecretRetrieverForSoapui() {
//Empty Constructor
}
/**
* Constructor allowing to configure the properties file path.
*
* @param propertiesFile path to the properties file.
*/
public AudienceSecretRetrieverForSoapui(String propertiesFile) {
this.propertiesFile = propertiesFile;
}
public static Properties readPropertiesFile(String fileName) {
/**
* Read property file as {@link Properties}.
*
* @param filePath path to hte properties file.
* @return the {@link Properties} defined by the file.
*/
private static Properties readPropertiesFile(String filePath) {
Properties prop = null;
try (FileInputStream fis = new FileInputStream(fileName)) {
try (FileInputStream fis = new FileInputStream(filePath)) {
prop = new Properties();
prop.load(fis);
} catch (IOException e) {
......@@ -32,9 +50,12 @@ public class AudienceSecretRetrieverForSoapui implements AudienceSecretRetriever
return prop;
}
/**
* {@inheritDoc}
*/
@Override
public String retrieveSecretForAudience(String audience) {
Properties prop = readPropertiesFile(propertiesFile);
return prop.getProperty(audience);
return prop != null ? prop.getProperty(audience) : null;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment