aboutsummaryrefslogtreecommitdiff
path: root/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/authmodule_eIDASv2/handler/AbstracteIDPostProcessor.java
diff options
context:
space:
mode:
authorThomas Lenz <thomas.lenz@egiz.gv.at>2019-10-31 09:48:29 +0100
committerThomas Lenz <thomas.lenz@egiz.gv.at>2019-10-31 09:48:29 +0100
commit6bd9903633452f01531e9830db0242e9bf081242 (patch)
tree5745138b439e469cfc9f10ddea60cb71c8d467eb /eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/authmodule_eIDASv2/handler/AbstracteIDPostProcessor.java
parent5bda3bcc87f7c58dfa782e76eecb183631369ede (diff)
downloadNational_eIDAS_Gateway-6bd9903633452f01531e9830db0242e9bf081242.tar.gz
National_eIDAS_Gateway-6bd9903633452f01531e9830db0242e9bf081242.tar.bz2
National_eIDAS_Gateway-6bd9903633452f01531e9830db0242e9bf081242.zip
add country specific pre-processing to build country specific eIDAS requests
Diffstat (limited to 'eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/authmodule_eIDASv2/handler/AbstracteIDPostProcessor.java')
-rw-r--r--eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/authmodule_eIDASv2/handler/AbstracteIDPostProcessor.java221
1 files changed, 0 insertions, 221 deletions
diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/authmodule_eIDASv2/handler/AbstracteIDPostProcessor.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/authmodule_eIDASv2/handler/AbstracteIDPostProcessor.java
deleted file mode 100644
index 9c252d1d..00000000
--- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/authmodule_eIDASv2/handler/AbstracteIDPostProcessor.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*******************************************************************************
- * Copyright 2018 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.authmodule_eIDASv2.handler;
-
-import java.util.Map;
-
-import org.joda.time.DateTime;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asitplus.eidas.specific.modules.authmodule_eIDASv2.Constants;
-import at.asitplus.eidas.specific.modules.authmodule_eIDASv2.DAO.ERnBeIDData;
-import at.asitplus.eidas.specific.modules.authmodule_eIDASv2.exception.eIDASAttributeException;
-import at.asitplus.eidas.specific.modules.authmodule_eIDASv2.exception.eIDPostProcessingException;
-import at.asitplus.eidas.specific.modules.authmodule_eIDASv2.utils.eIDASResponseUtils;
-import at.gv.e_government.reference.namespace.persondata._20020228.PostalAddressType;
-import at.gv.egiz.eaaf.core.impl.data.Trible;
-import eu.eidas.auth.commons.protocol.eidas.impl.PostalAddress;
-
-public abstract class AbstracteIDPostProcessor implements INationaleIDPostProcessor {
- private static final Logger log = LoggerFactory.getLogger(AbstracteIDPostProcessor.class);
-
-
- @Override
- public ERnBeIDData postProcess(Map<String, Object> eIDASAttrMap) throws eIDPostProcessingException, eIDASAttributeException{
- ERnBeIDData result = new ERnBeIDData();
-
- Object eIdentifierObj = eIDASAttrMap.get(Constants.eIDAS_ATTR_PERSONALIDENTIFIER);
- Trible<String, String, String> eIdentifier =
- eIDASResponseUtils.parseEidasPersonalIdentifier((String)eIdentifierObj);
- result.setCitizenCountryCode(eIdentifier.getFirst());
-
- //MDS attributes
- result.setPseudonym(processPseudonym(eIDASAttrMap.get(Constants.eIDAS_ATTR_PERSONALIDENTIFIER)));
- result.setFamilyName(processFamilyName(eIDASAttrMap.get(Constants.eIDAS_ATTR_CURRENTFAMILYNAME)));
- result.setGivenName(processGivenName(eIDASAttrMap.get(Constants.eIDAS_ATTR_CURRENTGIVENNAME)));
- result.setDateOfBirth(processDateOfBirth(eIDASAttrMap.get(Constants.eIDAS_ATTR_DATEOFBIRTH)));
-
- //additional attributes
- result.setPlaceOfBirth(processPlaceOfBirth(eIDASAttrMap.get(Constants.eIDAS_ATTR_PLACEOFBIRTH)));
- result.setBirthName(processBirthName(eIDASAttrMap.get(Constants.eIDAS_ATTR_BIRTHNAME)));
- result.setAddress(processAddress(eIDASAttrMap.get(Constants.eIDAS_ATTR_CURRENTADDRESS)));
-
- return result;
-
- }
-
- /**
- * Post-Process the eIDAS CurrentAddress attribute
- *
- * @param currentAddressObj
- * @return current address or null if no attribute is available
- * @throws eIDPostProcessingException if post-processing fails
- * @throws eIDASAttributeException if eIDAS attribute is of a wrong type
- */
- protected PostalAddressType processAddress(Object currentAddressObj) throws eIDPostProcessingException, eIDASAttributeException {
-
- if (currentAddressObj != null) {
- if ((currentAddressObj instanceof PostalAddress)) {
- PostalAddressType result = new PostalAddressType();
- result.setPostalCode(((PostalAddress)currentAddressObj).getPostCode());
- result.setMunicipality(((PostalAddress)currentAddressObj).getPostName());
-
- //TODO: add more mappings
-
- } else {
- log.warn("eIDAS attr: " + Constants.eIDAS_ATTR_CURRENTADDRESS + " is of WRONG type");
- throw new eIDASAttributeException(Constants.eIDAS_ATTR_CURRENTADDRESS);
-
- }
-
- } else
- log.debug("NO '" + Constants.eIDAS_ATTR_CURRENTADDRESS + "' attribute. Post-Processing skipped ... ");
-
- return null;
-
- }
-
- /**
- * Post-Process the eIDAS BirthName attribute
- *
- * @param birthNameObj
- * @return birthName or null if no attribute is available
- * @throws eIDPostProcessingException if post-processing fails
- * @throws eIDASAttributeException if eIDAS attribute is of a wrong type
- */
- protected String processBirthName(Object birthNameObj) throws eIDPostProcessingException, eIDASAttributeException {
- if (birthNameObj != null) {
- if ((birthNameObj instanceof String)) {
- return (String)birthNameObj;
-
- } else {
- log.warn("eIDAS attr: " + Constants.eIDAS_ATTR_BIRTHNAME + " is of WRONG type");
- throw new eIDASAttributeException(Constants.eIDAS_ATTR_BIRTHNAME);
-
- }
-
- } else
- log.debug("NO '" + Constants.eIDAS_ATTR_BIRTHNAME + "' attribute. Post-Processing skipped ... ");
-
-
- return null;
-
- }
-
- /**
- * Post-Process the eIDAS PlaceOfBirth attribute
- *
- * @param placeOfBirthObj
- * @return place of Birth or null if no attribute is available
- * @throws eIDPostProcessingException if post-processing fails
- * @throws eIDASAttributeException if eIDAS attribute is of a wrong type
- */
- protected String processPlaceOfBirth(Object placeOfBirthObj) throws eIDPostProcessingException, eIDASAttributeException {
- if (placeOfBirthObj != null) {
- if ((placeOfBirthObj instanceof String)) {
- return (String)placeOfBirthObj;
-
- } else {
- log.warn("eIDAS attr: " + Constants.eIDAS_ATTR_PLACEOFBIRTH + " is of WRONG type");
- throw new eIDASAttributeException(Constants.eIDAS_ATTR_PLACEOFBIRTH);
-
- }
-
- } else
- log.debug("NO '" + Constants.eIDAS_ATTR_PLACEOFBIRTH + "' attribute. Post-Processing skipped ... ");
-
-
- return null;
-
- }
-
- /**
- * Post-Process the eIDAS DateOfBirth attribute
- *
- * @param dateOfBirthObj
- * @return
- * @throws eIDASAttributeException if NO attribute is available
- * @throws eIDPostProcessingException if post-processing fails
- */
- protected DateTime processDateOfBirth(Object dateOfBirthObj) throws eIDPostProcessingException, eIDASAttributeException {
- if (dateOfBirthObj == null || !(dateOfBirthObj instanceof DateTime))
- throw new eIDASAttributeException(Constants.eIDAS_ATTR_DATEOFBIRTH);
-
- return (DateTime)dateOfBirthObj;
-
- }
-
- /**
- * Post-Process the eIDAS GivenName attribute
- *
- * @param givenNameObj
- * @return
- * @throws eIDASAttributeException if NO attribute is available
- * @throws eIDPostProcessingException if post-processing fails
- */
- protected String processGivenName(Object givenNameObj) throws eIDPostProcessingException, eIDASAttributeException {
- if (givenNameObj == null || !(givenNameObj instanceof String))
- throw new eIDASAttributeException(Constants.eIDAS_ATTR_CURRENTGIVENNAME);
-
- return (String)givenNameObj;
-
- }
-
- /**
- * Post-Process the eIDAS FamilyName attribute
- *
- * @param familyNameObj
- * @return
- * @throws eIDASAttributeException if NO attribute is available
- * @throws eIDPostProcessingException if post-processing fails
- */
- protected String processFamilyName(Object familyNameObj) throws eIDPostProcessingException, eIDASAttributeException {
- if (familyNameObj == null || !(familyNameObj instanceof String))
- throw new eIDASAttributeException(Constants.eIDAS_ATTR_CURRENTFAMILYNAME);
-
- return (String) familyNameObj;
-
- }
-
- /**
- * Post-Process the eIDAS pseudonym to ERnB unique identifier
- *
- * @param eIdentifierObj eIDAS PersonalIdentifierAttribute
- * @return
- * @throws eIDPostProcessingException
- * @throws eIDASAttributeException if NO attribute is available
- * @throws eIDPostProcessingException if post-processing fails
- */
- protected String processPseudonym(Object eIdentifierObj) throws eIDPostProcessingException, eIDASAttributeException {
- if (eIdentifierObj == null || !(eIdentifierObj instanceof String))
- throw new eIDASAttributeException(Constants.eIDAS_ATTR_PERSONALIDENTIFIER);
-
- Trible<String, String, String> eIdentifier =
- eIDASResponseUtils.parseEidasPersonalIdentifier((String)eIdentifierObj);
-
- return eIdentifier.getThird();
-
- }
-
-}