Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 4b8a31ba authored by Youn Cadoret's avatar Youn Cadoret
Browse files

IUAINFRA-47 quality

parent fe2e9a76
No related branches found
No related tags found
1 merge request!3Feature/iuainfra 31
......@@ -3,8 +3,9 @@ package net.ihe.gazelle.app.accesstokenproviderapi.application;
import net.ihe.gazelle.app.accesstokenproviderapi.business.AccessTokenRequest;
import net.ihe.gazelle.app.accesstokenproviderapi.business.SymmetricSignature;
import net.ihe.gazelle.app.audienceretriever.adapter.AudienceSecretRetrieverForSoapui;
import net.ihe.gazelle.app.audienceretriever.adapter.AudienceSecretRetrieverImpl;
import net.ihe.gazelle.app.audienceretriever.application.AudienceSecretRetriever;
import net.ihe.gazelle.framework.loggerservice.application.GazelleLogger;
import net.ihe.gazelle.framework.loggerservice.application.GazelleLoggerFactory;
import net.ihe.gazelle.modelapi.sb.business.EncodingException;
import net.ihe.gazelle.sb.iua.business.TokenType;
......@@ -15,6 +16,7 @@ import java.time.Duration;
*/
public class DummyAuthzServerSoapui implements DummyAuthzServer {
private static final GazelleLogger LOGGER = GazelleLoggerFactory.getInstance().getLogger(DummyAuthzServerSoapui.class);
private static final String ALGORITHM = "HS256";
private static final String ISSUER = "https://ehealthsuisse.ihe-europe.net/access-token-provider";
......@@ -85,14 +87,11 @@ public class DummyAuthzServerSoapui implements DummyAuthzServer {
byte[] token = null;
try {
token = tokenGenerator.generateAccessToken(getAccessTokenRequest(userId, audienceId)).getToken();
} catch (EncodingException e) {
e.printStackTrace();
} catch (TokenRequestException e) {
e.printStackTrace();
} finally {
} catch (EncodingException | TokenRequestException e) {
LOGGER.error("Error generating Access Token", e);
}
return token;
}
}
}
......@@ -45,7 +45,7 @@ public class TokenGenerator {
throw new TokenRequestException("Unsupported Algorithm");
}
Duration duration = !accessTokenRequest.getValidityTime().equals(null) ? accessTokenRequest.getValidityTime() : DEFAULT_DURATION;
Duration duration = accessTokenRequest.getValidityTime() != null ? accessTokenRequest.getValidityTime() : DEFAULT_DURATION;
if (accessTokenRequest.getTokenType() == null || !accessTokenRequest.getTokenType().equals(TOKEN_TYPE)) {
throw new TokenRequestException("Unsupported token type");
......
<?xml version="1.0" encoding="UTF-8"?>
<con:soapui-project id="4527283c-83fc-419a-9fa3-d9c072053eac" activeEnvironment="Default" name="getToken" resourceRoot="" soapui-version="5.6.0" abortOnError="false" runType="SEQUENTIAL" xmlns:con="http://eviware.com/soapui/config"><con:settings/><con:testSuite id="a7dd34e8-2441-4bf8-b2bc-3ea43c3b0f42" name="getToken"><con:settings/><con:runType>SEQUENTIAL</con:runType><con:testCase id="f8ac5a96-e7e9-4a60-9e9c-84f80664db91" failOnError="true" failTestCaseOnErrors="true" keepSession="false" maxResults="0" name="getToken" searchProperties="true"><con:settings/><con:testStep type="groovy" name="exemple" id="c65c443d-1476-4c4a-b9e6-b63eac62939f"><con:settings/><con:config><script>import net.ihe.gazelle.app.accesstokenproviderapi.application.DummyAuthzServerSoapui
def server = new DummyAuthzServerSoapui();
def token = server.getAccessToken("aamrein", "audience", null, null);
log.info new String(token)</script></con:config></con:testStep><con:properties/></con:testCase><con:properties/></con:testSuite><con:properties/><con:wssContainer/><con:oAuth2ProfileContainer/><con:oAuth1ProfileContainer/><con:sensitiveInformation/></con:soapui-project>
\ No newline at end of file
def server = new DummyAuthzServerSoapui("/opt/simulators/audience.properties");
def token = server.getAccessToken("aamrein", "audience", null, null );
log.info new String(token)
</script>
</con:config>
</con:testStep>
<con:properties/>
</con:testCase>
<con:properties/>
</con:testSuite>
<con:properties/>
<con:wssContainer/>
<con:oAuth2ProfileContainer/>
<con:oAuth1ProfileContainer/>
<con:sensitiveInformation/>
</con:soapui-project>
\ No newline at end of file
package net.ihe.gazelle.app.audienceretriever.adapter;
import net.ihe.gazelle.app.audienceretriever.application.AudienceSecretRetriever;
import net.ihe.gazelle.framework.loggerservice.application.GazelleLogger;
import net.ihe.gazelle.framework.loggerservice.application.GazelleLoggerFactory;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
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) throws IOException {
FileInputStream fis = null;
/**
* 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 {
fis = new FileInputStream(fileName);
try (FileInputStream fis = new FileInputStream(filePath)) {
prop = new Properties();
prop.load(fis);
} catch(FileNotFoundException fnfe) {
fnfe.printStackTrace();
} catch(IOException ioe) {
ioe.printStackTrace();
} finally {
fis.close();
} catch (IOException e) {
LOGGER.error("Error reading properties file !", e);
}
return prop;
}
/**
* {@inheritDoc}
*/
@Override
public String retrieveSecretForAudience(String audience) {
String secret = null;
try {
Properties prop = readPropertiesFile(propertiesFile);
secret = prop.getProperty(audience);
} catch (IOException e) {
e.printStackTrace();
} finally {
return secret;
}
Properties prop = readPropertiesFile(propertiesFile);
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