Skip to content

Commit

Permalink
Merge pull request #141 from Freja-eID/master
Browse files Browse the repository at this point in the history
Support for NETWORK_INFO attribute
  • Loading branch information
banepavl authored Sep 9, 2024
2 parents fcdf0d4 + bea409b commit 283c789
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 13 deletions.
6 changes: 3 additions & 3 deletions 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.24.1-SNAPSHOT</version>
<version>2.25.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>FrejaEidClient</name>
Expand Down Expand Up @@ -34,8 +34,8 @@
</developers>

<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.scm.id>github</project.scm.id>
</properties>
Expand Down
Original file line number Diff line number Diff line change
@@ -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 + '}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -35,6 +36,7 @@ public class RequestedAttributes {
private final CovidCertificates covidCertificates;
private final DocumentInfoWithPdf documentInfoWithPdf;
private final List<DocumentInfoWithPdf> childrenDocumentInfoWithPdf;
private final NetworkInfo networkInfo;

@JsonCreator
public RequestedAttributes(@JsonProperty(value = "basicUserInfo") BasicUserInfo basicUserInfo,
Expand All @@ -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<DocumentInfoWithPdf> childrenDocumentInfoWithPdf) {
@JsonProperty(value = "childrenDocumentInfoWithPdf") List<DocumentInfoWithPdf> childrenDocumentInfoWithPdf,
@JsonProperty(value = "networkInfo") NetworkInfo networkInfo) {
this.basicUserInfo = basicUserInfo;
this.customIdentifier = customIdentifier;
this.ssn = ssn;
Expand All @@ -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() {
Expand Down Expand Up @@ -159,13 +163,17 @@ public List<DocumentInfoWithPdf> 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
Expand Down Expand Up @@ -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;
}

Expand All @@ -266,6 +277,7 @@ public java.lang.String toString() {
", covidCertificates=" + covidCertificates +
", documentInfoWithPdf=" + documentInfoWithPdf +
", childrenDocumentInfoWithPdf=" + childrenDocumentInfoWithPdf +
", networkInfo=" + networkInfo +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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<AuthenticationResult> responses = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 283c789

Please sign in to comment.