diff --git a/FrejaEidClient/pom.xml b/FrejaEidClient/pom.xml
index d3e32e4..97d5957 100644
--- a/FrejaEidClient/pom.xml
+++ b/FrejaEidClient/pom.xml
@@ -3,7 +3,7 @@
4.0.0
com.verisec.frejaeid
FrejaEidClient
- 2.22.1-SNAPSHOT
+ 2.23.0-SNAPSHOT
jar
FrejaEidClient
diff --git a/FrejaEidClient/src/main/java/com/verisec/frejaeid/client/beans/general/RequestedAttributes.java b/FrejaEidClient/src/main/java/com/verisec/frejaeid/client/beans/general/RequestedAttributes.java
index 2c3d957..950f52d 100644
--- a/FrejaEidClient/src/main/java/com/verisec/frejaeid/client/beans/general/RequestedAttributes.java
+++ b/FrejaEidClient/src/main/java/com/verisec/frejaeid/client/beans/general/RequestedAttributes.java
@@ -34,6 +34,7 @@ public class RequestedAttributes {
private final String documentPhoto;
private final CovidCertificates covidCertificates;
private final DocumentInfoWithPdf documentInfoWithPdf;
+ private final List childrenDocumentInfoWithPdf;
@JsonCreator
public RequestedAttributes(@JsonProperty(value = "basicUserInfo") BasicUserInfo basicUserInfo,
@@ -54,7 +55,8 @@ public RequestedAttributes(@JsonProperty(value = "basicUserInfo") BasicUserInfo
@JsonProperty(value = "documentPhoto") String documentPhoto,
@JsonProperty(value = "covidCertificates") CovidCertificates covidCertificates,
@JsonProperty(value = "organisationId") OrganisationIdInfo organisationId,
- @JsonProperty(value = "documentInfoWithPdf") DocumentInfoWithPdf documentInfoWithPdf) {
+ @JsonProperty(value = "documentInfoWithPdf") DocumentInfoWithPdf documentInfoWithPdf,
+ @JsonProperty(value = "childrenDocumentInfoWithPdf") List childrenDocumentInfoWithPdf) {
this.basicUserInfo = basicUserInfo;
this.customIdentifier = customIdentifier;
this.ssn = ssn;
@@ -74,6 +76,7 @@ public RequestedAttributes(@JsonProperty(value = "basicUserInfo") BasicUserInfo
this.documentPhoto = documentPhoto;
this.covidCertificates = covidCertificates;
this.documentInfoWithPdf = documentInfoWithPdf;
+ this.childrenDocumentInfoWithPdf = childrenDocumentInfoWithPdf;
}
public BasicUserInfo getBasicUserInfo() {
@@ -152,12 +155,17 @@ public DocumentInfoWithPdf getDocumentInfoWithPdf() {
return documentInfoWithPdf;
}
+ public List getChildrenDocumentInfoWithPdf() {
+ return childrenDocumentInfoWithPdf;
+ }
+
@Override
public int hashCode() {
return Objects.hash(basicUserInfo, customIdentifier, ssn, integratorSpecificUserId,
dateOfBirth, relyingPartyUserId, emailAddress, organisationIdIdentifier,
organisationId, addresses, allEmailAddresses, allPhoneNumbers, registrationLevel, age,
- photo, document, documentPhoto, covidCertificates, documentInfoWithPdf);
+ photo, document, documentPhoto, covidCertificates, documentInfoWithPdf,
+ childrenDocumentInfoWithPdf);
}
@Override
@@ -229,6 +237,9 @@ public boolean equals(Object obj) {
if (!Objects.equals(this.documentInfoWithPdf, other.documentInfoWithPdf)) {
return false;
}
+ if (!Objects.equals(this.childrenDocumentInfoWithPdf, other.childrenDocumentInfoWithPdf)) {
+ return false;
+ }
return true;
}
@@ -254,6 +265,7 @@ public java.lang.String toString() {
", documentPhoto=" + documentPhoto +
", covidCertificates=" + covidCertificates +
", documentInfoWithPdf=" + documentInfoWithPdf +
+ ", childrenDocumentInfoWithPdf=" + childrenDocumentInfoWithPdf +
'}';
}
}
diff --git a/FrejaEidClient/src/main/java/com/verisec/frejaeid/client/client/impl/SignClient.java b/FrejaEidClient/src/main/java/com/verisec/frejaeid/client/client/impl/SignClient.java
index 6b495ec..a52d0f2 100644
--- a/FrejaEidClient/src/main/java/com/verisec/frejaeid/client/client/impl/SignClient.java
+++ b/FrejaEidClient/src/main/java/com/verisec/frejaeid/client/client/impl/SignClient.java
@@ -1,7 +1,5 @@
package com.verisec.frejaeid.client.client.impl;
-import com.verisec.frejaeid.client.beans.authentication.get.AuthenticationResult;
-import com.verisec.frejaeid.client.beans.authentication.get.AuthenticationResultRequest;
import com.verisec.frejaeid.client.beans.general.SslSettings;
import com.verisec.frejaeid.client.beans.sign.cancel.CancelSignRequest;
import com.verisec.frejaeid.client.beans.sign.get.SignResultRequest;
diff --git a/FrejaEidClient/src/main/java/com/verisec/frejaeid/client/enums/AttributeToReturn.java b/FrejaEidClient/src/main/java/com/verisec/frejaeid/client/enums/AttributeToReturn.java
index bfaf6a5..1bbd78f 100644
--- a/FrejaEidClient/src/main/java/com/verisec/frejaeid/client/enums/AttributeToReturn.java
+++ b/FrejaEidClient/src/main/java/com/verisec/frejaeid/client/enums/AttributeToReturn.java
@@ -32,6 +32,7 @@
*
- {@link #DOCUMENT_PHOTO}
*
- {@link #COVID_CERTIFICATES}
*
- {@link #DOCUMENT_INFO_WITH_PDF}
+ *
- {@link #CHILDREN_DOCUMENT_INFO_WITH_PDF}
*/
public enum AttributeToReturn {
@@ -151,7 +152,14 @@ public enum AttributeToReturn {
* {@linkplain MinRegistrationLevel#EXTENDED} and
* {@linkplain MinRegistrationLevel#PLUS}.
*/
- DOCUMENT_INFO_WITH_PDF("DOCUMENT_INFO_WITH_PDF");
+ DOCUMENT_INFO_WITH_PDF("DOCUMENT_INFO_WITH_PDF"),
+ /**
+ * Data about the user's children's documents and accompanying PDF files as a Base64-encoded String.
+ * Children documents with PDF can be requested only for
+ * {@linkplain MinRegistrationLevel#EXTENDED} and
+ * {@linkplain MinRegistrationLevel#PLUS}.
+ */
+ CHILDREN_DOCUMENT_INFO_WITH_PDF("CHILDREN_DOCUMENT_INFO_WITH_PDF");
private final String name;
diff --git a/FrejaEidClient/src/main/java/com/verisec/frejaeid/client/service/BasicService.java b/FrejaEidClient/src/main/java/com/verisec/frejaeid/client/service/BasicService.java
index 8d9dd01..842fd58 100644
--- a/FrejaEidClient/src/main/java/com/verisec/frejaeid/client/service/BasicService.java
+++ b/FrejaEidClient/src/main/java/com/verisec/frejaeid/client/service/BasicService.java
@@ -10,7 +10,6 @@
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
public class BasicService {
diff --git a/FrejaEidClient/src/test/java/com/verisec/frejaeid/client/beans/authentication/init/InitiateAuthenticationRequestBuildersTest.java b/FrejaEidClient/src/test/java/com/verisec/frejaeid/client/beans/authentication/init/InitiateAuthenticationRequestBuildersTest.java
index cabcd2a..30719fa 100644
--- a/FrejaEidClient/src/test/java/com/verisec/frejaeid/client/beans/authentication/init/InitiateAuthenticationRequestBuildersTest.java
+++ b/FrejaEidClient/src/test/java/com/verisec/frejaeid/client/beans/authentication/init/InitiateAuthenticationRequestBuildersTest.java
@@ -45,6 +45,7 @@ public static void createRequestedAttributes() {
REQUESTED_ATTRIBUTES.add(attributeOf(AttributeToReturn.DOCUMENT_PHOTO));
REQUESTED_ATTRIBUTES.add(attributeOf(AttributeToReturn.COVID_CERTIFICATES));
REQUESTED_ATTRIBUTES.add(attributeOf(AttributeToReturn.DOCUMENT_INFO_WITH_PDF));
+ REQUESTED_ATTRIBUTES.add(attributeOf(AttributeToReturn.CHILDREN_DOCUMENT_INFO_WITH_PDF));
}
private static AttributeToReturnInfo attributeOf(AttributeToReturn attributeToReturn){
diff --git a/FrejaEidClient/src/test/java/com/verisec/frejaeid/client/beans/sign/init/InitiateSignRequestBuildersTest.java b/FrejaEidClient/src/test/java/com/verisec/frejaeid/client/beans/sign/init/InitiateSignRequestBuildersTest.java
index 6bc6fa9..f4e9d4d 100644
--- a/FrejaEidClient/src/test/java/com/verisec/frejaeid/client/beans/sign/init/InitiateSignRequestBuildersTest.java
+++ b/FrejaEidClient/src/test/java/com/verisec/frejaeid/client/beans/sign/init/InitiateSignRequestBuildersTest.java
@@ -48,6 +48,7 @@ public static void createRequestedAttributes() {
REQUESTED_ATTRIBUTES.add(attributeOf(AttributeToReturn.DOCUMENT_PHOTO));
REQUESTED_ATTRIBUTES.add(attributeOf(AttributeToReturn.COVID_CERTIFICATES));
REQUESTED_ATTRIBUTES.add(attributeOf(AttributeToReturn.DOCUMENT_INFO_WITH_PDF));
+ REQUESTED_ATTRIBUTES.add(attributeOf(AttributeToReturn.CHILDREN_DOCUMENT_INFO_WITH_PDF));
}
private static AttributeToReturnInfo attributeOf(AttributeToReturn attributeToReturn){
diff --git a/FrejaEidClient/src/test/java/com/verisec/frejaeid/client/client/impl/AuthenticationClientGetResultTest.java b/FrejaEidClient/src/test/java/com/verisec/frejaeid/client/client/impl/AuthenticationClientGetResultTest.java
index f4a5655..cc42d95 100644
--- a/FrejaEidClient/src/test/java/com/verisec/frejaeid/client/client/impl/AuthenticationClientGetResultTest.java
+++ b/FrejaEidClient/src/test/java/com/verisec/frejaeid/client/client/impl/AuthenticationClientGetResultTest.java
@@ -22,6 +22,7 @@
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.junit.Assert;
import org.junit.Before;
@@ -58,11 +59,13 @@ public class AuthenticationClientGetResultTest {
private static final List ALL_EMAIL_ADDRESSES = Arrays.asList(new Email(EMAIL_ADDRESS));
private static final List 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 = "https://image-hashId/test";
private static final DocumentInfo DOCUMENT_INFO =
new DocumentInfo(DocumentType.PASSPORT, "123456789", Country.SWEDEN, "2050-01-01");
private static final DocumentInfoWithPdf DOCUMENT_WITH_PDF =
new DocumentInfoWithPdf(DocumentType.PASSPORT, "123456789", Country.SWEDEN, "2050-01-01", "Base64Pdf");
+ private static final DocumentInfoWithPdf CHILDREN_DOCUMENT_WITH_PDF =
+ new DocumentInfoWithPdf(DocumentType.PASSPORT, "987654321", Country.SWEDEN, "20240-01-01", "Base64Pdf");
private static final String DOCUMENT_PHOTO = "Base64EncodedDocPhoto";
private static final CovidCertificates COVID_CERTIFICATES =
new CovidCertificates(new Vaccines("covidCertificate"), null, null, true);
@@ -71,7 +74,7 @@ public class AuthenticationClientGetResultTest {
@BeforeClass
public static void initTestData() {
- HashMap organisationIdIssuerNames = new HashMap<>();
+ Map organisationIdIssuerNames = new HashMap<>();
organisationIdIssuerNames.put("EN", "Org ID issuer");
organisationIdIssuerNames.put("SV", "Org ID issuer Swedish");
ORGANISATION_ID_INFO =
@@ -87,7 +90,7 @@ public static void initTestData() {
ALL_EMAIL_ADDRESSES, ALL_PHONE_NUMBERS, RegistrationLevel.EXTENDED,
AGE, PHOTO, DOCUMENT_INFO, DOCUMENT_PHOTO,
COVID_CERTIFICATES, ORGANISATION_ID_INFO,
- DOCUMENT_WITH_PDF);
+ DOCUMENT_WITH_PDF, Arrays.asList(CHILDREN_DOCUMENT_WITH_PDF));
}
@Before
@@ -102,14 +105,14 @@ public void getAuthenticationResult_relyingPartyIdNull_success()
throws FrejaEidClientInternalException, FrejaEidException {
AuthenticationResultRequest authenticationResultRequest = AuthenticationResultRequest.create(REFERENCE);
when(httpServiceMock.send(anyString(), any(RequestTemplate.class),
- any(RelyingPartyRequest.class),
- Mockito.eq(AuthenticationResult.class), (String) Mockito.isNull()))
+ any(RelyingPartyRequest.class),
+ Mockito.eq(AuthenticationResult.class), (String) Mockito.isNull()))
.thenReturn(new AuthenticationResult(REFERENCE, TransactionStatus.STARTED, DETAILS,
REQUESTED_ATTRIBUTES));
AuthenticationResult response = authenticationClient.getResult(authenticationResultRequest);
verify(httpServiceMock).send(FrejaEnvironment.TEST.getServiceUrl() + MethodUrl.AUTHENTICATION_GET_RESULT,
- RequestTemplate.AUTHENTICATION_RESULT_TEMPLATE,
- authenticationResultRequest, AuthenticationResult.class, null);
+ RequestTemplate.AUTHENTICATION_RESULT_TEMPLATE,
+ authenticationResultRequest, AuthenticationResult.class, null);
assertEquals(REFERENCE, response.getAuthRef());
assertEquals(TransactionStatus.STARTED, response.getStatus());
assertEquals(DETAILS, response.getDetails());
@@ -127,8 +130,8 @@ public void getAuthenticationResultPersonal_success() throws FrejaEidClientInter
REQUESTED_ATTRIBUTES));
AuthenticationResult response = authenticationClient.getResult(authenticationResultRequest);
verify(httpServiceMock).send(FrejaEnvironment.TEST.getServiceUrl() + MethodUrl.AUTHENTICATION_GET_RESULT,
- RequestTemplate.AUTHENTICATION_RESULT_TEMPLATE,
- authenticationResultRequest, AuthenticationResult.class, RELYING_PARTY_ID);
+ RequestTemplate.AUTHENTICATION_RESULT_TEMPLATE,
+ authenticationResultRequest, AuthenticationResult.class, RELYING_PARTY_ID);
assertEquals(REFERENCE, response.getAuthRef());
assertEquals(TransactionStatus.STARTED, response.getStatus());
assertEquals(DETAILS, response.getDetails());
@@ -170,7 +173,8 @@ public void getAuthenticationResultOrganisational_withAdditionalAttributes_succe
ALL_EMAIL_ADDRESSES, ALL_PHONE_NUMBERS,
RegistrationLevel.EXTENDED, AGE, PHOTO,
DOCUMENT_INFO, DOCUMENT_PHOTO, COVID_CERTIFICATES,
- ORGANISATION_ID_INFO_WITH_ADDITIONAL_ATTRIBUTES, DOCUMENT_WITH_PDF);
+ ORGANISATION_ID_INFO_WITH_ADDITIONAL_ATTRIBUTES, DOCUMENT_WITH_PDF,
+ Arrays.asList(CHILDREN_DOCUMENT_WITH_PDF));
AuthenticationClientApi authenticationClient =
AuthenticationClient.create(TestUtil.getDefaultSslSettings(), FrejaEnvironment.TEST)
.setHttpService(httpServiceMock)
@@ -208,9 +212,9 @@ public void getAuthenticationResult_invalidReference_expectInvalidReferenceError
Assert.fail("Test should throw exception!");
} catch (FrejaEidException rpEx) {
verify(httpServiceMock).send(FrejaEnvironment.TEST.getServiceUrl() + MethodUrl.AUTHENTICATION_GET_RESULT,
- RequestTemplate.AUTHENTICATION_RESULT_TEMPLATE,
- getOneAuthenticationResultRequest, AuthenticationResult.class,
- RELYING_PARTY_ID);
+ RequestTemplate.AUTHENTICATION_RESULT_TEMPLATE,
+ getOneAuthenticationResultRequest, AuthenticationResult.class,
+ RELYING_PARTY_ID);
assertEquals(1100, rpEx.getErrorCode());
assertEquals("Invalid reference (for example, nonexistent or expired).", rpEx.getLocalizedMessage());
}
@@ -228,8 +232,8 @@ public void pollForResult_relyingPartyIdNull_finalResponseRejected_success()
.thenReturn(expectedResponse);
AuthenticationResult response = authenticationClient.pollForResult(authenticationResultRequest, 10000);
verify(httpServiceMock).send(FrejaEnvironment.TEST.getServiceUrl() + MethodUrl.AUTHENTICATION_GET_RESULT,
- RequestTemplate.AUTHENTICATION_RESULT_TEMPLATE,
- authenticationResultRequest, AuthenticationResult.class, null);
+ RequestTemplate.AUTHENTICATION_RESULT_TEMPLATE,
+ authenticationResultRequest, AuthenticationResult.class, null);
assertEquals(TransactionStatus.REJECTED, response.getStatus());
}
@@ -247,8 +251,8 @@ public void pollForResult_relyingPartyIdNotNull_finalResponseRejected_success()
AuthenticationResult response = authenticationClient
.pollForResult(AuthenticationResultRequest.create(REFERENCE, RELYING_PARTY_ID), 10000);
verify(httpServiceMock).send(FrejaEnvironment.TEST.getServiceUrl() + MethodUrl.AUTHENTICATION_GET_RESULT,
- RequestTemplate.AUTHENTICATION_RESULT_TEMPLATE,
- authenticationResultRequest, AuthenticationResult.class, RELYING_PARTY_ID);
+ RequestTemplate.AUTHENTICATION_RESULT_TEMPLATE,
+ authenticationResultRequest, AuthenticationResult.class, RELYING_PARTY_ID);
assertEquals(TransactionStatus.REJECTED, response.getStatus());
}
@@ -293,9 +297,9 @@ private void getAuthenticationResults_success(AuthenticationResultsRequest getAu
throws FrejaEidClientInternalException, FrejaEidException {
List response = authenticationClient.getResults(getAuthenticationResultsRequest);
verify(httpServiceMock).send(FrejaEnvironment.TEST.getServiceUrl() + MethodUrl.AUTHENTICATION_GET_RESULTS,
- RequestTemplate.AUTHENTICATION_RESULTS_TEMPLATE,
- getAuthenticationResultsRequest, AuthenticationResults.class,
- getAuthenticationResultsRequest.getRelyingPartyId());
+ RequestTemplate.AUTHENTICATION_RESULTS_TEMPLATE,
+ getAuthenticationResultsRequest, AuthenticationResults.class,
+ getAuthenticationResultsRequest.getRelyingPartyId());
AuthenticationResult first = response.get(0);
assertEquals(REFERENCE, first.getAuthRef());
assertEquals(TransactionStatus.STARTED, first.getStatus());
@@ -315,12 +319,13 @@ private AuthenticationResults prepareResponse() {
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, DOCUMENT_WITH_PDF);
+ ORGANISATION_ID_INFO, DOCUMENT_WITH_PDF,
+ Arrays.asList(CHILDREN_DOCUMENT_WITH_PDF));
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, null, null);
+ null, null, null, null, null, null, null, null, null, null);
AuthenticationResult secondResponse =
new AuthenticationResult(REFERENCE, TransactionStatus.DELIVERED_TO_MOBILE, "test", attributes2);
List responses = new ArrayList<>();
diff --git a/FrejaEidClient/src/test/java/com/verisec/frejaeid/client/client/impl/SignClientGetResultTest.java b/FrejaEidClient/src/test/java/com/verisec/frejaeid/client/client/impl/SignClientGetResultTest.java
index 9a7c80d..04bf659 100644
--- a/FrejaEidClient/src/test/java/com/verisec/frejaeid/client/client/impl/SignClientGetResultTest.java
+++ b/FrejaEidClient/src/test/java/com/verisec/frejaeid/client/client/impl/SignClientGetResultTest.java
@@ -22,6 +22,7 @@
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.junit.Assert;
import org.junit.Before;
@@ -58,6 +59,8 @@ public class SignClientGetResultTest {
new DocumentInfo(DocumentType.PASSPORT, "123456789", Country.SWEDEN, "2050-01-01");
private static final DocumentInfoWithPdf DOCUMENT_WITH_PDF =
new DocumentInfoWithPdf(DocumentType.PASSPORT, "123456789", Country.SWEDEN, "2050-01-01", "Base64Pdf");
+ private static final DocumentInfoWithPdf CHILDREN_DOCUMENT_WITH_PDF =
+ new DocumentInfoWithPdf(DocumentType.PASSPORT, "987654321", Country.SWEDEN, "20240-01-01", "Base64Pdf");
private static final String DOCUMENT_PHOTO = "Base64EncodedDocPhoto";
protected static final CovidCertificates COVID_CERTIFICATES =
new CovidCertificates(new Vaccines("covidCertificate"), null, null, true);
@@ -66,7 +69,7 @@ public class SignClientGetResultTest {
@BeforeClass
public static void initTestData() {
- HashMap organisationIdIssuerNames = new HashMap<>();
+ Map organisationIdIssuerNames = new HashMap<>();
organisationIdIssuerNames.put("EN", "Org ID issuer");
organisationIdIssuerNames.put("SV", "Org ID issuer Swedish");
ORGANISATION_ID_INFO =
@@ -82,7 +85,8 @@ public static void initTestData() {
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, DOCUMENT_WITH_PDF);
+ COVID_CERTIFICATES, ORGANISATION_ID_INFO, DOCUMENT_WITH_PDF,
+ Arrays.asList(CHILDREN_DOCUMENT_WITH_PDF));
}
@Before
@@ -99,12 +103,12 @@ public void getSignResult_relyingPartyIdNull_expectSuccess()
SignResult expectedResponse = new SignResult(SIGN_REFERENCE, TransactionStatus.STARTED, SIGN_DETAILS,
REQUESTED_ATTRIBUTES);
when(httpServiceMock.send(anyString(), any(RequestTemplate.class),
- any(RelyingPartyRequest.class), Mockito.eq(SignResult.class),
- (String) Mockito.isNull())).thenReturn(expectedResponse);
+ any(RelyingPartyRequest.class), Mockito.eq(SignResult.class),
+ (String) Mockito.isNull())).thenReturn(expectedResponse);
SignResult response = signClient.getResult(signResultsRequest);
verify(httpServiceMock).send(FrejaEnvironment.TEST.getServiceUrl() + MethodUrl.SIGN_GET_RESULT,
- RequestTemplate.SIGN_RESULT_TEMPLATE, signResultsRequest,
- SignResult.class, null);
+ RequestTemplate.SIGN_RESULT_TEMPLATE, signResultsRequest,
+ SignResult.class, null);
assertEquals(SIGN_REFERENCE, response.getSignRef());
assertEquals(TransactionStatus.STARTED, response.getStatus());
assertEquals(SIGN_DETAILS, response.getDetails());
@@ -121,8 +125,8 @@ public void getSignResultPersonal_expectSuccess() throws FrejaEidClientInternalE
anyString())).thenReturn(expectedResponse);
SignResult response = signClient.getResult(signResultRequest);
verify(httpServiceMock).send(FrejaEnvironment.TEST.getServiceUrl() + MethodUrl.SIGN_GET_RESULT,
- RequestTemplate.SIGN_RESULT_TEMPLATE, signResultRequest,
- SignResult.class, RELYING_PARTY_ID);
+ RequestTemplate.SIGN_RESULT_TEMPLATE, signResultRequest,
+ SignResult.class, RELYING_PARTY_ID);
assertEquals(SIGN_REFERENCE, response.getSignRef());
assertEquals(TransactionStatus.STARTED, response.getStatus());
assertEquals(SIGN_DETAILS, response.getDetails());
@@ -151,7 +155,8 @@ public void getSignResultOrganisational_expectSuccess() throws FrejaEidClientInt
}
@Test
- public void getSignResultOrganisational_withAdditionalAttributes_expectSuccess() throws FrejaEidClientInternalException, FrejaEidException {
+ public void getSignResultOrganisational_withAdditionalAttributes_expectSuccess() throws
+ FrejaEidClientInternalException, FrejaEidException {
RequestedAttributes requestedAttributes =
new RequestedAttributes(new BasicUserInfo("name", "surname"), "customIdentifier",
SsnUserInfo.create(Country.SWEDEN, "ssn"), null,
@@ -160,7 +165,8 @@ public void getSignResultOrganisational_withAdditionalAttributes_expectSuccess()
ALL_EMAIL_ADDRESSES, ALL_PHONE_NUMBERS,
RegistrationLevel.EXTENDED, AGE, PHOTO,
DOCUMENT_INFO, DOCUMENT_PHOTO, COVID_CERTIFICATES,
- ORGANISATION_ID_INFO_WITH_ADDITIONAL_ATTRIBUTES, DOCUMENT_WITH_PDF);
+ ORGANISATION_ID_INFO_WITH_ADDITIONAL_ATTRIBUTES, DOCUMENT_WITH_PDF,
+ Arrays.asList(CHILDREN_DOCUMENT_WITH_PDF));
SignResultRequest signResultRequest = SignResultRequest.create(SIGN_REFERENCE, RELYING_PARTY_ID);
SignResult expectedResponse =
new SignResult(SIGN_REFERENCE, TransactionStatus.APPROVED, SIGN_DETAILS, requestedAttributes);
@@ -194,8 +200,8 @@ public void getSignResult_invalidReference_expectInvalidReferenceError()
Assert.fail("Test should throw exception!");
} catch (FrejaEidException rpEx) {
verify(httpServiceMock).send(FrejaEnvironment.TEST.getServiceUrl() + MethodUrl.SIGN_GET_RESULT,
- RequestTemplate.SIGN_RESULT_TEMPLATE, signResultRequest,
- SignResult.class, RELYING_PARTY_ID);
+ RequestTemplate.SIGN_RESULT_TEMPLATE, signResultRequest,
+ SignResult.class, RELYING_PARTY_ID);
assertEquals(1100, rpEx.getErrorCode());
assertEquals("Invalid reference (for example, nonexistent or expired).", rpEx.getLocalizedMessage());
}
@@ -211,8 +217,8 @@ public void pollForResult_finalResponseRejected_success()
SignResultRequest signResultRequest = SignResultRequest.create(SIGN_REFERENCE);
SignResult response = signClient.pollForResult(signResultRequest, 10000);
verify(httpServiceMock).send(FrejaEnvironment.TEST.getServiceUrl() + MethodUrl.SIGN_GET_RESULT,
- RequestTemplate.SIGN_RESULT_TEMPLATE, signResultRequest,
- SignResult.class, null);
+ RequestTemplate.SIGN_RESULT_TEMPLATE, signResultRequest,
+ SignResult.class, null);
assertEquals(TransactionStatus.REJECTED, response.getStatus());
}
@@ -264,8 +270,8 @@ public void getSignResults_expectError() throws FrejaEidClientInternalException,
Assert.fail("Test should throw exception!");
} catch (FrejaEidException rpEx) {
verify(httpServiceMock).send(FrejaEnvironment.TEST.getServiceUrl() + MethodUrl.SIGN_GET_RESULTS,
- RequestTemplate.SIGN_RESULTS_TEMPLATE, signResultsRequest,
- SignResults.class, RELYING_PARTY_ID);
+ RequestTemplate.SIGN_RESULTS_TEMPLATE, signResultsRequest,
+ SignResults.class, RELYING_PARTY_ID);
assertEquals(1008, rpEx.getErrorCode());
assertEquals("Unknown Relying party.", rpEx.getLocalizedMessage());
}
@@ -276,8 +282,8 @@ private void getSignResults_success(SignResultsRequest signResultsRequest)
throws FrejaEidClientInternalException, FrejaEidException {
List response = signClient.getResults(signResultsRequest);
verify(httpServiceMock).send(FrejaEnvironment.TEST.getServiceUrl() + MethodUrl.SIGN_GET_RESULTS,
- RequestTemplate.SIGN_RESULTS_TEMPLATE, signResultsRequest,
- SignResults.class, signResultsRequest.getRelyingPartyId());
+ RequestTemplate.SIGN_RESULTS_TEMPLATE, signResultsRequest,
+ SignResults.class, signResultsRequest.getRelyingPartyId());
SignResult firstResponse = response.get(0);
assertEquals(SIGN_REFERENCE, firstResponse.getSignRef());
diff --git a/FrejaEidClient/src/test/java/com/verisec/frejaeid/client/http/CommonHttpTest.java b/FrejaEidClient/src/test/java/com/verisec/frejaeid/client/http/CommonHttpTest.java
index a511b40..f6d1ea7 100644
--- a/FrejaEidClient/src/test/java/com/verisec/frejaeid/client/http/CommonHttpTest.java
+++ b/FrejaEidClient/src/test/java/com/verisec/frejaeid/client/http/CommonHttpTest.java
@@ -20,6 +20,7 @@
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.apache.commons.codec.binary.Base64;
import org.junit.After;
@@ -56,6 +57,8 @@ public abstract class CommonHttpTest {
new DocumentInfo(DocumentType.PASSPORT, "123456789", Country.SWEDEN, "2050-01-01");
private static final DocumentInfoWithPdf DOCUMENT_WITH_PDF =
new DocumentInfoWithPdf(DocumentType.PASSPORT, "123456789", Country.SWEDEN, "2050-01-01", "Base64Pdf");
+ private static final DocumentInfoWithPdf CHILDREN_DOCUMENT_WITH_PDF =
+ new DocumentInfoWithPdf(DocumentType.PASSPORT, "987654321", Country.SWEDEN, "20240-01-01", "Base64Pdf");
private static final CovidCertificates COVID_CERTIFICATES =
new CovidCertificates(new Vaccines("covidCertificate"), null, null, true);
private static final String DOCUMENT_PHOTO = "Base64EncodedDocPhoto";
@@ -64,7 +67,8 @@ public abstract class CommonHttpTest {
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, DOCUMENT_WITH_PDF);
+ COVID_CERTIFICATES, ORGANISATION_ID_INFO, DOCUMENT_WITH_PDF,
+ Arrays.asList(CHILDREN_DOCUMENT_WITH_PDF));
protected static final String POST_PARAMS_DELIMITER = "&";
protected static final String KEY_VALUE_DELIMITER = "=";
protected static final int MOCK_SERVICE_PORT = 30665;
@@ -73,7 +77,7 @@ public abstract class CommonHttpTest {
@BeforeClass
public static void initTestData() {
- HashMap organisationIdIssuerNames = new HashMap<>();
+ Map organisationIdIssuerNames = new HashMap<>();
organisationIdIssuerNames.put("EN", "Org ID issuer");
organisationIdIssuerNames.put("SV", "Org ID issuer Swedish");
ORGANISATION_ID_INFO =
@@ -86,56 +90,56 @@ protected void startMockServer(final RelyingPartyRequest expectedRequest,
throws IOException {
server = HttpServer.create(new InetSocketAddress(MOCK_SERVICE_PORT), 0);
server.createContext("/", new HttpHandler() {
- @Override
- public void handle(HttpExchange t) throws IOException {
- String requestData;
- try (InputStreamReader isr = new InputStreamReader(t.getRequestBody())) {
- BufferedReader reader = new BufferedReader(isr);
- requestData = reader.readLine();
-
- if (requestData != null) {
- String[] postParams = requestData.split(POST_PARAMS_DELIMITER);
- if (postParams.length == 2) {
- String relyingPartyIdParam = postParams[1].split(KEY_VALUE_DELIMITER, 2)[1];
- assertEquals(RELYING_PARTY_ID, relyingPartyIdParam);
-
- String requestParam = postParams[0].split(KEY_VALUE_DELIMITER, 2)[1];
- String jsonReceivedRequest = new String(Base64.decodeBase64(requestParam),
- StandardCharsets.UTF_8);
- String jsonExpectedRequest = jsonService.serializeToJson(expectedRequest);
- assertEquals(jsonExpectedRequest, jsonReceivedRequest);
-
- RelyingPartyRequest receivedRequest =
- jsonService.deserializeFromJson(Base64.decodeBase64(requestParam),
- expectedRequest.getClass());
- assertEquals(expectedRequest, receivedRequest);
- } else if (containsKeyValueDelimiter(postParams)) {
- String relyingPartyIdParam = postParams[0].split(KEY_VALUE_DELIMITER, 2)[1];
- assertEquals(RELYING_PARTY_ID, relyingPartyIdParam);
- } else {
- String requestParam = postParams[0].split(KEY_VALUE_DELIMITER, 2)[1];
- String jsonReceivedRequest = new String(Base64.decodeBase64(requestParam),
- StandardCharsets.UTF_8);
- String jsonExpectedRequest = jsonService.serializeToJson(expectedRequest);
- assertEquals(jsonExpectedRequest, jsonReceivedRequest);
-
- RelyingPartyRequest receivedRequest =
- jsonService.deserializeFromJson(Base64.decodeBase64(requestParam),
- expectedRequest.getClass());
- assertEquals(expectedRequest, receivedRequest);
- }
-
- }
- } catch (Exception ex) {
- Assert.fail(ex.getMessage());
- }
-
- t.sendResponseHeaders(statusCodeToReturn, responseToReturn.length());
- try (OutputStream os = t.getResponseBody()) {
- os.write(responseToReturn.getBytes());
- }
- }
- });
+ @Override
+ public void handle(HttpExchange t) throws IOException {
+ String requestData;
+ try (InputStreamReader isr = new InputStreamReader(t.getRequestBody())) {
+ BufferedReader reader = new BufferedReader(isr);
+ requestData = reader.readLine();
+
+ if (requestData != null) {
+ String[] postParams = requestData.split(POST_PARAMS_DELIMITER);
+ if (postParams.length == 2) {
+ String relyingPartyIdParam = postParams[1].split(KEY_VALUE_DELIMITER, 2)[1];
+ assertEquals(RELYING_PARTY_ID, relyingPartyIdParam);
+
+ String requestParam = postParams[0].split(KEY_VALUE_DELIMITER, 2)[1];
+ String jsonReceivedRequest = new String(Base64.decodeBase64(requestParam),
+ StandardCharsets.UTF_8);
+ String jsonExpectedRequest = jsonService.serializeToJson(expectedRequest);
+ assertEquals(jsonExpectedRequest, jsonReceivedRequest);
+
+ RelyingPartyRequest receivedRequest =
+ jsonService.deserializeFromJson(Base64.decodeBase64(requestParam),
+ expectedRequest.getClass());
+ assertEquals(expectedRequest, receivedRequest);
+ } else if (containsKeyValueDelimiter(postParams)) {
+ String relyingPartyIdParam = postParams[0].split(KEY_VALUE_DELIMITER, 2)[1];
+ assertEquals(RELYING_PARTY_ID, relyingPartyIdParam);
+ } else {
+ String requestParam = postParams[0].split(KEY_VALUE_DELIMITER, 2)[1];
+ String jsonReceivedRequest = new String(Base64.decodeBase64(requestParam),
+ StandardCharsets.UTF_8);
+ String jsonExpectedRequest = jsonService.serializeToJson(expectedRequest);
+ assertEquals(jsonExpectedRequest, jsonReceivedRequest);
+
+ RelyingPartyRequest receivedRequest =
+ jsonService.deserializeFromJson(Base64.decodeBase64(requestParam),
+ expectedRequest.getClass());
+ assertEquals(expectedRequest, receivedRequest);
+ }
+
+ }
+ } catch (Exception ex) {
+ Assert.fail(ex.getMessage());
+ }
+
+ t.sendResponseHeaders(statusCodeToReturn, responseToReturn.length());
+ try (OutputStream os = t.getResponseBody()) {
+ os.write(responseToReturn.getBytes());
+ }
+ }
+ });
server.setExecutor(null); // creates a default executor
server.start();
}