aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas <>2022-08-16 11:21:04 +0200
committerThomas <>2022-08-16 11:21:04 +0200
commit72e8da84f3ff8cd36d6f62d0d0690ad3f9a19efd (patch)
tree3e5dfe6bf683db79df055dbe603c64575a481f2c
parentca50cb8dda0a24b5a4589db126bfab8d0d885b00 (diff)
downloadNational_eIDAS_Gateway-72e8da84f3ff8cd36d6f62d0d0690ad3f9a19efd.tar.gz
National_eIDAS_Gateway-72e8da84f3ff8cd36d6f62d0d0690ad3f9a19efd.tar.bz2
National_eIDAS_Gateway-72e8da84f3ff8cd36d6f62d0d0690ad3f9a19efd.zip
chore(core): check if custom attribute-handler implementations are available on start-up
-rw-r--r--modules/eidas_proxy-sevice/src/main/java/at/asitplus/eidas/specific/modules/msproxyservice/handler/EJusticePersonRoleHandler.java13
-rw-r--r--modules/eidas_proxy-sevice/src/main/java/at/asitplus/eidas/specific/modules/msproxyservice/handler/IEidasAttributeHandler.java13
-rw-r--r--modules/eidas_proxy-sevice/src/main/java/at/asitplus/eidas/specific/modules/msproxyservice/service/ProxyEidasAttributeRegistry.java15
-rw-r--r--modules/eidas_proxy-sevice/src/main/resources/spring/eidas_proxy-service.beans.xml3
-rw-r--r--modules/eidas_proxy-sevice/src/test/java/at/asitplus/eidas/specific/modules/msproxyservice/test/services/ProxyEidasAttributeRegistryTest.java3
-rw-r--r--modules/eidas_proxy-sevice/src/test/resources/config/idaAttributeMapping.json2
6 files changed, 48 insertions, 1 deletions
diff --git a/modules/eidas_proxy-sevice/src/main/java/at/asitplus/eidas/specific/modules/msproxyservice/handler/EJusticePersonRoleHandler.java b/modules/eidas_proxy-sevice/src/main/java/at/asitplus/eidas/specific/modules/msproxyservice/handler/EJusticePersonRoleHandler.java
new file mode 100644
index 00000000..f42a7172
--- /dev/null
+++ b/modules/eidas_proxy-sevice/src/main/java/at/asitplus/eidas/specific/modules/msproxyservice/handler/EJusticePersonRoleHandler.java
@@ -0,0 +1,13 @@
+package at.asitplus.eidas.specific.modules.msproxyservice.handler;
+
+/**
+ * Attribute handling to integrate BORIS attributes without full IDA support for sector-specific attributes.
+ *
+ * <p>This attribute-handler maps a specific mandate-profile to an eIDAS attribute.</p>
+ *
+ * @author tlenz
+ *
+ */
+public class EJusticePersonRoleHandler implements IEidasAttributeHandler {
+
+}
diff --git a/modules/eidas_proxy-sevice/src/main/java/at/asitplus/eidas/specific/modules/msproxyservice/handler/IEidasAttributeHandler.java b/modules/eidas_proxy-sevice/src/main/java/at/asitplus/eidas/specific/modules/msproxyservice/handler/IEidasAttributeHandler.java
new file mode 100644
index 00000000..153cf262
--- /dev/null
+++ b/modules/eidas_proxy-sevice/src/main/java/at/asitplus/eidas/specific/modules/msproxyservice/handler/IEidasAttributeHandler.java
@@ -0,0 +1,13 @@
+package at.asitplus.eidas.specific.modules.msproxyservice.handler;
+
+/**
+ * Handlers for attribute-processing that requires more features than a simple mapping.
+ *
+ * @author tlenz
+ *
+ */
+public interface IEidasAttributeHandler {
+
+
+
+}
diff --git a/modules/eidas_proxy-sevice/src/main/java/at/asitplus/eidas/specific/modules/msproxyservice/service/ProxyEidasAttributeRegistry.java b/modules/eidas_proxy-sevice/src/main/java/at/asitplus/eidas/specific/modules/msproxyservice/service/ProxyEidasAttributeRegistry.java
index a0c99019..747c808c 100644
--- a/modules/eidas_proxy-sevice/src/main/java/at/asitplus/eidas/specific/modules/msproxyservice/service/ProxyEidasAttributeRegistry.java
+++ b/modules/eidas_proxy-sevice/src/main/java/at/asitplus/eidas/specific/modules/msproxyservice/service/ProxyEidasAttributeRegistry.java
@@ -17,6 +17,7 @@ import javax.annotation.PostConstruct;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
@@ -27,6 +28,7 @@ import com.google.common.collect.Sets;
import at.asitplus.eidas.specific.modules.core.eidas.service.EidasAttributeRegistry;
import at.asitplus.eidas.specific.modules.msproxyservice.MsProxyServiceConstants;
import at.asitplus.eidas.specific.modules.msproxyservice.dto.attributes.AttrMappingElement;
+import at.asitplus.eidas.specific.modules.msproxyservice.handler.IEidasAttributeHandler;
import at.gv.egiz.eaaf.core.api.idp.IConfiguration;
import at.gv.egiz.eaaf.core.exceptions.EaafConfigurationException;
import at.gv.egiz.eaaf.core.impl.utils.FileUtils;
@@ -41,6 +43,7 @@ public class ProxyEidasAttributeRegistry {
private static ObjectMapper mapper = new ObjectMapper();
+ @Autowired ApplicationContext context;
@Autowired IConfiguration basicConfig;
@Autowired ResourceLoader resourceLoader;
@@ -204,6 +207,18 @@ public class ProxyEidasAttributeRegistry {
if (StringUtils.isNotEmpty(el.getEidasAttributeName())) {
if (ATTR_CONFIG_ALL.equals(el.getEidasAttributeName())
|| coreRegistry.getCoreAttributeRegistry().getByName(el.getEidasAttributeName()) != null) {
+
+ // check if custom attribute-handler implementation is available
+ if (StringUtils.isNotEmpty(el.getSpecificAttributeHandlerClass())) {
+ try {
+ context.getBean(el.getSpecificAttributeHandlerClass(), IEidasAttributeHandler.class);
+
+ } catch (Exception e) {
+ log.error("No custom attribute-handler implementation for: {}", el.getSpecificAttributeHandlerClass(), e);
+ return false;
+ }
+ }
+
return true;
} else {
diff --git a/modules/eidas_proxy-sevice/src/main/resources/spring/eidas_proxy-service.beans.xml b/modules/eidas_proxy-sevice/src/main/resources/spring/eidas_proxy-service.beans.xml
index 78b7640a..38bd44da 100644
--- a/modules/eidas_proxy-sevice/src/main/resources/spring/eidas_proxy-service.beans.xml
+++ b/modules/eidas_proxy-sevice/src/main/resources/spring/eidas_proxy-service.beans.xml
@@ -35,4 +35,7 @@
<bean id="proxyAttributeRegistry"
class="at.asitplus.eidas.specific.modules.msproxyservice.service.ProxyEidasAttributeRegistry" />
+ <bean id="at.asitplus.eidas.specific.modules.msproxyservice.handler.EJusticePersonRoleHandler"
+ class="at.asitplus.eidas.specific.modules.msproxyservice.handler.EJusticePersonRoleHandler" />
+
</beans> \ No newline at end of file
diff --git a/modules/eidas_proxy-sevice/src/test/java/at/asitplus/eidas/specific/modules/msproxyservice/test/services/ProxyEidasAttributeRegistryTest.java b/modules/eidas_proxy-sevice/src/test/java/at/asitplus/eidas/specific/modules/msproxyservice/test/services/ProxyEidasAttributeRegistryTest.java
index fb7d257e..d3d1d7b0 100644
--- a/modules/eidas_proxy-sevice/src/test/java/at/asitplus/eidas/specific/modules/msproxyservice/test/services/ProxyEidasAttributeRegistryTest.java
+++ b/modules/eidas_proxy-sevice/src/test/java/at/asitplus/eidas/specific/modules/msproxyservice/test/services/ProxyEidasAttributeRegistryTest.java
@@ -137,6 +137,9 @@ public class ProxyEidasAttributeRegistryTest {
attrRegistry.mapEidasAttributeToAttributeHandler(
"http://eidas.europa.eu/attributes/naturalperson/representative/DateOfBirth").isPresent());
+ assertFalse("find wrong attribute",
+ attrRegistry.mapEidasAttributeToAttributeHandler(
+ "http://e-justice.europa.eu/attributes/legalperson/eJusticeLegalPersonRole").isPresent());
Optional<String> attr2 = attrRegistry.mapEidasAttributeToAttributeHandler(
"http://e-justice.europa.eu/attributes/naturalperson/eJusticeNaturalPersonRole");
diff --git a/modules/eidas_proxy-sevice/src/test/resources/config/idaAttributeMapping.json b/modules/eidas_proxy-sevice/src/test/resources/config/idaAttributeMapping.json
index daaaa37d..a3ff1ead 100644
--- a/modules/eidas_proxy-sevice/src/test/resources/config/idaAttributeMapping.json
+++ b/modules/eidas_proxy-sevice/src/test/resources/config/idaAttributeMapping.json
@@ -138,7 +138,7 @@
},
{
"eidasAttribute": "http://e-justice.europa.eu/attributes/legalperson/eJusticeLegalPersonRole",
- "specificAttributeHandlerClass": "at.asitplus.eidas.specific.modules.msproxyservice.handler.EJusticePersonRoleHandler",
+ "specificAttributeHandlerClass": "at.asitplus.eidas.specific.modules.msproxyservice.handler.notExist",
"type": {
"mds": false,
"autoIncludeWithMandates": false