aboutsummaryrefslogtreecommitdiff
path: root/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus
diff options
context:
space:
mode:
authorThomas <>2022-10-17 15:41:13 +0200
committerThomas <>2022-10-17 15:41:13 +0200
commita59cc4920dd182f258ef7d431d5549ede1ef6033 (patch)
tree00d3e022ec543185b556c0a1db607077f4e72fbb /modules/authmodule-eIDAS-v2/src/main/java/at/asitplus
parent7e7291581ca59bb8f5c8fbf18dba37e0d262fa7a (diff)
downloadNational_eIDAS_Gateway-a59cc4920dd182f258ef7d431d5549ede1ef6033.tar.gz
National_eIDAS_Gateway-a59cc4920dd182f258ef7d431d5549ede1ef6033.tar.bz2
National_eIDAS_Gateway-a59cc4920dd182f258ef7d431d5549ede1ef6033.zip
style(matching): fix some code-style issues
Diffstat (limited to 'modules/authmodule-eIDAS-v2/src/main/java/at/asitplus')
-rw-r--r--modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/ErnpRestClient.java525
-rw-r--r--modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/ErnpPersonRegisterResult.java6
-rw-r--r--modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/service/RegisterSearchService.java2
3 files changed, 274 insertions, 259 deletions
diff --git a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/ErnpRestClient.java b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/ErnpRestClient.java
index 5d3f43e6..ce474793 100644
--- a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/ErnpRestClient.java
+++ b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/clients/ernp/ErnpRestClient.java
@@ -95,7 +95,8 @@ import lombok.extern.slf4j.Slf4j;
public class ErnpRestClient implements IErnpClient {
private static final String ERROR_MATCHING_11 = "module.eidasauth.matching.11";
- //private static final String ERROR_MATCHING_12 = "module.eidasauth.matching.12";
+ // private static final String ERROR_MATCHING_12 =
+ // "module.eidasauth.matching.12";
private static final String ERROR_MATCHING_99 = "module.eidasauth.matching.99";
private static final String LOGMSG_MISSING_CONFIG = "Missing configuration with key: {0}";
@@ -104,8 +105,8 @@ public class ErnpRestClient implements IErnpClient {
private static final String LOGMSG_ERNP_RESP_PROCESS =
"Proces ERnP response during '{}' operation failes with msg: {}";
- //private static final String LOGMSG_ERNP_REST_ERROR =
- // "ERnP anwser for transaction: {0} with code: {1} and message: {2}";
+ // private static final String LOGMSG_ERNP_REST_ERROR =
+ // "ERnP anwser for transaction: {0} with code: {1} and message: {2}";
private static final String PROCESS_SEARCH_PERSONAL_IDENTIFIER =
"Searching " + EidasConstants.eIDAS_ATTR_PERSONALIDENTIFIER;
@@ -116,16 +117,15 @@ public class ErnpRestClient implements IErnpClient {
private static final String PROCESS_KITT_IDENITIES_GET = "KITT get-latest-version";
private static final String PROCESS_KITT_IDENITIES_UPDATE = "KITT update dataset";
private static final String PROCESS_ADD_IDENITY = "Add new person";
-
+
private static final String FRIENDLYNAME_HTTP_CLIENT = "ERnP Client";
- // HTTP header-names from ERnP response
+ // HTTP header-names from ERnP response
private static final String ERNP_RESPONSE_HEADER_SERVER_ID = "Server-Request-Id";
-
+
// ERnP person type that indicates mark a person as ZMR entry
private static final String ERNP_RESPONSE_OPERATION_ZMR_FORWARD = "PersonUebernehmen";
-
-
+
@Autowired
IConfiguration basicConfig;
@Autowired
@@ -165,10 +165,10 @@ public class ErnpRestClient implements IErnpClient {
// parse ZMR response
return processErnpResponse(resp, citizenCountryCode, true, PROCESS_SEARCH_PERSONAL_IDENTIFIER);
- } catch (RestClientException e) {
+ } catch (final RestClientException e) {
log.warn(LOGMSG_ERNP_ERROR, PROCESS_SEARCH_PERSONAL_IDENTIFIER, e.getMessage());
throw new EidasSAuthenticationException(ERROR_MATCHING_11, new Object[] { e.getMessage() }, e);
-
+
} catch (final EidasSAuthenticationException e) {
throw e;
@@ -191,10 +191,10 @@ public class ErnpRestClient implements IErnpClient {
searchInfos.setFamilienname(familyName);
searchInfos.setVorname(givenName);
searchInfos.setGeburtsdatum(buildErnpBirthday(dateOfBirth));
-
+
final PersonSuchen personSuchen = new PersonSuchen();
personSuchen.setSuchoptionen(generateSearchParameters());
- personSuchen.setBegruendung(PROCESS_SEARCH_MDS_ONLY);
+ personSuchen.setBegruendung(PROCESS_SEARCH_MDS_ONLY);
personSuchen.setSuchdaten(searchInfos);
// request ERnP
@@ -205,10 +205,10 @@ public class ErnpRestClient implements IErnpClient {
// parse ZMR response
return processErnpResponse(resp, citizenCountryCode, false, PROCESS_SEARCH_MDS_ONLY);
- } catch (RestClientException e) {
+ } catch (final RestClientException e) {
log.warn(LOGMSG_ERNP_ERROR, PROCESS_SEARCH_MDS_ONLY, e.getMessage());
throw new EidasSAuthenticationException(ERROR_MATCHING_11, new Object[] { e.getMessage() }, e);
-
+
} catch (final EidasSAuthenticationException e) {
throw e;
@@ -217,20 +217,20 @@ public class ErnpRestClient implements IErnpClient {
throw new EidasSAuthenticationException(ERROR_MATCHING_99, new Object[] { e.getMessage() }, e);
}
}
-
+
@Override
public ErnpRegisterResult searchCountrySpecific(PersonSuchenRequest personSearchDao,
String citizenCountryCode) throws EidasSAuthenticationException {
- String countrySearchMsg = MessageFormat.format(PROCESS_SEARCH_COUNTRY_SPECIFIC, citizenCountryCode);
-
- try {
+ final String countrySearchMsg = MessageFormat.format(PROCESS_SEARCH_COUNTRY_SPECIFIC, citizenCountryCode);
+
+ try {
// build generic request metadata
final GenericRequestParams generic = buildGenericRequestParameters();
- // build search request
+ // build search request
final PersonSuchen personSuchen = new PersonSuchen();
personSuchen.setSuchoptionen(generateSearchParameters());
- personSuchen.setBegruendung(countrySearchMsg);
+ personSuchen.setBegruendung(countrySearchMsg);
personSuchen.setSuchdaten(mapCountrySpecificSearchData(personSearchDao));
// request ERnP
@@ -241,17 +241,17 @@ public class ErnpRestClient implements IErnpClient {
// parse ZMR response
return processErnpResponse(resp, citizenCountryCode, true, countrySearchMsg);
- } catch (RestClientException e) {
+ } catch (final RestClientException e) {
log.warn(LOGMSG_ERNP_ERROR, countrySearchMsg, e.getMessage());
throw new EidasSAuthenticationException(ERROR_MATCHING_11, new Object[] { e.getMessage() }, e);
-
+
} catch (final EidasSAuthenticationException e) {
throw e;
} catch (final Exception e) {
log.warn(LOGMSG_ERNP_RESP_PROCESS, countrySearchMsg, e.getMessage());
throw new EidasSAuthenticationException(ERROR_MATCHING_99, new Object[] { e.getMessage() }, e);
-
+
}
}
@@ -259,39 +259,42 @@ public class ErnpRestClient implements IErnpClient {
public ErnpRegisterResult update(RegisterResult registerResult, SimpleEidasData eidData)
throws EidasSAuthenticationException {
try {
- //search person with register result, because update needs information from search response
- Person ernpPersonToKitt = searchPersonForUpdate(registerResult);
-
+ // search person with register result, because update needs information from
+ // search response
+ final Person ernpPersonToKitt = searchPersonForUpdate(registerResult);
+
// select elements that have to be updated
- Collection<? extends Eidas> eidasDocumentToAdd =
- selectEidasDocumentsToAdd(ernpPersonToKitt, eidData);
- SimpleEidasData mdsToUpdate = selectMdsInformationToUpdate(ernpPersonToKitt, eidData);
-
+ final Collection<? extends Eidas> eidasDocumentToAdd =
+ selectEidasDocumentsToAdd(ernpPersonToKitt, eidData);
+ final SimpleEidasData mdsToUpdate = selectMdsInformationToUpdate(ernpPersonToKitt, eidData);
+
if (eidasDocumentToAdd.isEmpty() && mdsToUpdate == null) {
- log.info("Find no eIDAS document or MDS for update during: {}. Nothing todo on ERnP side",
+ log.info("Find no eIDAS document or MDS for update during: {}. Nothing todo on ERnP side",
PROCESS_KITT_GENERAL);
return new ErnpRegisterResult(Arrays.asList(new ErnpPersonRegisterResult(registerResult, false)));
-
+
} else {
- log.info("Find #{} eIDAS documents for update during: {}", eidasDocumentToAdd.size(), PROCESS_KITT_GENERAL);
-
- // update entry based on selected update info's and results from search response
- return updatePersonInErnp(ernpPersonToKitt, eidasDocumentToAdd, mdsToUpdate, eidData.getCitizenCountryCode());
-
+ log.info("Find #{} eIDAS documents for update during: {}", eidasDocumentToAdd.size(),
+ PROCESS_KITT_GENERAL);
+
+ // update entry based on selected update info's and results from search response
+ return updatePersonInErnp(ernpPersonToKitt, eidasDocumentToAdd, mdsToUpdate, eidData
+ .getCitizenCountryCode());
+
}
- } catch (RestClientException e) {
+ } catch (final RestClientException e) {
log.warn(LOGMSG_ERNP_ERROR, PROCESS_KITT_GENERAL, e.getMessage());
throw new EidasSAuthenticationException(ERROR_MATCHING_11, new Object[] { e.getMessage() }, e);
-
+
} catch (final EidasSAuthenticationException e) {
throw e;
} catch (final Exception e) {
log.warn(LOGMSG_ERNP_RESP_PROCESS, PROCESS_KITT_GENERAL, e.getMessage());
throw new EidasSAuthenticationException(ERROR_MATCHING_99, new Object[] { e.getMessage() }, e);
-
- }
+
+ }
}
@Override
@@ -299,48 +302,48 @@ public class ErnpRestClient implements IErnpClient {
try {
// build generic request metadata
final GenericRequestParams generic = buildGenericRequestParameters();
-
+
// build update request
- PersonAnlegen ernpReq = new PersonAnlegen();
+ final PersonAnlegen ernpReq = new PersonAnlegen();
ernpReq.setBegruendung(PROCESS_ADD_IDENITY);
-
+
// inject person data
- Personendaten person = new Personendaten();
+ final Personendaten person = new Personendaten();
person.setFamilienname(eidData.getFamilyName());
person.setVorname(eidData.getGivenName());
- person.setGeburtsdatum(buildErnpBirthday(eidData.getDateOfBirth()));
+ person.setGeburtsdatum(buildErnpBirthday(eidData.getDateOfBirth()));
ernpReq.setPersonendaten(person);
-
+
buildNewEidasDocumens(ernpReq, eidData);
-
+
// request ERnP
- log.trace("Requesting ERnP for '{}' operation", PROCESS_ADD_IDENITY);
- AnlegenResponse ernpResp = ernpClient.anlegen(generic.getClientBehkz(), generic.clientName,
- generic.getClientRequestTime(), generic.getClientRequestId(), ernpReq);
+ log.trace("Requesting ERnP for '{}' operation", PROCESS_ADD_IDENITY);
+ final AnlegenResponse ernpResp = ernpClient.anlegen(generic.getClientBehkz(), generic.clientName,
+ generic.getClientRequestTime(), generic.getClientRequestId(), ernpReq);
log.trace("Receive response from ERnP for '{}' operation", PROCESS_ADD_IDENITY);
-
- return new ErnpRegisterResult(Arrays.asList(
- mapErnpResponseToRegisterResult(ernpResp.getPerson(), eidData.getCitizenCountryCode())));
-
- } catch (RestClientException e) {
+
+ return new ErnpRegisterResult(Arrays.asList(
+ mapErnpResponseToRegisterResult(ernpResp.getPerson(), eidData.getCitizenCountryCode())));
+
+ } catch (final RestClientException e) {
log.warn(LOGMSG_ERNP_ERROR, PROCESS_ADD_IDENITY, e.getMessage());
throw new EidasSAuthenticationException(ERROR_MATCHING_11, new Object[] { e.getMessage() }, e);
-
+
} catch (final Exception e) {
log.warn(LOGMSG_ERNP_RESP_PROCESS, PROCESS_ADD_IDENITY, e.getMessage());
throw new EidasSAuthenticationException(ERROR_MATCHING_99, new Object[] { e.getMessage() }, e);
-
- }
+
+ }
}
-
+
@Override
public ErnpRegisterResult searchWithResidenceData(String givenName, String familyName, String dateOfBirth,
- String zipcode, String city, String street) {
+ String zipcode, String city, String street) {
log.warn("Matching with residence information is prohibited by design! This requests will be ignored");
return new ErnpRegisterResult(Collections.emptyList());
-
+
}
-
+
@PostConstruct
private void initialize() throws EaafException {
// validate additional Ernp communication parameters
@@ -406,11 +409,11 @@ public class ErnpRestClient implements IErnpClient {
private ErnpRegisterResult processSearchPersonResponse(
@Nonnull List<Person> list,
@Nonnull String citizenCountryCode) throws EaafAuthenticationException {
- List<ErnpPersonRegisterResult> ernpResult = list.stream()
+ final List<ErnpPersonRegisterResult> ernpResult = list.stream()
.map(el -> mapErnpResponseToRegisterResult(el, citizenCountryCode))
.filter(Objects::nonNull)
.collect(Collectors.toList());
- log.info("Get #{} ERnP results after post-processing", ernpResult.size());
+ log.info("Get #{} ERnP results after post-processing", ernpResult.size());
return new ErnpRegisterResult(ernpResult);
}
@@ -425,224 +428,230 @@ public class ErnpRestClient implements IErnpClient {
"Find more-than-one ERnP entry with search criteria that has to be unique", true);
} else {
- ErnpPersonRegisterResult activeResult =
+ final ErnpPersonRegisterResult activeResult =
mapErnpResponseToRegisterResult(persons.get(0), citizenCountryCode);
if (activeResult == null) {
log.error("ERnP entry, which was selected by matching, looks already closed. "
+ "Automated operations on closed entries not supported my matching");
- throw new WorkflowException(processStepFiendlyname,
+ throw new WorkflowException(processStepFiendlyname,
"ERnP entry, which was selected by matching, is not active any more.", true);
-
- }
-
+
+ }
+
return new ErnpRegisterResult(Arrays.asList(activeResult));
-
+
}
}
/**
- * Process a single Person data-set from ERnP.
- *
- * @param personEl Person data-set from ERnP
+ * Process a single Person data-set from ERnP.
+ *
+ * @param personEl Person data-set from ERnP
* @param citizenCountryCode Country-Code of the citizen
- * @return {@link Pair} of Simplified register result and 'isZMREntry' flag,
- * or <code>null</code> if the person data-set is not active anymore
+ * @return {@link Pair} of Simplified register result and 'isZMREntry' flag, or
+ * <code>null</code> if the person data-set is not active anymore
* @throws EaafAuthenticationException In case of a validation error
*/
@Nullable
private ErnpPersonRegisterResult mapErnpResponseToRegisterResult(@Nonnull Person person,
@Nonnull String citizenCountryCode) {
- if (checkIfPersonIsActive(person)) {
+ if (checkIfPersonIsActive(person)) {
// build result
return new ErnpPersonRegisterResult(
RegisterResult.builder()
- .pseudonym(selectAllEidasDocument(person, citizenCountryCode,
- EidasConstants.eIDAS_ATTRURN_PERSONALIDENTIFIER))
- .familyName(person.getPersonendaten().getFamilienname())
- .givenName(person.getPersonendaten().getVorname())
- .dateOfBirth(getTextualBirthday(person.getPersonendaten().getGeburtsdatum()))
- .bpk(person.getPersonendaten().getBpkZp())
- .placeOfBirth(selectSingleEidasDocument(person, citizenCountryCode,
- EidasConstants.eIDAS_ATTRURN_PLACEOFBIRTH))
- .birthName(selectSingleEidasDocument(person, citizenCountryCode,
- EidasConstants.eIDAS_ATTRURN_BIRTHNAME))
- .build(),
- isPersonMovedToZmr(person));
-
+ .pseudonym(selectAllEidasDocument(person, citizenCountryCode,
+ EidasConstants.eIDAS_ATTRURN_PERSONALIDENTIFIER))
+ .familyName(person.getPersonendaten().getFamilienname())
+ .givenName(person.getPersonendaten().getVorname())
+ .dateOfBirth(getTextualBirthday(person.getPersonendaten().getGeburtsdatum()))
+ .bpk(person.getPersonendaten().getBpkZp())
+ .placeOfBirth(selectSingleEidasDocument(person, citizenCountryCode,
+ EidasConstants.eIDAS_ATTRURN_PLACEOFBIRTH))
+ .birthName(selectSingleEidasDocument(person, citizenCountryCode,
+ EidasConstants.eIDAS_ATTRURN_BIRTHNAME))
+ .build(),
+ isPersonMovedToZmr(person));
+
} else {
log.debug("Entity is not valid anymore. Skip it ... ");
return null;
-
+
}
}
- private boolean checkIfPersonIsActive(Person person) {
+ private boolean checkIfPersonIsActive(Person person) {
if (person.getGueltigBis() != null) {
- LocalDateTime validTo = person.getGueltigBis().toLocalDateTime();
- LocalDateTime now = LocalDateTime.now();
-
+ final LocalDateTime validTo = person.getGueltigBis().toLocalDateTime();
+ final LocalDateTime now = LocalDateTime.now();
+
if (isPersonMovedToZmr(person)) {
- log.debug("Entity has a 'validTo' element, but it's marked as {}. Use it as a ZMR entry",
- ERNP_RESPONSE_OPERATION_ZMR_FORWARD);
-
- } else if (validTo.isBefore(now)) {
+ log.debug("Entity has a 'validTo' element, but it's marked as {}. Use it as a ZMR entry",
+ ERNP_RESPONSE_OPERATION_ZMR_FORWARD);
+
+ } else if (validTo.isBefore(now)) {
log.warn("Enity was valid to: {}, but now its: {}. Ignore that entry", validTo, now);
return false;
-
+
} else {
log.debug("Entity has a 'validTo' element, but it is in the future.");
-
+
}
-
+
} else {
log.trace("Entity has no 'validTo' element. Therefore it should be valid");
-
+
}
-
+
return true;
}
-
-
+
/**
* Check if ERnP person is marked as KITT to ZMR entry.
- *
- * <p>If person is marked as ZMR person then it has the same quality as a ZMR match.</p>
- *
+ *
+ * <p>
+ * If person is marked as ZMR person then it has the same quality as a ZMR
+ * match.
+ * </p>
+ *
* @param person ERnP person result
- * @return <code>true</code> if the person should be in ERnP, otherwise <code>false</code>
+ * @return <code>true</code> if the person should be in ERnP, otherwise
+ * <code>false</code>
*/
private boolean isPersonMovedToZmr(Person person) {
- return person.getLetzteOperation() != null
+ return person.getLetzteOperation() != null
&& ERNP_RESPONSE_OPERATION_ZMR_FORWARD.equals(person.getLetzteOperation().getVorgang());
-
+
}
- private Suchdaten mapCountrySpecificSearchData(PersonSuchenRequest personSearchDao) {
+ private Suchdaten mapCountrySpecificSearchData(PersonSuchenRequest personSearchDao) {
final Suchdaten searchInfos = new Suchdaten();
- searchInfos.setFamilienname(personSearchDao.getNatuerlichePerson().getPersonenName().getFamilienname());
+ searchInfos.setFamilienname(personSearchDao.getNatuerlichePerson().getPersonenName().getFamilienname());
searchInfos.setVorname(personSearchDao.getNatuerlichePerson().getPersonenName().getVorname());
- searchInfos.setGeburtsdatum(buildErnpBirthday(personSearchDao.getNatuerlichePerson().getGeburtsdatum()));
-
+ searchInfos.setGeburtsdatum(buildErnpBirthday(personSearchDao.getNatuerlichePerson().getGeburtsdatum()));
+
// map all eIDAS documents into ERnP format
searchInfos.setEidas(personSearchDao.getEidasSuchdaten().stream()
.map(el -> buildErnpEidasDocument(el))
.collect(Collectors.toList()));
-
+
return searchInfos;
-
+
}
-
+
private ErnpRegisterResult updatePersonInErnp(Person ernpPersonToKitt,
- Collection<? extends Eidas> eidasDocumentToAdd, SimpleEidasData mdsToUpdate, String citizenCountryCode)
- throws ServiceFault {
+ Collection<? extends Eidas> eidasDocumentToAdd, SimpleEidasData mdsToUpdate, String citizenCountryCode)
+ throws ServiceFault {
// build generic request metadata
final GenericRequestParams generic = buildGenericRequestParameters();
-
+
// build update request
- PersonAendern ernpReq = new PersonAendern();
+ final PersonAendern ernpReq = new PersonAendern();
ernpReq.setBegruendung(PROCESS_KITT_IDENITIES_UPDATE);
-
+
// set reference elements for person update
ernpReq.setEntityId(ernpPersonToKitt.getEntityId());
- ernpReq.setVersion(ernpPersonToKitt.getVersion());
-
+ ernpReq.setVersion(ernpPersonToKitt.getVersion());
+
// add new eIDAS attributes
if (!eidasDocumentToAdd.isEmpty()) {
log.debug("Find eIDAS Documents to update. Injection update entries into ERnP request ... ");
- ernpReq.setAnlegen(new Anlegen());
+ ernpReq.setAnlegen(new Anlegen());
eidasDocumentToAdd.stream().forEach(el -> ernpReq.getAnlegen().addEidasItem(el));
-
+
}
-
+
// update MDS if required
if (mdsToUpdate != null) {
log.debug("Find MDS to update. Injection update entries into ERnP request ... ");
ernpReq.setAendern(generateMdsChangeRequest(ernpPersonToKitt, mdsToUpdate));
-
+
}
-
+
// request ERnP
- log.trace("Requesting ERnP for '{}' operation", PROCESS_KITT_IDENITIES_UPDATE);
- AendernResponse ernpResp = ernpClient.aendern(generic.getClientBehkz(), generic.clientName,
- generic.getClientRequestTime(), generic.getClientRequestId(), ernpReq);
+ log.trace("Requesting ERnP for '{}' operation", PROCESS_KITT_IDENITIES_UPDATE);
+ final AendernResponse ernpResp = ernpClient.aendern(generic.getClientBehkz(), generic.clientName,
+ generic.getClientRequestTime(), generic.getClientRequestId(), ernpReq);
log.trace("Receive response from ERnP for '{}' operation", PROCESS_KITT_IDENITIES_UPDATE);
-
+
return new ErnpRegisterResult(Collections.singletonList(
mapErnpResponseToRegisterResult(ernpResp.getPerson(), citizenCountryCode)));
-
+
}
-
+
private Collection<? extends Eidas> selectEidasDocumentsToAdd(
Person ernpPersonToKitt, SimpleEidasData eidData) {
- //TODO: maybe we should re-factor SimpleEidasData to a generic data-model to facilitate arbitrary eIDAS attributes
- Set<Eidas> result = new HashSet<>();
- addEidasDocumentIfNotAvailable(result, ernpPersonToKitt, eidData.getCitizenCountryCode(),
- EidasConstants.eIDAS_ATTRURN_PERSONALIDENTIFIER, eidData.getPseudonym(), true);
- addEidasDocumentIfNotAvailable(result, ernpPersonToKitt, eidData.getCitizenCountryCode(),
+ // TODO: maybe we should re-factor SimpleEidasData to a generic data-model to
+ // facilitate arbitrary eIDAS attributes
+ final Set<Eidas> result = new HashSet<>();
+ addEidasDocumentIfNotAvailable(result, ernpPersonToKitt, eidData.getCitizenCountryCode(),
+ EidasConstants.eIDAS_ATTRURN_PERSONALIDENTIFIER, eidData.getPseudonym(), true);
+ addEidasDocumentIfNotAvailable(result, ernpPersonToKitt, eidData.getCitizenCountryCode(),
EidasConstants.eIDAS_ATTRURN_PLACEOFBIRTH, eidData.getPlaceOfBirth(), false);
- addEidasDocumentIfNotAvailable(result, ernpPersonToKitt, eidData.getCitizenCountryCode(),
+ addEidasDocumentIfNotAvailable(result, ernpPersonToKitt, eidData.getCitizenCountryCode(),
EidasConstants.eIDAS_ATTRURN_BIRTHNAME, eidData.getBirthName(), false);
-
+
return result;
-
+
}
-
+
private void addEidasDocumentIfNotAvailable(Set<Eidas> result,
- Person ernpPersonToKitt, String citizenCountryCode,
+ Person ernpPersonToKitt, String citizenCountryCode,
String attrName, String attrValue, boolean allowMoreThanOneEntry) {
if (StringUtils.isEmpty(attrValue)) {
log.trace("No eIDAS document: {}. Nothing todo for KITT process ... ", attrName);
return;
-
+
}
-
+
// get all eIDAS documents from current ERnP entry or an empty list of no exists
- List<Eidas> currentEidasDocs = ernpPersonToKitt.getEidas() != null
- ? ernpPersonToKitt.getEidas() : Collections.emptyList();
-
- // check if eIDAS attribute is already includes an eIDAS-Document
- boolean alreadyExist = currentEidasDocs.stream()
- .filter(el -> el.getWert().equals(attrValue)
+ final List<Eidas> currentEidasDocs = ernpPersonToKitt.getEidas() != null
+ ? ernpPersonToKitt.getEidas()
+ : Collections.emptyList();
+
+ // check if eIDAS attribute is already includes an eIDAS-Document
+ final boolean alreadyExist = currentEidasDocs.stream()
+ .filter(el -> el.getWert().equals(attrValue)
&& el.getArt().equals(attrName)
- && el.getStaatscode2().equals(citizenCountryCode))
+ && el.getStaatscode2().equals(citizenCountryCode))
.findAny()
.isPresent();
-
- if (!alreadyExist) {
- // check eIDAS documents already contains a document with this pair of country-code and attribute-name
- Optional<Eidas> oneDocWithNameExists = currentEidasDocs.stream()
- .filter(el -> el.getStaatscode2().equals(citizenCountryCode)
+
+ if (!alreadyExist) {
+ // check eIDAS documents already contains a document with this pair of
+ // country-code and attribute-name
+ final Optional<Eidas> oneDocWithNameExists = currentEidasDocs.stream()
+ .filter(el -> el.getStaatscode2().equals(citizenCountryCode)
&& el.getArt().equals(attrName))
.findAny();
-
+
if (!allowMoreThanOneEntry && oneDocWithNameExists.isPresent()
- && !oneDocWithNameExists.get().getWert().equals(attrValue)) {
+ && !oneDocWithNameExists.get().getWert().equals(attrValue)) {
log.warn("eIDAS document: {} already exists for country: {} but attribute-value does not match. "
+ "Skip update process because no multi-value allowed for this ... ",
- attrName, citizenCountryCode);
-
+ attrName, citizenCountryCode);
+
} else {
-
- Eidas eidasDocToAdd = new Eidas();
+
+ final Eidas eidasDocToAdd = new Eidas();
eidasDocToAdd.setStaatscode2(citizenCountryCode);
eidasDocToAdd.setArt(attrName);
- eidasDocToAdd.setWert(attrValue);
+ eidasDocToAdd.setWert(attrValue);
log.info("Add eIDAS document: {} for country: {} to ERnP person", attrName, citizenCountryCode);
result.add(eidasDocToAdd);
-
+
}
-
+
} else {
log.debug("eIDAS document: {} already exists for country: {}. Skip update process for this ... ",
- attrName, citizenCountryCode);
-
+ attrName, citizenCountryCode);
+
}
}
-
+
private Person searchPersonForUpdate(RegisterResult registerResult) throws WorkflowException {
// build generic request metadata
final GenericRequestParams generic = buildGenericRequestParameters();
@@ -652,11 +661,11 @@ public class ErnpRestClient implements IErnpClient {
searchInfos.setBpkZp(registerResult.getBpk());
searchInfos.setFamilienname(registerResult.getFamilyName());
searchInfos.setVorname(registerResult.getGivenName());
- searchInfos.setGeburtsdatum(buildErnpBirthday(registerResult.getDateOfBirth()));
-
+ searchInfos.setGeburtsdatum(buildErnpBirthday(registerResult.getDateOfBirth()));
+
final PersonSuchen personSuchen = new PersonSuchen();
personSuchen.setSuchoptionen(generateSearchParameters());
- personSuchen.setBegruendung(PROCESS_KITT_IDENITIES_GET);
+ personSuchen.setBegruendung(PROCESS_KITT_IDENITIES_GET);
personSuchen.setSuchdaten(searchInfos);
// request ERnP
@@ -667,110 +676,109 @@ public class ErnpRestClient implements IErnpClient {
// perform shot validation of ERnP response
if (resp.getPerson() == null || resp.getPerson().size() != 1) {
log.error("ERnP result contains NO 'Person' or 'Person' is empty");
- throw new WorkflowException(PROCESS_KITT_IDENITIES_GET,
+ throw new WorkflowException(PROCESS_KITT_IDENITIES_GET,
"Find NO data-set with already matchted eID during ERnP KITT process");
-
+
} else {
log.debug("Find person for '{}' operation", PROCESS_KITT_IDENITIES_GET);
- return resp.getPerson().get(0);
-
- }
+ return resp.getPerson().get(0);
+
+ }
}
-
+
private void buildNewEidasDocumens(PersonAnlegen ernpReq, SimpleEidasData eidData) {
- ernpReq.addEidasItem(buildNewEidasDocument(eidData.getCitizenCountryCode(),
+ ernpReq.addEidasItem(buildNewEidasDocument(eidData.getCitizenCountryCode(),
EidasConstants.eIDAS_ATTRURN_PERSONALIDENTIFIER, eidData.getPseudonym()));
-
+
if (StringUtils.isNotEmpty(eidData.getPlaceOfBirth())) {
ernpReq.addEidasItem(buildNewEidasDocument(eidData.getCitizenCountryCode(),
EidasConstants.eIDAS_ATTRURN_PLACEOFBIRTH, eidData.getPlaceOfBirth()));
-
+
}
-
+
if (StringUtils.isNotEmpty(eidData.getBirthName())) {
- ernpReq.addEidasItem(buildNewEidasDocument(eidData.getCitizenCountryCode(),
+ ernpReq.addEidasItem(buildNewEidasDocument(eidData.getCitizenCountryCode(),
EidasConstants.eIDAS_ATTRURN_BIRTHNAME, eidData.getBirthName()));
-
- }
+
+ }
}
private Eidas buildNewEidasDocument(String citizenCountryCode, String eidasAttrName,
String eidasAddrValue) {
- Eidas el = new Eidas();
+ final Eidas el = new Eidas();
el.setArt(eidasAttrName);
el.setWert(eidasAddrValue);
el.setStaatscode2(citizenCountryCode);
return el;
}
-
- private SimpleEidasData selectMdsInformationToUpdate(Person ernpPersonToKitt, SimpleEidasData eidData) {
- PersonendatenErgebnis person = ernpPersonToKitt.getPersonendaten();
- SimpleEidasDataBuilder builder = SimpleEidasData.builder()
+
+ private SimpleEidasData selectMdsInformationToUpdate(Person ernpPersonToKitt, SimpleEidasData eidData) {
+ final PersonendatenErgebnis person = ernpPersonToKitt.getPersonendaten();
+ final SimpleEidasDataBuilder builder = SimpleEidasData.builder()
.givenName(eidData.getGivenName())
.familyName(eidData.getFamilyName())
.dateOfBirth(eidData.getDateOfBirth());
-
- boolean findMatch = person.getVorname().equals(eidData.getGivenName())
+
+ final boolean findMatch = person.getVorname().equals(eidData.getGivenName())
&& person.getFamilienname().equals(eidData.getFamilyName())
- && getTextualBirthday(person.getGeburtsdatum()).equals(eidData.getDateOfBirth());
+ && getTextualBirthday(person.getGeburtsdatum()).equals(eidData.getDateOfBirth());
return findMatch ? null : builder.build();
-
+
}
-
+
private Aendern generateMdsChangeRequest(Person ernpPersonToKitt, SimpleEidasData mdsToUpdate) {
- Aendern el = new Aendern();
- Personendaten person = new Personendaten();
+ final Aendern el = new Aendern();
+ final Personendaten person = new Personendaten();
person.setEntityId(ernpPersonToKitt.getPersonendaten().getEntityId());
el.setPersonendaten(person);
person.setFamilienname(mdsToUpdate.getFamilyName());
person.setVorname(mdsToUpdate.getGivenName());
- person.setGeburtsdatum(buildErnpBirthday(mdsToUpdate.getDateOfBirth()));
+ person.setGeburtsdatum(buildErnpBirthday(mdsToUpdate.getDateOfBirth()));
return el;
-
+
}
-
+
/**
* Map an AT specific Date String 'yyyy-MM-dd' to ERnP birthday representation.
- *
+ *
* <p>
- * <b>Info:</b> {@link LocalDate} can not be used, because '1940-00-00' is also
+ * <b>Info:</b> {@link LocalDate} can not be used, because '1940-00-00' is also
* a valid birthday.
* </p>
- *
+ *
* @param dateOfBirth in 'yyyy-MM-dd' format
* @return ERnP birthday representation
*/
- private PartialDate buildErnpBirthday(String dateOfBirth) {
- String[] elements = dateOfBirth.split("-");
+ private PartialDate buildErnpBirthday(String dateOfBirth) {
+ final String[] elements = dateOfBirth.split("-");
Assert.isTrue(elements.length == 3, "Find invalid dateOfBirth element: " + dateOfBirth);
-
- PartialDate result = new PartialDate();
+
+ final PartialDate result = new PartialDate();
result.setJahr(Integer.valueOf(elements[0]));
result.setMonat(Integer.valueOf(elements[1]));
- result.setTag(Integer.valueOf(elements[2]));
+ result.setTag(Integer.valueOf(elements[2]));
return result;
-
+
}
/**
* Map eIDAS search-data from ZMR model into ERnP model.
- *
+ *
* @param daten eIDAS document as ZMR model
* @return the same eIDAS document as an ERnP model
*/
- private SuchEidas buildErnpEidasDocument(EidasSuchdatenType daten) {
+ private SuchEidas buildErnpEidasDocument(EidasSuchdatenType daten) {
return new SuchEidas()
.art(daten.getEidasArt())
.wert(daten.getEidasWert())
- .staatscode2(daten.getStaatscode2());
+ .staatscode2(daten.getStaatscode2());
}
-
-
+
/**
* Build AT specific Date String 'yyyy-MM-dd' from ERnP birthday representation.
*
* <p>
- * <b>Info:</b> {@link LocalDate} can not be used, because '1940-00-00' is also
+ * <b>Info:</b> {@link LocalDate} can not be used, because '1940-00-00' is also
* a valid birthday on ERnP site.
* </p>
*
@@ -785,7 +793,6 @@ public class ErnpRestClient implements IErnpClient {
}
-
/**
* Get all eIDAS document with the specified country code and document type.
*
@@ -845,30 +852,31 @@ public class ErnpRestClient implements IErnpClient {
final RestTemplate springClient = new RestTemplate(requestFactory);
springClient.setErrorHandler(buildErrorHandler());
springClient.getMessageConverters().add(0, buildCustomJacksonObjectMapper());
- //springClient.getInterceptors().add(buildTransactionIdInterceptor());
+ // springClient.getInterceptors().add(buildTransactionIdInterceptor());
return springClient;
}
-
- //private ClientHttpRequestInterceptor buildTransactionIdInterceptor() {
- // return new ClientHttpRequestInterceptor() {
- //
- // @Override
- // public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution)
- // throws IOException {
- // request.getHeaders().add("dfafsafafsaf", TransactionIdUtils.getTransactionId());
- // return execution.execute(request, body);
- //
- // }
- // };
- //}
+ // private ClientHttpRequestInterceptor buildTransactionIdInterceptor() {
+ // return new ClientHttpRequestInterceptor() {
+ //
+ // @Override
+ // public ClientHttpResponse intercept(HttpRequest request, byte[] body,
+ // ClientHttpRequestExecution execution)
+ // throws IOException {
+ // request.getHeaders().add("dfafsafafsaf",
+ // TransactionIdUtils.getTransactionId());
+ // return execution.execute(request, body);
+ //
+ // }
+ // };
+ // }
private HttpMessageConverter<?> buildCustomJacksonObjectMapper() {
final MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
converter.setSupportedMediaTypes(Collections.singletonList(MediaType.APPLICATION_JSON));
converter.getObjectMapper().setSerializationInclusion(Include.NON_NULL);
-
+
converter.getObjectMapper().registerModule(new JavaTimeModule());
converter.getObjectMapper().configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
return converter;
@@ -890,12 +898,12 @@ public class ErnpRestClient implements IErnpClient {
public void handleError(ClientHttpResponse response) throws IOException {
// TODO: opimize errorHandling based on response info's from real ERnP
- List<String> serverId = response.getHeaders().getOrEmpty(ERNP_RESPONSE_HEADER_SERVER_ID);
+ final List<String> serverId = response.getHeaders().getOrEmpty(ERNP_RESPONSE_HEADER_SERVER_ID);
log.warn("Receive http-error: {} from ERnP with serverTransactionId {}",
response.getRawStatusCode(), serverId.isEmpty() ? "'not set'" : serverId.get(0));
- log.warn(" Full ERnP response-body: {}", IOUtils.toString(response.getBody(), "UTF-8"));
+ log.warn(" Full ERnP response-body: {}", IOUtils.toString(response.getBody(), "UTF-8"));
throw new ErnpRestCommunicationException(response.getRawStatusCode());
-
+
}
};
}
@@ -927,61 +935,62 @@ public class ErnpRestClient implements IErnpClient {
@Getter
public static class ErnpRegisterResult {
- private List<ErnpPersonRegisterResult> fullErnpResults;
-
+ private final List<ErnpPersonRegisterResult> fullErnpResults;
+
/**
* Build reduced ERnP register result.
- * @param list {@link List} of ERnP entities
+ *
+ * @param list {@link List} of ERnP entities
*/
public ErnpRegisterResult(List<ErnpPersonRegisterResult> list) {
fullErnpResults = list;
-
+
}
-
+
/**
* Get all active ERnP results.
- *
+ *
* @return ERnP entities
*/
public Stream<ErnpPersonRegisterResult> getPersonResultStream() {
- return fullErnpResults.stream()
- .filter(el -> !el.isZmrEntryNow());
-
+ return fullErnpResults.stream()
+ .filter(el -> !el.isZmrEntryNow());
+
}
-
+
/**
* Get all active ERnP results.
- *
+ *
* @return ERnP entities
*/
public List<RegisterResult> getPersonResult() {
- return getPersonResultStream()
- .collect(Collectors.toList());
-
+ return getPersonResultStream()
+ .collect(Collectors.toList());
+
}
/**
* Get all ERnP results that are kitted to ZMR entries.
- *
+ *
* @return entities that are in ZMR now
*/
public Stream<ErnpPersonRegisterResult> getZmrPersonResultStream() {
return fullErnpResults.stream()
.filter(el -> el.isZmrEntryNow());
-
+
}
-
+
/**
* Get all ERnP results that are kitted to ZMR entries.
- *
+ *
* @return entities that are in ZMR now
*/
public List<RegisterResult> getZmrPersonResult() {
return getZmrPersonResultStream()
.collect(Collectors.toList());
-
+
}
-
+
}
private GenericRequestParams buildGenericRequestParameters() {
diff --git a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/ErnpPersonRegisterResult.java b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/ErnpPersonRegisterResult.java
index 1b9454db..9710e31e 100644
--- a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/ErnpPersonRegisterResult.java
+++ b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/dao/ErnpPersonRegisterResult.java
@@ -18,6 +18,12 @@ public class ErnpPersonRegisterResult extends RegisterResult {
*/
private final boolean zmrEntryNow;
+ /**
+ * ERnP specific result with basic entity data and ZMR KITT flag.
+ *
+ * @param result Basic ERnP register result
+ * @param isZmrEntryNow <code>true</code> if person should be already in ZMR, otherwise <code>false</code>
+ */
public ErnpPersonRegisterResult(RegisterResult result, boolean isZmrEntryNow) {
super(result.getPseudonym(), result.getGivenName(), result.getFamilyName(), result.getDateOfBirth(),
result.getPlaceOfBirth(), result.getBirthName(), result.getTaxNumber(), result.getAddress(),
diff --git a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/service/RegisterSearchService.java b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/service/RegisterSearchService.java
index b947fbe3..096c9d5f 100644
--- a/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/service/RegisterSearchService.java
+++ b/modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/service/RegisterSearchService.java
@@ -478,7 +478,7 @@ public class RegisterSearchService {
result.getPersonResult().stream())
.collect(Collectors.toList());
if (zmrCleared.size() < result.getPersonResult().size() + resultErnp.getZmrPersonResult().size()) {
- log.info(LOG_MSG_RESULTS_CLEARING,
+ log.info(LOG_MSG_RESULTS_CLEARING_KITT,
result.getPersonResult().size() + resultErnp.getZmrPersonResult().size() - zmrCleared.size());
}