diff options
author | Thomas <> | 2021-04-21 13:49:36 +0200 |
---|---|---|
committer | Thomas <> | 2021-04-21 13:49:36 +0200 |
commit | cc8c96de6330f9186ea271fe9e120e2fef0b5375 (patch) | |
tree | cb0436a47570ff1609a38755b960a64ecc21489b /eaaf_core/src/main/java/at/gv | |
parent | 3cbba3fcda614fa37357822d0eeb543c3e19276e (diff) | |
download | EAAF-Components-cc8c96de6330f9186ea271fe9e120e2fef0b5375.tar.gz EAAF-Components-cc8c96de6330f9186ea271fe9e120e2fef0b5375.tar.bz2 EAAF-Components-cc8c96de6330f9186ea271fe9e120e2fef0b5375.zip |
add missing error-handling and add a few more tests
Diffstat (limited to 'eaaf_core/src/main/java/at/gv')
3 files changed, 32 insertions, 7 deletions
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/DefaultErrorService.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/DefaultErrorService.java index e8be535c..e41905a6 100644 --- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/DefaultErrorService.java +++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/DefaultErrorService.java @@ -20,7 +20,7 @@ import lombok.extern.slf4j.Slf4j; @Slf4j public class DefaultErrorService implements IErrorService { - private static final String TECH_LOG_MSG = "errorCode={} Message={}"; + private static final String TECH_LOG_MSG = "errorCode={0} Message={1}"; private static final String CONFIG_PROP_LOGGER_ON_INFO_LEVEL = "core.logging.level.info.errorcodes"; @Autowired IConfiguration basicConfig; 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 4b2cbd0e..635cfa0e 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 @@ -242,10 +242,21 @@ public class ProtocolAuthenticationService implements IProtocolAuthenticationSer protocolRequest.getUniqueTransactionIdentifier()); if (ActionType.TICKET.equals(errorData.getActionType())) { - // Put pending request - final ExceptionContainer exceptionContainer = new ExceptionContainer(protocolRequest, throwable); - final byte[] serialized = SerializationUtils.serialize(exceptionContainer); - transactionStorage.put(errorData.getErrorIdTokenForRedirect(), serialized, -1); + + if (errorData.getErrorIdTokenForRedirect() != null) { + // Put pending request + final ExceptionContainer exceptionContainer = new ExceptionContainer(protocolRequest, throwable); + final byte[] serialized = SerializationUtils.serialize(exceptionContainer); + log.debug("Put error into cache to support SP forwarding ... "); + String internalErrorToken = pendingReqIdGenerationStrategy.getPendingRequestIdWithOutChecks( + errorData.getErrorIdTokenForRedirect()); + log.trace("errorIdToken: {}", internalErrorToken); + transactionStorage.put(internalErrorToken, serialized, -1); + + } else { + log.debug("No errorTokenId. Forwarding to SP will not be available"); + + } // render GUI displayException(req, resp, errorData); @@ -299,7 +310,7 @@ public class ProtocolAuthenticationService implements IProtocolAuthenticationSer final HttpServletResponse resp, final boolean writeExceptionToStatisticLog) throws EaafException, IOException { - final IErrorService.IHandleData errorData = errorTicketService.createHandleData(throwable, true); + final IErrorService.IHandleData errorData = errorTicketService.createHandleData(throwable, false); // log Exception into statistic database if (writeExceptionToStatisticLog) { 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 dce2251a..a22cbe9d 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 @@ -110,8 +110,15 @@ public class ProtocolFinalizationController extends AbstractController { } } - } + } + } else { + log.info("Find no exception with internal error-token: {}", errorId); + protAuthService + .handleErrorNoRedirect(new EaafException(IStatusMessenger.CODES_INTERNAL_ERROR_AUTH_TIMEOUT, null), + req, resp, false); + } + } catch (Throwable e) { log.error(e.getMessage(), e); protAuthService.handleErrorNoRedirect(e, req, resp, false); @@ -124,6 +131,13 @@ public class ProtocolFinalizationController extends AbstractController { } } + + } else { + log.debug("Request contains NO ErrorId"); + protAuthService + .handleErrorNoRedirect(new EaafException(IStatusMessenger.CODES_INTERNAL_ERROR_AUTH_NOPENDIGREQID, null), req, + resp, false); + } } |