Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 402ea69b authored by Nicolas Bailliet's avatar Nicolas Bailliet
Browse files

Merge branch 'feature/IUAINFRA-30' into 'develop'

Feature/iuainfra 30

See merge request !1
parents a24d2693 66247ee1
No related branches found
No related tags found
2 merge requests!5Develop,!1Feature/iuainfra 30
Showing
with 962 additions and 17 deletions
......@@ -19,28 +19,16 @@ variables:
P_NAME: "app.access-token-provider"
P_APP_TYPE: "java"
P_CODE_SRC_PATH: "."
P_MAVEN_IMAGE_TAG: "3.6.3"
# Define jobs
code:
stage: build
extends:
- .codeForJava
variables:
P_MAVEN_IMAGE_TAG: "3.6.3"
- .buildCodeForJava
quality:
stage: tests
extends:
- .sonarqubeForJava
variables:
P_MAVEN_IMAGE_TAG: "3.6.3"
P_CODE_BINARIES: "target/classes/"
P_CODE_JACOCO_REPORT_PATH: "target/jacoco.exec"
P_CODE_JUNIT_REPORTS_PATH: "target/surefire-reports"
P_CODE_DYNAMIC_ANALYSIS: "reuseReports"
P_CODE_COVERAGE_PLUGIN: "jacoco"
P_CODE_SOURCE_ENCODING: "UTF-8"
P_CODE_LANGUAGE: "java"
P_CODE_DEVELOPER_EDITION: "true"
- .testQualityForJavaWithSonarqube
\ No newline at end of file
......@@ -11,8 +11,22 @@
</parent>
<groupId>net.ihe.gazelle</groupId>
<artifactId>lib.access-token-provider-api</artifactId>
<artifactId>app.access-token-provider-api</artifactId>
<name>Access Token Provider Api</name>
<version>1.0.0-SNAPSHOT</version>
</project>
\ No newline at end of file
<dependencies>
<dependency>
<groupId>net.ihe.gazelle</groupId>
<artifactId>lib.annotations</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>net.ihe.gazelle</groupId>
<artifactId>sb.iua-standard-block</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
package net.ihe.gazelle.app.accesstokenproviderapi.adapter.webservice;
import net.ihe.gazelle.app.accesstokenproviderapi.business.Credential;
/**
* Interface to interact with the audience registry where is store all known audience with their credential
*/
public interface AudienceRegistry {
/**
* Get credential's audience
* @param audienceId
* @return credential
*/
Credential getAudienceCredentials(String audienceId);
}
package net.ihe.gazelle.app.accesstokenproviderapi.adapter.webservice;
/**
* For SoapUI integration need, a simplified Authorization Server (or IDP) is required.
*/
public interface DummyAuthzServer {
/**
* get a dummy access token
* @param userId
* @param audienceId
* @param purposeOfUser
* @param resourceId
* @return an access token
*/
byte[] getAccessToken(String userId, String audienceId, String purposeOfUser, String resourceId);
}
package net.ihe.gazelle.app.accesstokenproviderapi.adapter.webservice;
import net.ihe.gazelle.app.accesstokenproviderapi.business.testuser.TestUser;
/**
* Interface to interact with the test-users’ database for authentication step and token content
*/
public interface TestUserRegistry {
/**
* @param userId
* @return TestUser
*/
TestUser getTestUser(String userId);
}
package net.ihe.gazelle.app.accesstokenproviderapi.adapter.webservice;
import net.ihe.gazelle.app.accesstokenproviderapi.business.AccessTokenRequest;
import net.ihe.gazelle.sb.iua.business.EncodedIUAToken;
/**
* Interface to interact with the access token generator
*/
public interface TokenGenerator {
/**
* generate an access token from an access token request
* @param accessTokenRequest
* @return EncodedIUAToken
*/
EncodedIUAToken generateAccessToken(AccessTokenRequest accessTokenRequest);
}
package net.ihe.gazelle.app.accesstokenproviderapi.business;
import java.util.ArrayList;
import java.util.List;
/**
* Extensions for the Access Token
*/
public class AccessTokenExtension {
private String subjectId;
private List<String> subjectOrganizations = new ArrayList<>();
private List<String> subjectOrganizationIds = new ArrayList<>();
private String homeCommunityId;
private String nationalProviderIdentifier;
private List<String> providerIds = new ArrayList<>();
private CodedValue subjectRole;
private CodedValue purposeOfUse;
private String resourceId;
private String onBehalfOf;
/**
* constructor
*/
public AccessTokenExtension() {
// Constructor is empty because all variables are optionals.
}
/**
* get the subjectId
* @return subjectId
*/
public String getSubjectId() {
return subjectId;
}
/**
* set the subjectId
* @param subjectId the subjectId
*/
public void setSubjectId(String subjectId) {
this.subjectId = subjectId;
}
/**
* get subjectOrganizations list
* @return subjectOrganizations
*/
public List<String> getSubjectOrganizations() {
return subjectOrganizations;
}
/**
* add a subjectOrganization in the subjectOrganizations list
* @param subjectOrganization a nationalProviderIdentifier
*/
public void addSubjectOrganization(String subjectOrganization) {
this.subjectOrganizations.add(subjectOrganization);
}
/**
* remove a subjectOrganization from the subjectOrganizations list
* @param subjectOrganization a nationalProviderIdentifier
*/
public void removeSubjectOrganization(String subjectOrganization) {
this.subjectOrganizations.remove(subjectOrganization);
}
/**
* get subjectOrganizationIds list
* @return subjectOrganizationIds
*/
public List<String> getSubjectOrganizationIds() {
return subjectOrganizationIds;
}
/**
* add a subjectOrganizationId in the subjectOrganizationIds list
* @param subjectOrganizationId a subjectOrganizationId
*/
public void addSubjectOrganizationId(String subjectOrganizationId) {
this.subjectOrganizationIds.add(subjectOrganizationId);
}
/**
* remove a subjectOrganizationId from the subjectOrganizationIds list
* @param subjectOrganizationId a subjectOrganizationId
*/
public void removeSubjectOrganizationId(String subjectOrganizationId) {
this.subjectOrganizationIds.remove(subjectOrganizationId);
}
/**
* get the homeCommunityId
* @return homeCommunityId
*/
public String getHomeCommunityId() {
return homeCommunityId;
}
/**
* set the homeCommunityId
* @param homeCommunityId the homeCommunityId
*/
public void setHomeCommunityId(String homeCommunityId) {
this.homeCommunityId = homeCommunityId;
}
/**
* get the nationalProviderIdentifier
* @return nationalProviderIdentifier
*/
public String getNationalProviderIdentifier() {
return nationalProviderIdentifier;
}
/**
* set the nationalProviderIdentifier
* @param nationalProviderIdentifier the nationalProviderIdentifier
*/
public void setNationalProviderIdentifier(String nationalProviderIdentifier) {
this.nationalProviderIdentifier = nationalProviderIdentifier;
}
/**
* get providerIds list
* @return providerIds
*/
public List<String> getProviderIds() {
return providerIds;
}
/**
* add a providerId in the providerIds list
* @param providerId a providerId
*/
public void addProviderId(String providerId) {
this.providerIds.add(providerId);
}
/**
* remove a providerId in the providerIds list
* @param providerId a providerId
*/
public void removeProviderId(String providerId) {
this.providerIds.remove(providerId);
}
/**
* get the subjectRole
* @return subjectRole
*/
public CodedValue getSubjectRole() {
return subjectRole;
}
/**
* set the subjectRole
* @param subjectRole the subjectRole
*/
public void setSubjectRole(CodedValue subjectRole) {
this.subjectRole = subjectRole;
}
/**
* get the purposeOfUse
* @return purposeOfUse
*/
public CodedValue getPurposeOfUse() {
return purposeOfUse;
}
/**
* set the purposeOfUse
* @param purposeOfUse the purposeOfUse
*/
public void setPurposeOfUse(CodedValue purposeOfUse) {
this.purposeOfUse = purposeOfUse;
}
/**
* get the resourceId
* @return resourceId
*/
public String getResourceId() {
return resourceId;
}
/**
* set the resourceId
* @param resourceId the resourceId
*/
public void setResourceId(String resourceId) {
this.resourceId = resourceId;
}
/**
* get the onBehalfOf
* @return onBehalfOf
*/
public String getOnBehalfOf() {
return onBehalfOf;
}
/**
* set the onBehalfOf
* @param onBehalfOf the onBehalfOf
*/
public void setOnBehalfOf(String onBehalfOf) {
this.onBehalfOf = onBehalfOf;
}
@Override
/**
* {@inheritDoc}
*/
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
AccessTokenExtension that = (AccessTokenExtension) o;
if (subjectId != null ? !subjectId.equals(that.subjectId) : that.subjectId != null) return false;
if (subjectOrganizations != null ? !subjectOrganizations.equals(that.subjectOrganizations) : that.subjectOrganizations != null)
return false;
if (subjectOrganizationIds != null ? !subjectOrganizationIds.equals(that.subjectOrganizationIds) : that.subjectOrganizationIds != null)
return false;
if (homeCommunityId != null ? !homeCommunityId.equals(that.homeCommunityId) : that.homeCommunityId != null)
return false;
if (nationalProviderIdentifier != null ? !nationalProviderIdentifier.equals(that.nationalProviderIdentifier) : that.nationalProviderIdentifier != null)
return false;
if (providerIds != null ? !providerIds.equals(that.providerIds) : that.providerIds != null) return false;
if (subjectRole != null ? !subjectRole.equals(that.subjectRole) : that.subjectRole != null) return false;
if (purposeOfUse != null ? !purposeOfUse.equals(that.purposeOfUse) : that.purposeOfUse != null) return false;
if (resourceId != null ? !resourceId.equals(that.resourceId) : that.resourceId != null) return false;
return onBehalfOf != null ? onBehalfOf.equals(that.onBehalfOf) : that.onBehalfOf == null;
}
@Override
/**
* {@inheritDoc}
*/
public int hashCode() {
int result = subjectId != null ? subjectId.hashCode() : 0;
result = 31 * result + (subjectOrganizations != null ? subjectOrganizations.hashCode() : 0);
result = 31 * result + (subjectOrganizationIds != null ? subjectOrganizationIds.hashCode() : 0);
result = 31 * result + (homeCommunityId != null ? homeCommunityId.hashCode() : 0);
result = 31 * result + (nationalProviderIdentifier != null ? nationalProviderIdentifier.hashCode() : 0);
result = 31 * result + (providerIds != null ? providerIds.hashCode() : 0);
result = 31 * result + (subjectRole != null ? subjectRole.hashCode() : 0);
result = 31 * result + (purposeOfUse != null ? purposeOfUse.hashCode() : 0);
result = 31 * result + (resourceId != null ? resourceId.hashCode() : 0);
result = 31 * result + (onBehalfOf != null ? onBehalfOf.hashCode() : 0);
return result;
}
}
package net.ihe.gazelle.app.accesstokenproviderapi.business;
import net.ihe.gazelle.sb.iua.business.TokenType;
import java.time.Duration;
/**
* The Access Token request
*/
public class AccessTokenRequest {
private String issuer;
private String subject;
private String audience;
private Duration validityTime;
private TokenType tokenType;
private Signature signature;
private AccessTokenExtension extension;
/**
* constructor
*/
public AccessTokenRequest(String issuer, String subject, String audience, Duration validityTime, TokenType tokenType) {
this.issuer = issuer;
this.subject = subject;
this.audience = audience;
this.validityTime = validityTime;
this.tokenType = tokenType;
}
/**
* get the issuer
*
* @return issuer
*/
public String getIssuer() {
return issuer;
}
/**
* get the subject
*
* @return subject
*/
public String getSubject() {
return subject;
}
/**
* get the audience
*
* @return audience
*/
public String getAudience() {
return audience;
}
/**
* get the validityTime
*
* @return validityTime
*/
public Duration getValidityTime() {
return validityTime;
}
/**
* get the tokenType
*
* @return tokenType
*/
public TokenType getTokenType() {
return tokenType;
}
/**
* get the signature
*
* @return signature
*/
public Signature getSignature() {
return signature;
}
/**
* set the signature
*
* @param signature the signature
*/
public void setSignature(Signature signature) {
this.signature = signature;
}
/**
* get the extension
*
* @return extension
*/
public AccessTokenExtension getExtension() {
return extension;
}
/**
* set the extension
*
* @param extension the extension
*/
public void setExtension(AccessTokenExtension extension) {
this.extension = extension;
}
@Override
/**
* {@inheritDoc}
*/
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
AccessTokenRequest that = (AccessTokenRequest) o;
if (!issuer.equals(that.issuer)) return false;
if (!subject.equals(that.subject)) return false;
if (!audience.equals(that.audience)) return false;
if (!validityTime.equals(that.validityTime)) return false;
if (tokenType != that.tokenType) return false;
if (signature != null ? !signature.equals(that.signature) : that.signature != null) return false;
return extension != null ? extension.equals(that.extension) : that.extension == null;
}
@Override
/**
* {@inheritDoc}
*/
public int hashCode() {
int result = issuer.hashCode();
result = 31 * result + subject.hashCode();
result = 31 * result + audience.hashCode();
result = 31 * result + validityTime.hashCode();
result = 31 * result + tokenType.hashCode();
result = 31 * result + (signature != null ? signature.hashCode() : 0);
result = 31 * result + (extension != null ? extension.hashCode() : 0);
return result;
}
}
package net.ihe.gazelle.app.accesstokenproviderapi.business;
import java.util.Arrays;
/**
* Asymmetric signature information of the access token
*/
public class AsymmetricSignature extends Signature {
private byte[] privateKey;
private String privateKeyPassword;
/**
* constructor
*/
public AsymmetricSignature(String algorithm, byte[] privateKey, String privateKeyPassword) {
super(algorithm);
this.privateKey = privateKey;
this.privateKeyPassword = privateKeyPassword;
}
/**
* get the privateKey
* @return privateKey
*/
public byte[] getPrivateKey() {
return privateKey;
}
/**
* get the privateKeyPassword
* @return privateKeyPassword
*/
public String getPrivateKeyPassword() {
return privateKeyPassword;
}
@Override
/**
* {@inheritDoc}
*/
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
AsymmetricSignature that = (AsymmetricSignature) o;
if (!Arrays.equals(privateKey, that.privateKey)) return false;
return privateKeyPassword.equals(that.privateKeyPassword);
}
@Override
/**
* {@inheritDoc}
*/
public int hashCode() {
int result = Arrays.hashCode(privateKey);
result = 31 * result + privateKeyPassword.hashCode();
return result;
}
}
package net.ihe.gazelle.app.accesstokenproviderapi.business;
/**
* A Coded value
*/
public class CodedValue {
private String code;
private String codeSystem;
private String codeSystemName;
private String displayName;
/**
* constructor
*/
public CodedValue(String code, String codeSystem) {
this.code = code;
this.codeSystem = codeSystem;
}
/**
* get the code
*
* @return code
*/
public String getCode() {
return code;
}
/**
* get the codeSystem
*
* @return codeSystem
*/
public String getCodeSystem() {
return codeSystem;
}
/**
* get the codeSystemName
*
* @return codeSystemName
*/
public String getCodeSystemName() {
return codeSystemName;
}
/**
* set the codeSystemName
*
* @param codeSystemName the codeSystemName
*/
public void setCodeSystemName(String codeSystemName) {
this.codeSystemName = codeSystemName;
}
/**
* get the displayName
*
* @return displayName
*/
public String getDisplayName() {
return displayName;
}
/**
* set the displayName
*
* @param displayName the displayName
*/
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
}
package net.ihe.gazelle.app.accesstokenproviderapi.business;
/**
* Credential for an audience
*/
public abstract class Credential {
}
package net.ihe.gazelle.app.accesstokenproviderapi.business;
import java.util.Arrays;
/**
* A password
*/
public class Password extends Credential {
private byte[] value;
/**
* constructor
*/
public Password(byte[] value) {
this.value = value;
}
/**
* get the value
* @return value
*/
public byte[] getValue() {
return value;
}
@Override
/**
* {@inheritDoc}
*/
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Password password = (Password) o;
return Arrays.equals(value, password.value);
}
@Override
/**
* {@inheritDoc}
*/
public int hashCode() {
return Arrays.hashCode(value);
}
}
package net.ihe.gazelle.app.accesstokenproviderapi.business;
import java.util.Arrays;
/**
* A public key
*/
public class PublicKey extends Credential {
private byte[] key;
/**
* constructor
*/
public PublicKey(byte[] key) {
this.key = key;
}
/**
* get the key
* @return key
*/
public byte[] getKey() {
return key;
}
@Override
/**
* {@inheritDoc}
*/
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
PublicKey publicKey = (PublicKey) o;
return Arrays.equals(key, publicKey.key);
}
@Override
/**
* {@inheritDoc}
*/
public int hashCode() {
return Arrays.hashCode(key);
}
}
package net.ihe.gazelle.app.accesstokenproviderapi.business;
/**
* Signature information of the access token
*/
public abstract class Signature {
private String algorithm;
/**
* constructor
*/
public Signature(String algorithm) {
this.algorithm = algorithm;
}
/**
* get the algorithm
* @return algorithm
*/
public String getAlgorithm() {
return algorithm;
}
@Override
/**
* {@inheritDoc}
*/
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Signature signature = (Signature) o;
return algorithm.equals(signature.algorithm);
}
@Override
/**
* {@inheritDoc}
*/
public int hashCode() {
return algorithm.hashCode();
}
}
package net.ihe.gazelle.app.accesstokenproviderapi.business;
/**
* Symmetric signature information of the access token
*/
public class SymmetricSignature extends Signature {
private String secret;
/**
* constructor
*/
public SymmetricSignature(String algorithm, String secret) {
super(algorithm);
this.secret = secret;
}
/**
* get the secret
* @return secret
*/
public String getSecret() {
return secret;
}
@Override
/**
* {@inheritDoc}
*/
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
SymmetricSignature that = (SymmetricSignature) o;
return secret.equals(that.secret);
}
@Override
/**
* {@inheritDoc}
*/
public int hashCode() {
return secret.hashCode();
}
}
package net.ihe.gazelle.app.accesstokenproviderapi.business.testuser;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Test user used for authentication and token content
*/
public class TestUser {
private String userId;
private List<String> givenNames = new ArrayList<>();
private String lastName;
private Date birthDate; //fixme Date ?
private String gender; //fixme String ?
private Map<String, String> extensions = new HashMap<>();
/**
* Constructor
*/
public TestUser(String userId, List<String> givenNames, String lastName) {
this.userId = userId;
this.givenNames = givenNames;
this.lastName = lastName;
}
/**
* get the userId
* @return userId
*/
public String getUserId() {
return userId;
}
/**
* get the givenNames
* @return givenNames
*/
public List<String> getGivenNames() {
return givenNames;
}
/**
* get the lastName
* @return lastName
*/
public String getLastName() {
return lastName;
}
/**
* get the birthDate
* @return birthDate
*/
public Date getBirthDate() {
return birthDate;
}
/**
* set the birthDate
*
* @param birthDate the birthDate
*/
public void setBirthDate(Date birthDate) {
this.birthDate = birthDate;
}
/**
* get the gender
* @return gender
*/
public String getGender() {
return gender;
}
/**
* set the gender
*
* @param gender the gender
*/
public void setGender(String gender) {
this.gender = gender;
}
/**
* get the extensions
* @return extensions
*/
public Map<String, String> getExtensions() {
return extensions;
}
/**
* add an extension in the extensions map
* @param key key of the extension
* @param value value of the extension
*/
public void addExtension(String key, String value) {
extensions.put(key, value);
}
/**
* remove an extension in the extensions map
* @param key key of the extension
*/
public void removeExtension(String key) {
extensions.remove(key);
}
@Override
/**
* {@inheritDoc}
*/
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
TestUser testUser = (TestUser) o;
if (!userId.equals(testUser.userId)) return false;
if (!givenNames.equals(testUser.givenNames)) return false;
if (!lastName.equals(testUser.lastName)) return false;
if (birthDate != null ? !birthDate.equals(testUser.birthDate) : testUser.birthDate != null) return false;
if (gender != null ? !gender.equals(testUser.gender) : testUser.gender != null) return false;
return extensions != null ? extensions.equals(testUser.extensions) : testUser.extensions == null;
}
@Override
/**
* {@inheritDoc}
*/
public int hashCode() {
int result = userId.hashCode();
result = 31 * result + givenNames.hashCode();
result = 31 * result + lastName.hashCode();
result = 31 * result + (birthDate != null ? birthDate.hashCode() : 0);
result = 31 * result + (gender != null ? gender.hashCode() : 0);
result = 31 * result + (extensions != null ? extensions.hashCode() : 0);
return result;
}
}
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