From f18e44490057ba6e5fa719fefc47c8fd2e039b04 Mon Sep 17 00:00:00 2001 From: lalber Date: Wed, 7 Apr 2021 16:56:26 +0200 Subject: Interface extraction --- .../services/ProtocolAuthenticationService.java | 41 ++++++++++------------ 1 file changed, 19 insertions(+), 22 deletions(-) (limited to 'eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/ProtocolAuthenticationService.java') 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 4ac8bba2..c1c2ab00 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 @@ -103,7 +103,7 @@ public class ProtocolAuthenticationService implements IProtocolAuthenticationSer private IConfiguration basicConfig; @Autowired(required = true) - private ErrorTicketService errorTicketService; + private IErrorTicketService errorTicketService; @Autowired(required = false) private ISsoManager ssoManager; @@ -232,10 +232,10 @@ public class ProtocolAuthenticationService implements IProtocolAuthenticationSer public void buildProtocolSpecificErrorResponse(final Throwable throwable, final HttpServletRequest req, final HttpServletResponse resp, final IRequest protocolRequest) throws EaafException, IOException { try { - ErrorTicketService.HandleData errorData = errorTicketService.createHandleData(throwable, req); + IErrorTicketService.IHandleData errorData = errorTicketService.createHandleData(throwable, req); - if (errorData.getActionType().equals(ErrorTicketService.ActionType.TICKET_REDIRECT) || errorData.getActionType() - .equals(ErrorTicketService.ActionType.NOTICKET_REDIRECT)) { + if (errorData.getActionType().equals(IErrorTicketService.ActionType.TICKET_REDIRECT) || errorData.getActionType() + .equals(IErrorTicketService.ActionType.NOTICKET_REDIRECT)) { // Put pending request ExceptionContainer exceptionContainer = new ExceptionContainer(protocolRequest, throwable); @@ -254,7 +254,7 @@ public class ProtocolAuthenticationService implements IProtocolAuthenticationSer displayException(req, resp, errorData); - } else if (errorData.getActionType().equals(ErrorTicketService.ActionType.NOTICKET_AUTOREDIRECT)) { + } else if (errorData.getActionType().equals(IErrorTicketService.ActionType.NOTICKET_AUTOREDIRECT)) { IModulInfo handlingModule = extractShibbolethHandling(protocolRequest, applicationContext); if (handlingModule.generateErrorMessage(throwable, req, resp, protocolRequest)) { @@ -312,7 +312,7 @@ public class ProtocolAuthenticationService implements IProtocolAuthenticationSer public void handleErrorNoRedirect(final Throwable throwable, final HttpServletRequest req, final HttpServletResponse resp, final boolean writeExceptionToStatisticLog) throws EaafException, IOException { - ErrorTicketService.HandleData errorData = null; + IErrorTicketService.IHandleData errorData = null; errorData = errorTicketService.createHandleData(throwable, req); // log Exception into statistic database @@ -323,14 +323,14 @@ public class ProtocolAuthenticationService implements IProtocolAuthenticationSer // write errror to console logExceptionToTechnicalLog(errorData); - if (errorData.getActionType().equals(ErrorTicketService.ActionType.NOTICKET_NOREDIRECT) || errorData.getActionType() - .equals(ErrorTicketService.ActionType.TICKET_NOREDIRECT)) { + if (errorData.getActionType().equals(IErrorTicketService.ActionType.NOTICKET_NOREDIRECT) || errorData + .getActionType().equals(IErrorTicketService.ActionType.TICKET_NOREDIRECT)) { // return error to Web browser displayException(req, resp, errorData); } else { // TODO introduce separate error type? throw new EaafException("internal.configuration.01", new Object[]{ - errorData.getErrorCode() + " in on_error_action" + ".properties", "Erroraction mapping mismatch"}); + errorData.getInternalErrorCode() + " in on_error_action" + ".properties", "Erroraction mapping mismatch"}); } } @@ -418,7 +418,7 @@ public class ProtocolAuthenticationService implements IProtocolAuthenticationSer * * @param data errordata structure */ - protected void logExceptionToTechnicalLog(ErrorTicketService.HandleData data) { + protected void logExceptionToTechnicalLog(IErrorTicketService.IHandleData data) { // In case of a TaskExecutionException, which is only a container for process-errors, // extract internal exception @@ -429,7 +429,7 @@ public class ProtocolAuthenticationService implements IProtocolAuthenticationSer } else { - if (logOnInfoLevel.contains(data.getErrorCode())) { + if (logOnInfoLevel.contains(data.getInternalErrorCode())) { data.log_info(); } else { @@ -492,7 +492,8 @@ public class ProtocolAuthenticationService implements IProtocolAuthenticationSer private void writeHtmlErrorResponse(@NonNull final HttpServletRequest httpReq, @NonNull final HttpServletResponse httpResp, @NonNull final String msg, @NonNull final String errorCode, - @Nullable final Object[] params, String externalErrorCode, String url, String ticket) throws EaafException { + @Nullable final Object[] params, String externalErrorCode, IErrorTicketService.IHandleData errorData) + throws EaafException { try { final IGuiBuilderConfiguration config = guiConfigFactory @@ -523,8 +524,7 @@ public class ProtocolAuthenticationService implements IProtocolAuthenticationSer externalErrorCode); c.putCustomParameterWithOutEscaption(AbstractGuiFormBuilderConfiguration.PARAM_GROUP_MSG, PARAM_GUI_ERRORCODEPARAMS, ArrayUtils.toString(errorCodeParams)); - c.putCustomParameter(AbstractGuiFormBuilderConfiguration.PARAM_GROUP_MSG, PARAM_GUI_TICKET, ticket); - c.putCustomParameter(AbstractGuiFormBuilderConfiguration.PARAM_GROUP_MSG, PARAM_GUI_REDIRECT, url); + errorTicketService.displayErrorData(c, errorData); } else { log.info("Can not ADD error message, because 'GUIBuilderConfiguration' is not modifieable "); @@ -541,9 +541,9 @@ public class ProtocolAuthenticationService implements IProtocolAuthenticationSer } private void displayException(final HttpServletRequest req, final HttpServletResponse resp, - final ErrorTicketService.HandleData errorData) throws IOException, EaafException { + final IErrorTicketService.IHandleData errorData) throws IOException, EaafException { final Throwable e = errorData.getThrowable(); - final String internalErrorCode = errorData.getErrorCode(); + final String internalErrorCode = errorData.getInternalErrorCode(); // send error response if (e instanceof ProtocolNotActiveException) { @@ -556,21 +556,18 @@ public class ProtocolAuthenticationService implements IProtocolAuthenticationSer || e instanceof ProcessExecutionException || e instanceof ConfigurationException) { // write error message writeHtmlErrorResponse(req, resp, e.getMessage(), internalErrorCode, null, - statusMessager.mapInternalErrorToExternalError(internalErrorCode), errorData.getRedirectUrl(), - errorData.getSupportTicket()); + statusMessager.mapInternalErrorToExternalError(internalErrorCode), errorData); } else if (e instanceof EaafException) { // send HTML formated error message writeHtmlErrorResponse(req, resp, e.getMessage(), internalErrorCode, ((EaafException) e).getParams(), - statusMessager.mapInternalErrorToExternalError(internalErrorCode), errorData.getRedirectUrl(), - errorData.getSupportTicket()); + statusMessager.mapInternalErrorToExternalError(internalErrorCode), 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, - statusMessager.mapInternalErrorToExternalError(internalErrorCode), errorData.getRedirectUrl(), - errorData.getSupportTicket()); + statusMessager.mapInternalErrorToExternalError(internalErrorCode), errorData); } } -- cgit v1.2.3