aboutsummaryrefslogtreecommitdiff
path: root/id/server/idserverlib/src/main
diff options
context:
space:
mode:
authorThomas Lenz <tlenz@iaik.tugraz.at>2016-02-24 13:19:11 +0100
committerThomas Lenz <tlenz@iaik.tugraz.at>2016-02-24 13:19:11 +0100
commit07e6b72e9f0d3edb1e6295d4c27d1e7675b79543 (patch)
treef3fbfc45191e82e7f1802a453a61f56ab33fdc6e /id/server/idserverlib/src/main
parent5498b94c14a973bc39ca989b97e06987cea9bdf5 (diff)
downloadmoa-id-spss-07e6b72e9f0d3edb1e6295d4c27d1e7675b79543.tar.gz
moa-id-spss-07e6b72e9f0d3edb1e6295d4c27d1e7675b79543.tar.bz2
moa-id-spss-07e6b72e9f0d3edb1e6295d4c27d1e7675b79543.zip
update error messageing into Web-browser
Diffstat (limited to 'id/server/idserverlib/src/main')
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/AbstractController.java42
1 files changed, 34 insertions, 8 deletions
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/AbstractController.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/AbstractController.java
index 8c0708fd5..49035aba3 100644
--- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/AbstractController.java
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/AbstractController.java
@@ -56,6 +56,7 @@ import at.gv.egovernment.moa.id.protocols.AbstractAuthProtocolModulController;
import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.AuthnRequestValidatorException;
import at.gv.egovernment.moa.id.storage.ITransactionStorage;
import at.gv.egovernment.moa.id.util.ErrorResponseUtils;
+import at.gv.egovernment.moa.id.util.MOAIDMessageProvider;
import at.gv.egovernment.moa.id.util.Random;
import at.gv.egovernment.moa.id.util.ServletUtils;
import at.gv.egovernment.moa.id.util.VelocityProvider;
@@ -98,7 +99,7 @@ public abstract class AbstractController extends MOAIDAuthConstants {
}
@ExceptionHandler({IOException.class})
- public void IOExceptionHandler(HttpServletResponse resp, IOException exception) {
+ public void IOExceptionHandler(HttpServletResponse resp, Throwable exception) {
Logger.error("Internel Server Error." , exception);
resp.setContentType("text/html;charset=UTF-8");
resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
@@ -136,8 +137,11 @@ public abstract class AbstractController extends MOAIDAuthConstants {
String redirectURL = null;
redirectURL = ServletUtils.getBaseUrl(req);
redirectURL += "/"+AbstractAuthProtocolModulController.FINALIZEPROTOCOL_ENDPOINT
- + "?" + ERROR_CODE_PARAM + "=" + key
- + "&" + MOAIDAuthConstants.PARAM_TARGET_PENDINGREQUESTID + "=" + pendingRequestID;
+ + "?" + ERROR_CODE_PARAM + "=" + key;
+
+ //only add pending-request Id if it exists
+ if (MiscUtil.isNotEmpty(pendingRequestID))
+ redirectURL += "&" + MOAIDAuthConstants.PARAM_TARGET_PENDINGREQUESTID + "=" + pendingRequestID;
resp.setContentType("text/html");
resp.setStatus(302);
@@ -178,8 +182,13 @@ public abstract class AbstractController extends MOAIDAuthConstants {
if (throwable instanceof MOAIDException || throwable instanceof ProcessExecutionException)
internalMOAIDExceptionHandler(req, resp, (Exception)throwable, false);
- else
- GenericExceptionHandler(resp, (Exception)throwable);
+ else {
+ //write generic message for general exceptions
+ String msg = MOAIDMessageProvider.getInstance().getMessage("internal.00", null);
+ writeHTMLErrorResponse(resp, msg, "9199", (Exception) throwable);
+
+ }
+
}
/**
@@ -213,7 +222,22 @@ public abstract class AbstractController extends MOAIDAuthConstants {
" | Description=" + descr + ")");
}
+
+ private void writeHTMLErrorResponse(HttpServletResponse httpResp, String msg, String errorCode, Exception error) throws IOException {
+ VelocityContext context = new VelocityContext();
+ //add errorcode and errormessage
+ context.put("errorMsg", msg);
+ context.put("errorCode", errorCode);
+
+ //add stacktrace if debug is enabled
+ if (Logger.isTraceEnabled()) {
+ context.put("stacktrace", getStacktraceFromException(error));
+
+ }
+
+ }
+
private void writeHTMLErrorResponse(HttpServletResponse httpResp, Exception error) throws IOException {
VelocityContext context = new VelocityContext();
@@ -222,11 +246,13 @@ public abstract class AbstractController extends MOAIDAuthConstants {
context.put("errorCode", ErrorResponseUtils.getInstance().getResponseErrorCode(error));
//add stacktrace if debug is enabled
- if (Logger.isDebugEnabled()) {
+ if (Logger.isTraceEnabled()) {
context.put("stacktrace", getStacktraceFromException(error));
}
-
+ }
+
+ private void writeHTMLErrorResponse(HttpServletResponse httpResp, VelocityContext context) throws IOException {
try {
InputStream is = null;
String pathLocation = null;
@@ -260,7 +286,7 @@ public abstract class AbstractController extends MOAIDAuthConstants {
}
} catch (Exception e) {
Logger.error("Error-message form can not created.", e);
- GenericExceptionHandler(httpResp, error);
+ IOExceptionHandler(httpResp, e);
}
}