Skip to content

Commit

Permalink
Added support for DOCUMENT_PHOTO attribute.
Browse files Browse the repository at this point in the history
  • Loading branch information
Branko Pavlovic committed Feb 13, 2024
1 parent 4d5dcb8 commit 0fccb0b
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 17 deletions.
2 changes: 1 addition & 1 deletion FrejaEidClient/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.verisec.frejaeid</groupId>
<artifactId>FrejaEidClient</artifactId>
<version>2.20.2-SNAPSHOT</version>
<version>2.21.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>FrejaEidClient</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class RequestedAttributes {
private final Integer age;
private final String photo;
private final DocumentInfo document;
private final String documentPhoto;
private final CovidCertificates covidCertificates;

@JsonCreator
Expand All @@ -49,6 +50,7 @@ public RequestedAttributes(@JsonProperty(value = "basicUserInfo") BasicUserInfo
@JsonProperty(value = "age") Integer age,
@JsonProperty(value = "photo") String photo,
@JsonProperty(value = "document") DocumentInfo document,
@JsonProperty(value = "documentPhoto") String documentPhoto,
@JsonProperty(value = "covidCertificates") CovidCertificates covidCertificates,
@JsonProperty(value = "organisationId") OrganisationIdInfo organisationId) {
this.basicUserInfo = basicUserInfo;
Expand All @@ -67,6 +69,7 @@ public RequestedAttributes(@JsonProperty(value = "basicUserInfo") BasicUserInfo
this.age = age;
this.photo = photo;
this.document = document;
this.documentPhoto = documentPhoto;
this.covidCertificates = covidCertificates;
}

Expand Down Expand Up @@ -134,6 +137,10 @@ public DocumentInfo getDocument() {
return document;
}

public String getDocumentPhoto() {
return documentPhoto;
}

public CovidCertificates getCovidCertificates() {
return covidCertificates;
}
Expand All @@ -143,7 +150,7 @@ public int hashCode() {
return Objects.hash(basicUserInfo, customIdentifier, ssn, integratorSpecificUserId,
dateOfBirth, relyingPartyUserId, emailAddress, organisationIdIdentifier,
organisationId, addresses, allEmailAddresses, allPhoneNumbers, registrationLevel, age,
photo, document, covidCertificates);
photo, document, documentPhoto, covidCertificates);
}

@Override
Expand Down Expand Up @@ -206,6 +213,9 @@ public boolean equals(Object obj) {
if (!Objects.equals(this.document, other.document)) {
return false;
}
if (!Objects.equals(this.documentPhoto, other.documentPhoto)) {
return false;
}
if (!Objects.equals(this.covidCertificates, other.covidCertificates)) {
return false;
}
Expand All @@ -231,6 +241,7 @@ public java.lang.String toString() {
", age=" + age +
", photo=" + photo +
", documentInfo=" + document +
", documentPhoto=" + documentPhoto +
", covidCertificates=" + covidCertificates +
'}';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
* <br> - {@link #REGISTRATION_LEVEL}
* <br> - {@link #AGE}
* <br> - {@link #PHOTO}
* <br> - {@link #DOCUMENT}
* <br> - {@link #DOCUMENT_PHOTO}
* <br> - {@link #COVID_CERTIFICATES}
*/
public enum AttributeToReturn {
Expand Down Expand Up @@ -126,6 +128,13 @@ public enum AttributeToReturn {
* {@linkplain MinRegistrationLevel#PLUS}.
*/
DOCUMENT("DOCUMENT"),
/**
* ID document photo returned as a Base64-encoded String.
* Photo can be requested only for
* {@linkplain MinRegistrationLevel#EXTENDED} and
* {@linkplain MinRegistrationLevel#PLUS}.
*/
DOCUMENT_PHOTO("DOCUMENT_PHOTO"),
/**
* Proof that the user has been vaccinated against COVID-19,
* received a negative test result or recovered from COVID-19,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public class AuthenticationClientGetResultTest {
private static final String PHOTO = "https://image-hashId/test";
private static final DocumentInfo DOCUMENT_INFO =
new DocumentInfo(DocumentType.PASSPORT, "123456789", Country.SWEDEN, "2050-01-01");
private static final String DOCUMENT_PHOTO = "Base64EncodedDocPhoto";
private static final CovidCertificates COVID_CERTIFICATES =
new CovidCertificates(new Vaccines("covidCertificate"), null, null, true);
private static RequestedAttributes REQUESTED_ATTRIBUTES;
Expand All @@ -73,9 +74,11 @@ public static void initTestData() {
new OrganisationIdInfo("org_id_with_attributes", organisationIdIssuerNames, "org_id_issuer",
Arrays.asList(additionalOrgIdAttribute));
REQUESTED_ATTRIBUTES =
new RequestedAttributes(BASIC_USER_INFO, CUSTOM_IDENTIFIER, SSN, null, DATE_OF_BIRTH, RELYING_PARTY_USER_ID,
EMAIL_ADDRESS, ORGANISATION_ID, ADDRESSES, ALL_EMAIL_ADDRESSES, ALL_PHONE_NUMBERS, RegistrationLevel.EXTENDED, AGE, PHOTO, DOCUMENT_INFO, COVID_CERTIFICATES, ORGANISATION_ID_INFO
);
new RequestedAttributes(BASIC_USER_INFO, CUSTOM_IDENTIFIER, SSN, null, DATE_OF_BIRTH,
RELYING_PARTY_USER_ID, EMAIL_ADDRESS, ORGANISATION_ID, ADDRESSES,
ALL_EMAIL_ADDRESSES, ALL_PHONE_NUMBERS, RegistrationLevel.EXTENDED,
AGE, PHOTO, DOCUMENT_INFO, DOCUMENT_PHOTO,
COVID_CERTIFICATES, ORGANISATION_ID_INFO);
}

@Before
Expand Down Expand Up @@ -157,7 +160,7 @@ public void getAuthenticationResultOrganisational_withAdditionalAttributes_succe
EMAIL_ADDRESS, ORGANISATION_ID, ADDRESSES,
ALL_EMAIL_ADDRESSES, ALL_PHONE_NUMBERS,
RegistrationLevel.EXTENDED, AGE, PHOTO,
DOCUMENT_INFO, COVID_CERTIFICATES,
DOCUMENT_INFO, DOCUMENT_PHOTO, COVID_CERTIFICATES,
ORGANISATION_ID_INFO_WITH_ADDITIONAL_ATTRIBUTES);
AuthenticationClientApi authenticationClient =
AuthenticationClient.create(TestUtil.getDefaultSslSettings(), FrejaEnvironment.TEST)
Expand Down Expand Up @@ -300,13 +303,14 @@ private void getAuthenticationResults_success(AuthenticationResultsRequest getAu
private AuthenticationResults prepareResponse() {
RequestedAttributes attributes1 =
new RequestedAttributes(BASIC_USER_INFO, CUSTOM_IDENTIFIER, SSN, null, DATE_OF_BIRTH,
RELYING_PARTY_USER_ID, EMAIL_ADDRESS, ORGANISATION_ID, ADDRESSES, ALL_EMAIL_ADDRESSES, ALL_PHONE_NUMBERS, RegistrationLevel.EXTENDED, AGE, PHOTO, DOCUMENT_INFO, COVID_CERTIFICATES, ORGANISATION_ID_INFO
);
RELYING_PARTY_USER_ID, EMAIL_ADDRESS, ORGANISATION_ID, ADDRESSES,
ALL_EMAIL_ADDRESSES, ALL_PHONE_NUMBERS, RegistrationLevel.EXTENDED, AGE,
PHOTO, DOCUMENT_INFO, DOCUMENT_PHOTO, COVID_CERTIFICATES, ORGANISATION_ID_INFO);
AuthenticationResult firstResponse =
new AuthenticationResult(REFERENCE, TransactionStatus.STARTED, DETAILS, attributes1);
RequestedAttributes attributes2 =
new RequestedAttributes(null, "test", null, null, null, null, null, null, null, null, null, null, null, null, null, null, null
);
new RequestedAttributes(null, "test", null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null);
AuthenticationResult secondResponse =
new AuthenticationResult(REFERENCE, TransactionStatus.DELIVERED_TO_MOBILE, "test", attributes2);
List<AuthenticationResult> responses = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ public class SignClientGetResultTest {
private static final List<Email> ALL_EMAIL_ADDRESSES = Arrays.asList(new Email(EMAIL_ADDRESS));
private static final List<PhoneNumberInfo> ALL_PHONE_NUMBERS = Arrays.asList(new PhoneNumberInfo(PHONE_NUMBER));
private static final Integer AGE = 35;
private static final String PHOTO = "https://image-hashId/test";
private static final String PHOTO = "Base64EncodedAvatarPhoto";
private static final DocumentInfo DOCUMENT_INFO =
new DocumentInfo(DocumentType.PASSPORT, "123456789", Country.SWEDEN, "2050-01-01");
private static final String DOCUMENT_PHOTO = "Base64EncodedDocPhoto";
protected static final CovidCertificates COVID_CERTIFICATES =
new CovidCertificates(new Vaccines("covidCertificate"), null, null, true);
private static RequestedAttributes REQUESTED_ATTRIBUTES;
Expand All @@ -70,8 +71,10 @@ public static void initTestData() {
REQUESTED_ATTRIBUTES =
new RequestedAttributes(new BasicUserInfo("name", "surname"), "customIdentifier",
SsnUserInfo.create(Country.SWEDEN, "ssn"), "integratorSpecificId", "1987-10-18",
RELYING_PARTY_USER_ID, EMAIL_ADDRESS, ORGANISATION_ID, ADDRESSES, ALL_EMAIL_ADDRESSES, ALL_PHONE_NUMBERS, RegistrationLevel.EXTENDED, AGE, PHOTO, DOCUMENT_INFO, COVID_CERTIFICATES, ORGANISATION_ID_INFO
);
RELYING_PARTY_USER_ID, EMAIL_ADDRESS, ORGANISATION_ID, ADDRESSES,
ALL_EMAIL_ADDRESSES, ALL_PHONE_NUMBERS, RegistrationLevel.EXTENDED,
AGE, PHOTO, DOCUMENT_INFO, DOCUMENT_PHOTO,
COVID_CERTIFICATES, ORGANISATION_ID_INFO);
}

@Before
Expand Down Expand Up @@ -148,7 +151,7 @@ public void getSignResultOrganisational_withAdditionalAttributes_expectSuccess()
EMAIL_ADDRESS, ORGANISATION_ID, ADDRESSES,
ALL_EMAIL_ADDRESSES, ALL_PHONE_NUMBERS,
RegistrationLevel.EXTENDED, AGE, PHOTO,
DOCUMENT_INFO, COVID_CERTIFICATES,
DOCUMENT_INFO, DOCUMENT_PHOTO, COVID_CERTIFICATES,
ORGANISATION_ID_INFO_WITH_ADDITIONAL_ATTRIBUTES);
SignResultRequest signResultRequest = SignResultRequest.create(SIGN_REFERENCE, RELYING_PARTY_ID);
SignResult expectedResponse =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,18 @@ public abstract class CommonHttpTest {
private static final List<Email> ALL_EMAIL_ADDRESSES = Arrays.asList(new Email(EMAIL_ADDRESS));
private static final List<PhoneNumberInfo> ALL_PHONE_NUMBERS = Arrays.asList(new PhoneNumberInfo(PHONE_NUMBER));
private static final Integer AGE = 35;
private static final String PHOTO = "photo";
private static final String PHOTO = "Base64EncodedAvatarPhoto";
private static final DocumentInfo DOCUMENT_INFO =
new DocumentInfo(DocumentType.PASSPORT, "123456789", Country.SWEDEN, "2050-01-01");
private static final CovidCertificates COVID_CERTIFICATES =
new CovidCertificates(new Vaccines("covidCertificate"), null, null, true);
private static final String DOCUMENT_PHOTO = "Base64EncodedDocPhoto";
protected static final RequestedAttributes REQUESTED_ATTRIBUTES =
new RequestedAttributes(BASIC_USER_INFO, CUSTOM_IDENTIFIER, SSN_USER_INFO, null, DATE_OF_BIRTH,
RELYING_PARTY_USER_ID, EMAIL_ADDRESS, ORGANISATION_ID, ADDRESSES, ALL_EMAIL_ADDRESSES, ALL_PHONE_NUMBERS, RegistrationLevel.EXTENDED, AGE, PHOTO, DOCUMENT_INFO, COVID_CERTIFICATES, ORGANISATION_ID_INFO
);
RELYING_PARTY_USER_ID, EMAIL_ADDRESS, ORGANISATION_ID, ADDRESSES,
ALL_EMAIL_ADDRESSES, ALL_PHONE_NUMBERS, RegistrationLevel.EXTENDED, AGE,
PHOTO, DOCUMENT_INFO, DOCUMENT_PHOTO,
COVID_CERTIFICATES, ORGANISATION_ID_INFO);
protected static final String POST_PARAMS_DELIMITER = "&";
protected static final String KEY_VALUE_DELIMITER = "=";
protected static final int MOCK_SERVICE_PORT = 30665;
Expand Down

0 comments on commit 0fccb0b

Please sign in to comment.