From 6e98a1e160c081545f7ae5215194969618671308 Mon Sep 17 00:00:00 2001 From: Branko Pavlovic Date: Mon, 9 Sep 2024 11:51:31 +0200 Subject: [PATCH 1/2] RN Introduced new RP attribute called `NETWORK_INFO`, whose value contains a public IP address of the client (more info may be added later on to the returned object/structure). --- .../client/beans/general/NetworkInfo.java | 36 +++++++++++++++++++ .../beans/general/RequestedAttributes.java | 16 +++++++-- .../client/enums/AttributeToReturn.java | 7 +++- ...iateAuthenticationRequestBuildersTest.java | 1 + .../init/InitiateSignRequestBuildersTest.java | 1 + .../AuthenticationClientGetResultTest.java | 12 ++++--- .../client/impl/SignClientGetResultTest.java | 7 ++-- .../frejaeid/client/http/CommonHttpTest.java | 4 ++- 8 files changed, 74 insertions(+), 10 deletions(-) create mode 100644 FrejaEidClient/src/main/java/com/verisec/frejaeid/client/beans/general/NetworkInfo.java diff --git a/FrejaEidClient/src/main/java/com/verisec/frejaeid/client/beans/general/NetworkInfo.java b/FrejaEidClient/src/main/java/com/verisec/frejaeid/client/beans/general/NetworkInfo.java new file mode 100644 index 0000000..10b022f --- /dev/null +++ b/FrejaEidClient/src/main/java/com/verisec/frejaeid/client/beans/general/NetworkInfo.java @@ -0,0 +1,36 @@ +package com.verisec.frejaeid.client.beans.general; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.Objects; + +public class NetworkInfo { + + private final String publicIp; + + public NetworkInfo(@JsonProperty(value = "publicIp") String publicIp) { + this.publicIp = publicIp; + } + + public String getPublicIp() { + return publicIp; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof NetworkInfo)) return false; + NetworkInfo that = (NetworkInfo) o; + return Objects.equals(publicIp, that.publicIp); + } + + @Override + public int hashCode() { + return Objects.hashCode(publicIp); + } + + @Override + public String toString() { + return "NetworkInfo{" + "publicIp=" + publicIp + '}'; + } +} 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 950f52d..54ec9de 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 @@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.verisec.frejaeid.client.beans.covidcertificate.CovidCertificates; import com.verisec.frejaeid.client.enums.RegistrationLevel; +import sun.nio.ch.Net; import java.util.List; import java.util.Objects; @@ -35,6 +36,7 @@ public class RequestedAttributes { private final CovidCertificates covidCertificates; private final DocumentInfoWithPdf documentInfoWithPdf; private final List childrenDocumentInfoWithPdf; + private final NetworkInfo networkInfo; @JsonCreator public RequestedAttributes(@JsonProperty(value = "basicUserInfo") BasicUserInfo basicUserInfo, @@ -56,7 +58,8 @@ public RequestedAttributes(@JsonProperty(value = "basicUserInfo") BasicUserInfo @JsonProperty(value = "covidCertificates") CovidCertificates covidCertificates, @JsonProperty(value = "organisationId") OrganisationIdInfo organisationId, @JsonProperty(value = "documentInfoWithPdf") DocumentInfoWithPdf documentInfoWithPdf, - @JsonProperty(value = "childrenDocumentInfoWithPdf") List childrenDocumentInfoWithPdf) { + @JsonProperty(value = "childrenDocumentInfoWithPdf") List childrenDocumentInfoWithPdf, + @JsonProperty(value = "networkInfo") NetworkInfo networkInfo) { this.basicUserInfo = basicUserInfo; this.customIdentifier = customIdentifier; this.ssn = ssn; @@ -77,6 +80,7 @@ public RequestedAttributes(@JsonProperty(value = "basicUserInfo") BasicUserInfo this.covidCertificates = covidCertificates; this.documentInfoWithPdf = documentInfoWithPdf; this.childrenDocumentInfoWithPdf = childrenDocumentInfoWithPdf; + this.networkInfo = networkInfo; } public BasicUserInfo getBasicUserInfo() { @@ -159,13 +163,17 @@ public List getChildrenDocumentInfoWithPdf() { return childrenDocumentInfoWithPdf; } + public NetworkInfo getNetworkInfo() { + return networkInfo; + } + @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, - childrenDocumentInfoWithPdf); + childrenDocumentInfoWithPdf, networkInfo); } @Override @@ -240,6 +248,9 @@ public boolean equals(Object obj) { if (!Objects.equals(this.childrenDocumentInfoWithPdf, other.childrenDocumentInfoWithPdf)) { return false; } + if (!Objects.equals(this.networkInfo, other.networkInfo)) { + return false; + } return true; } @@ -266,6 +277,7 @@ public java.lang.String toString() { ", covidCertificates=" + covidCertificates + ", documentInfoWithPdf=" + documentInfoWithPdf + ", childrenDocumentInfoWithPdf=" + childrenDocumentInfoWithPdf + + ", networkInfo=" + networkInfo + '}'; } } 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 1bbd78f..a6f9d76 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 @@ -159,7 +159,12 @@ public enum AttributeToReturn { * {@linkplain MinRegistrationLevel#EXTENDED} and * {@linkplain MinRegistrationLevel#PLUS}. */ - CHILDREN_DOCUMENT_INFO_WITH_PDF("CHILDREN_DOCUMENT_INFO_WITH_PDF"); + CHILDREN_DOCUMENT_INFO_WITH_PDF("CHILDREN_DOCUMENT_INFO_WITH_PDF"), + + /** + * Data contains information about the client device network connection. + */ + NETWORK_INFO("NETWORK_INFO"); private final String name; 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 30719fa..8c6058f 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 @@ -46,6 +46,7 @@ public static void createRequestedAttributes() { 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)); + REQUESTED_ATTRIBUTES.add(attributeOf(AttributeToReturn.NETWORK_INFO)); } 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 f4e9d4d..6f40cc1 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 @@ -49,6 +49,7 @@ public static void createRequestedAttributes() { 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)); + REQUESTED_ATTRIBUTES.add(attributeOf(AttributeToReturn.NETWORK_INFO)); } 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 cc42d95..f695513 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 @@ -69,6 +69,7 @@ public class AuthenticationClientGetResultTest { private static final String DOCUMENT_PHOTO = "Base64EncodedDocPhoto"; private static final CovidCertificates COVID_CERTIFICATES = new CovidCertificates(new Vaccines("covidCertificate"), null, null, true); + private static final NetworkInfo NETWORK_INFO = new NetworkInfo("123.45.6.7"); private static RequestedAttributes REQUESTED_ATTRIBUTES; private AuthenticationClientApi authenticationClient; @@ -90,7 +91,8 @@ 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, Arrays.asList(CHILDREN_DOCUMENT_WITH_PDF)); + DOCUMENT_WITH_PDF, Arrays.asList(CHILDREN_DOCUMENT_WITH_PDF), + NETWORK_INFO); } @Before @@ -174,7 +176,8 @@ public void getAuthenticationResultOrganisational_withAdditionalAttributes_succe RegistrationLevel.EXTENDED, AGE, PHOTO, DOCUMENT_INFO, DOCUMENT_PHOTO, COVID_CERTIFICATES, ORGANISATION_ID_INFO_WITH_ADDITIONAL_ATTRIBUTES, DOCUMENT_WITH_PDF, - Arrays.asList(CHILDREN_DOCUMENT_WITH_PDF)); + Arrays.asList(CHILDREN_DOCUMENT_WITH_PDF), + NETWORK_INFO); AuthenticationClientApi authenticationClient = AuthenticationClient.create(TestUtil.getDefaultSslSettings(), FrejaEnvironment.TEST) .setHttpService(httpServiceMock) @@ -320,12 +323,13 @@ private AuthenticationResults prepareResponse() { ALL_EMAIL_ADDRESSES, ALL_PHONE_NUMBERS, RegistrationLevel.EXTENDED, AGE, PHOTO, DOCUMENT_INFO, DOCUMENT_PHOTO, COVID_CERTIFICATES, ORGANISATION_ID_INFO, DOCUMENT_WITH_PDF, - Arrays.asList(CHILDREN_DOCUMENT_WITH_PDF)); + Arrays.asList(CHILDREN_DOCUMENT_WITH_PDF), + NETWORK_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, 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 04bf659..41f6122 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 @@ -64,6 +64,7 @@ public class SignClientGetResultTest { private static final String DOCUMENT_PHOTO = "Base64EncodedDocPhoto"; protected static final CovidCertificates COVID_CERTIFICATES = new CovidCertificates(new Vaccines("covidCertificate"), null, null, true); + private static final NetworkInfo NETWORK_INFO = new NetworkInfo("123.45.6.7"); private static RequestedAttributes REQUESTED_ATTRIBUTES; private SignClientApi signClient; @@ -86,7 +87,8 @@ 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, - Arrays.asList(CHILDREN_DOCUMENT_WITH_PDF)); + Arrays.asList(CHILDREN_DOCUMENT_WITH_PDF), + NETWORK_INFO); } @Before @@ -166,7 +168,8 @@ public void getSignResultOrganisational_withAdditionalAttributes_expectSuccess() RegistrationLevel.EXTENDED, AGE, PHOTO, DOCUMENT_INFO, DOCUMENT_PHOTO, COVID_CERTIFICATES, ORGANISATION_ID_INFO_WITH_ADDITIONAL_ATTRIBUTES, DOCUMENT_WITH_PDF, - Arrays.asList(CHILDREN_DOCUMENT_WITH_PDF)); + Arrays.asList(CHILDREN_DOCUMENT_WITH_PDF), + NETWORK_INFO); SignResultRequest signResultRequest = SignResultRequest.create(SIGN_REFERENCE, RELYING_PARTY_ID); SignResult expectedResponse = new SignResult(SIGN_REFERENCE, TransactionStatus.APPROVED, SIGN_DETAILS, requestedAttributes); 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 f6d1ea7..b2938d8 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 @@ -62,13 +62,15 @@ public abstract class CommonHttpTest { private static final CovidCertificates COVID_CERTIFICATES = new CovidCertificates(new Vaccines("covidCertificate"), null, null, true); private static final String DOCUMENT_PHOTO = "Base64EncodedDocPhoto"; + private static final NetworkInfo NETWORK_INFO = new NetworkInfo("123.45.6.7"); 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, DOCUMENT_PHOTO, COVID_CERTIFICATES, ORGANISATION_ID_INFO, DOCUMENT_WITH_PDF, - Arrays.asList(CHILDREN_DOCUMENT_WITH_PDF)); + Arrays.asList(CHILDREN_DOCUMENT_WITH_PDF), + NETWORK_INFO); protected static final String POST_PARAMS_DELIMITER = "&"; protected static final String KEY_VALUE_DELIMITER = "="; protected static final int MOCK_SERVICE_PORT = 30665; From f2cfefafd1f92a69dd6ae3fb0f43f770ea9467a2 Mon Sep 17 00:00:00 2001 From: Branko Pavlovic Date: Mon, 9 Sep 2024 11:52:22 +0200 Subject: [PATCH 2/2] RN JDK 20 dropped support for Java source/target 1.7, and since we migrated to JDK 21 we had to upgrade source/version to 1.8. --- FrejaEidClient/pom.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/FrejaEidClient/pom.xml b/FrejaEidClient/pom.xml index cd78a5e..1175ec4 100644 --- a/FrejaEidClient/pom.xml +++ b/FrejaEidClient/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.verisec.frejaeid FrejaEidClient - 2.24.1-SNAPSHOT + 2.25.0-SNAPSHOT jar FrejaEidClient @@ -34,8 +34,8 @@ - 1.7 - 1.7 + 1.8 + 1.8 UTF-8 github