summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Lenz <thomas.lenz@egiz.gv.at>2020-07-01 12:40:24 +0200
committerThomas Lenz <thomas.lenz@egiz.gv.at>2020-07-01 12:40:24 +0200
commitfd6ffb7bf3ffbc00bb96c0eb215d89edbbb021e3 (patch)
tree9d30caea5b5099d1f0fe289b4d44771c6d5f3362
parent234cee5815f8688d45146b792ebe3c8015a7dc74 (diff)
downloadEAAF-Components-fd6ffb7bf3ffbc00bb96c0eb215d89edbbb021e3.tar.gz
EAAF-Components-fd6ffb7bf3ffbc00bb96c0eb215d89edbbb021e3.tar.bz2
EAAF-Components-fd6ffb7bf3ffbc00bb96c0eb215d89edbbb021e3.zip
update log message in case of SL2.0 VDA connection error
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/modules/AbstractAuthServletTask.java39
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/ProtocolAuthenticationService.java43
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/AbstractController.java18
-rw-r--r--eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/tasks/AbstractCreateQualEidRequestTask.java11
-rw-r--r--pom.xml2
5 files changed, 67 insertions, 46 deletions
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/modules/AbstractAuthServletTask.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/modules/AbstractAuthServletTask.java
index 3d093a9f..32d1e66e 100644
--- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/modules/AbstractAuthServletTask.java
+++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/modules/AbstractAuthServletTask.java
@@ -31,17 +31,6 @@ import java.util.Map.Entry;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.apache.commons.fileupload.FileItem;
-import org.apache.commons.fileupload.FileItemFactory;
-import org.apache.commons.fileupload.FileUploadException;
-import org.apache.commons.fileupload.disk.DiskFileItemFactory;
-import org.apache.commons.fileupload.servlet.ServletFileUpload;
-import org.apache.commons.lang3.ArrayUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.core.io.ResourceLoader;
-
import at.gv.egiz.eaaf.core.api.IRequest;
import at.gv.egiz.eaaf.core.api.IRequestStorage;
import at.gv.egiz.eaaf.core.api.data.EaafConstants;
@@ -55,6 +44,17 @@ import at.gv.egiz.eaaf.core.impl.idp.controller.ProtocolFinalizationController;
import at.gv.egiz.eaaf.core.impl.idp.process.springweb.AbstractTask;
import at.gv.egiz.eaaf.core.impl.utils.DataUrlBuilder;
+import org.apache.commons.fileupload.FileItem;
+import org.apache.commons.fileupload.FileItemFactory;
+import org.apache.commons.fileupload.FileUploadException;
+import org.apache.commons.fileupload.disk.DiskFileItemFactory;
+import org.apache.commons.fileupload.servlet.ServletFileUpload;
+import org.apache.commons.lang3.ArrayUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.io.ResourceLoader;
+
/**
* Task based counterpart to {@link AuthServlet}, providing the same utility
* methods (error handling, parameter parsing etc.).
@@ -268,4 +268,21 @@ public abstract class AbstractAuthServletTask extends AbstractTask {
return url + "&" + param;
}
}
+
+ /**
+ * Get a {@link Boolean} parameter from http request.
+ *
+ * @param httpReq http Request object
+ * @param paramName http Parameter name
+ * @return <code>true</code> if the parameter exists and the <code>Boolean.parseBoolean(value)</code>
+ * evaluates to <code>true</code>, otherwise <code>false</code>
+ */
+ protected boolean evaluteBooleanReqParam(final HttpServletRequest httpReq, final String paramName) {
+ final String value = httpReq.getParameter(paramName);
+ if (value != null) {
+ return Boolean.parseBoolean(value);
+ } else {
+ return false;
+ }
+ }
}
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/ProtocolAuthenticationService.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/ProtocolAuthenticationService.java
index fbf19429..72fa1faf 100644
--- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/ProtocolAuthenticationService.java
+++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/ProtocolAuthenticationService.java
@@ -29,17 +29,6 @@ import javax.naming.ConfigurationException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.apache.commons.lang3.ArrayUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.text.StringEscapeUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.ApplicationContext;
-import org.springframework.lang.NonNull;
-import org.springframework.lang.Nullable;
-import org.springframework.stereotype.Service;
-
import at.gv.egiz.components.eventlog.api.EventConstants;
import at.gv.egiz.eaaf.core.api.IRequest;
import at.gv.egiz.eaaf.core.api.IRequestStorage;
@@ -76,6 +65,17 @@ import at.gv.egiz.eaaf.core.impl.idp.controller.ProtocolFinalizationController;
import at.gv.egiz.eaaf.core.impl.idp.controller.protocols.RequestImpl;
import at.gv.egiz.eaaf.core.impl.utils.ServletUtils;
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.text.StringEscapeUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
+import org.springframework.lang.NonNull;
+import org.springframework.lang.Nullable;
+import org.springframework.stereotype.Service;
+
@Service
public class ProtocolAuthenticationService implements IProtocolAuthenticationService {
private static final Logger log = LoggerFactory.getLogger(ProtocolAuthenticationService.class);
@@ -213,7 +213,7 @@ public class ProtocolAuthenticationService implements IProtocolAuthenticationSer
revisionsLogger.logEvent(EventConstants.TRANSACTION_DESTROYED,
pendingReq.getUniqueTransactionIdentifier());
}
-
+
}
@Override
@@ -276,6 +276,7 @@ public class ProtocolAuthenticationService implements IProtocolAuthenticationSer
// return error to Web browser
if (throwable instanceof EaafException || throwable instanceof ProcessExecutionException) {
internalMoaidExceptionHandler(req, resp, (Exception) throwable, false);
+
} else {
// write generic message for general exceptions
final String msg =
@@ -289,34 +290,34 @@ public class ProtocolAuthenticationService implements IProtocolAuthenticationSer
@Override
public void forwardToErrorHandler(Pair<IRequest, Throwable> errorToHandle, String errorKey,
final HttpServletRequest req, final HttpServletResponse resp) throws GuiBuildException {
- IGuiBuilderConfiguration parentHopGuiConfig =
+ final IGuiBuilderConfiguration parentHopGuiConfig =
evaluateRequiredErrorHandlingMethod(errorToHandle.getFirst(), errorKey);
if (parentHopGuiConfig != null) {
log.trace("iFrame to parent hop requested. Building GUI step for error handling ... ");
guiBuilder.build(req, resp, parentHopGuiConfig, "iFrame-to-parent");
-
- } else {
+
+ } else {
// build up redirect URL
final String redirectUrl = generateErrorRedirectUrl(req, errorKey);
resp.setContentType("text/html");
resp.setStatus(302);
resp.addHeader("Location", redirectUrl);
log.debug("REDIRECT TO: " + redirectUrl);
-
+
}
}
-
+
private IGuiBuilderConfiguration evaluateRequiredErrorHandlingMethod(IRequest first, String errorId) {
if (first != null && first.isProcessInIframe()) {
- return guiConfigFactory.getDefaultIFrameParentHopGui(first,
+ return guiConfigFactory.getDefaultIFrameParentHopGui(first,
"/" + ProtocolFinalizationController.ENDPOINT_ERRORHANDLING,
errorId);
-
+
}
return null;
}
-
+
private String generateErrorRedirectUrl(final HttpServletRequest req, String errorKey) {
String redirectUrl = null;
redirectUrl = ServletUtils.getBaseUrl(req);
@@ -325,7 +326,7 @@ public class ProtocolAuthenticationService implements IProtocolAuthenticationSer
return redirectUrl;
}
-
+
public void setGuiBuilder(final IGuiFormBuilder guiBuilder) {
this.guiBuilder = guiBuilder;
}
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/AbstractController.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/AbstractController.java
index fc62af45..e9687833 100644
--- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/AbstractController.java
+++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/AbstractController.java
@@ -26,13 +26,6 @@ import javax.annotation.Nullable;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.apache.commons.text.StringEscapeUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.ApplicationContext;
-import org.springframework.web.bind.annotation.ExceptionHandler;
-
import at.gv.egiz.components.eventlog.api.EventConstants;
import at.gv.egiz.eaaf.core.api.IRequest;
import at.gv.egiz.eaaf.core.api.IStatusMessenger;
@@ -49,6 +42,13 @@ import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException;
import at.gv.egiz.eaaf.core.impl.data.Pair;
import at.gv.egiz.eaaf.core.impl.utils.Random;
+import org.apache.commons.text.StringEscapeUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+
/**
* Basic application controller that implements core error-handling.
*
@@ -69,7 +69,7 @@ public abstract class AbstractController {
protected ITransactionStorage transactionStorage;
@Autowired(required = true)
protected IStatusMessenger statusMessager;
-
+
@Autowired
protected IRevisionLogger revisionsLogger;
@@ -150,8 +150,6 @@ public abstract class AbstractController {
try {
final String errorKey = storeErrorAndGetErrorToken(errorToHandle);
protAuthService.forwardToErrorHandler(errorToHandle, errorKey, req, resp);
-
- return;
} catch (final Exception e) {
log.warn("Default error-handling FAILED. Exception can not be stored ....", e);
diff --git a/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/tasks/AbstractCreateQualEidRequestTask.java b/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/tasks/AbstractCreateQualEidRequestTask.java
index 7fa50e3f..5be5a61f 100644
--- a/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/tasks/AbstractCreateQualEidRequestTask.java
+++ b/eaaf_modules/eaaf_module_auth_sl20/src/main/java/at/gv/egiz/eaaf/modules/auth/sl20/tasks/AbstractCreateQualEidRequestTask.java
@@ -1,6 +1,7 @@
package at.gv.egiz.eaaf.modules.auth.sl20.tasks;
import java.io.Serializable;
+import java.net.ConnectException;
import java.security.cert.CertificateEncodingException;
import java.util.ArrayList;
import java.util.List;
@@ -39,16 +40,15 @@ import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.message.BasicNameValuePair;
import org.jose4j.base64url.Base64Url;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.i18n.LocaleContextHolder;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
+import lombok.extern.slf4j.Slf4j;
+@Slf4j
public abstract class AbstractCreateQualEidRequestTask extends AbstractAuthServletTask {
- private static final Logger log = LoggerFactory.getLogger(AbstractCreateQualEidRequestTask.class);
@Autowired(required = true)
private IHttpClientFactory httpClientFactory;
@@ -186,6 +186,11 @@ public abstract class AbstractCreateQualEidRequestTask extends AbstractAuthServl
} catch (final EaafAuthenticationException e) {
throw new TaskExecutionException(pendingReq, "SL2.0 Authentication FAILED. Msg: " + e.getMessage(), e);
+ } catch (final ConnectException e) {
+ log.error("SL2.0 Authentication has a VDA connector error.", e);
+ throw new TaskExecutionException(pendingReq, e.getMessage(),
+ new SL20Exception("sl20.02", new Object[] { e.getMessage()}, e));
+
} catch (final Exception e) {
log.warn("SL2.0 Authentication FAILED with a generic error.", e);
throw new TaskExecutionException(pendingReq, e.getMessage(), e);
diff --git a/pom.xml b/pom.xml
index 14497582..0732d8bf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -82,7 +82,7 @@
<com.squareup.okhttp3.version>4.4.1</com.squareup.okhttp3.version>
<!-- Code helper plug-ins -->
- <org.projectlombok.lombok.version>1.18.10</org.projectlombok.lombok.version>
+ <org.projectlombok.lombok.version>1.18.12</org.projectlombok.lombok.version>
<!-- Code quality checks -->
<jacoco-maven-plugin.version>0.8.5</jacoco-maven-plugin.version>