aboutsummaryrefslogtreecommitdiff
path: root/modules/core_common_lib
diff options
context:
space:
mode:
authorThomas <>2022-05-13 08:59:16 +0200
committerThomas <>2022-05-13 08:59:16 +0200
commita11517f4d25f31e352a9665392ad000dff4a44c5 (patch)
treed9bbd0b09c68b0d86bd43ae5ccb5b277fd9c3fd3 /modules/core_common_lib
parent9e3b78d931d220e1ed5ecbaadcb13df7cbe96e22 (diff)
parente412bda31b304821c08d8f8c7b2473d67246dba0 (diff)
downloadNational_eIDAS_Gateway-a11517f4d25f31e352a9665392ad000dff4a44c5.tar.gz
National_eIDAS_Gateway-a11517f4d25f31e352a9665392ad000dff4a44c5.tar.bz2
National_eIDAS_Gateway-a11517f4d25f31e352a9665392ad000dff4a44c5.zip
Merge branch 'nightlybuild' into feature/ms_proxy_before_refactoring
# Conflicts: # basicConfig/templates/error_message.html # connector/src/main/resources/specific_eIDAS_connector.beans.xml # connector/src/test/resources/config/junit_config_1_springboot.properties # connector/src/test/resources/config/junit_config_2_springboot.properties # connector/src/test/resources/config/templates/countrySelection.html # modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/Constants.java # modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/handler/AbstractEidProcessor.java # modules/authmodule-eIDAS-v2/src/main/java/at/asitplus/eidas/specific/modules/auth/eidas/v2/tasks/GenerateAuthnRequestTask.java # pom.xml
Diffstat (limited to 'modules/core_common_lib')
-rw-r--r--modules/core_common_lib/pom.xml20
-rw-r--r--modules/core_common_lib/src/main/java/at/asitplus/eidas/specific/core/MsEidasNodeConstants.java29
-rw-r--r--modules/core_common_lib/src/main/java/at/asitplus/eidas/specific/core/gui/config/StaticResourceConfiguration.java220
-rw-r--r--modules/core_common_lib/src/main/resources/common_gui.beans.xml3
4 files changed, 262 insertions, 10 deletions
diff --git a/modules/core_common_lib/pom.xml b/modules/core_common_lib/pom.xml
index b5a95005..8b06a9ee 100644
--- a/modules/core_common_lib/pom.xml
+++ b/modules/core_common_lib/pom.xml
@@ -7,7 +7,7 @@
<parent>
<groupId>at.asitplus.eidas.ms_specific</groupId>
<artifactId>modules</artifactId>
- <version>1.2.5-SNAPSHOT</version>
+ <version>1.3.0-SNAPSHOT</version>
</parent>
<artifactId>core_common_lib</artifactId>
<name>ms_specific_common_lib</name>
@@ -27,6 +27,14 @@
<artifactId>spring-webmvc</artifactId>
</dependency>
<dependency>
+ <groupId>org.thymeleaf</groupId>
+ <artifactId>thymeleaf-spring5</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hibernate.validator</groupId>
+ <artifactId>hibernate-validator</artifactId>
+ </dependency>
+ <dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>
@@ -36,6 +44,8 @@
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
+
+
<!-- jUnit test dependencies -->
<dependency>
@@ -61,6 +71,14 @@
<type>test-jar</type>
</dependency>
+ <dependency>
+ <groupId>at.gv.egiz.eaaf</groupId>
+ <artifactId>eaaf_module_pvp2_core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>at.gv.egiz.eaaf</groupId>
+ <artifactId>eaaf_module_pvp2_sp</artifactId>
+ </dependency>
</dependencies>
<build>
diff --git a/modules/core_common_lib/src/main/java/at/asitplus/eidas/specific/core/MsEidasNodeConstants.java b/modules/core_common_lib/src/main/java/at/asitplus/eidas/specific/core/MsEidasNodeConstants.java
index 8580950f..be5d7c7d 100644
--- a/modules/core_common_lib/src/main/java/at/asitplus/eidas/specific/core/MsEidasNodeConstants.java
+++ b/modules/core_common_lib/src/main/java/at/asitplus/eidas/specific/core/MsEidasNodeConstants.java
@@ -51,7 +51,13 @@ public class MsEidasNodeConstants {
public static final String PROP_CONFIG_WEBCONTENT_TEMPLATES_PATH = "webcontent.templates";
public static final String PROP_CONFIG_WEBCONTENT_TEMPLATES_CCSELECTION = "webcontent.templates.countryselection";
-
+ public static final String PROP_CONFIG_WEBCONTENT_TEMPLATES_OTHER_LOGIN_METHOD_SELECTION = "webcontent.templates"
+ + ".otherLoginMethodselection";
+ public static final String PROP_CONFIG_WEBCONTENT_TEMPLATES_RESIDENCY = "webcontent.templates"
+ + ".residency";
+ public static final String PROP_CONFIG_WEBCONTENT_TEMPLATES_OTHER_CONTACTS_WITH_AUSTRIAN_EGOV =
+ "webcontent.templates.otherContactsWithAustrianEgov";
+
public static final String PROP_CONFIG_MONITORING_EIDASNODE_METADATAURL =
"monitoring.eIDASNode.metadata.url";
@@ -84,7 +90,7 @@ public class MsEidasNodeConstants {
PROP_CONFIG_PVP2_PREFIX + "metadata.organisation.friendyname";
public static final String CONFIG_PROPS_METADATA_ORGANISATION_URL =
PROP_CONFIG_PVP2_PREFIX + "metadata.organisation.url";
-
+
// TODO: is not implemented yet
public static final String PROP_CONFIG_SP_VALIDATION_DISABLED =
"configuration.sp.disableRegistrationRequirement";
@@ -99,14 +105,14 @@ public class MsEidasNodeConstants {
public static final String PROP_CONFIG_AUTHBLOCK_KEYSTORE_PASSWORD =
"auth.eIDAS.authblock.keystore.password";
public static final String PROP_CONFIG_AUTHBLOCK_KEYSTORE_NAME =
- "auth.eIDAS.authblock.keystore.name";
+ "auth.eIDAS.authblock.keystore.name";
public static final String PROP_CONFIG_AUTHBLOCK_KEY_ALIAS =
"auth.eIDAS.authblock.key.alias";
public static final String PROP_CONFIG_AUTHBLOCK_KEY_PASSWORD =
"auth.eIDAS.authblock.key.password";
-
-
-
+
+
+
public static final String PROP_CONFIG_SP_LIST_PREFIX = "sp";
public static final String PROP_CONFIG_SP_UNIQUEIDENTIFIER = EaafConfigConstants.SERVICE_UNIQUEIDENTIFIER;
@@ -144,7 +150,10 @@ public class MsEidasNodeConstants {
public static final String ENDPOINT_PVP_REDIRECT = "/pvp/redirect";
public static final String ENDPOINT_COUNTRYSELECTION = "/myHomeCountry";
-
+ public static final String ENDPOINT_OTHER_LOGIN_METHOD_SELECTION = "/otherLoginMethod";
+ public static final String ENDPOINT_RESIDENCY_INPUT = "/residency";
+ public static final String ENDPOINT_RESIDENCY_SEARCH = "/residency/search";
+ public static final String ENDPOINT_OTHER_CONTACTS_INPUT = "/otherContacts";
public static final String ENDPOINT_MONITORING_MONITOR = "/monitoring";
public static final String ENDPOINT_MONITORING_VERIFY = "/verify";
@@ -155,7 +164,9 @@ public class MsEidasNodeConstants {
public static final String TEMPLATE_HTML_ERROR = "error_message.html";
public static final String TEMPLATE_HTML_PVP_POSTBINDING = "pvp2_post_binding.html";
public static final String TEMPLATE_HTML_COUNTRYSELECTION = "countrySelection.html";
-
+ public static final String TEMPLATE_HTML_OTHERLOGINMETHODS = "other_login_method.html";
+ public static final String TEMPLATE_HTML_RESIDENCY = "residency.html";
+ public static final String TEMPLATE_HTML_OTHERCONTACTSWITHAUSTRIANEGOV = "otherContactsWithAustrianEgov.html";
// ************ execution context and generic data ************
public static final String REQ_PARAM_SELECTED_COUNTRY = "selectedCountry";
public static final String REQ_PARAM_SELECTED_ENVIRONMENT = "selectedEnvironment";
@@ -227,5 +238,5 @@ public class MsEidasNodeConstants {
private MsEidasNodeConstants() {
//hidden Constructor for class with static values only.
}
-
+
}
diff --git a/modules/core_common_lib/src/main/java/at/asitplus/eidas/specific/core/gui/config/StaticResourceConfiguration.java b/modules/core_common_lib/src/main/java/at/asitplus/eidas/specific/core/gui/config/StaticResourceConfiguration.java
new file mode 100644
index 00000000..ea080497
--- /dev/null
+++ b/modules/core_common_lib/src/main/java/at/asitplus/eidas/specific/core/gui/config/StaticResourceConfiguration.java
@@ -0,0 +1,220 @@
+/*
+ * Copyright 2019 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.core.gui.config;
+
+import java.net.MalformedURLException;
+import java.util.List;
+
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.support.ReloadableResourceBundleMessageSource;
+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+import org.springframework.web.servlet.i18n.CookieLocaleResolver;
+import org.thymeleaf.templateresolver.FileTemplateResolver;
+
+import at.asitplus.eidas.specific.core.MsEidasNodeConstants;
+import at.gv.egiz.eaaf.core.api.idp.IConfiguration;
+import at.gv.egiz.eaaf.core.api.logging.IMessageSourceLocation;
+import at.gv.egiz.eaaf.core.impl.utils.FileUtils;
+
+/**
+ * Spring configurator for Web resources.
+ *
+ * @author tlenz
+ *
+ */
+@Configuration
+public class StaticResourceConfiguration implements WebMvcConfigurer {
+ private static final Logger log = LoggerFactory.getLogger(StaticResourceConfiguration.class);
+ private static final String[] CLASSPATH_RESOURCE_LOCATIONS = {
+ "/"
+ };
+
+ private static final String DEFAULT_MESSAGE_SOURCE = "classpath:properties/status_messages";
+
+ @Autowired
+ private IConfiguration basicConfig;
+
+ @Override
+ public void addResourceHandlers(ResourceHandlerRegistry registry) {
+ final String staticResources = basicConfig.getBasicConfiguration(
+ MsEidasNodeConstants.PROP_CONFIG_WEBCONTENT_STATIC_PATH);
+ try {
+ if (StringUtils.isNotEmpty(staticResources)) {
+ String absPath = FileUtils.makeAbsoluteUrl(staticResources, basicConfig
+ .getConfigurationRootDirectory());
+ if (!absPath.endsWith("/")) {
+ absPath += "/";
+ }
+
+ registry.addResourceHandler("/static/**").addResourceLocations(absPath);
+ log.info("Add Ressourcefolder: " + absPath + " for static Web content");
+
+ } else {
+ log.debug("No Ressourcefolder for static Web content");
+ }
+
+ } catch (final MalformedURLException e) {
+ log.warn("Can NOT initialize ressourcefolder for static Web content", e);
+
+ }
+
+ registry.addResourceHandler("/**").addResourceLocations(CLASSPATH_RESOURCE_LOCATIONS);
+
+ }
+
+ /**
+ * Get a message source with only internal message properties.
+ *
+ * @param ressourceLocations List of source-locations
+ * @return
+ */
+ @Bean
+ public ReloadableResourceBundleMessageSource internalMessageSource(
+ @Autowired(required = false) final List<IMessageSourceLocation> ressourceLocations) {
+ final ReloadableResourceBundleMessageSource messageSource =
+ new ReloadableResourceBundleMessageSource();
+
+ // add default message source
+ messageSource.setBasename(DEFAULT_MESSAGE_SOURCE);
+
+ if (ressourceLocations != null) {
+ // load more message sources
+ for (final IMessageSourceLocation el : ressourceLocations) {
+ if (el.getMessageSourceLocation() != null) {
+ for (final String source : el.getMessageSourceLocation()) {
+ messageSource.addBasenames(source);
+ log.debug("Add additional messageSources: {}", el.getMessageSourceLocation().toArray());
+
+ }
+ }
+ }
+ }
+
+ messageSource.setDefaultEncoding("UTF-8");
+ return messageSource;
+
+ }
+
+ /**
+ * Get full message source with internal and external message-properties files.
+ *
+ * @param ressourceLocations List of source-locations
+ * @return
+ */
+ @Bean
+ public ReloadableResourceBundleMessageSource messageSource(
+ @Autowired(required = false) final List<IMessageSourceLocation> ressourceLocations) {
+ final ReloadableResourceBundleMessageSource messageSource =
+ new ReloadableResourceBundleMessageSource();
+ messageSource.setDefaultEncoding("UTF-8");
+ messageSource.setParentMessageSource(internalMessageSource(ressourceLocations));
+
+ final String staticResources = basicConfig
+ .getBasicConfiguration(MsEidasNodeConstants.PROP_CONFIG_WEBCONTENT_PROPERTIES_PATH);
+ try {
+ if (StringUtils.isNotEmpty(staticResources)) {
+ final String absPath =
+ FileUtils.makeAbsoluteUrl(staticResources, basicConfig.getConfigurationRootDirectory());
+ messageSource.setBasename(absPath);
+
+ } else {
+ log.debug("No Ressourcefolder for dynamic Web content templates");
+
+ }
+
+ } catch (final MalformedURLException e) {
+ log.warn("Can NOT initialize ressourcefolder for dynamic Web content templates", e);
+
+ }
+
+ return messageSource;
+
+ }
+
+ /**
+ * Get a i18n resolver based on cookies.
+ *
+ * @return
+ */
+ @Bean
+ public CookieLocaleResolver localeResolver() {
+ final CookieLocaleResolver localeResolver = new CookieLocaleResolver();
+ localeResolver.setCookieName("currentLanguage");
+ localeResolver.setCookieMaxAge(3600);
+ return localeResolver;
+
+ }
+
+ /**
+ * Get a Tyhmeleaf Template-Resolver with external configuration path.
+ *
+ * @return
+ */
+ @Bean(name = "templateResolver")
+ public FileTemplateResolver templateResolver() {
+ final String staticResources = basicConfig
+ .getBasicConfiguration(MsEidasNodeConstants.PROP_CONFIG_WEBCONTENT_TEMPLATES_PATH);
+ try {
+ if (StringUtils.isNotEmpty(staticResources)) {
+ String absPath =
+ FileUtils.makeAbsoluteUrl(staticResources, basicConfig.getConfigurationRootDirectory());
+ if (!absPath.endsWith("/")) {
+ absPath += "/";
+
+ }
+
+ if (absPath.startsWith("file:")) {
+ absPath = absPath.substring("file:".length());
+
+ }
+
+ final FileTemplateResolver viewResolver = new FileTemplateResolver();
+ viewResolver.setPrefix(absPath);
+ viewResolver.setSuffix(".html");
+ viewResolver.setTemplateMode("HTML");
+ viewResolver.setCacheable(false);
+
+ log.info("Add Ressourcefolder: {} for dynamic Web content templates", absPath);
+ return viewResolver;
+
+ } else {
+ log.debug("No Ressourcefolder for dynamic Web content templates");
+
+ }
+
+ } catch (final MalformedURLException e) {
+ log.warn("Can NOT initialize ressourcefolder for dynamic Web content templates", e);
+
+ }
+
+ throw new RuntimeException("Can NOT initialize HTML template resolver");
+
+ }
+}
diff --git a/modules/core_common_lib/src/main/resources/common_gui.beans.xml b/modules/core_common_lib/src/main/resources/common_gui.beans.xml
index 969a40f7..c482f8d2 100644
--- a/modules/core_common_lib/src/main/resources/common_gui.beans.xml
+++ b/modules/core_common_lib/src/main/resources/common_gui.beans.xml
@@ -11,6 +11,9 @@
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd">
+ <bean id="WebResourceConfiguration"
+ class="at.asitplus.eidas.specific.core.gui.config.StaticResourceConfiguration" />
+
<bean id="contentNegotiationManager"
class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean"
primary="true">