From 9df463ce8c8567a8f70c4f8f1988f5ae299b6369 Mon Sep 17 00:00:00 2001 From: Christian Kollmann Date: Thu, 4 Mar 2021 17:29:03 +0100 Subject: Replace ErnpEidData with SimpleEidasData --- .../modules/auth/eidas/v2/dao/ErnpEidData.java | 55 ---------------------- .../eidas/v2/handler/AbstractEidProcessor.java | 18 +++---- .../eidas/v2/handler/INationalEidProcessor.java | 5 +- .../v2/service/CcSpecificEidProcessingService.java | 4 +- .../service/ICcSpecificEidProcessingService.java | 4 +- .../modules/auth/eidas/v2/szr/SzrClient.java | 31 ++++-------- .../eidas/v2/tasks/CreateIdentityLinkTask.java | 48 +++++++++---------- .../auth/eidas/v2/utils/EidasResponseUtils.java | 11 ++++- 8 files changed, 58 insertions(+), 118 deletions(-) delete mode 100644 eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/ErnpEidData.java (limited to 'eidas_modules/authmodule-eIDAS-v2/src/main') diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/ErnpEidData.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/ErnpEidData.java deleted file mode 100644 index 137ef984..00000000 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/ErnpEidData.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2020 A-SIT Plus GmbH - * AT-specific eIDAS Connector has been developed in a cooperation between EGIZ, - * A-SIT Plus GmbH, A-SIT, and Graz University of Technology. - * - * Licensed under the EUPL, Version 1.2 or - as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "License"); - * You may not use this work except in compliance with the License. - * You may obtain a copy of the License at: - * https://joinup.ec.europa.eu/news/understanding-eupl-v12 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * This product combines work with different licenses. See the "NOTICE" text - * file for details on the various modules and licenses. - * The "NOTICE" text file is part of the distribution. Any derivative works - * that you distribute must include a readable copy of the "NOTICE" text file. -*/ - -package at.asitplus.eidas.specific.modules.auth.eidas.v2.dao; - -import java.text.SimpleDateFormat; - -import lombok.Builder; -import lombok.Data; -import org.joda.time.DateTime; - -import at.gv.e_government.reference.namespace.persondata._20020228.PostalAddressType; - -@Data -@Builder -public class ErnpEidData { - - private final String citizenCountryCode; - - // MDS - private final String pseudonym; - private final String givenName; - private final String familyName; - private final DateTime dateOfBirth; - - // additional attributes - private final String placeOfBirth; - private final String birthName; - private final PostalAddressType address; - - public String getFormatedDateOfBirth() { - return dateOfBirth == null ? null : new SimpleDateFormat("yyyy-MM-dd").format(dateOfBirth.toDate()); - } - -} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/AbstractEidProcessor.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/AbstractEidProcessor.java index 14deefa5..f97517d5 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/AbstractEidProcessor.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/AbstractEidProcessor.java @@ -28,6 +28,7 @@ import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData; import org.apache.commons.lang3.StringUtils; import org.joda.time.DateTime; import org.slf4j.Logger; @@ -37,7 +38,6 @@ import org.springframework.lang.NonNull; import com.google.common.collect.ImmutableSortedSet; import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.ErnpEidData; import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidPostProcessingException; import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidasAttributeException; import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.EidasAttributeRegistry; @@ -47,13 +47,16 @@ import at.gv.egiz.eaaf.core.api.IRequest; import at.gv.egiz.eaaf.core.api.data.EaafConstants; import at.gv.egiz.eaaf.core.api.idp.IConfigurationWithSP; import at.gv.egiz.eaaf.core.api.idp.ISpConfiguration; -import at.gv.egiz.eaaf.core.impl.data.Triple; import eu.eidas.auth.commons.attribute.AttributeDefinition; import eu.eidas.auth.commons.attribute.ImmutableAttributeMap; import eu.eidas.auth.commons.light.impl.LightRequest.Builder; import eu.eidas.auth.commons.protocol.eidas.SpType; +import static at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants.eIDAS_ATTR_PERSONALIDENTIFIER; +import static at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.EidasResponseUtils.processCountryCode; +import static at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.EidasResponseUtils.processDateOfBirthToString; + public abstract class AbstractEidProcessor implements INationalEidProcessor { private static final Logger log = LoggerFactory.getLogger(AbstractEidProcessor.class); @@ -72,21 +75,20 @@ public abstract class AbstractEidProcessor implements INationalEidProcessor { @Override - public final ErnpEidData postProcess(Map eidasAttrMap) throws EidPostProcessingException, + public final SimpleEidasData postProcess(Map eidasAttrMap) throws EidPostProcessingException, EidasAttributeException { - final Object eIdentifierObj = eidasAttrMap.get(Constants.eIDAS_ATTR_PERSONALIDENTIFIER); - final Triple eIdentifier = - EidasResponseUtils.parseEidasPersonalIdentifier((String) eIdentifierObj); - return ErnpEidData.builder().citizenCountryCode(eIdentifier.getFirst()) + return SimpleEidasData.builder() // MDS attributes + .citizenCountryCode(processCountryCode(eidasAttrMap.get(eIDAS_ATTR_PERSONALIDENTIFIER))) .pseudonym(processPseudonym(eidasAttrMap.get(Constants.eIDAS_ATTR_PERSONALIDENTIFIER))) .familyName(processFamilyName(eidasAttrMap.get(Constants.eIDAS_ATTR_CURRENTFAMILYNAME))) .givenName(processGivenName(eidasAttrMap.get(Constants.eIDAS_ATTR_CURRENTGIVENNAME))) - .dateOfBirth(processDateOfBirth(eidasAttrMap.get(Constants.eIDAS_ATTR_DATEOFBIRTH))) + .dateOfBirth(processDateOfBirthToString(eidasAttrMap.get(Constants.eIDAS_ATTR_DATEOFBIRTH))) // additional attributes .placeOfBirth(processPlaceOfBirth(eidasAttrMap.get(Constants.eIDAS_ATTR_PLACEOFBIRTH))) .birthName(processBirthName(eidasAttrMap.get(Constants.eIDAS_ATTR_BIRTHNAME))) .address(processAddress(eidasAttrMap.get(Constants.eIDAS_ATTR_CURRENTADDRESS))) + //.taxNumber(processTaxReference(eidasAttrMap.get(Constants.eIDAS_ATTR_TAXREFERENCE))) .build(); } diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/INationalEidProcessor.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/INationalEidProcessor.java index 5b130e48..a40e3b37 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/INationalEidProcessor.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/INationalEidProcessor.java @@ -25,7 +25,7 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.handler; import java.util.Map; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.ErnpEidData; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData; import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidasAttributeException; import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidPostProcessingException; import at.gv.egiz.eaaf.core.api.IRequest; @@ -67,8 +67,9 @@ public interface INationalEidProcessor { * attribute * @throws EidPostProcessingException In case of a post-processing error * @throws EidasAttributeException In case of an invalid eIDAS attribute + * @return */ - ErnpEidData postProcess(Map eidasAttrMap) throws EidPostProcessingException, + SimpleEidasData postProcess(Map eidasAttrMap) throws EidPostProcessingException, EidasAttributeException; /** diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/service/CcSpecificEidProcessingService.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/service/CcSpecificEidProcessingService.java index c2f13aa6..b5493edb 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/service/CcSpecificEidProcessingService.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/service/CcSpecificEidProcessingService.java @@ -32,6 +32,7 @@ import java.util.Map.Entry; import javax.annotation.PostConstruct; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -40,7 +41,6 @@ import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Service; import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.ErnpEidData; import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidPostProcessingException; import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidasAttributeException; import at.asitplus.eidas.specific.modules.auth.eidas.v2.handler.INationalEidProcessor; @@ -104,7 +104,7 @@ public class CcSpecificEidProcessingService implements ICcSpecificEidProcessingS } @Override - public ErnpEidData postProcess(Map eidasAttrMap) throws EidPostProcessingException, + public SimpleEidasData postProcess(Map eidasAttrMap) throws EidPostProcessingException, EidasAttributeException { // extract citizen country from eIDAS unique identifier final Object eIdentifierObj = eidasAttrMap.get(Constants.eIDAS_ATTR_PERSONALIDENTIFIER); diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/service/ICcSpecificEidProcessingService.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/service/ICcSpecificEidProcessingService.java index 983830e3..fb9ba318 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/service/ICcSpecificEidProcessingService.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/service/ICcSpecificEidProcessingService.java @@ -25,7 +25,7 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.service; import java.util.Map; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.ErnpEidData; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData; import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidasAttributeException; import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidPostProcessingException; import at.gv.egiz.eaaf.core.api.IRequest; @@ -44,7 +44,7 @@ public interface ICcSpecificEidProcessingService { * @throws EidPostProcessingException In case of a post-processing error * @throws EidasAttributeException In case of an invalid eIDAS attribute value */ - ErnpEidData postProcess(Map eidasAttrMap) throws EidPostProcessingException, + SimpleEidasData postProcess(Map eidasAttrMap) throws EidPostProcessingException, EidasAttributeException; /** diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/szr/SzrClient.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/szr/SzrClient.java index 22f38c2a..091fe209 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/szr/SzrClient.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/szr/SzrClient.java @@ -60,7 +60,6 @@ import javax.xml.ws.BindingProvider; import javax.xml.ws.Dispatch; import javax.xml.ws.handler.Handler; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.ErnpEidData; import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData; import at.gv.e_government.reference.namespace.persondata._20020228.AlternativeNameType; import at.gv.e_government.reference.namespace.persondata._20020228.PersonNameType; @@ -143,11 +142,11 @@ public class SzrClient { * @return IdentityLink * @throws SzrCommunicationException In case of a SZR error */ - public IdentityLinkType getIdentityLinkInRawMode(ErnpEidData eidData) + public IdentityLinkType getIdentityLinkInRawMode(SimpleEidasData eidData) throws SzrCommunicationException { try { final GetIdentityLinkEidas getIdl = new GetIdentityLinkEidas(); - getIdl.setPersonInfo(generateSzrRequest(convertTemp(eidData))); + getIdl.setPersonInfo(generateSzrRequest(eidData)); final JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class); final Marshaller jaxbMarshaller = jaxbContext.createMarshaller(); @@ -208,11 +207,11 @@ public class SzrClient { * @return bPK for this person * @throws SzrCommunicationException In case of a SZR error */ - public List getBpk(ErnpEidData eidData, String target, String vkz) + public List getBpk(SimpleEidasData eidData, String target, String vkz) throws SzrCommunicationException { try { final GetBPK parameters = new GetBPK(); - parameters.setPersonInfo(generateSzrRequest(convertTemp(eidData))); + parameters.setPersonInfo(generateSzrRequest(eidData)); parameters.getBereichsKennung().add(target); parameters.setVKZ(vkz); final GetBPKResponse result = this.szr.getBPK(parameters); @@ -259,11 +258,11 @@ public class SzrClient { * @return encrypted baseId * @throws SzrCommunicationException In case of a SZR error */ - public String getEncryptedStammzahl(final ErnpEidData eidData) + public String getEncryptedStammzahl(final SimpleEidasData eidData) throws SzrCommunicationException { final String resp; try { - resp = this.szr.getStammzahlEncrypted(generateSzrRequest(convertTemp(eidData)), false); + resp = this.szr.getStammzahlEncrypted(generateSzrRequest(eidData), false); } catch (SZRException_Exception e) { throw new SzrCommunicationException("ernb.02", new Object[]{e.getMessage()}, e); } @@ -276,20 +275,6 @@ public class SzrClient { } - private SimpleEidasData convertTemp(ErnpEidData eidData) { - return SimpleEidasData.builder() - .citizenCountryCode(eidData.getCitizenCountryCode()) - .pseudonym(eidData.getPseudonym()) - .givenName(eidData.getGivenName()) - .familyName(eidData.getFamilyName()) - .dateOfBirth(eidData.getFormatedDateOfBirth()) - .placeOfBirth(eidData.getPlaceOfBirth()) - .birthName(eidData.getBirthName()) - .address(eidData.getAddress()) - //TODO not available.taxNumber() - .build(); - } - /** * Sign an eidasBind data-structure that combines vsz with user's pubKey and E-ID status. * @@ -301,7 +286,7 @@ public class SzrClient { * @throws SzrCommunicationException In case of a SZR error */ public String getEidasBind(final String vsz, final String bindingPubKey, final String eidStatus, - ErnpEidData eidData)throws SzrCommunicationException { + SimpleEidasData eidData)throws SzrCommunicationException { final Map eidsaBindMap = new HashMap<>(); eidsaBindMap.put(ATTR_NAME_VSZ, vsz); @@ -588,7 +573,7 @@ public class SzrClient { } - private void injectMdsIfAvailableAndActive(Map eidsaBindMap, ErnpEidData eidData) { + private void injectMdsIfAvailableAndActive(Map eidsaBindMap, SimpleEidasData eidData) { if (basicConfig.getBasicConfigurationBoolean( Constants.CONIG_PROPS_EIDAS_SZRCLIENT_SET_MDS_TO_EIDASBIND, false)) { log.info("Injecting MDS into eidasBind ... "); diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/CreateIdentityLinkTask.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/CreateIdentityLinkTask.java index 0287fe35..f70f0f85 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/CreateIdentityLinkTask.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/CreateIdentityLinkTask.java @@ -26,7 +26,7 @@ package at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks; import at.asitplus.eidas.specific.connector.MsConnectorEventCodes; import at.asitplus.eidas.specific.connector.MsEidasNodeConstants; import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.ErnpEidData; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData; import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.EidasAttributeException; import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.SzrCommunicationException; import at.asitplus.eidas.specific.modules.auth.eidas.v2.service.AuthBlockSigningService; @@ -42,7 +42,6 @@ import at.gv.egiz.eaaf.core.exceptions.EaafException; import at.gv.egiz.eaaf.core.exceptions.EaafStorageException; import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException; import at.gv.egiz.eaaf.core.impl.data.Pair; -import at.gv.egiz.eaaf.core.impl.data.Triple; import at.gv.egiz.eaaf.core.impl.idp.auth.builder.BpkBuilder; import at.gv.egiz.eaaf.core.impl.idp.auth.data.AuthProcessDataWrapper; import at.gv.egiz.eaaf.core.impl.idp.auth.data.SimpleIdentityLinkAssertionParser; @@ -78,7 +77,6 @@ import java.io.InputStream; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Objects; /** * Task that creates the IdentityLink for an eIDAS authenticated person. @@ -136,7 +134,10 @@ public class CreateIdentityLinkTask extends AbstractAuthServletTask { .getGenericDataFromSession(Constants.DATA_FULL_EIDAS_RESPONSE, ILightResponse.class); final Map eidasAttributes = convertEidasAttrToSimpleMap( eidasResponse.getAttributes().getAttributeMap()); - final ErnpEidData eidData = eidPostProcessor.postProcess(eidasAttributes); + final String personalIdentifier = (String) eidasAttributes.get(Constants.eIDAS_ATTR_PERSONALIDENTIFIER); + final SimpleEidasData eidData = eidPostProcessor.postProcess(eidasAttributes); + //final SimpleEidasData eidData = + getAuthProcessDataWrapper().getGenericDataFromSession(Constants.DATA_SIMPLE_EIDAS, SimpleEidasData.class); writeMdsLogInformation(eidData); if (basicConfig.getBasicConfigurationBoolean(Constants.CONIG_PROPS_EIDAS_SZRCLIENT_DEBUG_USEDUMMY, false)) { @@ -145,12 +146,12 @@ public class CreateIdentityLinkTask extends AbstractAuthServletTask { //request SZR based on IDL or E-ID mode if (pendingReq.getServiceProviderConfiguration() .isConfigurationValue(MsEidasNodeConstants.PROP_CONFIG_SP_NEW_EID_MODE, false)) { - executeEidMode(eidasAttributes, eidData); + executeEidMode(eidData, personalIdentifier); } else { - executeIdlMode(eidasAttributes, eidData); + executeIdlMode(eidData, personalIdentifier); } } - storeGenericInfoToSession(eidasAttributes); + storeGenericInfoToSession(eidData); requestStoreage.storePendingRequest(pendingReq); } catch (final EidasAttributeException e) { throw new TaskExecutionException(pendingReq, "Minimum required eIDAS attributeset not found.", e); @@ -162,21 +163,19 @@ public class CreateIdentityLinkTask extends AbstractAuthServletTask { } } - private void storeGenericInfoToSession(Map eidasAttributes) throws EaafStorageException { + private void storeGenericInfoToSession(SimpleEidasData eidData) throws EaafStorageException { AuthProcessDataWrapper authProcessData = getAuthProcessDataWrapper(); authProcessData.setForeigner(true); - Triple eidasPersonalIdentifier = EidasResponseUtils - .parseEidasPersonalIdentifier((String) eidasAttributes.get(Constants.eIDAS_ATTR_PERSONALIDENTIFIER)); authProcessData.setGenericDataToSession(PvpAttributeDefinitions.EID_ISSUING_NATION_NAME, - Objects.requireNonNull(eidasPersonalIdentifier).getFirst()); + eidData.getCitizenCountryCode()); } - private void executeIdlMode(Map simpleAttrMap, ErnpEidData eidData) throws EaafException { + private void executeIdlMode(SimpleEidasData eidData, String personalIdentifier) throws EaafException { //request SZR SzrResultHolder idlResult = requestSzrForIdentityLink(eidData); //write revision-Log entry for personal-identifier mapping - writeExtendedRevisionLogEntry(simpleAttrMap, eidData); + writeExtendedRevisionLogEntry(eidData, personalIdentifier); //check result-data and write revision-log based on current state checkStateAndWriteRevisionLog(idlResult); @@ -194,13 +193,13 @@ public class CreateIdentityLinkTask extends AbstractAuthServletTask { .getAreaSpecificTargetIdentifier()); } - private void executeEidMode(Map simpleAttrMap, ErnpEidData eidData) throws JsonProcessingException, EaafException, JoseException { + private void executeEidMode(SimpleEidasData eidData, String personalIdentifier) throws JsonProcessingException, EaafException, JoseException { // get encrypted baseId String vsz = szrClient.getEncryptedStammzahl(eidData); //write revision-Log entry and extended infos personal-identifier mapping revisionsLogger.logEvent(pendingReq, MsConnectorEventCodes.SZR_VSZ_RECEIVED); - writeExtendedRevisionLogEntry(simpleAttrMap, eidData); + writeExtendedRevisionLogEntry(eidData, personalIdentifier); // get eIDAS bind String signedEidasBind = szrClient @@ -218,7 +217,7 @@ public class CreateIdentityLinkTask extends AbstractAuthServletTask { authProcessDataWrapper.setEidProcess(true); } - private void buildDummyIdentityLink(ErnpEidData eidData) throws ParserConfigurationException, SAXException, IOException, EaafException { + private void buildDummyIdentityLink(SimpleEidasData eidData) throws ParserConfigurationException, SAXException, IOException, EaafException { AuthProcessDataWrapper authProcessDataWrapper = getAuthProcessDataWrapper(); SzrResultHolder idlResult = createDummyIdentityLinkForTestDeployment(eidData); //inject personal-data into session @@ -232,18 +231,17 @@ public class CreateIdentityLinkTask extends AbstractAuthServletTask { .getAreaSpecificTargetIdentifier()); } - private void writeExtendedRevisionLogEntry(Map simpleAttrMap, ErnpEidData eidData) { + private void writeExtendedRevisionLogEntry(SimpleEidasData eidData, String personalIdentifier) { // write ERnP input-data into revision-log if (basicConfig.getBasicConfigurationBoolean( Constants.CONIG_PROPS_EIDAS_SZRCLIENT_WORKAROUND_REVISIONLOGDATASTORE_ACTIVE, false)) { - revisionsLogger.logEvent(pendingReq, MsConnectorEventCodes.SZR_ERNB_EIDAS_RAW_ID, - (String) simpleAttrMap.get(Constants.eIDAS_ATTR_PERSONALIDENTIFIER)); + revisionsLogger.logEvent(pendingReq, MsConnectorEventCodes.SZR_ERNB_EIDAS_RAW_ID, personalIdentifier); revisionsLogger.logEvent(pendingReq, MsConnectorEventCodes.SZR_ERNB_EIDAS_ERNB_ID, eidData.getPseudonym()); } } - private SzrResultHolder requestSzrForIdentityLink(ErnpEidData eidData) throws EaafException { + private SzrResultHolder requestSzrForIdentityLink(SimpleEidasData eidData) throws EaafException { //request IdentityLink from SZR final IdentityLinkType result = szrClient.getIdentityLinkInRawMode(eidData); @@ -377,12 +375,12 @@ public class CreateIdentityLinkTask extends AbstractAuthServletTask { /** * write MDS into technical log and revision log */ - private void writeMdsLogInformation(ErnpEidData eidData) { + private void writeMdsLogInformation(SimpleEidasData eidData) { boolean writeMdsInTechLog = basicConfig .getBasicConfigurationBoolean(MsEidasNodeConstants.PROP_CONFIG_TECHNICALLOG_WRITE_MDS_INTO_TECH_LOG, false); if (writeMdsInTechLog) { log.info("eIDAS Auth. for user: " + eidData.getGivenName() + " " + eidData.getFamilyName() + " " + eidData - .getFormatedDateOfBirth() + " " + "from " + eidData.getCitizenCountryCode()); + .getDateOfBirth() + " " + "from " + eidData.getCitizenCountryCode()); } boolean writeMdsInRevLog = basicConfig @@ -391,7 +389,7 @@ public class CreateIdentityLinkTask extends AbstractAuthServletTask { if (writeMdsInRevLog) { revisionsLogger.logEvent(pendingReq, MsConnectorEventCodes.RESPONSE_FROM_EIDAS_MDSDATA, "{" + eidData.getGivenName() + "," + eidData.getFamilyName() + "," + eidData - .getFormatedDateOfBirth() + "," + eidData.getCitizenCountryCode() + "}"); + .getDateOfBirth() + "," + eidData.getCitizenCountryCode() + "}"); } } @@ -415,7 +413,7 @@ public class CreateIdentityLinkTask extends AbstractAuthServletTask { * @throws IOException In case of an IDL processing error * @throws EaafException In case of a bPK generation error */ - private SzrResultHolder createDummyIdentityLinkForTestDeployment(ErnpEidData eidData) + private SzrResultHolder createDummyIdentityLinkForTestDeployment(SimpleEidasData eidData) throws ParserConfigurationException, SAXException, IOException, EaafException { log.warn("SZR-Dummy IS ACTIVE! IdentityLink is NOT VALID!!!!"); // create fake IdL @@ -448,7 +446,7 @@ public class CreateIdentityLinkTask extends AbstractAuthServletTask { final Node prDateOfBirth = XPathUtils .selectSingleNode(idlassertion, SimpleIdentityLinkAssertionParser.PERSON_DATE_OF_BIRTH_XPATH); - prDateOfBirth.getFirstChild().setNodeValue(eidData.getFormatedDateOfBirth()); + prDateOfBirth.getFirstChild().setNodeValue(eidData.getDateOfBirth()); identityLink = new SimpleIdentityLinkAssertionParser(idlassertion).parseIdentityLink(); diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/utils/EidasResponseUtils.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/utils/EidasResponseUtils.java index 94b85b7c..3023bc0a 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/utils/EidasResponseUtils.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/utils/EidasResponseUtils.java @@ -41,6 +41,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.annotation.Nullable; +import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.List; @@ -280,6 +281,14 @@ public class EidasResponseUtils { * @throws EidasAttributeException if NO attribute is available */ public static String processDateOfBirthToString(Object dateOfBirthObj) throws EidasAttributeException { + if (dateOfBirthObj instanceof String) { + try { + new SimpleDateFormat("yyyy-MM-dd").parse((String) dateOfBirthObj); + return (String) dateOfBirthObj; + } catch (ParseException e) { + throw new EidasAttributeException(Constants.eIDAS_ATTR_DATEOFBIRTH); + } + } if (!(dateOfBirthObj instanceof DateTime)) { throw new EidasAttributeException(Constants.eIDAS_ATTR_DATEOFBIRTH); } @@ -361,7 +370,7 @@ public class EidasResponseUtils { */ public static String processTaxReference(Object taxReferenceObj) throws EidasAttributeException { if (!(taxReferenceObj instanceof String)) { - throw new EidasAttributeException(Constants.eIDAS_ATTR_CURRENTGIVENNAME); + throw new EidasAttributeException(Constants.eIDAS_ATTR_TAXREFERENCE); } return (String) taxReferenceObj; } -- cgit v1.2.3