From 4c621edbacbaed95edf4cac3a44a84e9e5c55819 Mon Sep 17 00:00:00 2001 From: Alexander Marsalek Date: Fri, 29 Jan 2021 17:11:32 +0100 Subject: remove unnecessary classes --- .../config/junit_config_1_springboot.properties | 1 + .../AhAuthProcessDataConstants.java | 9 - .../idaustriaclient/AhAuthProcessDataWrapper.java | 224 ---------- .../AhExtendedPvpAttributeDefinitions.java | 24 -- .../v2/idaustriaclient/AuthHandlerConstants.java | 141 ------- .../v2/idaustriaclient/IAhAuthProcessData.java | 190 --------- .../v2/idaustriaclient/IAhSpConfiguration.java | 151 ------- .../eidas/v2/idaustriaclient/IRawMandateDao.java | 32 -- .../eidas/v2/idaustriaclient/ISignedMandate.java | 19 - .../IdAustriaClientAuthConstants.java | 55 +-- .../IdAustriaClientAuthMetadataConfiguration.java | 16 +- .../eidas/v2/idaustriaclient/MisException.java | 17 - .../GenerateMobilePhoneSignatureRequestTask.java | 6 +- ...eSignatureResponseAndSearchInRegistersTask.java | 121 +++--- .../v2/test/tasks/InitialSearchTaskFirstTest.java | 463 --------------------- .../eidas/v2/test/tasks/InitialSearchTaskTest.java | 463 +++++++++++++++++++++ 16 files changed, 527 insertions(+), 1405 deletions(-) delete mode 100644 eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/AhAuthProcessDataConstants.java delete mode 100644 eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/AhAuthProcessDataWrapper.java delete mode 100644 eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/AhExtendedPvpAttributeDefinitions.java delete mode 100644 eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/AuthHandlerConstants.java delete mode 100644 eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/IAhAuthProcessData.java delete mode 100644 eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/IAhSpConfiguration.java delete mode 100644 eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/IRawMandateDao.java delete mode 100644 eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/ISignedMandate.java delete mode 100644 eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/MisException.java delete mode 100644 eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskFirstTest.java create mode 100644 eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskTest.java diff --git a/connector/src/test/resources/config/junit_config_1_springboot.properties b/connector/src/test/resources/config/junit_config_1_springboot.properties index 1cfeef37..fc0c7241 100644 --- a/connector/src/test/resources/config/junit_config_1_springboot.properties +++ b/connector/src/test/resources/config/junit_config_1_springboot.properties @@ -107,6 +107,7 @@ eidas.ms.modules.idaustriaclient.truststore.password=password eidas.ms.modules.idaustriaclient.truststore.type=jks eidas.ms.modules.idaustriaclient.node.entityId= +eidas.ms.modules.idaustriaclient.sp.entityId= eidas.ms.modules.idaustriaclient.node.metadataUrl= eidas.ms.modules.idaustriaclient.metadata.organisation.name=JUnit diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/AhAuthProcessDataConstants.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/AhAuthProcessDataConstants.java deleted file mode 100644 index 36ea2440..00000000 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/AhAuthProcessDataConstants.java +++ /dev/null @@ -1,9 +0,0 @@ -package at.asitplus.eidas.specific.modules.auth.eidas.v2.idaustriaclient; - -import at.gv.egiz.eaaf.core.api.idp.EaafAuthProcessDataConstants; - -public interface AhAuthProcessDataConstants extends EaafAuthProcessDataConstants { - - - -} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/AhAuthProcessDataWrapper.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/AhAuthProcessDataWrapper.java deleted file mode 100644 index 1b20960b..00000000 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/AhAuthProcessDataWrapper.java +++ /dev/null @@ -1,224 +0,0 @@ -package at.asitplus.eidas.specific.modules.auth.eidas.v2.idaustriaclient; - - -import java.security.cert.CertificateEncodingException; -import java.security.cert.CertificateException; -import java.util.Map; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import at.gv.egiz.eaaf.core.impl.idp.auth.data.AuthProcessDataWrapper; -import iaik.x509.X509Certificate; - -public class AhAuthProcessDataWrapper extends AuthProcessDataWrapper - implements IAhAuthProcessData, AhAuthProcessDataConstants { - private static final Logger log = LoggerFactory.getLogger(AhAuthProcessDataWrapper.class); - - public static final String VALUE_SIGNER_CERT = "direct_signerCert"; - public static final String VALUE_VDAURL = "direct_bkuUrl"; - - public static final String VALUE_MANDATES_REFVALUE = "direct_mis_refvalue"; - - public static final String VALUE_EID_QCBIND = "direct_eid_qcBind"; - public static final String VALUE_EID_VSZ = "direct_eid_vsz"; - public static final String VALUE_EID_SIGNEDAUTHBLOCK = "direct_eid_authblock"; - public static final String VALUE_EID_SIGNEDAUTHBLOCK_TYPE = "direct_eid_authblock_type"; - public static final String VALUE_EID_MIS_MANDATE = "direct_eid_mis_mandate"; - - public static final String VALUE_INTERNAL_BPK = "direct_internal_bpk"; - public static final String VALUE_INTERNAL_BPKYPE = "direct_internal_bpktype"; - - public static final String VALUE_INTERNAL_MANDATE_ELGA_PROCESS = "direct_is_elga_mandate_process"; - public static final String VALUE_INTERNAL_VDA_AUTHENTICATION_PROCESS = "direct_is_vda_auth_process"; - - public AhAuthProcessDataWrapper(final Map authProcessData) { - super(authProcessData); - - } - - /* - * (non-Javadoc) - * - * @see at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#getSignerCertificate() - */ - @Override - public X509Certificate getSignerCertificate() { - final byte[] encCert = getEncodedSignerCertificate(); - - if (encCert != null) { - try { - return new X509Certificate(encCert); - } catch (final CertificateException e) { - log.warn("Signer certificate can not be loaded from session database!", e); - - } - } - return null; - } - - /* - * (non-Javadoc) - * - * @see at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#getEncodedSignerCertificate() - */ - @Override - public byte[] getEncodedSignerCertificate() { - return wrapStoredObject(VALUE_SIGNER_CERT, null, byte[].class); - - } - - /* - * (non-Javadoc) - * - * @see at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#setSignerCertificate(iaik.x509. - * X509Certificate) - */ - @Override - public void setSignerCertificate(final java.security.cert.X509Certificate signerCertificate) { - try { - authProcessData.put(VALUE_SIGNER_CERT, signerCertificate.getEncoded()); - - } catch (final CertificateEncodingException e) { - log.warn("Signer certificate can not be stored to session database!", e); - } - - } - - /* - * (non-Javadoc) - * - * @see at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#getBkuURL() - */ - @Override - public String getVdaUrl() { - return wrapStoredObject(VALUE_VDAURL, null, String.class); - } - - /* - * (non-Javadoc) - * - * @see at.gv.egovernment.moa.id.auth.data.IAuthenticationSession#setBkuURL(java.lang.String) - */ - @Override - public void setVdaUrl(final String vdaUrl) { - authProcessData.put(VALUE_VDAURL, vdaUrl); - - } - - @Override - public String getMandateReferenceValue() { - return wrapStoredObject(VALUE_MANDATES_REFVALUE, null, String.class); - } - - @Override - public void setMandateReferenceValue(final String refValue) { - authProcessData.put(VALUE_MANDATES_REFVALUE, refValue); - - } - - @Override - public String getQcBind() { - return wrapStoredObject(VALUE_EID_QCBIND, null, String.class); - } - - @Override - public void setQcBind(final String qcBind) { - authProcessData.put(VALUE_EID_QCBIND, qcBind); - - } - - @Override - public String getVsz() { - return wrapStoredObject(VALUE_EID_VSZ, null, String.class); - } - - @Override - public void setVsz(final String vsz) { - authProcessData.put(VALUE_EID_VSZ, vsz); - - } - - @Override - public byte[] getSignedAuthBlock() { - return wrapStoredObject(VALUE_EID_SIGNEDAUTHBLOCK, null, byte[].class); - } - - @Override - public void setSignedAuthBlock(final byte[] signedConsent) { - authProcessData.put(VALUE_EID_SIGNEDAUTHBLOCK, signedConsent); - - } - - @Override - public AuthHandlerConstants.AuthBlockType getSignedAuthBlockType() { - return wrapStoredObject(VALUE_EID_SIGNEDAUTHBLOCK_TYPE, AuthHandlerConstants.AuthBlockType.NONE, - AuthHandlerConstants.AuthBlockType.class); - } - - @Override - public void setSignedAuthBlockType(final AuthHandlerConstants.AuthBlockType authBlockType) { - authProcessData.put(VALUE_EID_SIGNEDAUTHBLOCK_TYPE, authBlockType); - - } - - @Override - public ISignedMandate getMandateDate() { - return wrapStoredObject(VALUE_EID_MIS_MANDATE, null, ISignedMandate.class); - - } - - @Override - public void setMandateDate(final ISignedMandate mandateDate) { - authProcessData.put(VALUE_EID_MIS_MANDATE, mandateDate); - - } - - @Override - public String getInternalBpk() { - return wrapStoredObject(VALUE_INTERNAL_BPK, null, String.class); - } - - @Override - public void setInternalBpk(final String bpk) { - authProcessData.put(VALUE_INTERNAL_BPK, bpk); - - } - - @Override - public String getInternalBpkType() { - return wrapStoredObject(VALUE_INTERNAL_BPKYPE, null, String.class); - - } - - @Override - public void setInternalBpkType(final String bpkType) { - authProcessData.put(VALUE_INTERNAL_BPKYPE, bpkType); - - } - - @Override - public boolean isElgaMandateProcess() { - return wrapStoredObject(VALUE_INTERNAL_MANDATE_ELGA_PROCESS, false, Boolean.class); - - } - - @Override - public void setElgaMandateProcess(boolean flag) { - authProcessData.put(VALUE_INTERNAL_MANDATE_ELGA_PROCESS, flag); - - } - - @Override - public boolean isVdaAuthentication() { - return wrapStoredObject(VALUE_INTERNAL_VDA_AUTHENTICATION_PROCESS, false, Boolean.class); - - } - - @Override - public void setVdaAuthentication(boolean flag) { - authProcessData.put(VALUE_INTERNAL_VDA_AUTHENTICATION_PROCESS, flag); - - } - -} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/AhExtendedPvpAttributeDefinitions.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/AhExtendedPvpAttributeDefinitions.java deleted file mode 100644 index b74767de..00000000 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/AhExtendedPvpAttributeDefinitions.java +++ /dev/null @@ -1,24 +0,0 @@ -package at.asitplus.eidas.specific.modules.auth.eidas.v2.idaustriaclient; - -import at.gv.egiz.eaaf.core.api.data.ExtendedPvpAttributeDefinitions; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class AhExtendedPvpAttributeDefinitions implements ExtendedPvpAttributeDefinitions { - private static final Logger log = - LoggerFactory.getLogger(AhExtendedPvpAttributeDefinitions.class); - - private AhExtendedPvpAttributeDefinitions() { - log.trace("Instance class: {} for SonarQube", - AhExtendedPvpAttributeDefinitions.class.getName()); - - } - - public static final String EID_BCBIND_NAME = "urn:eidgvat:attributes.bcbind"; - public static final String EID_BCBIND_FRIENDLY_NAME = "bcBind"; - - public static final String EID_BINDING_PUBKEY_NAME = "urn:eidgvat:attributes.binding.pubkey"; - public static final String EID_BINDING_PUBKEY_FRIENDLY_NAME = "BindingPubKey"; - -} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/AuthHandlerConstants.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/AuthHandlerConstants.java deleted file mode 100644 index 1bbc31e0..00000000 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/AuthHandlerConstants.java +++ /dev/null @@ -1,141 +0,0 @@ -package at.asitplus.eidas.specific.modules.auth.eidas.v2.idaustriaclient; - - -public class AuthHandlerConstants { - - private AuthHandlerConstants() { - - } - - // TODO: maybe update to another target - public static final String DEFAULT_INTERNAL_BPK_TARGET = "urn:publicid:gv.at:cdid+ZP-MH"; - - // configuration parameters - public static final String PROP_CONFIG_APPLICATION_PREFIX = "authhandler."; - public static final String PROP_CONFIG_APPLICATION_PUBLIC_URL_PREFIX = "core.context.url.prefix"; - public static final String PROP_CONFIG_APPLICATION_PUBLIC_URL_REQUEST_VALIDATION = - "core.context.url.request.validation"; - public static final String PROP_CONFIG_LEGACY_ALLOW = "core.legacy.allowLegacyMode"; - - public static final String PROP_CONFIG_WEBCONTENT_STATIC_PATH = - "core.webcontent.static.directory"; - public static final String PROP_CONFIG_WEBCONTENT_TEMPLATES_PATH = "core.webcontent.templates"; - public static final String PROP_CONFIG_WEBCONTENT_PROPERTIES_PATH = "core.webcontent.properties"; - - public static final String PROP_CONFIG_CACHE_TRANSACTIONS_NAME = "core.cache.transaction.name"; - public static final String PROP_CONFIG_CACHE_TRANSACTIONS_ENC_ENABLED = - "core.cache.transaction.encryption.enabled"; - public static final String PROP_CONFIG_CACHE_TRANSACTIONS_ENC_KEY_TYPE = - "core.cache.transaction.encryption.type"; - public static final String PROP_CONFIG_CACHE_TRANSACTIONS_ENC_PASSPHRASE = - "core.cache.transaction.encryption.passphrase"; - public static final String PROP_CONFIG_CACHE_TRANSACTIONS_ENC_SALT = - "core.cache.transaction.encryption.salt"; - public static final String PROP_CONFIG_CACHE_TRANSACTIONS_ENC_KEYSTORE_NAME = - "core.cache.transaction.encryption.keystore.name"; - public static final String PROP_CONFIG_CACHE_TRANSACTIONS_ENC_KEY_ALIAS = - "core.cache.transaction.encryption.key.alias"; - - public static final String PROP_CONFIG_CACHE_ATTRIBUTEPROXY_NAME = - "core.cache.attributeproxy.name"; - - public static final String PROP_CONFIG_BACKEND_ENDPOINT_GETALLSUPPORTEDATTRIBUTES = - "backend.endpoints.getallsupportedattributes"; - public static final String PROP_CONFIG_BACKEND_ENDPOINT_GETAPPLICATIONCONFIGURATION = - "backend.endpoints.getapplicationconfiguration"; - - public static final String PROP_CONFIG_INTERNAL_BPK_TARGET = "core.internal.bpk.target"; - - public static final String PROP_CONFIG_INTERNAL_FRONTEND_ONLY_MODE = "core.internal.frontend.only.mode"; - public static final boolean PROP_DEFAULT_CONFIG_INTERNAL_FRONTEND_ONLY_MODE = false; - - // Servlet End-Points - public static final String ENDPOINT_PROCESSENGINE_CONTROLLER = "/api/process"; - public static final String ENDPOINT_ERROR_IFRAME_HOPPING = "/error/parenthop"; - - - // GUI template directories - public static final String CLASSPATH_TEMPLATE_DIR = "/templates/"; - public static final String FILESYSTEM_TEMPLATE_DIR = "./templates/"; - public static final String TEMPLATE_HTML_ERROR = "error_message.html"; - - // GUI template defaultfiles - public static final String TEMPLATE_AUTHPROCESS_SELECTION_VDA_FULLFRAME = "authSelection.html"; - public static final String TEMPLATE_AUTHPROCESS_SELECTION_VDA_IFRAME = "authSelection_iframe.html"; - public static final String TEMPLATE_USER_CONSENT_REQUEST = "userConsent.html"; - public static final String TEMPLATE_IFRAME_TO_PARENT_HOPE = "iframe_parent_hope.html"; - public static final String TEMPLATE_MANDATE_SELECTION = "mandateSelection.html"; - public static final String TEMPLATE_PROF_REP_MANDATE_SELECTION = "profRepMandateSelection.html"; - public static final String TEMPLATE_MANDATE_SELECTION_DUMMY = "mandateSelection_dummy.html"; - - - - // http request parameters - public static final String HTTP_PARAM_APPLICATION_ID = "appId"; - public static final String HTTP_PARAM_STOP_PROCESS = "stopAuthProcess"; - public static final String HTTP_PARAM_EIDAS_PROCESS = "useeIDAS"; - public static final String HTTP_PARAM_EID_PROCESS = "useeID"; - public static final String HTTP_PARAM_EID_BINDING_AUTH_PROCESS = "useBindingAuth"; - public static final String HTTP_PARAM_USE_MANDATES = "useMandate"; - public static final String HTTP_PARAM_AUTHMETHOD = "authMethod"; - public static final String HTTP_PARAM_CONSENT_RELEASE_ATTRIBUTES = "releaseAttributes"; - public static final String HTTP_PARAM_CONSENT_STORE_CONSENT = "storeConsent"; - - @Deprecated - public static final String HTTP_PARAM_EIDMIGRATIONPILOT_PROCESS = "pilotMigration"; - @Deprecated - public static final String HTTP_PARAM_EIDMIGRATIONPILOT_SHOW_INFO_PAGE = "pilotMigrationInfoPage"; - @Deprecated - public static final String HTTP_PARAM_MOBILESIGNATURE_PROCESS = "usemobileSig"; - - // UI options - public static final String UI_PARAM_USE_MANDATES = HTTP_PARAM_USE_MANDATES; - public static final String UI_PARAM_USE_ONLY_MANDATES = "useOnlyMandate"; - public static final String UI_PARAM_USE_EIDAS = HTTP_PARAM_EIDAS_PROCESS; - public static final String UI_PARAM_DSGVO_SHORT_INFO = "dsgvoShortText"; - public static final String UI_PARAM_DSGVO_SP_PRIVACY_STATEMENT_URL = "dsgvoPrivacyStatementUrl"; - public static final String UI_PARAM_DSGVO_SP_SERVICE_URL = "dsgvoServiceUrl"; - public static final String UI_PARAM_DSGVO_SP_LOGO = "dsgvoSpLogo"; - public static final String UI_PARAM_DSGVO_SP_LOGO_SET = "dsgvoSpLogoSet"; - public static final String UI_PARAM_DSGVO_SP_LOGO_SET_DATAURL = "dataUrl"; - public static final String UI_PARAM_DSGVO_SP_LOGO_SET_THEME = "theme"; - public static final String UI_PARAM_DSGVO_SP_LOGO_SET_RESOLUTION = "resolution"; - public static final String UI_PARAM_DSGVO_SP_LOGO_SET_TYPE = "type"; - - public enum LogoType { SVG, PNG, UNKNOWN } - - public enum AuthBlockType { - CADES("CAdES"), JWS("JWS"), NONE("none"); - - private final String internalType; - - AuthBlockType(final String type) { - this.internalType = type; - - } - - /** - * Get Type identifier for this AuthBlock. - * - * @return - */ - public String getAuthBlockType() { - return this.internalType; - } - - @Override - public String toString() { - return getAuthBlockType(); - - } - } - - // process context parameters - public static final String PROCESSCONTEXT_USERCONSENT_NEEDED = "userConsentNeeded"; - public static final String PROCESSCONTEXT_AUTHPROCESSSELECTION_DONE = "authProcSelectDone"; - public static final String PROCESSCONTEXT_SWITCH_LANGUAGE = "changeLanguage"; - public static final String PROCESSCONTEXT_IFRAME_PARENT_NEEDED = "iframeParentNeeded"; - - public static final String PROCESSCONTEXT_WAS_EID_PROCESS = "wasEidProcess"; - -} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/IAhAuthProcessData.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/IAhAuthProcessData.java deleted file mode 100644 index 47d3d37c..00000000 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/IAhAuthProcessData.java +++ /dev/null @@ -1,190 +0,0 @@ -package at.asitplus.eidas.specific.modules.auth.eidas.v2.idaustriaclient; - -import java.security.cert.X509Certificate; - -import at.gv.egiz.eaaf.core.api.idp.auth.data.IAuthProcessDataContainer; - -public interface IAhAuthProcessData extends IAuthProcessDataContainer { - - /** - * Get the certificate that was used to sign the Consent. - * - * @return {@link X509Certificate} - */ - X509Certificate getSignerCertificate(); - - /** - * Get the certificate that was used to sign the Consent. - * - * @return Serialized certificate - */ - byte[] getEncodedSignerCertificate(); - - /** - * Set the certificate that was used to sign the Consent. - * - * @param signerCertificate Signer certificate of the user - */ - void setSignerCertificate(X509Certificate signerCertificate); - - - /** - * Get URL to VDA that was used for authentication. - * - * @return - */ - String getVdaUrl(); - - /** - * Set URL to VDA that was used for authentication. - * - * @param vdaUrl URL to VDA that was used for authentication - */ - void setVdaUrl(String vdaUrl); - - /** - * Get the reference-value that used to interact with MIS service. - * - * @return - */ - String getMandateReferenceValue(); - - /** - * Set the reference-value that used to interact with MIS service. - * - * @param refValue Mandate reference value - */ - void setMandateReferenceValue(String refValue); - - /** - * Get the qcBind of the user that was received by VDA or other storage during authentication. - * - * @return - */ - String getQcBind(); - - /** - * Set the qcBind of the user that was received by VDA or other storage during authentication. - * - * @param qcBind raw qcBind data-structure (serialized JSON) - */ - void setQcBind(String qcBind); - - /** - * Get the vSZ of the user. - * - * @return - */ - String getVsz(); - - /** - * Set the vSZ of the user. - * - * @param vsz user's encrypted baseId - */ - void setVsz(String vsz); - - /** - * Get the signed AuthBlock of the user. - * - * @return - */ - byte[] getSignedAuthBlock(); - - /** - * Set the signed AuthBlock of the user. - * - * @param authBlock raw signed consent - */ - void setSignedAuthBlock(byte[] authBlock); - - /** - * Get a textual type identifier of the AuthBlock. - * - * @return AuthBlock type - */ - AuthHandlerConstants.AuthBlockType getSignedAuthBlockType(); - - /** - * Set a textual identifier for the type of the AuthBlock. - * - * @param authBlockType AuthBlock type - */ - void setSignedAuthBlockType(final AuthHandlerConstants.AuthBlockType authBlockType); - - /** - * Get the selected mandate of the user that was issued by MIS. - * - * @return - */ - ISignedMandate getMandateDate(); - - /** - * Set the selected mandate of the user that is issued by MIS. - * - * @param signedMandate Raw mandate structure for E-ID backend - */ - void setMandateDate(ISignedMandate signedMandate); - - - /** - * Get bPK for this entity.
- * THIS bPK is only for AuthHandler internal usage - * - * @return bPK, or null if no bPK is set - */ - String getInternalBpk(); - - /** - * Get bPK type for this entity.
- * THIS bPK is only for AuthHandler internal usage - * - * @return bPKType, or null if no bPKType is set - */ - String getInternalBpkType(); - - /** - * Set the bPK for INTERNAL USAGE of the current entity. - * - * @param bpk bPK for internal usage - */ - void setInternalBpk(String bpk); - - /** - * Set the bPK for INTERNAL USAGE of the current entity. - * - * @param bpkType bPK for internal usage - */ - void setInternalBpkType(String bpkType); - - - /** - * Indicate if the current process uses ELGA mandates. - * - * @return true if ELGA mandates are used, otherwise false - */ - boolean isElgaMandateProcess(); - - /** - * Set flag if the current process is an ELGA mandate process. - * - * @param flag true if it is an ELGA mandate-process, otherwise false - */ - void setElgaMandateProcess(boolean flag); - - - /** - * Indicate if the current process was authenticated by a VDA. - * - * @return true if the current process was authenticated by VDA, otherwise false - */ - boolean isVdaAuthentication(); - - /** - * Set flag that indicates if the current process was authenticated by a VDA. - * - * @param flag true in case of VDA authentication, otherwise false - */ - void setVdaAuthentication(boolean flag); - -} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/IAhSpConfiguration.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/IAhSpConfiguration.java deleted file mode 100644 index 081b215a..00000000 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/IAhSpConfiguration.java +++ /dev/null @@ -1,151 +0,0 @@ -package at.asitplus.eidas.specific.modules.auth.eidas.v2.idaustriaclient; - -import java.util.List; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import at.gv.egiz.eaaf.core.api.idp.ISpConfiguration; -import at.gv.egiz.eaaf.core.impl.data.Pair; - -public interface IAhSpConfiguration extends ISpConfiguration { - - - /** - * Flag if this Service Provider is enabled. - * - * @return true if the SP is enabled, otherwise false - */ - boolean isEnabled(); - - /** - * Get unique identifier that is used in Application-Register from BM.I. - * - *

If no BM.I specific identifier is available then this method returns - * the same identifier as getUniqueIdentifier()

- * - * @return unique identifier from BM.I AppReg, or generic uniqueId of no specific exists - */ - String getUniqueApplicationRegisterIdentifier(); - - /** - * Flag that marks this Service-Provider as public or private. - * - *

Default: If it is not set or has an unknown value, its private by default

- * - * @return true if it is from public, otherwise false - */ - boolean isPublicServiceProvider(); - - /** - * Enable test identities for this Service Provider. - * - * @return true if test identities are allowed, otherwise false - */ - boolean isTestCredentialEnabled(); - - /** - * Get a List of OID's that refine the set of allowed test identities. - * - * @return @link {@link List} of test-identity OID's - */ - @Nullable - List getTestCredentialOids(); - - - /** - * Get a List of unique attribute URI's that are required by this SP. - * - * @return {@link List} of attribute URI's / parameter {@link Pair}s - */ - List> getRequiredAttributes(); - - - /** - * Get the CountryCode for this service.
- *
- * Default: AT - * - * @return - */ - String getCountryCode(); - - /** - * Set the CountryCode for this service. If not countryCode is set, AT is used as default. - * - * @param cc Service-Provider country-code - */ - void setCountryCode(String cc); - - /** - * Enable mandates for this service provider. - * - * @return true if mandates are enabled, otherwise false - */ - boolean isMandateEnabled(); - - /** - * Enables multi-mandates for this service-provider. - * - * @return true if multi-mandates are enabled, otherwise false - */ - boolean isMultiMandateEnabled(); - - /** - * Only mandates are allowed for this service provider. - * - * @return true if only mandates are allowed, otherwise false - */ - boolean isOnlyMandateEnabled(); - - /** - * Get a {@link List} of mandate profiles that are supported by this Service provider. - * - * @return - */ - @Nonnull List getMandateProfiles(); - - - /** - * eIDAS authentication allowed flag. - * - * @return true if eIDAS authentication is enabled, otherwise false - */ - boolean isEidasEnabled(); - - /** - * Get a List of targets for additional bPKs that are required by this service provider. - * - * @return List of prefixed bPK targets - */ - @Nonnull List getAdditionalBpkTargets(); - - /** - * Get a list of foreign bPK targets that are required by this service provider. - * - * @return List of pairs with prefixed bPK targets as first element and VKZ as second element - */ - @Nonnull List> getAdditionalForeignBpkTargets(); - - /** - * Flag that indicates that service-provider as restricted or unrestricted. - * - *

A restricted service-provider can only used by test-identities that contains a - * valid application-restriction in User-Certificate Pinning

- * - *

Default: true

- * - * @return true if it is restricted, otherwise false - */ - boolean isRestrictedServiceProvider(); - - - /** - * Defines the time in minutes how long the last VDA registration h@Override - ave passed as maximum. - * - * @return time in minutes - */ - long lastVdaAuthenticationDelay(); - -} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/IRawMandateDao.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/IRawMandateDao.java deleted file mode 100644 index 7e3b2aa1..00000000 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/IRawMandateDao.java +++ /dev/null @@ -1,32 +0,0 @@ -package at.asitplus.eidas.specific.modules.auth.eidas.v2.idaustriaclient; - -import java.io.Serializable; -import java.util.Date; - -public interface IRawMandateDao extends Serializable { - - boolean isNaturalPerson(); - - boolean isProfRepresentation(); - - String getIdentifier(); - - String getIdentifierType(); - - String getGivenName(); - - String getFamilyName(); - - Date getDateOfBirth(); - - String getCommonName(); - - String getMandateTypeOid(); - - String getMandateAnnotation(); - - String getMandateId(); - - String getMandateContent(); - -} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/ISignedMandate.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/ISignedMandate.java deleted file mode 100644 index edd167fb..00000000 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/ISignedMandate.java +++ /dev/null @@ -1,19 +0,0 @@ -package at.asitplus.eidas.specific.modules.auth.eidas.v2.idaustriaclient; - -public interface ISignedMandate extends IRawMandateDao { - - /** - * Get the full signed mandate issued by the MIS component. - * - * @return serialized JWS that contains the mandate - */ - String getSignedMandate(); - - /** - * Get formated date-of-birth. - * - * @return date-of-birth as 'yyyy-MM-dd' - */ - String getDateOfBirthFormated(); - -} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/IdAustriaClientAuthConstants.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/IdAustriaClientAuthConstants.java index 7d8b9dc8..1a590aa1 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/IdAustriaClientAuthConstants.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/IdAustriaClientAuthConstants.java @@ -58,6 +58,7 @@ public class IdAustriaClientAuthConstants { public static final String CONFIG_PROPS_REQUIRED_LOA = CONFIG_PROPS_PREFIX + "required.loa"; public static final String CONFIG_PROPS_NODE_ENTITYID = CONFIG_PROPS_PREFIX + "node.entityId"; + public static final String CONFIG_PROPS_SP_ENTITYID = CONFIG_PROPS_PREFIX + "sp.entityId"; public static final String CONFIG_PROPS_NODE_METADATAURL = CONFIG_PROPS_PREFIX + "node.metadataUrl"; public static final String CONFIG_PROPS_NODE_TRUSTPROFILEID = CONFIG_PROPS_PREFIX + "node.trustprofileID"; @@ -77,55 +78,9 @@ public class IdAustriaClientAuthConstants { public static final String CONFIG_PROPS_APPSPECIFIC_EIDAS_NODE_URL = "auth.eidas.node.entityId"; - public static final String CONFIG_PROPS_SEMPER_MANDATES_ACTIVE = CONFIG_PROPS_PREFIX - + "semper.mandates.active"; - public static final String CONFIG_PROPS_SEMPER_MANDATES_MS_PROXY_LIST = CONFIG_PROPS_PREFIX - + "semper.msproxy.list"; public static final String CONFIG_DEFAULT_LOA_EIDAS_LEVEL = EaafConstants.EIDAS_LOA_HIGH; - @Deprecated - public static final List> DEFAULT_REQUIRED_PVP_ATTRIBUTES_WITHOUT_EID = - Collections.unmodifiableList(new ArrayList>() { - private static final long serialVersionUID = 1L; - { - // add PVP Version attribute - add(Triple.newInstance(PvpAttributeDefinitions.PVP_VERSION_NAME, - PvpAttributeDefinitions.PVP_VERSION_FRIENDLY_NAME, true)); - - // request entity information - add(Triple.newInstance(PvpAttributeDefinitions.EID_SECTOR_FOR_IDENTIFIER_NAME, - PvpAttributeDefinitions.EID_SECTOR_FOR_IDENTIFIER_FRIENDLY_NAME, false)); - add(Triple.newInstance(PvpAttributeDefinitions.EID_CITIZEN_EIDAS_QAA_LEVEL_NAME, - PvpAttributeDefinitions.EID_CITIZEN_EIDAS_QAA_LEVEL_FRIENDLY_NAME, true)); - add(Triple.newInstance(PvpAttributeDefinitions.EID_ISSUING_NATION_NAME, - PvpAttributeDefinitions.EID_ISSUING_NATION_FRIENDLY_NAME, true)); - - // entity eID information - add(Triple.newInstance(AhExtendedPvpAttributeDefinitions.EID_EIDBIND_NAME, - AhExtendedPvpAttributeDefinitions.EID_EIDBIND_FRIENDLY_NAME, false)); - add(Triple.newInstance(AhExtendedPvpAttributeDefinitions.EID_AUTHBLOCK_SIGNED_NAME, - AhExtendedPvpAttributeDefinitions.EID_AUTHBLOCK_SIGNED_FRIENDLY_NAME, false)); - - // Deprecated information - add(Triple.newInstance(PvpAttributeDefinitions.GIVEN_NAME_NAME, - PvpAttributeDefinitions.GIVEN_NAME_FRIENDLY_NAME, false)); - add(Triple.newInstance(PvpAttributeDefinitions.PRINCIPAL_NAME_NAME, - PvpAttributeDefinitions.PRINCIPAL_NAME_FRIENDLY_NAME, false)); - add(Triple.newInstance(PvpAttributeDefinitions.BIRTHDATE_NAME, - PvpAttributeDefinitions.BIRTHDATE_FRIENDLY_NAME, false)); - add(Triple.newInstance(PvpAttributeDefinitions.BPK_NAME, PvpAttributeDefinitions.BPK_FRIENDLY_NAME, - false)); - add(Triple.newInstance(PvpAttributeDefinitions.EID_IDENTITY_LINK_NAME, - PvpAttributeDefinitions.EID_IDENTITY_LINK_FRIENDLY_NAME, false)); - - //request pII transactionId from MS-Connector - add(Triple.newInstance(ExtendedPvpAttributeDefinitions.EID_PII_TRANSACTION_ID_NAME, - ExtendedPvpAttributeDefinitions.EID_PII_TRANSACTION_ID_FRIENDLY_NAME, false)); - - } - }); - public static final List> DEFAULT_REQUIRED_PVP_ATTRIBUTES = Collections.unmodifiableList(new ArrayList>() { private static final long serialVersionUID = 1L; @@ -141,10 +96,10 @@ public class IdAustriaClientAuthConstants { PvpAttributeDefinitions.EID_ISSUING_NATION_FRIENDLY_NAME, true)); // entity eID information - add(Triple.newInstance(AhExtendedPvpAttributeDefinitions.EID_EIDBIND_NAME, - AhExtendedPvpAttributeDefinitions.EID_EIDBIND_FRIENDLY_NAME, true)); - add(Triple.newInstance(AhExtendedPvpAttributeDefinitions.EID_AUTHBLOCK_SIGNED_NAME, - AhExtendedPvpAttributeDefinitions.EID_AUTHBLOCK_SIGNED_FRIENDLY_NAME, true)); + add(Triple.newInstance(ExtendedPvpAttributeDefinitions.EID_EIDBIND_NAME, + ExtendedPvpAttributeDefinitions.EID_EIDBIND_FRIENDLY_NAME, true)); + add(Triple.newInstance(ExtendedPvpAttributeDefinitions.EID_AUTHBLOCK_SIGNED_NAME, + ExtendedPvpAttributeDefinitions.EID_AUTHBLOCK_SIGNED_FRIENDLY_NAME, true)); //request pII transactionId from MS-Connector add(Triple.newInstance(ExtendedPvpAttributeDefinitions.EID_PII_TRANSACTION_ID_NAME, diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/IdAustriaClientAuthMetadataConfiguration.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/IdAustriaClientAuthMetadataConfiguration.java index 93aefb42..4e7f86f1 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/IdAustriaClientAuthMetadataConfiguration.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/IdAustriaClientAuthMetadataConfiguration.java @@ -356,18 +356,12 @@ public class IdAustriaClientAuthMetadataConfiguration implements IPvpMetadataBui public Collection getSpRequiredAttributes() { final Map requestedAttributes = new HashMap<>(); - if (pvpConfiguration.getBasicConfiguration().getBasicConfigurationBoolean( - AuthHandlerConstants.PROP_CONFIG_LEGACY_ALLOW, false)) { - log.trace("Build required attributes for legacy operaton ... "); - injectDefinedAttributes(requestedAttributes, - IdAustriaClientAuthConstants.DEFAULT_REQUIRED_PVP_ATTRIBUTES_WITHOUT_EID); - } else { - log.trace("Build required attributes for E-ID operaton ... "); - injectDefinedAttributes(requestedAttributes, - IdAustriaClientAuthConstants.DEFAULT_REQUIRED_PVP_ATTRIBUTES); + log.trace("Build required attributes for E-ID operaton ... "); + injectDefinedAttributes(requestedAttributes, + IdAustriaClientAuthConstants.DEFAULT_REQUIRED_PVP_ATTRIBUTES); + - } if (additionalAttributes != null) { log.trace("Add additional PVP attributes into metadata ... "); @@ -376,9 +370,7 @@ public class IdAustriaClientAuthMetadataConfiguration implements IPvpMetadataBui log.debug("Attribute " + el.getName() + " is already added by default configuration. Overwrite it by user configuration"); } - requestedAttributes.put(el.getName(), el); - } } diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/MisException.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/MisException.java deleted file mode 100644 index 71826d23..00000000 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/idaustriaclient/MisException.java +++ /dev/null @@ -1,17 +0,0 @@ -package at.asitplus.eidas.specific.modules.auth.eidas.v2.idaustriaclient; - -import at.gv.egiz.eaaf.core.exceptions.EaafException; - -public class MisException extends EaafException { - - private static final long serialVersionUID = 1L; - - public MisException(final String errorId, final Object[] params) { - super(errorId, params); - } - - public MisException(final String errorId, final Object[] params, final Throwable e) { - super(errorId, params, e); - } - -} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/GenerateMobilePhoneSignatureRequestTask.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/GenerateMobilePhoneSignatureRequestTask.java index aa8deb2b..546a2039 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/GenerateMobilePhoneSignatureRequestTask.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/GenerateMobilePhoneSignatureRequestTask.java @@ -27,7 +27,6 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.idaustriaclient.IdAustri import at.asitplus.eidas.specific.modules.auth.eidas.v2.idaustriaclient.IdAustriaClientAuthCredentialProvider; import at.asitplus.eidas.specific.modules.auth.eidas.v2.idaustriaclient.IdAustriaClientAuthMetadataProvider; import at.asitplus.eidas.specific.modules.auth.eidas.v2.idaustriaclient.IdAustriaClientAuthRequestBuilderConfiguration; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.idaustriaclient.IAhSpConfiguration; import at.gv.egiz.eaaf.core.api.IRequest; import at.gv.egiz.eaaf.core.api.data.ExtendedPvpAttributeDefinitions; import at.gv.egiz.eaaf.core.api.data.PvpAttributeDefinitions; @@ -117,9 +116,8 @@ public class GenerateMobilePhoneSignatureRequestTask extends AbstractAuthServlet IdAustriaClientAuthConstants.CONFIG_PROPS_REQUIRED_LOA, IdAustriaClientAuthConstants.CONFIG_DEFAULT_LOA_EIDAS_LEVEL)); - authnReqConfig.setScopeRequesterId( - pendingReq.getServiceProviderConfiguration(IAhSpConfiguration.class) - .getUniqueApplicationRegisterIdentifier()); + authnReqConfig.setScopeRequesterId(authConfig.getBasicConfiguration( + IdAustriaClientAuthConstants.CONFIG_PROPS_SP_ENTITYID)); authnReqConfig.setProviderName(pendingReq.getServiceProviderConfiguration().getFriendlyName()); authnReqConfig.setRequestedAttributes(buildRequestedAttributes(pendingReq)); diff --git a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveMobilePhoneSignatureResponseAndSearchInRegistersTask.java b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveMobilePhoneSignatureResponseAndSearchInRegistersTask.java index 9e6aa7cc..9d30b581 100644 --- a/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveMobilePhoneSignatureResponseAndSearchInRegistersTask.java +++ b/eidas_modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/ReceiveMobilePhoneSignatureResponseAndSearchInRegistersTask.java @@ -29,20 +29,15 @@ import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.RegisterResult; import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.SimpleEidasData; import at.asitplus.eidas.specific.modules.auth.eidas.v2.ernp.IErnpClient; import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.ManualFixNecessaryException; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.idaustriaclient.AhAuthProcessDataWrapper; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.idaustriaclient.AuthHandlerConstants; import at.asitplus.eidas.specific.modules.auth.eidas.v2.idaustriaclient.EidasAuthEventConstants; import at.asitplus.eidas.specific.modules.auth.eidas.v2.idaustriaclient.IdAustriaClientAuthConstants; import at.asitplus.eidas.specific.modules.auth.eidas.v2.idaustriaclient.IdAustriaClientAuthCredentialProvider; import at.asitplus.eidas.specific.modules.auth.eidas.v2.idaustriaclient.IdAustriaClientAuthMetadataProvider; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.idaustriaclient.MisException; import at.asitplus.eidas.specific.modules.auth.eidas.v2.utils.Utils; import at.asitplus.eidas.specific.modules.auth.eidas.v2.zmr.IZmrClient; import at.gv.egiz.eaaf.core.api.data.ExtendedPvpAttributeDefinitions; -import at.gv.egiz.eaaf.core.api.data.PvpAttributeDefinitions; import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext; import at.gv.egiz.eaaf.core.exceptions.EaafBuilderException; -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.idp.auth.data.AuthProcessDataWrapper; @@ -78,10 +73,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.xml.transform.TransformerException; import java.io.IOException; -import java.util.Arrays; -import java.util.Base64; import java.util.List; -import java.util.Set; /** * Task that searches ErnB and ZMR before adding person to SZR. @@ -211,10 +203,10 @@ public class ReceiveMobilePhoneSignatureResponseAndSearchInRegistersTask extends requestStoreage.storePendingRequest(pendingReq); //set E-ID process flag to execution context - final AhAuthProcessDataWrapper session = pendingReq.getSessionData( - AhAuthProcessDataWrapper.class); - executionContext.put(AuthHandlerConstants.PROCESSCONTEXT_WAS_EID_PROCESS, session.isEidProcess()); - executionContext.put(AuthHandlerConstants.HTTP_PARAM_USE_MANDATES, session.isMandateUsed()); + // final AhAuthProcessDataWrapper session = pendingReq.getSessionData( + // AhAuthProcessDataWrapper.class); + // executionContext.put(AuthHandlerConstants.PROCESSCONTEXT_WAS_EID_PROCESS, session.isEidProcess()); + // executionContext.put(AuthHandlerConstants.HTTP_PARAM_USE_MANDATES, session.isMandateUsed()); log.info("Receive a valid assertion from IDP " + msg.getEntityID()); @@ -337,15 +329,6 @@ public class ReceiveMobilePhoneSignatureResponseAndSearchInRegistersTask extends throws EaafBuilderException, ConfigurationException { List requiredEidasNodeAttributes = IdAustriaClientAuthConstants.DEFAULT_REQUIRED_PVP_ATTRIBUTE_NAMES; - if (authConfig.getBasicConfigurationBoolean( - AuthHandlerConstants.PROP_CONFIG_LEGACY_ALLOW, false)) { - log.trace("Build required attributes for legacy operaton ... "); - requiredEidasNodeAttributes = Arrays.asList( - PvpAttributeDefinitions.PVP_VERSION_NAME, - PvpAttributeDefinitions.EID_CITIZEN_EIDAS_QAA_LEVEL_NAME, - PvpAttributeDefinitions.EID_ISSUING_NATION_NAME); - - } try { // check if all attributes are include @@ -359,14 +342,14 @@ public class ReceiveMobilePhoneSignatureResponseAndSearchInRegistersTask extends } // copy attributes into MOASession - final AhAuthProcessDataWrapper session = pendingReq.getSessionData( - AhAuthProcessDataWrapper.class); - final Set includedAttrNames = extractor.getAllIncludeAttributeNames(); - for (final String attrName : includedAttrNames) { - injectAuthInfosIntoSession(session, attrName, - extractor.getSingleAttributeValue(attrName)); - - } + // final AhAuthProcessDataWrapper session = pendingReq.getSessionData( + // AhAuthProcessDataWrapper.class); + // final Set includedAttrNames = extractor.getAllIncludeAttributeNames(); + // for (final String attrName : includedAttrNames) { + // injectAuthInfosIntoSession(session, attrName, + // extractor.getSingleAttributeValue(attrName)); + // + // } //set piiTransactionId from eIDAS Connector String piiTransactionId = extractor.getSingleAttributeValue( @@ -381,58 +364,58 @@ public class ReceiveMobilePhoneSignatureResponseAndSearchInRegistersTask extends } // set foreigner flag - session.setForeigner(true); + // session.setForeigner(true); // set IssuerInstant from Assertion - session.setIssueInstant(extractor.getAssertionIssuingDate()); + // session.setIssueInstant(extractor.getAssertionIssuingDate()); // set CCE URL - if (extractor.getFullAssertion().getIssuer() != null - && StringUtils.isNotEmpty(extractor.getFullAssertion().getIssuer().getValue())) { - session.setVdaUrl(extractor.getFullAssertion().getIssuer().getValue()); + //if (extractor.getFullAssertion().getIssuer() != null + //&& StringUtils.isNotEmpty(extractor.getFullAssertion().getIssuer().getValue())) { + // session.setVdaUrl(extractor.getFullAssertion().getIssuer().getValue()); - } else { - session.setVdaUrl("eIDAS_Authentication"); + //} //else { + // session.setVdaUrl("eIDAS_Authentication"); - } + //} - } catch (final EaafStorageException | MisException | AssertionValidationExeption | IOException e) { + } catch (final AssertionValidationExeption e) { throw new EaafBuilderException(ERROR_PVP_06, null, e.getMessage(), e); } } - private void injectAuthInfosIntoSession(AhAuthProcessDataWrapper session, String attrName, String attrValue) - throws EaafStorageException, MisException, IOException { - log.trace("Inject attribute: {} with value: {} into AuthSession", attrName, attrValue); - log.debug("Inject attribute: {} into AuthSession", attrName); - - if (ExtendedPvpAttributeDefinitions.EID_EIDBIND_NAME.equals(attrName)) { - log.debug("Find eidasBind attribute. Switching to E-ID mode ... "); - session.setEidProcess(true); - session.setQcBind(attrValue); - // session.setVsz(extractVszFromEidasBind(attrValue)); - //T - - } else if (ExtendedPvpAttributeDefinitions.EID_AUTHBLOCK_SIGNED_NAME.equals(attrName)) { - session.setSignedAuthBlock(Base64.getDecoder().decode(attrValue)); - session.setSignedAuthBlockType(AuthHandlerConstants.AuthBlockType.JWS); - - } else if (PvpAttributeDefinitions.EID_CITIZEN_EIDAS_QAA_LEVEL_NAME.equals(attrName)) { - session.setQaaLevel(attrValue); - - // } else if (ExtendedPvpAttributeDefinitions.EID_MIS_MANDATE_NAME.equals(attrName) - // && authConfig.getBasicConfigurationBoolean( - // IdAustriaClientAuthConstants.CONFIG_PROPS_SEMPER_MANDATES_ACTIVE, false)) { - // session.setMandateDate(new SignedMandateDao(attrValue)); - // session.setUseMandates(true); - // - } else { - session.setGenericDataToSession(attrName, attrValue); - - } - - } + // private void injectAuthInfosIntoSession(AhAuthProcessDataWrapper session, String attrName, String attrValue) + // throws EaafStorageException, MisException, IOException { + // log.trace("Inject attribute: {} with value: {} into AuthSession", attrName, attrValue); + // log.debug("Inject attribute: {} into AuthSession", attrName); + // + // if (ExtendedPvpAttributeDefinitions.EID_EIDBIND_NAME.equals(attrName)) { + // log.debug("Find eidasBind attribute. Switching to E-ID mode ... "); + // session.setEidProcess(true); + // session.setQcBind(attrValue); + // // session.setVsz(extractVszFromEidasBind(attrValue)); + // //T + // + // } else if (ExtendedPvpAttributeDefinitions.EID_AUTHBLOCK_SIGNED_NAME.equals(attrName)) { + // session.setSignedAuthBlock(Base64.getDecoder().decode(attrValue)); + // session.setSignedAuthBlockType(AuthHandlerConstants.AuthBlockType.JWS); + // + // } else if (PvpAttributeDefinitions.EID_CITIZEN_EIDAS_QAA_LEVEL_NAME.equals(attrName)) { + // session.setQaaLevel(attrValue); + // + // // } else if (ExtendedPvpAttributeDefinitions.EID_MIS_MANDATE_NAME.equals(attrName) + // // && authConfig.getBasicConfigurationBoolean( + // // IdAustriaClientAuthConstants.CONFIG_PROPS_SEMPER_MANDATES_ACTIVE, false)) { + // // session.setMandateDate(new SignedMandateDao(attrValue)); + // // session.setUseMandates(true); + // // + // } else { + // session.setGenericDataToSession(attrName, attrValue); + // + // } + // + // } private MergedRegisterSearchResult searchInZmrAndErnp(String bpkzp) { diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskFirstTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskFirstTest.java deleted file mode 100644 index f2dc6d55..00000000 --- a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskFirstTest.java +++ /dev/null @@ -1,463 +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.test.tasks; - -import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.RegisterResult; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.ernp.IErnpClient; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.ManualFixNecessaryException; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.handler.DeSpecificDetailSearchProcessor; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.handler.ItSpecificDetailSearchProcessor; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.InitialSearchTask; -import at.asitplus.eidas.specific.modules.auth.eidas.v2.zmr.IZmrClient; -import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext; -import at.gv.egiz.eaaf.core.exceptions.EaafStorageException; -import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException; -import at.gv.egiz.eaaf.core.impl.idp.auth.data.AuthProcessDataWrapper; -import at.gv.egiz.eaaf.core.impl.idp.module.test.TestRequestImpl; -import at.gv.egiz.eaaf.core.impl.idp.process.ExecutionContextImpl; -import eu.eidas.auth.commons.attribute.AttributeDefinition; -import eu.eidas.auth.commons.attribute.ImmutableAttributeMap; -import eu.eidas.auth.commons.attribute.PersonType; -import eu.eidas.auth.commons.protocol.impl.AuthenticationResponse; -import lombok.val; -import org.apache.commons.lang3.RandomStringUtils; -import org.jetbrains.annotations.NotNull; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; -import org.springframework.mock.web.MockHttpServletRequest; -import org.springframework.mock.web.MockHttpServletResponse; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.test.annotation.DirtiesContext.ClassMode; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.web.context.request.RequestContextHolder; -import org.springframework.web.context.request.ServletRequestAttributes; - -import javax.xml.namespace.QName; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Random; - -import static org.junit.Assert.assertThrows; - -@RunWith(SpringJUnit4ClassRunner.class) -@ContextConfiguration(locations = { - "/SpringTest-context_tasks_test.xml", - "/SpringTest-context_basic_mapConfig.xml" -}) -@DirtiesContext(classMode = ClassMode.BEFORE_CLASS) -public class InitialSearchTaskFirstTest { - - private static final String DE_ST = "de/st/"; - private static final String IT_ST = "it/st/"; - - private InitialSearchTask task; - @Mock - private IZmrClient zmrClient; - @Mock - private IErnpClient ernpClient; - - final ExecutionContext executionContext = new ExecutionContextImpl(); - private TestRequestImpl pendingReq; - private final String randomBpk = RandomStringUtils.randomNumeric(6); - private final String randomIdentifier = RandomStringUtils.randomNumeric(10); - private final String randomPseudonym = DE_ST + randomIdentifier; - private final String randomFamilyName = RandomStringUtils.randomAlphabetic(10); - private final String randomGivenName = RandomStringUtils.randomAlphabetic(10); - private final String randomPlaceOfBirth = RandomStringUtils.randomAlphabetic(10); - private final String randomBirthName = RandomStringUtils.randomAlphabetic(10); - private final String randomDate = "2011-01-" + (10 + new Random().nextInt(18)); - -// /** -// * jUnit class initializer. -// * -// * @throws IOException In case of an error -// */ -// @BeforeClass -// public static void classInitializer() throws IOException { -// final String current = new java.io.File(".").toURI().toString(); -// System.setProperty("eidas.ms.configuration", current -// + "src/test/resources/config/junit_config_1.properties"); -// } - - /** - * jUnit test set-up. - */ - @Before - public void setUp() throws URISyntaxException, EaafStorageException { - MockitoAnnotations.initMocks(this); - task = new InitialSearchTask(new ArrayList<>(), ernpClient, zmrClient); - - MockHttpServletRequest httpReq = new MockHttpServletRequest("POST", "https://localhost/authhandler"); - MockHttpServletResponse httpResp = new MockHttpServletResponse(); - RequestContextHolder.resetRequestAttributes(); - RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(httpReq, httpResp)); - - final AuthenticationResponse response = buildDummyAuthResponseRandomPerson(); - pendingReq = new TestRequestImpl(); - pendingReq.getSessionData(AuthProcessDataWrapper.class) - .setGenericDataToSession(Constants.DATA_FULL_EIDAS_RESPONSE, response); - } - - /** - * One match, but register update needed - */ - @Test - @DirtiesContext - public void testNode100_UserIdentifiedUpdateNecessary_a() throws Exception { - String newFirstName = RandomStringUtils.randomAlphabetic(10); - Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.singletonList( - new RegisterResult(randomBpk, randomIdentifier, newFirstName, randomFamilyName, randomDate))); - Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList()); - - task.execute(pendingReq, executionContext); - String bPk = (String) - pendingReq.getSessionData(AuthProcessDataWrapper.class) - .getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK); - - Assert.assertEquals("Wrong bpk", bPk, randomBpk); - } - - /** - * One match, but register update needed - */ - @Test - @DirtiesContext - public void testNode100_UserIdentifiedUpdateNecessary_b() throws TaskExecutionException { - Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList()); - String newRandomGivenName = RandomStringUtils.randomAlphabetic(10); - Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.singletonList( - new RegisterResult(randomBpk, randomIdentifier, newRandomGivenName, randomFamilyName, randomDate))); - - task.execute(pendingReq, executionContext); - String bPk = (String) - pendingReq.getSessionData(AuthProcessDataWrapper.class) - .getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK); - - Assert.assertEquals("Wrong bpk", bPk, randomBpk); - } - - /** - * Two matches found in ZMR - */ - @Test - @DirtiesContext - public void testNode101_ManualFixNecessary_a() { - ArrayList zmrResult = new ArrayList<>(); - zmrResult.add(new RegisterResult(randomBpk, randomIdentifier, randomGivenName, randomFamilyName, randomDate)); - String newRandomGivenName = randomGivenName + RandomStringUtils.randomAlphabetic(2); - zmrResult.add(new RegisterResult(randomBpk, randomIdentifier, newRandomGivenName, randomFamilyName, randomDate)); - Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(zmrResult); - Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList()); - - TaskExecutionException exception = assertThrows(TaskExecutionException.class, - () -> task.execute(pendingReq, executionContext)); - - Throwable origE = exception.getOriginalException(); - Assert.assertTrue("Wrong exception", (origE.getCause() instanceof ManualFixNecessaryException)); - } - - - /** - * Two matches found in ErnP - */ - @Test - @DirtiesContext - public void testNode101_ManualFixNecessary_b() { - Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList()); - ArrayList ernpResult = new ArrayList<>(); - ernpResult.add(new RegisterResult(randomBpk, randomPseudonym, randomGivenName, randomFamilyName, randomDate)); - String newRandomGivenName = randomGivenName + RandomStringUtils.randomAlphabetic(2); - ernpResult.add( - new RegisterResult(randomBpk, randomIdentifier, newRandomGivenName, randomFamilyName, randomDate)); - Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(ernpResult); - - TaskExecutionException exception = assertThrows(TaskExecutionException.class, - () -> task.execute(pendingReq, executionContext)); - - Throwable origE = exception.getOriginalException(); - Assert.assertTrue("Wrong exception", (origE.getCause() instanceof ManualFixNecessaryException)); - } - - /** - * One match, no register update needed - */ - @Test - @DirtiesContext - public void testNode102_UserIdentified_a() throws Exception { - Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList()); - Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.singletonList( - new RegisterResult(randomBpk, randomIdentifier, randomGivenName, randomFamilyName, randomDate))); - - task.execute(pendingReq, executionContext); - String bPk = (String) - pendingReq.getSessionData(AuthProcessDataWrapper.class) - .getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK); - Assert.assertEquals("Wrong bpk", bPk, randomBpk); - } - - /** - * One match, no register update needed - */ - @Test - @DirtiesContext - public void testNode102_UserIdentified_b() throws Exception { - Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.singletonList( - new RegisterResult(randomBpk, randomIdentifier, randomGivenName, randomFamilyName, randomDate))); - Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList()); - - task.execute(pendingReq, executionContext); - - String bPk = (String) - pendingReq.getSessionData(AuthProcessDataWrapper.class) - .getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK); - Assert.assertEquals("Wrong bpk", bPk, randomBpk); - } - - /** - * One match found in ZMR and ErnP with detail search - */ - @Test - @DirtiesContext - public void testNode103_UserIdentified_IT() throws Exception { - String taxNumber = RandomStringUtils.randomNumeric(14); - final AuthenticationResponse response = buildDummyAuthResponseRandomPersonIT_Tax(taxNumber); - TestRequestImpl pendingReq1 = new TestRequestImpl(); - pendingReq1.getSessionData(AuthProcessDataWrapper.class) - .setGenericDataToSession(Constants.DATA_FULL_EIDAS_RESPONSE, response); - Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList()); - String newRandomIdentifier = randomIdentifier + RandomStringUtils.randomNumeric(2); - Mockito.when(zmrClient.searchItSpecific(taxNumber)).thenReturn(Collections.singletonList( - new RegisterResult(randomBpk, newRandomIdentifier, randomGivenName, randomFamilyName, - randomDate, null, null, taxNumber, null))); - Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList()); - task = new InitialSearchTask( - Collections.singletonList(new ItSpecificDetailSearchProcessor(ernpClient, zmrClient)), - ernpClient, zmrClient); - - task.execute(pendingReq1, executionContext); - - String bPk = (String) - pendingReq1.getSessionData(AuthProcessDataWrapper.class) - .getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK); - Assert.assertEquals("Wrong bpk", bPk, randomBpk); - } - - /** - * Multiple matches found in ZMR and ErnP with detail search - */ - @Test - @DirtiesContext - public void testNode103_UserIdentified_DE() throws Exception { - final AuthenticationResponse response = buildDummyAuthResponseDE(randomGivenName, randomFamilyName, - randomPseudonym, - randomDate, randomPlaceOfBirth, randomBirthName); - TestRequestImpl pendingReq1 = new TestRequestImpl(); - pendingReq1.getSessionData(AuthProcessDataWrapper.class) - .setGenericDataToSession(Constants.DATA_FULL_EIDAS_RESPONSE, response); - Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList()); - Mockito.when(zmrClient.searchDeSpecific(randomGivenName, randomFamilyName, randomDate, randomPlaceOfBirth, - randomBirthName)) - .thenReturn(Collections.singletonList(new RegisterResult(randomBpk, randomIdentifier, randomGivenName, - randomFamilyName, randomDate, randomPlaceOfBirth, randomBirthName, null, null))); - Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList()); - task = new InitialSearchTask( - Collections.singletonList(new DeSpecificDetailSearchProcessor(ernpClient, zmrClient)), - ernpClient, zmrClient); - - task.execute(pendingReq1, executionContext); - - String resultBpk = (String) - pendingReq1.getSessionData(AuthProcessDataWrapper.class) - .getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK); - Assert.assertEquals("Wrong bpk", resultBpk, randomBpk); - } - - /** - * Multiple matches found in ZMR and ErnP with detail search - */ - @Test - @DirtiesContext - public void testNode104_ManualFixNecessary_DE() throws Exception { - String newRandomPseudonym = randomPseudonym + RandomStringUtils.randomNumeric(2); - String newRandomBpk = randomBpk + RandomStringUtils.randomNumeric(6); - final AuthenticationResponse response = buildDummyAuthResponseDE(randomGivenName, randomFamilyName, - randomPseudonym, - randomDate, randomPlaceOfBirth, randomBirthName); - TestRequestImpl pendingReq1 = new TestRequestImpl(); - pendingReq1.getSessionData(AuthProcessDataWrapper.class) - .setGenericDataToSession(Constants.DATA_FULL_EIDAS_RESPONSE, response); - Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList()); - ArrayList zmrResultSpecific = new ArrayList<>(); - zmrResultSpecific.add( - new RegisterResult(randomBpk, randomIdentifier, randomGivenName, randomFamilyName, randomDate, - randomPlaceOfBirth, randomBirthName, null, null)); - zmrResultSpecific.add(new RegisterResult(newRandomBpk, newRandomPseudonym, randomGivenName, randomFamilyName, randomDate, - randomPlaceOfBirth, randomBirthName, null, null)); - Mockito.when(zmrClient.searchDeSpecific(randomGivenName, randomFamilyName, randomDate, randomPlaceOfBirth, - randomBirthName)).thenReturn(zmrResultSpecific); - Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList()); - task = new InitialSearchTask( - Collections.singletonList(new DeSpecificDetailSearchProcessor(ernpClient, zmrClient)), - ernpClient, zmrClient); - - TaskExecutionException exception = assertThrows(TaskExecutionException.class, - () -> task.execute(pendingReq1, executionContext)); - - Throwable origE = exception.getOriginalException(); - Assert.assertTrue("Wrong exception", (origE.getCause() instanceof ManualFixNecessaryException)); - } - - /** - * Multiple matches found in ZMR and ErnP with detail search - */ - @Test - @DirtiesContext - public void testNode104_ManualFixNecessary_IT() throws Exception { - String randomTaxNumber = RandomStringUtils.randomNumeric(14); - final AuthenticationResponse response = buildDummyAuthResponseRandomPersonIT_Tax(randomTaxNumber); - TestRequestImpl pendingReq1 = new TestRequestImpl(); - pendingReq1.getSessionData(AuthProcessDataWrapper.class) - .setGenericDataToSession(Constants.DATA_FULL_EIDAS_RESPONSE, response); - Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList()); - ArrayList zmrResultSpecific = new ArrayList<>(); - String randomPseudonym = IT_ST + randomIdentifier + "4"; - zmrResultSpecific.add(new RegisterResult(randomBpk, randomPseudonym, randomGivenName, - randomFamilyName, randomDate, null, null, randomTaxNumber, null)); - String newRandomPseudonym = IT_ST + randomIdentifier + "5"; - String newRandomBpk = RandomStringUtils.randomNumeric(6); - zmrResultSpecific.add(new RegisterResult(newRandomBpk, newRandomPseudonym, randomGivenName, - randomFamilyName, randomDate, null, null, randomTaxNumber, null)); - Mockito.when(zmrClient.searchItSpecific(randomTaxNumber)).thenReturn(zmrResultSpecific); - Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList()); - task = new InitialSearchTask( - Collections.singletonList(new ItSpecificDetailSearchProcessor(ernpClient, zmrClient)), - ernpClient, zmrClient); - - TaskExecutionException exception = assertThrows(TaskExecutionException.class, - () -> task.execute(pendingReq1, executionContext)); - - Throwable origE = exception.getOriginalException(); - Assert.assertTrue("Wrong exception", (origE.getCause() instanceof ManualFixNecessaryException)); - } - - /** - * NO match found in ZMR and ErnP with Initial search - */ - @Test - @DirtiesContext - public void testNode105_TemporaryEnd() throws TaskExecutionException { - Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList()); - Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList()); - - task.execute(pendingReq, executionContext); - - String bPk = (String) - pendingReq.getSessionData(AuthProcessDataWrapper.class) - .getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK); - Assert.assertEquals("Wrong bpk", "TODO-Temporary-Endnode-105", bPk); - } - - - @NotNull - private AuthenticationResponse buildDummyAuthResponseRandomPerson() throws URISyntaxException { - return buildDummyAuthResponse(randomGivenName, randomFamilyName, DE_ST + randomIdentifier, randomDate); - } - - private AuthenticationResponse buildDummyAuthResponseRandomPersonIT_Tax(String taxNumber) - throws URISyntaxException { - return buildDummyAuthResponse(randomGivenName, randomFamilyName, IT_ST + randomIdentifier, randomDate, - taxNumber, null, null); - } - - @NotNull - private AuthenticationResponse buildDummyAuthResponse(String givenName, String familyName, String identifier, - String dateOfBirth) throws URISyntaxException { - return buildDummyAuthResponse(givenName, familyName, identifier, dateOfBirth, null, null, null); - } - - @NotNull - private AuthenticationResponse buildDummyAuthResponseDE(String givenName, String familyName, String identifier, - String dateOfBirth, String placeOfBirth, - String birthName) throws URISyntaxException { - return buildDummyAuthResponse(givenName, familyName, identifier, dateOfBirth, null, placeOfBirth, birthName); - } - - @NotNull - private AuthenticationResponse buildDummyAuthResponse(String givenName, String familyName, String identifier, - String dateOfBirth, String taxNumber, String placeOfBirth, - String birthName) throws URISyntaxException { - ImmutableAttributeMap.Builder builder = ImmutableAttributeMap.builder() - .put(generateStringAttribute(Constants.eIDAS_ATTR_PERSONALIDENTIFIER, "ff", "af"), identifier) - .put(generateStringAttribute(Constants.eIDAS_ATTR_CURRENTFAMILYNAME, "fff", "aff"), familyName) - .put(generateStringAttribute(Constants.eIDAS_ATTR_CURRENTGIVENNAME, "ffff", "afff"), givenName) - .put(generateDateTimeAttribute(Constants.eIDAS_ATTR_DATEOFBIRTH, "fffff", "affff"), dateOfBirth); - if (taxNumber != null) { - builder.put(generateStringAttribute(Constants.eIDAS_ATTR_TAXREFERENCE, "ffffff", "afffff"), taxNumber); - } - if (birthName != null) { - builder.put(generateStringAttribute(Constants.eIDAS_ATTR_BIRTHNAME, "fffffff", "affffff"), birthName); - } - if (placeOfBirth != null) { - builder.put(generateStringAttribute(Constants.eIDAS_ATTR_PLACEOFBIRTH, "ffffffff", "afffffff"), - placeOfBirth); - } - final ImmutableAttributeMap attributeMap = builder.build(); - - val b = new AuthenticationResponse.Builder(); - return b.id("aasdf").issuer("asd").subject("asf").statusCode("200").inResponseTo("asdf").subjectNameIdFormat( - "afaf").attributes(attributeMap).build(); - } - - private AttributeDefinition generateStringAttribute(String friendlyName, String fragment, String prefix) - throws URISyntaxException { - return generateAttribute(friendlyName, fragment, prefix, "eu.eidas.auth.commons.attribute.impl" + - ".LiteralStringAttributeValueMarshaller"); - } - - private AttributeDefinition generateDateTimeAttribute(String friendlyName, String fragment, String prefix) - throws URISyntaxException { - return generateAttribute(friendlyName, fragment, prefix, "eu.eidas.auth.commons.attribute.impl" + - ".DateTimeAttributeValueMarshaller"); - } - - private AttributeDefinition generateAttribute(String friendlyName, String fragment, String prefix, - String marshaller) throws URISyntaxException { - return AttributeDefinition.builder() - .friendlyName(friendlyName).nameUri(new URI("ad", "sd", fragment)) - .personType(PersonType.LEGAL_PERSON).xmlType(new QName("http://saf", "as", prefix)) - .attributeValueMarshaller(marshaller).build(); - } - -} diff --git a/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskTest.java b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskTest.java new file mode 100644 index 00000000..ac188cda --- /dev/null +++ b/eidas_modules/authmodule-eIDAS-v2/src/test/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/test/tasks/InitialSearchTaskTest.java @@ -0,0 +1,463 @@ +/* + * 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.test.tasks; + +import at.asitplus.eidas.specific.modules.auth.eidas.v2.Constants; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.dao.RegisterResult; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.ernp.IErnpClient; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.exception.ManualFixNecessaryException; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.handler.DeSpecificDetailSearchProcessor; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.handler.ItSpecificDetailSearchProcessor; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.tasks.InitialSearchTask; +import at.asitplus.eidas.specific.modules.auth.eidas.v2.zmr.IZmrClient; +import at.gv.egiz.eaaf.core.api.idp.process.ExecutionContext; +import at.gv.egiz.eaaf.core.exceptions.EaafStorageException; +import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException; +import at.gv.egiz.eaaf.core.impl.idp.auth.data.AuthProcessDataWrapper; +import at.gv.egiz.eaaf.core.impl.idp.module.test.TestRequestImpl; +import at.gv.egiz.eaaf.core.impl.idp.process.ExecutionContextImpl; +import eu.eidas.auth.commons.attribute.AttributeDefinition; +import eu.eidas.auth.commons.attribute.ImmutableAttributeMap; +import eu.eidas.auth.commons.attribute.PersonType; +import eu.eidas.auth.commons.protocol.impl.AuthenticationResponse; +import lombok.val; +import org.apache.commons.lang3.RandomStringUtils; +import org.jetbrains.annotations.NotNull; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.mock.web.MockHttpServletResponse; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.DirtiesContext.ClassMode; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.xml.namespace.QName; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Random; + +import static org.junit.Assert.assertThrows; + +@RunWith(SpringJUnit4ClassRunner.class) +@ContextConfiguration(locations = { + "/SpringTest-context_tasks_test.xml", + "/SpringTest-context_basic_mapConfig.xml" +}) +@DirtiesContext(classMode = ClassMode.BEFORE_CLASS) +public class InitialSearchTaskTest { + + private static final String DE_ST = "de/st/"; + private static final String IT_ST = "it/st/"; + + private InitialSearchTask task; + @Mock + private IZmrClient zmrClient; + @Mock + private IErnpClient ernpClient; + + final ExecutionContext executionContext = new ExecutionContextImpl(); + private TestRequestImpl pendingReq; + private final String randomBpk = RandomStringUtils.randomNumeric(6); + private final String randomIdentifier = RandomStringUtils.randomNumeric(10); + private final String randomPseudonym = DE_ST + randomIdentifier; + private final String randomFamilyName = RandomStringUtils.randomAlphabetic(10); + private final String randomGivenName = RandomStringUtils.randomAlphabetic(10); + private final String randomPlaceOfBirth = RandomStringUtils.randomAlphabetic(10); + private final String randomBirthName = RandomStringUtils.randomAlphabetic(10); + private final String randomDate = "2011-01-" + (10 + new Random().nextInt(18)); + +// /** +// * jUnit class initializer. +// * +// * @throws IOException In case of an error +// */ +// @BeforeClass +// public static void classInitializer() throws IOException { +// final String current = new java.io.File(".").toURI().toString(); +// System.setProperty("eidas.ms.configuration", current +// + "src/test/resources/config/junit_config_1.properties"); +// } + + /** + * jUnit test set-up. + */ + @Before + public void setUp() throws URISyntaxException, EaafStorageException { + MockitoAnnotations.initMocks(this); + task = new InitialSearchTask(new ArrayList<>(), ernpClient, zmrClient); + + MockHttpServletRequest httpReq = new MockHttpServletRequest("POST", "https://localhost/authhandler"); + MockHttpServletResponse httpResp = new MockHttpServletResponse(); + RequestContextHolder.resetRequestAttributes(); + RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(httpReq, httpResp)); + + final AuthenticationResponse response = buildDummyAuthResponseRandomPerson(); + pendingReq = new TestRequestImpl(); + pendingReq.getSessionData(AuthProcessDataWrapper.class) + .setGenericDataToSession(Constants.DATA_FULL_EIDAS_RESPONSE, response); + } + + /** + * One match, but register update needed + */ + @Test + @DirtiesContext + public void testNode100_UserIdentifiedUpdateNecessary_a() throws Exception { + String newFirstName = RandomStringUtils.randomAlphabetic(10); + Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.singletonList( + new RegisterResult(randomBpk, randomIdentifier, newFirstName, randomFamilyName, randomDate))); + Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList()); + + task.execute(pendingReq, executionContext); + String bPk = (String) + pendingReq.getSessionData(AuthProcessDataWrapper.class) + .getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK); + + Assert.assertEquals("Wrong bpk", bPk, randomBpk); + } + + /** + * One match, but register update needed + */ + @Test + @DirtiesContext + public void testNode100_UserIdentifiedUpdateNecessary_b() throws TaskExecutionException { + Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList()); + String newRandomGivenName = RandomStringUtils.randomAlphabetic(10); + Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.singletonList( + new RegisterResult(randomBpk, randomIdentifier, newRandomGivenName, randomFamilyName, randomDate))); + + task.execute(pendingReq, executionContext); + String bPk = (String) + pendingReq.getSessionData(AuthProcessDataWrapper.class) + .getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK); + + Assert.assertEquals("Wrong bpk", bPk, randomBpk); + } + + /** + * Two matches found in ZMR + */ + @Test + @DirtiesContext + public void testNode101_ManualFixNecessary_a() { + ArrayList zmrResult = new ArrayList<>(); + zmrResult.add(new RegisterResult(randomBpk, randomIdentifier, randomGivenName, randomFamilyName, randomDate)); + String newRandomGivenName = randomGivenName + RandomStringUtils.randomAlphabetic(2); + zmrResult.add(new RegisterResult(randomBpk, randomIdentifier, newRandomGivenName, randomFamilyName, randomDate)); + Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(zmrResult); + Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList()); + + TaskExecutionException exception = assertThrows(TaskExecutionException.class, + () -> task.execute(pendingReq, executionContext)); + + Throwable origE = exception.getOriginalException(); + Assert.assertTrue("Wrong exception", (origE.getCause() instanceof ManualFixNecessaryException)); + } + + + /** + * Two matches found in ErnP + */ + @Test + @DirtiesContext + public void testNode101_ManualFixNecessary_b() { + Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList()); + ArrayList ernpResult = new ArrayList<>(); + ernpResult.add(new RegisterResult(randomBpk, randomPseudonym, randomGivenName, randomFamilyName, randomDate)); + String newRandomGivenName = randomGivenName + RandomStringUtils.randomAlphabetic(2); + ernpResult.add( + new RegisterResult(randomBpk, randomIdentifier, newRandomGivenName, randomFamilyName, randomDate)); + Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(ernpResult); + + TaskExecutionException exception = assertThrows(TaskExecutionException.class, + () -> task.execute(pendingReq, executionContext)); + + Throwable origE = exception.getOriginalException(); + Assert.assertTrue("Wrong exception", (origE.getCause() instanceof ManualFixNecessaryException)); + } + + /** + * One match, no register update needed + */ + @Test + @DirtiesContext + public void testNode102_UserIdentified_a() throws Exception { + Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList()); + Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.singletonList( + new RegisterResult(randomBpk, randomIdentifier, randomGivenName, randomFamilyName, randomDate))); + + task.execute(pendingReq, executionContext); + String bPk = (String) + pendingReq.getSessionData(AuthProcessDataWrapper.class) + .getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK); + Assert.assertEquals("Wrong bpk", bPk, randomBpk); + } + + /** + * One match, no register update needed + */ + @Test + @DirtiesContext + public void testNode102_UserIdentified_b() throws Exception { + Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.singletonList( + new RegisterResult(randomBpk, randomIdentifier, randomGivenName, randomFamilyName, randomDate))); + Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList()); + + task.execute(pendingReq, executionContext); + + String bPk = (String) + pendingReq.getSessionData(AuthProcessDataWrapper.class) + .getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK); + Assert.assertEquals("Wrong bpk", bPk, randomBpk); + } + + /** + * One match found in ZMR and ErnP with detail search + */ + @Test + @DirtiesContext + public void testNode103_UserIdentified_IT() throws Exception { + String taxNumber = RandomStringUtils.randomNumeric(14); + final AuthenticationResponse response = buildDummyAuthResponseRandomPersonIT_Tax(taxNumber); + TestRequestImpl pendingReq1 = new TestRequestImpl(); + pendingReq1.getSessionData(AuthProcessDataWrapper.class) + .setGenericDataToSession(Constants.DATA_FULL_EIDAS_RESPONSE, response); + Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList()); + String newRandomIdentifier = randomIdentifier + RandomStringUtils.randomNumeric(2); + Mockito.when(zmrClient.searchItSpecific(taxNumber)).thenReturn(Collections.singletonList( + new RegisterResult(randomBpk, newRandomIdentifier, randomGivenName, randomFamilyName, + randomDate, null, null, taxNumber, null))); + Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList()); + task = new InitialSearchTask( + Collections.singletonList(new ItSpecificDetailSearchProcessor(ernpClient, zmrClient)), + ernpClient, zmrClient); + + task.execute(pendingReq1, executionContext); + + String bPk = (String) + pendingReq1.getSessionData(AuthProcessDataWrapper.class) + .getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK); + Assert.assertEquals("Wrong bpk", bPk, randomBpk); + } + + /** + * Multiple matches found in ZMR and ErnP with detail search + */ + @Test + @DirtiesContext + public void testNode103_UserIdentified_DE() throws Exception { + final AuthenticationResponse response = buildDummyAuthResponseDE(randomGivenName, randomFamilyName, + randomPseudonym, + randomDate, randomPlaceOfBirth, randomBirthName); + TestRequestImpl pendingReq1 = new TestRequestImpl(); + pendingReq1.getSessionData(AuthProcessDataWrapper.class) + .setGenericDataToSession(Constants.DATA_FULL_EIDAS_RESPONSE, response); + Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList()); + Mockito.when(zmrClient.searchDeSpecific(randomGivenName, randomFamilyName, randomDate, randomPlaceOfBirth, + randomBirthName)) + .thenReturn(Collections.singletonList(new RegisterResult(randomBpk, randomIdentifier, randomGivenName, + randomFamilyName, randomDate, randomPlaceOfBirth, randomBirthName, null, null))); + Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList()); + task = new InitialSearchTask( + Collections.singletonList(new DeSpecificDetailSearchProcessor(ernpClient, zmrClient)), + ernpClient, zmrClient); + + task.execute(pendingReq1, executionContext); + + String resultBpk = (String) + pendingReq1.getSessionData(AuthProcessDataWrapper.class) + .getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK); + Assert.assertEquals("Wrong bpk", resultBpk, randomBpk); + } + + /** + * Multiple matches found in ZMR and ErnP with detail search + */ + @Test + @DirtiesContext + public void testNode104_ManualFixNecessary_DE() throws Exception { + String newRandomPseudonym = randomPseudonym + RandomStringUtils.randomNumeric(2); + String newRandomBpk = randomBpk + RandomStringUtils.randomNumeric(6); + final AuthenticationResponse response = buildDummyAuthResponseDE(randomGivenName, randomFamilyName, + randomPseudonym, + randomDate, randomPlaceOfBirth, randomBirthName); + TestRequestImpl pendingReq1 = new TestRequestImpl(); + pendingReq1.getSessionData(AuthProcessDataWrapper.class) + .setGenericDataToSession(Constants.DATA_FULL_EIDAS_RESPONSE, response); + Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList()); + ArrayList zmrResultSpecific = new ArrayList<>(); + zmrResultSpecific.add( + new RegisterResult(randomBpk, randomIdentifier, randomGivenName, randomFamilyName, randomDate, + randomPlaceOfBirth, randomBirthName, null, null)); + zmrResultSpecific.add(new RegisterResult(newRandomBpk, newRandomPseudonym, randomGivenName, randomFamilyName, randomDate, + randomPlaceOfBirth, randomBirthName, null, null)); + Mockito.when(zmrClient.searchDeSpecific(randomGivenName, randomFamilyName, randomDate, randomPlaceOfBirth, + randomBirthName)).thenReturn(zmrResultSpecific); + Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList()); + task = new InitialSearchTask( + Collections.singletonList(new DeSpecificDetailSearchProcessor(ernpClient, zmrClient)), + ernpClient, zmrClient); + + TaskExecutionException exception = assertThrows(TaskExecutionException.class, + () -> task.execute(pendingReq1, executionContext)); + + Throwable origE = exception.getOriginalException(); + Assert.assertTrue("Wrong exception", (origE.getCause() instanceof ManualFixNecessaryException)); + } + + /** + * Multiple matches found in ZMR and ErnP with detail search + */ + @Test + @DirtiesContext + public void testNode104_ManualFixNecessary_IT() throws Exception { + String randomTaxNumber = RandomStringUtils.randomNumeric(14); + final AuthenticationResponse response = buildDummyAuthResponseRandomPersonIT_Tax(randomTaxNumber); + TestRequestImpl pendingReq1 = new TestRequestImpl(); + pendingReq1.getSessionData(AuthProcessDataWrapper.class) + .setGenericDataToSession(Constants.DATA_FULL_EIDAS_RESPONSE, response); + Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList()); + ArrayList zmrResultSpecific = new ArrayList<>(); + String randomPseudonym = IT_ST + randomIdentifier + "4"; + zmrResultSpecific.add(new RegisterResult(randomBpk, randomPseudonym, randomGivenName, + randomFamilyName, randomDate, null, null, randomTaxNumber, null)); + String newRandomPseudonym = IT_ST + randomIdentifier + "5"; + String newRandomBpk = RandomStringUtils.randomNumeric(6); + zmrResultSpecific.add(new RegisterResult(newRandomBpk, newRandomPseudonym, randomGivenName, + randomFamilyName, randomDate, null, null, randomTaxNumber, null)); + Mockito.when(zmrClient.searchItSpecific(randomTaxNumber)).thenReturn(zmrResultSpecific); + Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList()); + task = new InitialSearchTask( + Collections.singletonList(new ItSpecificDetailSearchProcessor(ernpClient, zmrClient)), + ernpClient, zmrClient); + + TaskExecutionException exception = assertThrows(TaskExecutionException.class, + () -> task.execute(pendingReq1, executionContext)); + + Throwable origE = exception.getOriginalException(); + Assert.assertTrue("Wrong exception", (origE.getCause() instanceof ManualFixNecessaryException)); + } + + /** + * NO match found in ZMR and ErnP with Initial search + */ + @Test + @DirtiesContext + public void testNode105_TemporaryEnd() throws TaskExecutionException { + Mockito.when(zmrClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList()); + Mockito.when(ernpClient.searchWithPersonIdentifier(randomIdentifier)).thenReturn(Collections.emptyList()); + + task.execute(pendingReq, executionContext); + + String bPk = (String) + pendingReq.getSessionData(AuthProcessDataWrapper.class) + .getGenericDataFromSession(Constants.DATA_RESULT_MATCHING_BPK); + Assert.assertEquals("Wrong bpk", "TODO-Temporary-Endnode-105", bPk); + } + + + @NotNull + private AuthenticationResponse buildDummyAuthResponseRandomPerson() throws URISyntaxException { + return buildDummyAuthResponse(randomGivenName, randomFamilyName, DE_ST + randomIdentifier, randomDate); + } + + private AuthenticationResponse buildDummyAuthResponseRandomPersonIT_Tax(String taxNumber) + throws URISyntaxException { + return buildDummyAuthResponse(randomGivenName, randomFamilyName, IT_ST + randomIdentifier, randomDate, + taxNumber, null, null); + } + + @NotNull + private AuthenticationResponse buildDummyAuthResponse(String givenName, String familyName, String identifier, + String dateOfBirth) throws URISyntaxException { + return buildDummyAuthResponse(givenName, familyName, identifier, dateOfBirth, null, null, null); + } + + @NotNull + private AuthenticationResponse buildDummyAuthResponseDE(String givenName, String familyName, String identifier, + String dateOfBirth, String placeOfBirth, + String birthName) throws URISyntaxException { + return buildDummyAuthResponse(givenName, familyName, identifier, dateOfBirth, null, placeOfBirth, birthName); + } + + @NotNull + private AuthenticationResponse buildDummyAuthResponse(String givenName, String familyName, String identifier, + String dateOfBirth, String taxNumber, String placeOfBirth, + String birthName) throws URISyntaxException { + ImmutableAttributeMap.Builder builder = ImmutableAttributeMap.builder() + .put(generateStringAttribute(Constants.eIDAS_ATTR_PERSONALIDENTIFIER, "ff", "af"), identifier) + .put(generateStringAttribute(Constants.eIDAS_ATTR_CURRENTFAMILYNAME, "fff", "aff"), familyName) + .put(generateStringAttribute(Constants.eIDAS_ATTR_CURRENTGIVENNAME, "ffff", "afff"), givenName) + .put(generateDateTimeAttribute(Constants.eIDAS_ATTR_DATEOFBIRTH, "fffff", "affff"), dateOfBirth); + if (taxNumber != null) { + builder.put(generateStringAttribute(Constants.eIDAS_ATTR_TAXREFERENCE, "ffffff", "afffff"), taxNumber); + } + if (birthName != null) { + builder.put(generateStringAttribute(Constants.eIDAS_ATTR_BIRTHNAME, "fffffff", "affffff"), birthName); + } + if (placeOfBirth != null) { + builder.put(generateStringAttribute(Constants.eIDAS_ATTR_PLACEOFBIRTH, "ffffffff", "afffffff"), + placeOfBirth); + } + final ImmutableAttributeMap attributeMap = builder.build(); + + val b = new AuthenticationResponse.Builder(); + return b.id("aasdf").issuer("asd").subject("asf").statusCode("200").inResponseTo("asdf").subjectNameIdFormat( + "afaf").attributes(attributeMap).build(); + } + + private AttributeDefinition generateStringAttribute(String friendlyName, String fragment, String prefix) + throws URISyntaxException { + return generateAttribute(friendlyName, fragment, prefix, "eu.eidas.auth.commons.attribute.impl" + + ".LiteralStringAttributeValueMarshaller"); + } + + private AttributeDefinition generateDateTimeAttribute(String friendlyName, String fragment, String prefix) + throws URISyntaxException { + return generateAttribute(friendlyName, fragment, prefix, "eu.eidas.auth.commons.attribute.impl" + + ".DateTimeAttributeValueMarshaller"); + } + + private AttributeDefinition generateAttribute(String friendlyName, String fragment, String prefix, + String marshaller) throws URISyntaxException { + return AttributeDefinition.builder() + .friendlyName(friendlyName).nameUri(new URI("ad", "sd", fragment)) + .personType(PersonType.LEGAL_PERSON).xmlType(new QName("http://saf", "as", prefix)) + .attributeValueMarshaller(marshaller).build(); + } + +} -- cgit v1.2.3