summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/ProtocolAuthenticationService.java33
1 files changed, 27 insertions, 6 deletions
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 4ec9f028..7ed23619 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
@@ -504,6 +504,26 @@ public class ProtocolAuthenticationService implements IProtocolAuthenticationSer
}
+ /**
+ * Extension point to customize error-response generation.
+ *
+ * @param httpReq Current HTTP request
+ * @param httpResp Current HTTP response
+ * @param msg Error message from exception
+ * @param errorCode internal error-code
+ * @param params Parameters for internal error-code
+ * @param externalErrorCode external error-code
+ * @param errorData full error-data object from central error-handling
+ * @throws EaafException In case of response-generation error
+ */
+ protected void writeErrorResponse(@NonNull final HttpServletRequest httpReq,
+ @NonNull final HttpServletResponse httpResp, @NonNull final String msg, @NonNull final String errorCode,
+ @Nullable final Object[] params, String externalErrorCode, IErrorService.IHandleData errorData)
+ throws EaafException {
+ writeHtmlErrorResponse(httpReq, httpResp, msg, errorCode, params, externalErrorCode, errorData);
+
+ }
+
// private void writeHtmlErrorResponse(@NonNull final HttpServletRequest
// httpReq,
// @NonNull final HttpServletResponse httpResp, @NonNull final String msg,
@@ -578,6 +598,7 @@ public class ProtocolAuthenticationService implements IProtocolAuthenticationSer
final IErrorService.IHandleData errorData) throws IOException, EaafException {
final Throwable e = errorData.getThrowable();
final String internalErrorCode = errorData.getInternalErrorCode();
+ String externalErrorCode = errorTicketService.getExternalCodeFromInternal(internalErrorCode);
// send error response
if (e instanceof ProtocolNotActiveException) {
@@ -589,20 +610,20 @@ public class ProtocolAuthenticationService implements IProtocolAuthenticationSer
} else if (e instanceof AuthnRequestValidatorException || e instanceof InvalidProtocolRequestException
|| e instanceof ProcessExecutionException || e instanceof ConfigurationException) {
// write error message
- writeHtmlErrorResponse(req, resp, e.getMessage(), internalErrorCode,
+ writeErrorResponse(req, resp, e.getMessage(), internalErrorCode,
e instanceof EaafException ? ((EaafException) e).getParams() : null,
- errorTicketService.getExternalCodeFromInternal(internalErrorCode), errorData);
+ externalErrorCode, errorData);
} else if (e instanceof EaafException) {
// send HTML formated error message
- writeHtmlErrorResponse(req, resp, e.getMessage(), internalErrorCode, ((EaafException) e).getParams(),
- errorTicketService.getExternalCodeFromInternal(internalErrorCode), errorData);
+ writeErrorResponse(req, resp, e.getMessage(), internalErrorCode, ((EaafException) e).getParams(),
+ externalErrorCode, errorData);
} else {
// write generic message for general exceptions
final String msg = statusMessager.getMessage(IStatusMessenger.CODES_INTERNAL_ERROR_GENERIC, null);
- writeHtmlErrorResponse(req, resp, msg, internalErrorCode, null,
- errorTicketService.getExternalCodeFromInternal(internalErrorCode), errorData);
+ writeErrorResponse(req, resp, msg, internalErrorCode, null,
+ externalErrorCode, errorData);
}
}