Mentions légales du service

Skip to content
Snippets Groups Projects

Feature/iuainfra 52

Merged Wylem Bars requested to merge feature/IUAINFRA-52 into develop
2 unresolved threads
1 file
+ 24
3
Compare changes
  • Side-by-side
  • Inline
@@ -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;
}
}
Loading