Skip to content

Commit

Permalink
Merge pull request #148 from Freja-eID/master
Browse files Browse the repository at this point in the history
LOA Level and Unique Personal Identifier as attributes
  • Loading branch information
mirkostojmenovic-frejaeid authored Jan 31, 2025
2 parents e5aa04e + d03fdc3 commit ae5645c
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 11 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.26.1-SNAPSHOT</version>
<version>2.27.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>FrejaEidClient</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.verisec.frejaeid.client.beans.covidcertificate.CovidCertificates;
import com.verisec.frejaeid.client.enums.LoaLevel;
import com.verisec.frejaeid.client.enums.RegistrationLevel;

import java.util.List;
Expand Down Expand Up @@ -37,6 +38,9 @@ public class RequestedAttributes {
private final List<DocumentInfoWithPdf> childrenDocumentInfoWithPdf;
private final NetworkInfo networkInfo;

private final LoaLevel loaLevel;
private final String uniquePersonalIdentifier;

@JsonCreator
public RequestedAttributes(@JsonProperty(value = "basicUserInfo") BasicUserInfo basicUserInfo,
@JsonProperty(value = "customIdentifier") String customIdentifier,
Expand All @@ -58,7 +62,9 @@ public RequestedAttributes(@JsonProperty(value = "basicUserInfo") BasicUserInfo
@JsonProperty(value = "organisationId") OrganisationIdInfo organisationId,
@JsonProperty(value = "documentInfoWithPdf") DocumentInfoWithPdf documentInfoWithPdf,
@JsonProperty(value = "childrenDocumentInfoWithPdf") List<DocumentInfoWithPdf> childrenDocumentInfoWithPdf,
@JsonProperty(value = "networkInfo") NetworkInfo networkInfo) {
@JsonProperty(value = "networkInfo") NetworkInfo networkInfo,
@JsonProperty(value = "loaLevel") LoaLevel loaLevel,
@JsonProperty(value = "uniquePersonalIdentifier") String uniquePersonalIdentifier) {
this.basicUserInfo = basicUserInfo;
this.customIdentifier = customIdentifier;
this.ssn = ssn;
Expand All @@ -80,6 +86,8 @@ public RequestedAttributes(@JsonProperty(value = "basicUserInfo") BasicUserInfo
this.documentInfoWithPdf = documentInfoWithPdf;
this.childrenDocumentInfoWithPdf = childrenDocumentInfoWithPdf;
this.networkInfo = networkInfo;
this.loaLevel = loaLevel;
this.uniquePersonalIdentifier = uniquePersonalIdentifier;
}

public BasicUserInfo getBasicUserInfo() {
Expand Down Expand Up @@ -166,13 +174,21 @@ public NetworkInfo getNetworkInfo() {
return networkInfo;
}

public LoaLevel getLoaLevel() {
return loaLevel;
}

public String getUniquePersonalIdentifier() {
return uniquePersonalIdentifier;
}

@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, networkInfo);
childrenDocumentInfoWithPdf, networkInfo, loaLevel, uniquePersonalIdentifier);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
* <br> - {@link #COVID_CERTIFICATES}
* <br> - {@link #DOCUMENT_INFO_WITH_PDF}
* <br> - {@link #CHILDREN_DOCUMENT_INFO_WITH_PDF}
* <br> - {@link #NETWORK_INFO}
* <br> - {@link #LOA_LEVEL}
* <br> - {@link #UNIQUE_PERSONAL_IDENTIFIER}
*/
public enum AttributeToReturn {

Expand Down Expand Up @@ -164,7 +167,17 @@ public enum AttributeToReturn {
/**
* Data contains information about the client device network connection.
*/
NETWORK_INFO("NETWORK_INFO");
NETWORK_INFO("NETWORK_INFO"),
/**
* Level of Assurance as defined by The Swedish Agency for Digital Government (Digg)
* Corresponds to one of the values of {@linkplain LoaLevel}.
*/
LOA_LEVEL("LOA_LEVEL"),
/**
* Identifier generated by Freja for the purposes of identifying the same user
* across multiple Relying Parties
*/
UNIQUE_PERSONAL_IDENTIFIER("UNIQUE_PERSONAL_IDENTIFIER");

private final String name;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.verisec.frejaeid.client.enums;

public enum LoaLevel {
LOA1("LOA1"),
LOA2("LOA2"),
LOA3("LOA3"),
LOA3NR("LOA3-NR");

private final String level;

LoaLevel(String level) {
this.level = level;
}

public String getLevel() {
return level;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public static void createRequestedAttributes() {
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));
REQUESTED_ATTRIBUTES.add(attributeOf(AttributeToReturn.LOA_LEVEL));
REQUESTED_ATTRIBUTES.add(attributeOf(AttributeToReturn.UNIQUE_PERSONAL_IDENTIFIER));
}

private static AttributeToReturnInfo attributeOf(AttributeToReturn attributeToReturn){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public static void createRequestedAttributes() {
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));
REQUESTED_ATTRIBUTES.add(attributeOf(AttributeToReturn.LOA_LEVEL));
REQUESTED_ATTRIBUTES.add(attributeOf(AttributeToReturn.UNIQUE_PERSONAL_IDENTIFIER));
}

private static AttributeToReturnInfo attributeOf(AttributeToReturn attributeToReturn){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public static void initTestData() {
AGE, PHOTO, DOCUMENT_INFO, DOCUMENT_PHOTO,
COVID_CERTIFICATES, ORGANISATION_ID_INFO,
DOCUMENT_WITH_PDF, Arrays.asList(CHILDREN_DOCUMENT_WITH_PDF),
NETWORK_INFO);
NETWORK_INFO, null, null);
}

@Before
Expand Down Expand Up @@ -182,7 +182,7 @@ public void getAuthenticationResultOrganisational_withAdditionalAttributes_succe
DOCUMENT_INFO, DOCUMENT_PHOTO, COVID_CERTIFICATES,
ORGANISATION_ID_INFO_WITH_ADDITIONAL_ATTRIBUTES, DOCUMENT_WITH_PDF,
Arrays.asList(CHILDREN_DOCUMENT_WITH_PDF),
NETWORK_INFO);
NETWORK_INFO, null, null);
AuthenticationClientApi authenticationClient =
AuthenticationClient.create(TestUtil.getDefaultSslSettings(), FrejaEnvironment.TEST)
.setHttpService(httpServiceMock)
Expand Down Expand Up @@ -332,12 +332,12 @@ private AuthenticationResults prepareResponse() {
PHOTO, DOCUMENT_INFO, DOCUMENT_PHOTO, COVID_CERTIFICATES,
ORGANISATION_ID_INFO, DOCUMENT_WITH_PDF,
Arrays.asList(CHILDREN_DOCUMENT_WITH_PDF),
NETWORK_INFO);
NETWORK_INFO, null, null);
AuthenticationResult firstResponse =
new AuthenticationResult(REFERENCE, TransactionStatus.STARTED, DETAILS, attributes1, FREJA_COOKIE);
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, null, null, null);
AuthenticationResult secondResponse =
new AuthenticationResult(REFERENCE, TransactionStatus.DELIVERED_TO_MOBILE, "test", attributes2,
null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public static void initTestData() {
AGE, PHOTO, DOCUMENT_INFO, DOCUMENT_PHOTO,
COVID_CERTIFICATES, ORGANISATION_ID_INFO, DOCUMENT_WITH_PDF,
Arrays.asList(CHILDREN_DOCUMENT_WITH_PDF),
NETWORK_INFO);
NETWORK_INFO, null, null);
}

@Before
Expand Down Expand Up @@ -176,7 +176,7 @@ public void getSignResultOrganisational_withAdditionalAttributes_expectSuccess()
DOCUMENT_INFO, DOCUMENT_PHOTO, COVID_CERTIFICATES,
ORGANISATION_ID_INFO_WITH_ADDITIONAL_ATTRIBUTES, DOCUMENT_WITH_PDF,
Arrays.asList(CHILDREN_DOCUMENT_WITH_PDF),
NETWORK_INFO);
NETWORK_INFO, null, null);
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 @@ -64,14 +64,16 @@ public abstract class CommonHttpTest {
private static final String DOCUMENT_PHOTO = "Base64EncodedDocPhoto";
private static final NetworkInfo NETWORK_INFO = new NetworkInfo("123.45.6.7");
protected static final String FREJA_COOKIE = "frejaCookie";
private static final LoaLevel LOA_LEVEL = LoaLevel.LOA3;
private static final String UNIQUE_IDENTIFIER = "1234-567890-1234";
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),
NETWORK_INFO);
NETWORK_INFO, LOA_LEVEL, UNIQUE_IDENTIFIER);
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 ae5645c

Please sign in to comment.