From 5326c05f8d07d2935549b929511b9e0578bb022d Mon Sep 17 00:00:00 2001 From: Christian Kollmann Date: Thu, 4 Mar 2021 15:07:56 +0100 Subject: Refactor SimpleMobilePhoneData to make it immutable --- .../auth/eidas/v2/dao/MergedRegisterSearchResult.java | 4 ++-- .../modules/auth/eidas/v2/dao/SimpleMobileSignatureData.java | 12 +++++++----- .../v2/tasks/ReceiveMobilePhoneSignatureResponseTask.java | 12 ++++++------ 3 files changed, 15 insertions(+), 13 deletions(-) (limited to 'eidas_modules/authmodule-eIDAS-v2/src') diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/MergedRegisterSearchResult.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/MergedRegisterSearchResult.java index e147b8aa..0c977016 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/MergedRegisterSearchResult.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/MergedRegisterSearchResult.java @@ -31,8 +31,8 @@ import java.util.List; @Data public class MergedRegisterSearchResult { - final List resultsZmr; - final List resultsErnp; + private final List resultsZmr; + private final List resultsErnp; public MergedRegisterSearchResult(List resultsZmr, List resultsErnp) { this.resultsZmr = resultsZmr; diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/SimpleMobileSignatureData.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/SimpleMobileSignatureData.java index e7a5547a..4a27e60e 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/SimpleMobileSignatureData.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/SimpleMobileSignatureData.java @@ -23,17 +23,19 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.dao; +import lombok.Builder; import lombok.Data; import org.apache.commons.lang3.builder.EqualsBuilder; @Data +@Builder public class SimpleMobileSignatureData { - private String citizenCountryCode; - private String bpk; - private String givenName; - private String familyName; - private String dateOfBirth; + private final String citizenCountryCode; + private final String bpk; + private final String givenName; + private final String familyName; + private final String dateOfBirth; /** * Compares the received authentication data from the mobile phone signature with the eid data received via eIDAS. diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveMobilePhoneSignatureResponseTask.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveMobilePhoneSignatureResponseTask.java index 57531493..64327d40 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveMobilePhoneSignatureResponseTask.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveMobilePhoneSignatureResponseTask.java @@ -340,7 +340,7 @@ public class ReceiveMobilePhoneSignatureResponseTask extends AbstractAuthServlet private SimpleMobileSignatureData getAuthDataFromInterfederation(AssertionAttributeExtractor extractor) throws EaafBuilderException { List requiredAttributes = IdAustriaClientAuthConstants.DEFAULT_REQUIRED_PVP_ATTRIBUTE_NAMES; - SimpleMobileSignatureData result = new SimpleMobileSignatureData(); + SimpleMobileSignatureData.SimpleMobileSignatureDataBuilder builder = SimpleMobileSignatureData.builder(); if (!extractor.containsAllRequiredAttributes(requiredAttributes)) { log.warn("PVP Response from 'ID Austria node' contains not all requested attributes."); AssertionValidationExeption e = new AssertionValidationExeption(ERROR_PVP_06, @@ -350,23 +350,23 @@ public class ReceiveMobilePhoneSignatureResponseTask extends AbstractAuthServlet final Set includedAttrNames = extractor.getAllIncludeAttributeNames(); for (final String attrName : includedAttrNames) { if (PvpAttributeDefinitions.BPK_NAME.equals(attrName)) { - result.setBpk(extractor.getSingleAttributeValue(attrName)); + builder.bpk(extractor.getSingleAttributeValue(attrName)); } if (PvpAttributeDefinitions.GIVEN_NAME_NAME.equals(attrName)) { - result.setGivenName(extractor.getSingleAttributeValue(attrName)); + builder.givenName(extractor.getSingleAttributeValue(attrName)); } if (PvpAttributeDefinitions.PRINCIPAL_NAME_NAME.equals(attrName)) { - result.setFamilyName(extractor.getSingleAttributeValue(attrName)); + builder.familyName(extractor.getSingleAttributeValue(attrName)); } if (PvpAttributeDefinitions.BIRTHDATE_NAME.equals(attrName)) { - result.setDateOfBirth(extractor.getSingleAttributeValue(attrName)); + builder.dateOfBirth(extractor.getSingleAttributeValue(attrName)); } if (PvpAttributeDefinitions.EID_CITIZEN_EIDAS_QAA_LEVEL_NAME.equals(attrName)) { getAuthProcessDataWrapper().setQaaLevel(extractor.getSingleAttributeValue(attrName)); } } getAuthProcessDataWrapper().setIssueInstant(extractor.getAssertionIssuingDate()); - return result; + return builder.build(); } -- cgit v1.2.3