aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Lenz <thomas.lenz@egiz.gv.at>2019-12-11 07:33:04 +0100
committerThomas Lenz <thomas.lenz@egiz.gv.at>2019-12-11 07:33:04 +0100
commitce2250d0e285dfa456072729989f9ac2a498cec1 (patch)
treef944ca0927f3ac08f912ab1715f5a139be733095
parent8b0e6296527b6239d3fda64efe1c858e1cca6e3c (diff)
downloadNational_eIDAS_Gateway-ce2250d0e285dfa456072729989f9ac2a498cec1.tar.gz
National_eIDAS_Gateway-ce2250d0e285dfa456072729989f9ac2a498cec1.tar.bz2
National_eIDAS_Gateway-ce2250d0e285dfa456072729989f9ac2a498cec1.zip
add BM.I specific example of country-selection template
add new i18n content add jUnit tests
-rw-r--r--basicConfig/default_config.properties2
-rw-r--r--basicConfig/properties/messages.properties (renamed from basicConfig/properties/messages_en.properties)10
-rw-r--r--basicConfig/properties/messages_de.properties11
-rw-r--r--basicConfig/templates/countrySelection.html237
-rw-r--r--connector/src/main/java/at/asitplus/eidas/specific/connector/config/StaticResourceConfiguration.java1
-rw-r--r--connector/src/main/resources/specific_eIDAS_connector.beans.xml28
-rw-r--r--connector/src/main/resources/specific_eIDAS_connector.storage.beans.xml4
-rw-r--r--connector/src/test/java/at/asitplus/eidas/specific/connector/test/task/EvaluateCountrySelectionTaskTest.java191
-rw-r--r--connector/src/test/java/at/asitplus/eidas/specific/connector/test/task/GenerateCountrySelectionFrameTaskTest.java146
-rw-r--r--connector/src/test/resources/spring/SpringTest-context_simple_storage.xml15
10 files changed, 628 insertions, 17 deletions
diff --git a/basicConfig/default_config.properties b/basicConfig/default_config.properties
index 81ce2f6a..4cb6fa0a 100644
--- a/basicConfig/default_config.properties
+++ b/basicConfig/default_config.properties
@@ -17,7 +17,7 @@ eidas.ms.revisionlog.logIPAddressOfUser=true
eidas.ms.webcontent.static.directory=webcontent/
eidas.ms.webcontent.templates=templates/
eidas.ms.webcontent.properties=properties/messages
-eidas.ms.webcontent.templates.countryselection=countrySelection_example.html
+eidas.ms.webcontent.templates.countryselection=countrySelection.html
## extended validation of pending-request Id's
eidas.ms.core.pendingrequestid.maxlifetime=300
diff --git a/basicConfig/properties/messages_en.properties b/basicConfig/properties/messages.properties
index 0d312c75..ea604cda 100644
--- a/basicConfig/properties/messages_en.properties
+++ b/basicConfig/properties/messages.properties
@@ -21,6 +21,16 @@ gui.countryselection.header.selection=Select your country
gui.countryselection.cancle=Cancel
gui.countryselection.notsupportedinfo=If you cannot find your country in this list then your electronic identity (eID) is not yet supported.
+gui.countryselection.infos.general.header=Information on Logins with European eIDs
+gui.countryselection.infos.general.link.1=eIDAS regulation of the European Union
+gui.countryselection.infos.general.link.2=Austrian Supplementary Register for Natural Persons (ERnP)
+gui.countryselection.infos.general.part.1=This is the central eIDAS node of the Republic of Austria, operated by the
+gui.countryselection.infos.general.part.2=It enables logins at Austrian online services using an electronic identity (eID) of another EU member state. You have been redirected to this page, as you have initiated a login to an online service using the option "EU Login".
+gui.countryselection.infos.general.part.3=The central eIDAS node of the Republic of Austria allows you to login to Austrian online services using the eID of your home country. This way, compliance with the
+gui.countryselection.infos.general.part.4=, which regulates the mutual cross-border acceptance of national eIDs, is achieved. The mutual cross-border acceptance of national eIDs is implemented successively within the EU. Currently, the central eIDAS node of the Republic of Austria supports logins using the eID systems of the Member States mentioned above. More Member States will be added according to availability of their respective eID solutions.
+gui.countryselection.infos.general.part.5=After selecting your home country on this page, you are forwarded to the familiar login environment of the selected member state. There, you can login with your eID as usual. After successful completion of the login process, you are automatically forwarded and logged in to the online service, from which you have been redirected to this page. During your first login, your eID data is also registered in the
+gui.countryselection.infos.general.part.6=This ensures that you will also be successfully and uniquely identified in subsequent logins at Austrian online services.
+
gui.countryselection.country.be=Belgium
gui.countryselection.country.be.logo.alt=Belgium-eID
gui.countryselection.country.hr=Croatia
diff --git a/basicConfig/properties/messages_de.properties b/basicConfig/properties/messages_de.properties
index 945e66fd..989b8d9c 100644
--- a/basicConfig/properties/messages_de.properties
+++ b/basicConfig/properties/messages_de.properties
@@ -21,6 +21,17 @@ gui.countryselection.header.selection=Wählen Sie Ihr Land
gui.countryselection.cancle=Abbrechen
gui.countryselection.notsupportedinfo=Wenn Sie Ihr Land in dieser Aufzählung nicht entdecken, dann wird Ihre elektronische Identität (eID) leider noch nicht unterstützt.
+gui.countryselection.infos.general.header=Information zur Anmeldung über Europäische eIDs
+gui.countryselection.infos.general.link.1=eIDAS-Verordnung der Europäischen Union
+gui.countryselection.infos.general.link.2=Ergänzungsregister für natürliche Personen (ERnP)
+gui.countryselection.infos.general.part.1=Sie befinden sich am zentralen eIDAS-Knoten der Republik Österreich. Dieser wird vom Österreichischen
+gui.countryselection.infos.general.part.2=betrieben und ermöglicht eine Anmeldungen zu österreichischen Online-Anwendungen unter Verwendung einer elektronischen Identität (eID) anderer EU-Mitgliedstaaten. Sie wurden hierher weitergeleitet, da Sie in einer Online-Anwendung eine Anmeldung via EU-Login initiiert haben.
+gui.countryselection.infos.general.part.3=Der zentrale eIDAS-Knoten der Republik Österreich ermöglicht Ihnen eine Anmeldung zu österreichischen Online-Anwendungen mit der eID Ihres Herkunftsstaates. Damit werden die Vorgaben der
+gui.countryselection.infos.general.part.4=erfüllt, die eine staatenübergreifende Akzeptanz nationaler eIDs vorsieht. Die wechselseitige Anerkennung nationaler eIDs erfolgt in der EU schrittweise. Aktuell unterstützt der zentrale eIDAS-Knoten der Republik Österreich Anmeldungen mit den eID-Systemen der oben angeführten Mitgliedstaaten. Diese Liste wird laufend erweitert.
+gui.countryselection.infos.general.part.5=Nachdem Sie auf dieser Seite einen Mitgliedsstaat ausgewählt haben, werden Sie an die gewohnte Anmeldeumgebung des jeweiligen Mitgliedsstaats weitergeleitet. Dort können Sie sich mit Ihrer eID wie gewohnt anmelden. Haben Sie den Anmeldeprozess erfolgreich abgeschlossen, werden Sie automatisch an die Online-Anwendung, von der aus Sie auf diese Auswahlseite gelangt sind, weitergeleitet und dort mit den Identitätsdaten Ihrer eID angemeldet. Gleichzeitig werden Sie bei Ihrer ersten Anmeldung auf diesem Weg mit Ihren eID-Daten in das österreichische
+gui.countryselection.infos.general.part.6=eingetragen. Damit wird sichergestellt, dass Sie auch im Rahmen zukünftiger Anmeldeprozesse zu österreichischen Online-Anwendungen erfolgreich und eindeutig identifiziert werden können.
+
+
gui.countryselection.country.be=Belgien
gui.countryselection.country.be.logo.alt=Belgische-eID
gui.countryselection.country.hr=Kroatien
diff --git a/basicConfig/templates/countrySelection.html b/basicConfig/templates/countrySelection.html
new file mode 100644
index 00000000..0c9b42bf
--- /dev/null
+++ b/basicConfig/templates/countrySelection.html
@@ -0,0 +1,237 @@
+<!DOCTYPE html>
+<html xmlns:th="http://www.thymeleaf.org"
+ xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
+ layout:decorator="fragments/base"
+ th:with="lang=${#locale.language}" th:lang="${lang}">
+
+<head>
+ <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <link rel="stylesheet" href="$contextPath/static/css/css_country.css" th:href="@{/static/css/css_country.css}"/>
+ <title th:text="#{gui.countryselection.title}">eIDAS-Login Länderauswahl</title>
+<script type="text/javascript">
+</script>
+<style>
+body {
+ background-image: none;
+ margin: 0px;
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
+}
+
+div.header {
+ background-color: #e9ecef;
+ padding-top: 28px;
+ padding-left: 137px;
+ padding-right: 137px;
+ padding-bottom: 12px;
+}
+div.titlebar {
+ padding: 0px;
+}
+div.titlebar div {
+}
+.hidden {
+ display: none;
+}
+ul.nav_oben {
+ padding: 0px;
+ margin: 0px;
+ text-align: right;
+ text-transform: uppercase;
+}
+li {
+ display: inline-block;
+}
+div.header a {
+ text-decoration: none;
+ color: black;
+}
+a {
+ text-decoration: none;
+ color: #a22c1c;
+}
+.block {
+ /* override country.css */
+ width: 200px;
+ padding-bottom: 20px;
+}
+@media only screen and (min-width: 1000px) {
+ div.header {
+ padding-left: 137px;
+ padding-right: 137px;
+ }
+ .content {
+ padding-left: 137px;
+ padding-right: 137px;
+ }
+ footer {
+ padding-left: 137px;
+ padding-right: 137px;
+ }
+}
+@media only screen and (max-width: 999px) {
+ div.header {
+ padding-left: 1em;
+ padding-right: 1em;
+ }
+ .content {
+ padding-left: 1em;
+ padding-right: 1em;
+ }
+ footer {
+ padding-left: 1em;
+ padding-right: 1em;
+ }
+}
+
+div.subtitle h1 {
+ padding: 0px;
+ margin: 0px;
+ font-size: 130%;
+ align: right;
+}
+div.subtitle h2 {
+ padding: 0px;
+ margin: 0px;
+ font-size: 115%;
+}
+footer {
+ left: 0;
+ padding-top: 1em;
+ bottom: 0;
+ width: 100%;
+ height: 2em;
+ background-color: rgb(162,44,28);
+ color: white;
+}
+.float {
+ float: left;
+}
+.floatright {
+ float: right;
+}
+.copyright {
+ width: 66%;
+ font-size: 80%;
+}
+#countries {
+ padding-bottom: 40px;
+}
+#country {
+ padding-bottom: 20px;
+}
+input[type=submit] {
+ width: inherit;
+/* text-align: left; */
+}
+form {
+ justify-content: center;
+}
+</style>
+<script type="text/javascript">
+
+/* Element.closest polyfill - https://developer.mozilla.org/en-US/docs/Web/API/Element/closest License: public domain*/
+if (!Element.prototype.matches)
+ Element.prototype.matches = Element.prototype.msMatchesSelector ||
+ Element.prototype.webkitMatchesSelector;
+
+if (!Element.prototype.closest)
+ Element.prototype.closest = function(s) {
+ var el = this;
+ if (!document.documentElement.contains(el)) return null;
+ do {
+ if (el.matches(s)) return el;
+ el = el.parentElement || el.parentNode;
+ } while (el !== null && el.nodeType === 1);
+ return null;
+ };
+
+
+function clickCountryFlag(element) {
+ if (!element) return false;
+
+ var form = element.closest("form");
+
+ if (!form) return false;
+
+ form.submit();
+ return false;
+}
+</script>
+</head>
+<body>
+ <div class="header container">
+ <div class="titlebar">
+ <div>
+ <a href="https://www.bmi.gv.at/" target="_blank" title="Home">
+ <img class="toplogo img-responsive" src="/static/BMI.png" alt="Logo BMI"
+ th:attr="alt=#{gui.countryselection.logo.bmi.alt}">
+ <h1 class="hidden" th:text="#{gui.countryselection.header1}"> Bundesministerium für Inneres </h1>
+ </a>
+ </div>
+ <ul class="nav_oben">
+ <li>
+ <div class="languageselection" th:include="language_selection :: selectlanguage">
+ LanguageSelectionBlock
+ </div>
+ </li>
+ &nbsp; &nbsp;
+ <li><a href="https://www.bmi.gv.at/" target="_blank" th:text="#{gui.countryselection.link.bmi}" > Startseite BMI </a></li>
+ </ul>
+ </div>
+ </div>
+ <div class="content">
+ <div class="subtitle">
+ <h1 th:text="#{gui.countryselection.header2}" > Zentraler eIDAS Knoten der Republik Österreich </h1>
+ <h2 th:text="#{gui.countryselection.header3}" > Betrieben durch das Bundesministerium für Inneres </h2>
+ </div>
+
+ <h1 th:text="#{gui.countryselection.header.selection}"> Wählen Sie Ihr Land / Select your country </h1>
+
+ <div id="country">
+ <!-- Active countries -->
+ <form class="block" method="post" action="$contextPath$submitEndpoint" th:attr="action=@{${submitEndpoint}}">
+ <a><img class="countryimage" src="$contextPath/img/countries/germany-eu_.png" alt="Germany-eID"
+ th:attr="src=@{/img/countries/germany-eu_.png},alt=#{gui.countryselection.country.de.logo.alt}"/></a>
+ <input type="submit" role="button" value="Deutschland / Germany" th:attr="value=#{gui.countryselection.country.de}" />
+ <input type="hidden" name="selectedCountry" value="XX">
+ <input type="hidden" name="pendingid" value="$pendingid" th:attr="value=${pendingid}" />
+ </form>
+
+ </div>
+
+ <!-- Abbrechen Button -->
+ <form class="block" method="post" action="$contextPath$submitEndpoint" th:attr="action=@{${submitEndpoint}}">
+ <input type="submit" class="btn btn-outline-primary btn-block" value="Abbrechen/Cancel" th:attr="value=#{gui.countryselection.cancle}">
+ <input type="hidden" name="stopAuthProcess" value="true" >
+ <input type="hidden" name="pendingid" value="$pendingid" th:attr="value=${pendingid}">
+ </form>
+
+ <p th:text="#{gui.countryselection.notsupportedinfo}" >Wenn Sie Ihr Land in dieser Aufzählung nicht entdecken ... </p>
+
+<h2 th:text="#{gui.countryselection.infos.general.header}" > Information zur Anmeldung über Europäische eIDs </h2>
+<p>
+ <span th:text="#{gui.countryselection.infos.general.part.1}" > first part </span>
+ <a href="https://www.bmi.gv.at/" target="_blank" th:text="#{gui.countryselection.header1}" > Bundesministerium für Inneres </a>
+ <span th:text="#{gui.countryselection.infos.general.part.2}" > second part </span>
+</p>
+
+<p>
+ <span th:text="#{gui.countryselection.infos.general.part.3}" > third part </span>
+ <a href="https://eur-lex.europa.eu/legal-content/DE/TXT/HTML/?uri=CELEX:32014R0910&from=DE" target="_blank" th:text="#{gui.countryselection.infos.general.link.1}"> eIDAS-Verordnung der Europäischen Union </a>
+ <span th:text="#{gui.countryselection.infos.general.part.4}" > fourth part </span>
+</p>
+
+<p
+ <span th:text="#{gui.countryselection.infos.general.part.5}" > fived part </span>
+ <a href="https://www.dsb.gv.at/-/das-erganzungsregister-fur-naturliche-personen-ernp-" target="_blank" th:text="#{gui.countryselection.infos.general.link.2}" ></a>
+ <span th:text="#{gui.countryselection.infos.general.part.6}" > sixed part </span>
+</p>
+
+ </div>
+ <footer>
+ <div class="copyright">&copy; BUNDESMINISTERIUM FÜR INNERES</div>
+ <div></div>
+ </footer>
+</body>
+</html>
diff --git a/connector/src/main/java/at/asitplus/eidas/specific/connector/config/StaticResourceConfiguration.java b/connector/src/main/java/at/asitplus/eidas/specific/connector/config/StaticResourceConfiguration.java
index 81ab02ce..e3931afe 100644
--- a/connector/src/main/java/at/asitplus/eidas/specific/connector/config/StaticResourceConfiguration.java
+++ b/connector/src/main/java/at/asitplus/eidas/specific/connector/config/StaticResourceConfiguration.java
@@ -123,6 +123,7 @@ public class StaticResourceConfiguration implements WebMvcConfigurer {
final String absPath = FileUtils.makeAbsoluteUrl(staticResources, basicConfig
.getConfigurationRootDirectory());
messageSource.setBasename(absPath);
+ messageSource.setFallbackToSystemLocale(false);
} else {
log.debug("No Ressourcefolder for dynamic Web content templates");
diff --git a/connector/src/main/resources/specific_eIDAS_connector.beans.xml b/connector/src/main/resources/specific_eIDAS_connector.beans.xml
index e7a46657..5cf0d5b8 100644
--- a/connector/src/main/resources/specific_eIDAS_connector.beans.xml
+++ b/connector/src/main/resources/specific_eIDAS_connector.beans.xml
@@ -23,7 +23,7 @@
<bean id="MonitoringController"
class="at.asitplus.eidas.specific.connector.controller.MonitoringController">
- <property name="pvpIDPCredentials">
+ <property name="pvpIdpCredentials">
<ref bean="PVPEndPointCredentialProvider" />
</property>
</bean>
@@ -35,17 +35,17 @@
class="at.asitplus.eidas.specific.connector.builder.AuthenticationDataBuilder" />
<bean id="PVPEndPointConfiguration"
- class="at.asitplus.eidas.specific.connector.config.PVPEndPointConfiguration" />
+ class="at.asitplus.eidas.specific.connector.config.PvpEndPointConfiguration" />
<bean id="PVPEndPointCredentialProvider"
- class="at.asitplus.eidas.specific.connector.provider.PVPEndPointCredentialProvider" />
+ class="at.asitplus.eidas.specific.connector.provider.PvpEndPointCredentialProvider" />
<bean id="PVPMetadataConfigurationFactory"
- class="at.asitplus.eidas.specific.connector.provider.PVPMetadataConfigurationFactory" />
+ class="at.asitplus.eidas.specific.connector.provider.PvpMetadataConfigurationFactory" />
<bean id="PVP2XProtocol"
- class="at.asitplus.eidas.specific.connector.controller.PVP2SProfileEndpoint">
- <property name="pvpIDPCredentials">
+ class="at.asitplus.eidas.specific.connector.controller.Pvp2SProfileEndpoint">
+ <property name="pvpIdpCredentials">
<ref bean="PVPEndPointCredentialProvider" />
</property>
</bean>
@@ -54,18 +54,18 @@
class="at.asitplus.eidas.specific.connector.verification.AuthnRequestValidator" />
<bean id="SAMLVerificationEngine"
- class="at.gv.egiz.eaaf.modules.pvp2.impl.verification.SAMLVerificationEngine" />
+ class="at.gv.egiz.eaaf.modules.pvp2.impl.verification.SamlVerificationEngine" />
<bean id="pvpMetadataService"
class="at.gv.egiz.eaaf.modules.pvp2.idp.impl.MetadataAction">
- <property name="pvpIDPCredentials">
+ <property name="pvpIdpCredentials">
<ref bean="PVPEndPointCredentialProvider" />
</property>
</bean>
<bean id="PVPAuthenticationRequestAction"
class="at.gv.egiz.eaaf.modules.pvp2.idp.impl.AuthenticationAction">
- <property name="pvpIDPCredentials">
+ <property name="pvpIdpCredentials">
<ref bean="PVPEndPointCredentialProvider" />
</property>
</bean>
@@ -79,22 +79,22 @@
class="at.gv.egiz.eaaf.core.impl.utils.SecurePendingRequestIdGenerationStrategy" />
<bean id="PVPMetadataProvider"
- class="at.asitplus.eidas.specific.connector.provider.PVPMetadataProvider" />
+ class="at.asitplus.eidas.specific.connector.provider.PvpMetadataProvider" />
<bean id="PVPSubjectNameGenerator"
- class="at.asitplus.eidas.specific.connector.builder.PVPSubjectNameGenerator" />
+ class="at.asitplus.eidas.specific.connector.builder.PvpSubjectNameGenerator" />
<bean id="LoALevelMapper"
class="at.asitplus.eidas.specific.connector.mapper.LoALevelMapper" />
<bean id="GUIBuilderConfigurationFactory"
- class="at.asitplus.eidas.specific.connector.gui.GUIBuilderConfigurationFactory" />
+ class="at.asitplus.eidas.specific.connector.gui.GuiBuilderConfigurationFactory" />
<bean id="velocityGUIBuilderImpl"
- class="at.asitplus.eidas.specific.connector.gui.DefaultVelocityGUIBuilderImpl" />
+ class="at.asitplus.eidas.specific.connector.gui.DefaultVelocityGuiBuilderImpl" />
<bean id="mvcGUIBuilderImpl"
- class="at.asitplus.eidas.specific.connector.gui.SpringMVCGUIFormBuilderImpl" />
+ class="at.asitplus.eidas.specific.connector.gui.SpringMvcGuiFormBuilderImpl" />
<bean id="templateEngine"
class="org.thymeleaf.spring5.SpringTemplateEngine">
diff --git a/connector/src/main/resources/specific_eIDAS_connector.storage.beans.xml b/connector/src/main/resources/specific_eIDAS_connector.storage.beans.xml
index 9ee5cf88..08c7b672 100644
--- a/connector/src/main/resources/specific_eIDAS_connector.storage.beans.xml
+++ b/connector/src/main/resources/specific_eIDAS_connector.storage.beans.xml
@@ -18,10 +18,10 @@
/> -->
<bean id="eIDASCacheTransactionStoreDecorator"
- class="at.asitplus.eidas.specific.connector.storage.eIDASCacheTransactionStoreDecorator" />
+ class="at.asitplus.eidas.specific.connector.storage.EidasCacheTransactionStoreDecorator" />
<bean id="CacheWitheIDASBackend"
- class="at.asitplus.eidas.specific.connector.storage.CacheWitheIDASBackend">
+ class="at.asitplus.eidas.specific.connector.storage.CacheWithEidasBackend">
<constructor-arg ref="msNodeCacheImpl" />
</bean>
diff --git a/connector/src/test/java/at/asitplus/eidas/specific/connector/test/task/EvaluateCountrySelectionTaskTest.java b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/task/EvaluateCountrySelectionTaskTest.java
new file mode 100644
index 00000000..44b54366
--- /dev/null
+++ b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/task/EvaluateCountrySelectionTaskTest.java
@@ -0,0 +1,191 @@
+package at.asitplus.eidas.specific.connector.test.task;
+
+import java.io.UnsupportedEncodingException;
+
+import org.apache.commons.lang3.RandomStringUtils;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.i18n.LocaleContextHolder;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.mock.web.MockHttpServletResponse;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.web.WebAppConfiguration;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import at.asitplus.eidas.specific.connector.MsEidasNodeConstants;
+import at.asitplus.eidas.specific.connector.processes.tasks.EvaluateCountrySelectionTask;
+import at.gv.egiz.eaaf.core.api.data.EaafConstants;
+import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException;
+import at.gv.egiz.eaaf.core.impl.idp.controller.tasks.AbstractLocaleAuthServletTask;
+import at.gv.egiz.eaaf.core.impl.idp.module.test.TestRequestImpl;
+import at.gv.egiz.eaaf.core.impl.idp.process.ExecutionContextImpl;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration({
+ "/applicationContext.xml",
+ "/specific_eIDAS_connector.beans.xml",
+ "/eaaf_core.beans.xml",
+ "/eaaf_pvp.beans.xml",
+ "/eaaf_pvp_idp.beans.xml",
+ "/spring/SpringTest-context_simple_storage.xml" })
+@WebAppConfiguration
+public class EvaluateCountrySelectionTaskTest {
+
+ @Autowired private EvaluateCountrySelectionTask task;
+
+ private ExecutionContextImpl executionContext = new ExecutionContextImpl();
+ private TestRequestImpl pendingReq;
+ private MockHttpServletRequest httpReq;
+ private MockHttpServletResponse httpResp;
+
+ /**
+ * jUnit class initializer.
+ *
+ */
+ @BeforeClass
+ public static void classInitializer() {
+ final String current = new java.io.File(".").toURI().toString();
+ System.setProperty("eidas.ms.configuration", current + "../basicConfig/default_config.properties");
+
+ }
+
+ /**
+ * jUnit test set-up.
+ *
+ */
+ @Before
+ public void initialize() {
+ httpReq = new MockHttpServletRequest("POST", "https://localhost/ms_connector");
+ httpResp = new MockHttpServletResponse();
+ RequestContextHolder.resetRequestAttributes();
+ RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(httpReq, httpResp));
+
+ pendingReq = new TestRequestImpl();
+ pendingReq.setAuthUrl("https://localhost/ms_connector");
+ pendingReq.setPendingReqId(RandomStringUtils.randomAlphanumeric(10));
+
+ LocaleContextHolder.resetLocaleContext();
+ }
+
+ @Test
+ public void withoutCountrySelection() throws TaskExecutionException, UnsupportedEncodingException {
+
+
+ task.execute(pendingReq, executionContext);
+
+ //result validation
+ Assert.assertFalse("wrong pendingReq auth flag", pendingReq.isAuthenticated());
+ Assert.assertFalse("wrong process-cancelled flag", executionContext.isProcessCancelled());
+ Assert.assertEquals("wrong change-language flag", false,
+ executionContext.get(EaafConstants.PROCESSCONTEXT_SWITCH_LANGUAGE));
+ Assert.assertNull("Country-selection found",
+ executionContext.get(MsEidasNodeConstants.REQ_PARAM_SELECTED_COUNTRY));
+ Assert.assertNull("Environment-selection found",
+ executionContext.get(MsEidasNodeConstants.REQ_PARAM_SELECTED_ENVIRONMENT));
+
+ }
+
+ @Test
+ public void withCountrySelection() throws TaskExecutionException, UnsupportedEncodingException {
+ String ccc = RandomStringUtils.randomAlphabetic(2);
+ httpReq.setParameter(MsEidasNodeConstants.REQ_PARAM_SELECTED_COUNTRY, ccc);
+
+ task.execute(pendingReq, executionContext);
+
+ //result validation
+ Assert.assertFalse("wrong pendingReq auth flag", pendingReq.isAuthenticated());
+ Assert.assertFalse("wrong process-cancelled flag", executionContext.isProcessCancelled());
+ Assert.assertEquals("wrong change-language flag", false,
+ executionContext.get(EaafConstants.PROCESSCONTEXT_SWITCH_LANGUAGE));
+ Assert.assertNotNull("no Country-selection found",
+ executionContext.get(MsEidasNodeConstants.REQ_PARAM_SELECTED_COUNTRY));
+ Assert.assertEquals("Wrong country found", ccc,
+ executionContext.get(MsEidasNodeConstants.REQ_PARAM_SELECTED_COUNTRY));
+
+ Assert.assertNull("Environment-selection found",
+ executionContext.get(MsEidasNodeConstants.REQ_PARAM_SELECTED_ENVIRONMENT));
+
+ }
+
+ @Test
+ public void withCountrySelectionAndEnvironment()
+ throws TaskExecutionException, UnsupportedEncodingException {
+ String ccc = RandomStringUtils.randomAlphabetic(2);
+ String environment = RandomStringUtils.randomAlphabetic(5);
+ httpReq.setParameter(MsEidasNodeConstants.REQ_PARAM_SELECTED_COUNTRY, ccc);
+ httpReq.setParameter(MsEidasNodeConstants.REQ_PARAM_SELECTED_ENVIRONMENT, environment);
+
+ task.execute(pendingReq, executionContext);
+
+ //result validation
+ Assert.assertFalse("wrong pendingReq auth flag", pendingReq.isAuthenticated());
+ Assert.assertFalse("wrong process-cancelled flag", executionContext.isProcessCancelled());
+ Assert.assertEquals("wrong change-language flag", false,
+ executionContext.get(EaafConstants.PROCESSCONTEXT_SWITCH_LANGUAGE));
+ Assert.assertNotNull("no Country-selection found",
+ executionContext.get(MsEidasNodeConstants.REQ_PARAM_SELECTED_COUNTRY));
+ Assert.assertEquals("Wrong country found", ccc,
+ executionContext.get(MsEidasNodeConstants.REQ_PARAM_SELECTED_COUNTRY));
+
+ Assert.assertNotNull("No environment-selection found",
+ executionContext.get(MsEidasNodeConstants.REQ_PARAM_SELECTED_ENVIRONMENT));
+ Assert.assertEquals("Wrong environment-selection", environment,
+ executionContext.get(MsEidasNodeConstants.REQ_PARAM_SELECTED_ENVIRONMENT));
+
+ }
+
+ @Test
+ public void withCountrySelectionAndEnvironmentAndLangSelection()
+ throws TaskExecutionException, UnsupportedEncodingException {
+ String ccc = RandomStringUtils.randomAlphabetic(2);
+ String environment = RandomStringUtils.randomAlphabetic(5);
+ String lang = RandomStringUtils.randomAlphabetic(2);
+ httpReq.setParameter(MsEidasNodeConstants.REQ_PARAM_SELECTED_COUNTRY, ccc);
+ httpReq.setParameter(MsEidasNodeConstants.REQ_PARAM_SELECTED_ENVIRONMENT, environment);
+ httpReq.setParameter(AbstractLocaleAuthServletTask.PROP_REQ_PARAM_LOCALE, lang);
+
+ task.execute(pendingReq, executionContext);
+
+ //result validation
+ Assert.assertFalse("wrong pendingReq auth flag", pendingReq.isAuthenticated());
+ Assert.assertFalse("wrong process-cancelled flag", executionContext.isProcessCancelled());
+ Assert.assertEquals("wrong change-language flag", true,
+ executionContext.get(EaafConstants.PROCESSCONTEXT_SWITCH_LANGUAGE));
+ Assert.assertNull("Country-selection found",
+ executionContext.get(MsEidasNodeConstants.REQ_PARAM_SELECTED_COUNTRY));
+ Assert.assertNull("Environment-selection found",
+ executionContext.get(MsEidasNodeConstants.REQ_PARAM_SELECTED_ENVIRONMENT));
+
+ }
+
+ @Test
+ public void withCountrySelectionAndEnvironmentAndStopSelection()
+ throws TaskExecutionException, UnsupportedEncodingException {
+ String ccc = RandomStringUtils.randomAlphabetic(2);
+ String environment = RandomStringUtils.randomAlphabetic(5);
+ httpReq.setParameter(MsEidasNodeConstants.REQ_PARAM_SELECTED_COUNTRY, ccc);
+ httpReq.setParameter(MsEidasNodeConstants.REQ_PARAM_SELECTED_ENVIRONMENT, environment);
+ httpReq.setParameter(EaafConstants.PARAM_HTTP_STOP_PROCESS, "true");
+
+ task.execute(pendingReq, executionContext);
+
+ //result validation
+ Assert.assertTrue("wrong process-cancelled flag", executionContext.isProcessCancelled());
+ Assert.assertTrue("wrong pendingReq stop flag", pendingReq.isAbortedByUser());
+ Assert.assertFalse("wrong pendingReq auth flag", pendingReq.isAuthenticated());
+
+ Assert.assertEquals("wrong change-language flag", false,
+ executionContext.get(EaafConstants.PROCESSCONTEXT_SWITCH_LANGUAGE));
+ Assert.assertNull("Country-selection found",
+ executionContext.get(MsEidasNodeConstants.REQ_PARAM_SELECTED_COUNTRY));
+ Assert.assertNull("Environment-selection found",
+ executionContext.get(MsEidasNodeConstants.REQ_PARAM_SELECTED_ENVIRONMENT));
+
+ }
+}
diff --git a/connector/src/test/java/at/asitplus/eidas/specific/connector/test/task/GenerateCountrySelectionFrameTaskTest.java b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/task/GenerateCountrySelectionFrameTaskTest.java
new file mode 100644
index 00000000..61d68774
--- /dev/null
+++ b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/task/GenerateCountrySelectionFrameTaskTest.java
@@ -0,0 +1,146 @@
+package at.asitplus.eidas.specific.connector.test.task;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Locale;
+
+import org.apache.commons.lang3.RandomStringUtils;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.i18n.LocaleContextHolder;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.mock.web.MockHttpServletResponse;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.web.WebAppConfiguration;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import at.asitplus.eidas.specific.connector.processes.tasks.GenerateCountrySelectionFrameTask;
+import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException;
+import at.gv.egiz.eaaf.core.impl.idp.module.test.TestRequestImpl;
+import at.gv.egiz.eaaf.core.impl.idp.process.ExecutionContextImpl;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration({
+ "/applicationContext.xml",
+ "/specific_eIDAS_connector.beans.xml",
+ "/eaaf_core.beans.xml",
+ "/eaaf_pvp.beans.xml",
+ "/eaaf_pvp_idp.beans.xml",
+ "/spring/SpringTest-context_simple_storage.xml" })
+@WebAppConfiguration
+public class GenerateCountrySelectionFrameTaskTest {
+
+ @Autowired private GenerateCountrySelectionFrameTask task;
+
+ private ExecutionContextImpl executionContext = new ExecutionContextImpl();
+ private TestRequestImpl pendingReq;
+ private MockHttpServletRequest httpReq;
+ private MockHttpServletResponse httpResp;
+
+ /**
+ * jUnit class initializer.
+ *
+ */
+ @BeforeClass
+ public static void classInitializer() {
+ final String current = new java.io.File(".").toURI().toString();
+ System.setProperty("eidas.ms.configuration", current + "../basicConfig/default_config.properties");
+
+ }
+
+ /**
+ * jUnit test set-up.
+ *
+ */
+ @Before
+ public void initialize() {
+ httpReq = new MockHttpServletRequest("POST", "https://localhost/ms_connector");
+ httpResp = new MockHttpServletResponse();
+ RequestContextHolder.resetRequestAttributes();
+ RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(httpReq, httpResp));
+
+ pendingReq = new TestRequestImpl();
+ pendingReq.setAuthUrl("https://localhost/ms_connector");
+ pendingReq.setPendingReqId(RandomStringUtils.randomAlphanumeric(10));
+
+ LocaleContextHolder.resetLocaleContext();
+ }
+
+ @Test
+ public void validHtmlResponseWithOutLocale() throws TaskExecutionException, UnsupportedEncodingException {
+
+ task.execute(pendingReq, executionContext);
+
+ //result validation
+ String html = doBasicValidation();
+
+ Assert.assertTrue("No english text",
+ html.contains("Information on Logins with European eIDs"));
+
+ }
+
+ @Test
+ public void validHtmlResponseWithDE() throws TaskExecutionException, UnsupportedEncodingException {
+ LocaleContextHolder.setLocale(Locale.GERMAN);
+ httpReq.addHeader("Accept-Language", "de");
+
+ task.execute(pendingReq, executionContext);
+
+ //result validation
+ String html = doBasicValidation();
+
+ Assert.assertTrue("No english text",
+ html.contains("Information zur Anmeldung über Europäische eIDs"));
+
+ }
+
+ @Test
+ public void validHtmlResponseWithEN() throws TaskExecutionException, UnsupportedEncodingException {
+ LocaleContextHolder.setLocale(Locale.ENGLISH);
+
+ task.execute(pendingReq, executionContext);
+
+ //result validation
+ String html = doBasicValidation();
+
+ Assert.assertTrue("No english text",
+ html.contains("Information on Logins with European eIDs"));
+
+ }
+
+ @Test
+ public void validHtmlResponseWithFR() throws TaskExecutionException, UnsupportedEncodingException {
+ LocaleContextHolder.setLocale(Locale.FRANCE);
+ httpReq.addHeader("Accept-Language", "fr");
+
+ task.execute(pendingReq, executionContext);
+
+ //result validation
+ String html = doBasicValidation();
+
+ Assert.assertTrue("No english text",
+ html.contains("Information on Logins with European eIDs"));
+
+ }
+
+ private String doBasicValidation() throws UnsupportedEncodingException {
+ Assert.assertEquals("Wrong http StatusCode", 200, httpResp.getStatus());
+ Assert.assertEquals("Wrong http ContentType", "text/html;charset=UTF-8", httpResp.getContentType());
+
+ String html = httpResp.getContentAsString();
+ Assert.assertNotNull("html result is null", html);
+ Assert.assertFalse("html result is empty", html.isEmpty());
+ Assert.assertTrue("No language selector with pendingRequestId",
+ html.contains("/myHomeCountry?pendingid=" + pendingReq.getPendingRequestId()));
+ Assert.assertTrue("No country-selection form",
+ html.contains("<form class=\"block\" method=\"post\" action=\"/myHomeCountry\">"));
+
+ return html;
+
+ }
+}
diff --git a/connector/src/test/resources/spring/SpringTest-context_simple_storage.xml b/connector/src/test/resources/spring/SpringTest-context_simple_storage.xml
new file mode 100644
index 00000000..5ee3e0b8
--- /dev/null
+++ b/connector/src/test/resources/spring/SpringTest-context_simple_storage.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:tx="http://www.springframework.org/schema/tx"
+ xmlns:aop="http://www.springframework.org/schema/aop"
+ xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
+ http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
+
+ <bean id="SimpleInMemoryTransactionStorage"
+ class="at.asitplus.eidas.specific.connector.storage.SimpleInMemoryTransactionStorage" />
+
+</beans> \ No newline at end of file