From b8d3937a99e54036be491b5df606ab6c5a81f480 Mon Sep 17 00:00:00 2001 From: lalber Date: Fri, 12 Mar 2021 16:11:07 +0100 Subject: added some error Handling --- .../core/impl/idp/auth/services/ErrorTicketService.java | 7 ++++--- .../auth/services/ProtocolAuthenticationService.java | 17 ++++++++++++----- .../idp/controller/ProtocolFinalizationController.java | 2 -- 3 files changed, 16 insertions(+), 10 deletions(-) (limited to 'eaaf_core') diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/ErrorTicketService.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/ErrorTicketService.java index c5bac225..3471aebe 100644 --- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/ErrorTicketService.java +++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/ErrorTicketService.java @@ -92,7 +92,7 @@ public class ErrorTicketService { } } - public HandleData createHandleData(Throwable throwable, HttpServletRequest req) { + public HandleData createHandleData(Throwable throwable, HttpServletRequest req) throws EaafException { HandleData data = new HandleData(throwable, req); extractErrorCode(data); setUpErrorData(data); @@ -120,7 +120,7 @@ public class ErrorTicketService { } } - private void setUpErrorData(HandleData data) { + private void setUpErrorData(HandleData data) throws EaafException { if (propertyMap.containsKey(data.errorCode)) { String action = propertyMap.get(data.errorCode); @@ -145,7 +145,8 @@ public class ErrorTicketService { } else { data.generateSupportTicket(); - // TODO log with ticket gernal internal error + throw new EaafException("internal.configuration.00", new Object[] {data.errorCode + "in on_error_action" + + ".properties"}); } } 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 8300c31f..bb6f45d0 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 @@ -77,6 +77,8 @@ import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.HashSet; +import static at.gv.egiz.eaaf.core.api.IStatusMessenger.CODES_INTERNAL_ERROR_GENERIC; + @Service public class ProtocolAuthenticationService implements IProtocolAuthenticationService { private static final Logger log = LoggerFactory.getLogger(ProtocolAuthenticationService.class); @@ -260,11 +262,10 @@ public class ProtocolAuthenticationService implements IProtocolAuthenticationSer } - } catch (final Throwable e) { + } catch (final Throwable e) { // handleErrorNoRedirect(throwable, req, resp, true); } - } @Override @@ -281,8 +282,14 @@ public class ProtocolAuthenticationService implements IProtocolAuthenticationSer // write errror to console logExceptionToTechnicalLog(errorData); - // return error to Web browser - displayException(req, resp, errorData); + if (errorData.getActionType().equals(ErrorTicketService.ActionType.NOTICKET_NOREDIRECT) || + errorData.getActionType().equals(ErrorTicketService.ActionType.TICKET_NOREDIRECT)) { + // return error to Web browser + displayException(req, resp, errorData); + } else { + throw new EaafException(IStatusMessenger.CODES_INTERNAL_ERROR_GENERIC, null, + new Exception("On Erroraction mapping mismatch", throwable)); + } } @Override @@ -516,7 +523,7 @@ public class ProtocolAuthenticationService implements IProtocolAuthenticationSer } else { // write generic message for general exceptions - final String msg = statusMessager.getMessage(IStatusMessenger.CODES_INTERNAL_ERROR_GENERIC, null); + final String msg = statusMessager.getMessage(CODES_INTERNAL_ERROR_GENERIC, null); writeHtmlErrorResponse(req, resp, msg, internalErrorCode, null, statusMessager.mapInternalErrorToExternalError(internalErrorCode), errorData.getRedirectUrl(), errorData.getSupportTicket()); diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/ProtocolFinalizationController.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/ProtocolFinalizationController.java index 37aab8df..26feb3db 100644 --- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/ProtocolFinalizationController.java +++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/ProtocolFinalizationController.java @@ -89,7 +89,6 @@ public class ProtocolFinalizationController extends AbstractController { pendingReq = container.getPendingRequest(); if (pendingReq != null) { - //TODO finish final Class clazz = Class.forName(pendingReq.requestedModule()); if (clazz == null || !IModulInfo.class.isAssignableFrom(clazz)) { @@ -127,7 +126,6 @@ public class ProtocolFinalizationController extends AbstractController { * @throws EaafException In case of an internal error * @throws IOException In case of a servlet error */ - // TODO reuse for the redirection to SP or own enpoint @RequestMapping(value = ENDPOINT_ERRORHANDLING, method = {RequestMethod.GET, RequestMethod.POST}) public void errorHandling(final HttpServletRequest req, final HttpServletResponse resp) throws EaafException, IOException { -- cgit v1.2.3