From b8b5f661b4b16f2ae82e9a63bf1e2d9279e1dcbc Mon Sep 17 00:00:00 2001 From: lalber Date: Fri, 26 Mar 2021 08:48:10 +0100 Subject: better error conf and some fixes --- .../core/impl/idp/auth/services/ErrorTicketService.java | 11 ++++++++--- .../auth/services/ProtocolAuthenticationService.java | 17 +++++++++-------- 2 files changed, 17 insertions(+), 11 deletions(-) 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 8bcb5305..08fb04c6 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 @@ -39,7 +39,8 @@ public class ErrorTicketService { public enum ActionType { TICKET_REDIRECT("ticket_redirect"), TICKET_NOREDIRECT("ticket_noredirect"), NOTICKET_REDIRECT( - "noticket_redirect"), NOTICKET_NOREDIRECT("noticket_noredirect"); + "noticket_redirect"), NOTICKET_NOREDIRECT("noticket_noredirect"), NOTICKET_AUTOREDIRECT( + "noticket_autoredirect"); private final String name; @@ -67,7 +68,7 @@ public class ErrorTicketService { if (StringUtils.isEmpty(ticketConfPath)) { - log.error("Error: Path to errorhandling action configuration not known"); + log.error("Error: Path to errorhandling-action mapping not known"); throw new EaafException("internal.configuration.00", new Object[]{CONFIG_PROP_ERRORHANDLING_ACTION_PATH}); } else { @@ -90,7 +91,8 @@ public class ErrorTicketService { } catch (Exception e) { log.error("Error: could not found file.", e); throw new EaafException("internal.configuration.01", - new Object[]{CONFIG_PROP_ERRORHANDLING_ACTION_PATH, "File cloud not be found."}); + new Object[]{CONFIG_PROP_ERRORHANDLING_ACTION_PATH, "File for errorhandling-action mapping cloud " + + "not be found."}); } } } @@ -148,6 +150,9 @@ public class ErrorTicketService { data.actionType = ActionType.NOTICKET_REDIRECT; data.generateRedirect(); + } else if (action.equals(ActionType.NOTICKET_AUTOREDIRECT.toString())) { + data.actionType = ActionType.NOTICKET_AUTOREDIRECT; + } else { // ActionType.NOTICKET_NOREDIRECT -> nothing to be done data.actionType = ActionType.NOTICKET_NOREDIRECT; 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 e04fc626..ac2be693 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 @@ -237,7 +237,8 @@ public class ProtocolAuthenticationService implements IProtocolAuthenticationSer try { ErrorTicketService.HandleData errorData = errorTicketService.createHandleData(throwable, req); - if (errorData.getActionType().equals(ErrorTicketService.ActionType.TICKET_REDIRECT)) { + if (errorData.getActionType().equals(ErrorTicketService.ActionType.TICKET_REDIRECT) + || errorData.getActionType().equals(ErrorTicketService.ActionType.NOTICKET_REDIRECT)) { // Put pending request ExceptionContainer exceptionContainer = new ExceptionContainer(protocolRequest, throwable); @@ -256,7 +257,7 @@ public class ProtocolAuthenticationService implements IProtocolAuthenticationSer displayException(req, resp, errorData); - } else if (errorData.getActionType().equals(ErrorTicketService.ActionType.NOTICKET_REDIRECT)) { + } else if (errorData.getActionType().equals(ErrorTicketService.ActionType.NOTICKET_AUTOREDIRECT)) { IModulInfo handlingModule = extractShibbolethHandling(protocolRequest, applicationContext); if (handlingModule.generateErrorMessage(throwable, req, resp, protocolRequest)) { @@ -281,7 +282,7 @@ public class ProtocolAuthenticationService implements IProtocolAuthenticationSer } - } catch (final Throwable e) { // + } catch (final Throwable e) { // if building error response results in error, we try with with handleErrorNoRedirect handleErrorNoRedirect(e, req, resp, true); @@ -290,18 +291,18 @@ public class ProtocolAuthenticationService implements IProtocolAuthenticationSer /** * Retrieves shibboleth module info. - * @param protocolRequest current request + * + * @param protocolRequest current request * @param applicationContext spring context * @return IModulInfo * @throws ClassNotFoundException If no shibboleth handling implementation found */ - public static IModulInfo extractShibbolethHandling(IRequest protocolRequest, - ApplicationContext applicationContext) throws ClassNotFoundException { + public static IModulInfo extractShibbolethHandling(IRequest protocolRequest, ApplicationContext applicationContext) + throws ClassNotFoundException { final Class clazz = Class.forName(protocolRequest.requestedModule()); if (clazz == null || !IModulInfo.class.isAssignableFrom(clazz)) { - log.error( - "Requested protocol module Class is NULL or does not implement the IModulInfo interface."); + log.error("Requested protocol module Class is NULL or does not implement the IModulInfo interface."); throw new ClassCastException( "Requested protocol module Class is NULL or does not implement the IModulInfo interface."); -- cgit v1.2.3