aboutsummaryrefslogtreecommitdiff
path: root/id/server/modules/moa-id-module-E-ID_connector
diff options
context:
space:
mode:
authorThomas Lenz <tlenz@iaik.tugraz.at>2020-07-07 15:27:03 +0200
committerThomas Lenz <tlenz@iaik.tugraz.at>2020-07-07 15:27:03 +0200
commite9fa374738cf1bbc84b36c50bba898892d2c1688 (patch)
treea9a26d836f94a6e3cded80030aa6a1b411a0aab8 /id/server/modules/moa-id-module-E-ID_connector
parenta056118bbfabb53dc2856ff07d068cd57ddc8be3 (diff)
parent0e6a03ffbc11d07ee2d00abcd573239a971f89b5 (diff)
downloadmoa-id-spss-e9fa374738cf1bbc84b36c50bba898892d2c1688.tar.gz
moa-id-spss-e9fa374738cf1bbc84b36c50bba898892d2c1688.tar.bz2
moa-id-spss-e9fa374738cf1bbc84b36c50bba898892d2c1688.zip
Merge branch 'development_preview'
Diffstat (limited to 'id/server/modules/moa-id-module-E-ID_connector')
-rw-r--r--id/server/modules/moa-id-module-E-ID_connector/pom.xml2
-rw-r--r--id/server/modules/moa-id-module-E-ID_connector/src/main/java/at/gv/egovernment/moa/id/auth/modules/eidproxyauth/EIDProxyAuthConstants.java6
-rw-r--r--id/server/modules/moa-id-module-E-ID_connector/src/main/java/at/gv/egovernment/moa/id/auth/modules/eidproxyauth/controller/EidAppRegIdentifierGenerationController.java113
-rw-r--r--id/server/modules/moa-id-module-E-ID_connector/src/main/java/at/gv/egovernment/moa/id/auth/modules/eidproxyauth/tasks/CreateAuthnRequestTask.java3
-rw-r--r--id/server/modules/moa-id-module-E-ID_connector/src/main/java/at/gv/egovernment/moa/id/auth/modules/eidproxyauth/utils/Utils.java17
-rw-r--r--id/server/modules/moa-id-module-E-ID_connector/src/main/resources/moaid_EID_connector.beans.xml5
-rw-r--r--id/server/modules/moa-id-module-E-ID_connector/src/main/resources/templates/appreg_id_generator.html44
7 files changed, 186 insertions, 4 deletions
diff --git a/id/server/modules/moa-id-module-E-ID_connector/pom.xml b/id/server/modules/moa-id-module-E-ID_connector/pom.xml
index 70beb74e4..ac73237ae 100644
--- a/id/server/modules/moa-id-module-E-ID_connector/pom.xml
+++ b/id/server/modules/moa-id-module-E-ID_connector/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>MOA.id.server.modules</groupId>
<artifactId>moa-id-modules</artifactId>
- <version>4.1.2-SNAPSHOT</version>
+ <version>4.1.2</version>
</parent>
<artifactId>moa-id-module-EID_connector</artifactId>
<name>moa-id-module-E-ID_connector</name>
diff --git a/id/server/modules/moa-id-module-E-ID_connector/src/main/java/at/gv/egovernment/moa/id/auth/modules/eidproxyauth/EIDProxyAuthConstants.java b/id/server/modules/moa-id-module-E-ID_connector/src/main/java/at/gv/egovernment/moa/id/auth/modules/eidproxyauth/EIDProxyAuthConstants.java
index b057ecaf8..7fcabca1e 100644
--- a/id/server/modules/moa-id-module-E-ID_connector/src/main/java/at/gv/egovernment/moa/id/auth/modules/eidproxyauth/EIDProxyAuthConstants.java
+++ b/id/server/modules/moa-id-module-E-ID_connector/src/main/java/at/gv/egovernment/moa/id/auth/modules/eidproxyauth/EIDProxyAuthConstants.java
@@ -38,13 +38,14 @@ public class EIDProxyAuthConstants {
public static final String MODULE_NAME_FOR_LOGGING = "E-ID proxy authentication";
- public static final int METADATA_VALIDUNTIL_IN_HOURS = 24;
+ public static final int METADATA_VALIDUNTIL_IN_HOURS = 24 * 365 * 10;
public static final String HTTP_PARAM_EIDPROXY_AUTH_SELECTION = "forwardToEID";
public static final String ENDPOINT_POST = "/sp/eid/post";
public static final String ENDPOINT_REDIRECT = "/sp/eid/redirect";
public static final String ENDPOINT_METADATA = "/sp/eid/metadata";
+ public static final String ENDPOINT_APPREG_INFO = "/eid/getappregid";
public static final String CONFIG_PROPS_PREFIX = "modules.eidproxyauth.";
public static final String CONFIG_PROPS_KEYSTORE = CONFIG_PROPS_PREFIX + "keystore.path";
@@ -61,6 +62,9 @@ public class EIDProxyAuthConstants {
public static final String CONFIG_PROPS_REQUIRED_PVP_ATTRIBUTES_LIST = CONFIG_PROPS_PREFIX + "required.additional.attributes";
public static final String CONFIG_PROPS_DISABLE_PROCESS_ENFORCEMENT = CONFIG_PROPS_PREFIX + "enforce.process.disabled";
+ public static final String CONFIG_PROPS_ENABLE_APPREG_IDENTIFIER_GENERATION_ENDPOINT =
+ CONFIG_PROPS_PREFIX + "endpoint.appreginfo.enable";
+
public static final String CONFIG_DEFAULT_LOA_EIDAS_LEVEL = EAAFConstants.EIDAS_LOA_HIGH;
public static final List<Trible<String, String, Boolean>> DEFAULT_REQUIRED_PVP_ATTRIBUTES =
Collections.unmodifiableList(new ArrayList<Trible<String, String, Boolean>>() {
diff --git a/id/server/modules/moa-id-module-E-ID_connector/src/main/java/at/gv/egovernment/moa/id/auth/modules/eidproxyauth/controller/EidAppRegIdentifierGenerationController.java b/id/server/modules/moa-id-module-E-ID_connector/src/main/java/at/gv/egovernment/moa/id/auth/modules/eidproxyauth/controller/EidAppRegIdentifierGenerationController.java
new file mode 100644
index 000000000..091feb7fc
--- /dev/null
+++ b/id/server/modules/moa-id-module-E-ID_connector/src/main/java/at/gv/egovernment/moa/id/auth/modules/eidproxyauth/controller/EidAppRegIdentifierGenerationController.java
@@ -0,0 +1,113 @@
+package at.gv.egovernment.moa.id.auth.modules.eidproxyauth.controller;
+
+import java.io.IOException;
+import java.net.URL;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import at.gv.egiz.eaaf.core.api.gui.IGUIFormBuilder;
+import at.gv.egiz.eaaf.core.exceptions.EAAFException;
+import at.gv.egiz.eaaf.core.exceptions.GUIBuildException;
+import at.gv.egiz.eaaf.core.exceptions.InvalidProtocolRequestException;
+import at.gv.egiz.eaaf.core.impl.idp.controller.AbstractController;
+import at.gv.egiz.eaaf.core.impl.utils.HTTPUtils;
+import at.gv.egovernment.moa.id.auth.exception.WrongParametersException;
+import at.gv.egovernment.moa.id.auth.frontend.builder.DefaultGUIFormBuilderConfiguration;
+import at.gv.egovernment.moa.id.auth.modules.eidproxyauth.EIDProxyAuthConstants;
+import at.gv.egovernment.moa.id.auth.modules.eidproxyauth.utils.Utils;
+import at.gv.egovernment.moa.id.commons.MOAIDAuthConstants;
+import at.gv.egovernment.moa.id.commons.api.IOAAuthParameters;
+import at.gv.egovernment.moa.id.util.ParamValidatorUtils;
+import at.gv.egovernment.moa.logging.Logger;
+import at.gv.egovernment.moa.util.MiscUtil;
+
+@Controller
+public class EidAppRegIdentifierGenerationController extends AbstractController {
+
+ private static final String GUI_TEMPLATE_APPREG_ID = "appreg_id_generator.html";
+
+ @Autowired IGUIFormBuilder guiBuilder;
+
+
+ @RequestMapping(value = EIDProxyAuthConstants.ENDPOINT_APPREG_INFO,
+ method = {RequestMethod.GET})
+ public void getAppRegSpId(HttpServletRequest req, HttpServletResponse resp) throws IOException, EAAFException {
+ if (!authConfig.getBasicConfigurationBoolean(
+ EIDProxyAuthConstants.CONFIG_PROPS_ENABLE_APPREG_IDENTIFIER_GENERATION_ENDPOINT, true)) {
+ Logger.info("Endpoint: " + EIDProxyAuthConstants.ENDPOINT_APPREG_INFO + " DISABLED!");
+ resp.setStatus(HttpStatus.FORBIDDEN.value());
+ return;
+
+ }
+
+ String authUrl;
+ DefaultGUIFormBuilderConfiguration config;
+ try {
+ String authUrlString = HTTPUtils.extractAuthURLFromRequest(req);
+ URL authReqURL = new URL(authUrlString);
+ authUrl = authConfig.validateIDPURL(authReqURL);
+ config = new DefaultGUIFormBuilderConfiguration(
+ authUrl,
+ GUI_TEMPLATE_APPREG_ID,
+ null);
+
+ } catch (Exception e) {
+ Logger.warn("Bad request on: " + EIDProxyAuthConstants.ENDPOINT_APPREG_INFO, e);
+ resp.setStatus(HttpStatus.BAD_REQUEST.value());
+ resp.getWriter().write(e.getMessage());
+ return;
+
+ }
+
+
+ try {
+ String oaURL = req.getParameter(MOAIDAuthConstants.PARAM_OA);
+ if (MiscUtil.isEmpty(oaURL)) {
+ Logger.info("Receive OA parameter in SAML1 like request. Can not generate AppReg Identifier");
+ throw new WrongParametersException(EIDProxyAuthConstants.ENDPOINT_APPREG_INFO, MOAIDAuthConstants.PARAM_OA,
+ "auth.12");
+
+ }
+
+ if (!ParamValidatorUtils.isValidOA(oaURL))
+ throw new WrongParametersException(EIDProxyAuthConstants.ENDPOINT_APPREG_INFO, MOAIDAuthConstants.PARAM_OA,
+ "auth.12");
+
+ IOAAuthParameters oaParam = authConfig.getServiceProviderConfiguration(oaURL, IOAAuthParameters.class);
+ if (oaParam == null) {
+ Logger.info("No configuration for application with ID: " + oaURL);
+ throw new InvalidProtocolRequestException("auth.00",new Object[] { null });
+
+ }
+
+ String appRegId = Utils.getEidSystemApplicationId(oaParam, authUrl);
+ config.putCustomParameterWithOutEscaption(null, "appregId", appRegId);
+ guiBuilder.build(req, resp, config, "AppReg Id generation GUI");
+
+
+ } catch (Exception e) {
+ Logger.warn("Can not build AppReg Identifier", e);
+ config.putCustomParameterWithOutEscaption(null, "error", e.getMessage());
+ try {
+ guiBuilder.build(req, resp, config, "AppReg Id generation GUI");
+
+ } catch (GUIBuildException e1) {
+ Logger.error("Internal server error", e);
+ resp.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
+
+ }
+
+ }
+
+
+ }
+
+
+}
diff --git a/id/server/modules/moa-id-module-E-ID_connector/src/main/java/at/gv/egovernment/moa/id/auth/modules/eidproxyauth/tasks/CreateAuthnRequestTask.java b/id/server/modules/moa-id-module-E-ID_connector/src/main/java/at/gv/egovernment/moa/id/auth/modules/eidproxyauth/tasks/CreateAuthnRequestTask.java
index 38a7c4add..177103051 100644
--- a/id/server/modules/moa-id-module-E-ID_connector/src/main/java/at/gv/egovernment/moa/id/auth/modules/eidproxyauth/tasks/CreateAuthnRequestTask.java
+++ b/id/server/modules/moa-id-module-E-ID_connector/src/main/java/at/gv/egovernment/moa/id/auth/modules/eidproxyauth/tasks/CreateAuthnRequestTask.java
@@ -112,7 +112,8 @@ public class CreateAuthnRequestTask extends AbstractAuthServletTask {
authnReqConfig.setPassive(false);
authnReqConfig.setSignCred(credential.getIDPAssertionSigningCredential());
authnReqConfig.setSPEntityID(pendingReq.getAuthURL() + EIDProxyAuthConstants.ENDPOINT_METADATA);
- authnReqConfig.setScopeRequesterId(pendingReq.getServiceProviderConfiguration().getUniqueIdentifier());
+ authnReqConfig.setScopeRequesterId(
+ Utils.getEidSystemApplicationId(pendingReq.getServiceProviderConfiguration(), pendingReq.getAuthURL()));
//build and transmit AuthnRequest
authnReqBuilder.buildAuthnRequest(pendingReq, authnReqConfig , response);
diff --git a/id/server/modules/moa-id-module-E-ID_connector/src/main/java/at/gv/egovernment/moa/id/auth/modules/eidproxyauth/utils/Utils.java b/id/server/modules/moa-id-module-E-ID_connector/src/main/java/at/gv/egovernment/moa/id/auth/modules/eidproxyauth/utils/Utils.java
index cd578d373..0de1a9df2 100644
--- a/id/server/modules/moa-id-module-E-ID_connector/src/main/java/at/gv/egovernment/moa/id/auth/modules/eidproxyauth/utils/Utils.java
+++ b/id/server/modules/moa-id-module-E-ID_connector/src/main/java/at/gv/egovernment/moa/id/auth/modules/eidproxyauth/utils/Utils.java
@@ -14,6 +14,23 @@ import at.gv.egovernment.moa.logging.Logger;
public class Utils {
+ public static final String PARAM_APPREG_SP_ID = "?sp=";
+
+ public static String getEidSystemApplicationId(ISPConfiguration spConfiguration, String authUrl) {
+ StringBuilder builder = new StringBuilder();
+ if (authUrl.endsWith("/")) {
+ builder.append(authUrl.substring(0, authUrl.length() - 1));
+
+ } else {
+ builder.append(authUrl);
+
+ }
+ builder.append(PARAM_APPREG_SP_ID);
+ builder.append(spConfiguration.getUniqueIdentifier());
+ return builder.toString();
+
+ }
+
public static String getEIDSystemEntityId(ISPConfiguration spConfiguration, IConfiguration authConfig) {
//load from service-provider configuration
String msNodeEntityID = spConfiguration.getConfigurationValue(MOAIDConfigurationConstants.SERVICE_EXTERNAL_EID_SYSTEM_SERVICE_URL);
diff --git a/id/server/modules/moa-id-module-E-ID_connector/src/main/resources/moaid_EID_connector.beans.xml b/id/server/modules/moa-id-module-E-ID_connector/src/main/resources/moaid_EID_connector.beans.xml
index d5d255680..f357374cb 100644
--- a/id/server/modules/moa-id-module-E-ID_connector/src/main/resources/moaid_EID_connector.beans.xml
+++ b/id/server/modules/moa-id-module-E-ID_connector/src/main/resources/moaid_EID_connector.beans.xml
@@ -14,8 +14,11 @@
<bean id="EidAuthCredentialProvider"
class="at.gv.egovernment.moa.id.auth.modules.eidproxyauth.utils.EIDAuthCredentialProvider"/>
+ <bean id="appRegIdGenerationController"
+ class="at.gv.egovernment.moa.id.auth.modules.eidproxyauth.controller.EidAppRegIdentifierGenerationController" />
+
<bean id="EidAuthMetadataController"
- class="at.gv.egovernment.moa.id.auth.modules.eidproxyauth.controller.EIDAuthMetadataController"/>
+ class="at.gv.egovernment.moa.id.auth.modules.eidproxyauth.controller.EIDAuthMetadataController"/>
<bean id="EidAuthModuleImpl"
class="at.gv.egovernment.moa.id.auth.modules.eidproxyauth.EIDProxyAuthModuleImpl">
diff --git a/id/server/modules/moa-id-module-E-ID_connector/src/main/resources/templates/appreg_id_generator.html b/id/server/modules/moa-id-module-E-ID_connector/src/main/resources/templates/appreg_id_generator.html
new file mode 100644
index 000000000..d214d7663
--- /dev/null
+++ b/id/server/modules/moa-id-module-E-ID_connector/src/main/resources/templates/appreg_id_generator.html
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
+ <!-- MOA-ID 2.x BKUSelection Layout CSS -->
+ <link rel="stylesheet" href="$contextPath/css/buildCSS" />
+
+ <title>Application Id for Application-Register </title>
+</head>
+
+
+<body>
+ <div id="page">
+
+ <div id="page1" class="case selected-case" role="main">
+
+ <div id="main">
+
+ <div id="leftcontent" class="hell">
+ <div id="bku_header" class="dunkel">
+ <h2 id="tabheader" class="dunkel" role="heading">
+ Unique Identifier for Application-Register registration:
+ </h2>
+ </div>
+
+ #if($error)
+ <div>
+ <p><b>Error:</b> $error</p>
+ </div>
+ #end
+
+ #if($appregId)
+ <div id="selectArea" class="hell" role="application">
+ <p><b>Unique AppReg Id:</b> $appregId</p>
+ </div>
+ #end
+
+ </div>
+
+ </div>
+ </div>
+ </div>
+</body>
+</html>