summaryrefslogtreecommitdiff
path: root/eaaf_core/src/main/java/at
diff options
context:
space:
mode:
authorThomas <>2023-05-13 15:18:03 +0200
committerThomas <>2023-05-13 15:18:03 +0200
commit54f16e552a3d6c5579282de5c8d6a92395f6c049 (patch)
treeb01be728915391f1ed40cdf07fc6248fc3365f83 /eaaf_core/src/main/java/at
parent77ce26202ad7f1c36c2c5c385a4388b96d6bad65 (diff)
downloadEAAF-Components-54f16e552a3d6c5579282de5c8d6a92395f6c049.tar.gz
EAAF-Components-54f16e552a3d6c5579282de5c8d6a92395f6c049.tar.bz2
EAAF-Components-54f16e552a3d6c5579282de5c8d6a92395f6c049.zip
refact(core): remove double serialization in central error handling
Diffstat (limited to 'eaaf_core/src/main/java/at')
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/ProtocolAuthenticationService.java4
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/AbstractController.java15
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/ProtocolFinalizationController.java74
3 files changed, 28 insertions, 65 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 76687749..98ea339e 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
@@ -37,7 +37,6 @@ import org.springframework.context.ApplicationContext;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Service;
-import org.springframework.util.SerializationUtils;
import at.gv.egiz.components.eventlog.api.EventConstants;
import at.gv.egiz.eaaf.core.api.IRequest;
@@ -248,12 +247,11 @@ public class ProtocolAuthenticationService implements IProtocolAuthenticationSer
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);
+ transactionStorage.put(internalErrorToken, exceptionContainer, -1);
} else {
log.debug("No errorTokenId. Forwarding to SP will not be available");
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/AbstractController.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/AbstractController.java
index b05d8df0..4fa2676d 100644
--- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/AbstractController.java
+++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/AbstractController.java
@@ -30,7 +30,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
-import org.springframework.util.SerializationUtils;
import org.springframework.web.bind.annotation.ExceptionHandler;
import at.gv.egiz.components.eventlog.api.EventConstants;
@@ -178,21 +177,13 @@ public abstract class AbstractController {
if (errorToHandle.getFirst() != null) {
revisionsLogger.logEvent(errorToHandle.getFirst(), EventConstants.TRANSACTION_ERROR);
-
- log.trace("Serializing {} ... ", ExceptionContainer.class.getName());
- final byte[] serializedError = SerializationUtils.serialize(
- new ExceptionContainer(errorToHandle.getFirst(), errorToHandle.getSecond()));
-
log.debug("Put 'ExceptionContainer' into cache with id: {}... ", errorKey);
- transactionStorage.put(errorKey, serializedError, -1);
+ transactionStorage.put(errorKey,
+ new ExceptionContainer(errorToHandle.getFirst(), errorToHandle.getSecond()), -1);
} else {
- log.trace("Serializing {} ... ", ExceptionContainer.class.getName());
- final byte[] serializedError = SerializationUtils.serialize(
- new ExceptionContainer(null, errorToHandle.getSecond()));
-
log.trace("Put 'ExceptionContainer' into cache with id: {}... ",errorKey);
- transactionStorage.put(errorKey, serializedError, -1);
+ transactionStorage.put(errorKey, new ExceptionContainer(null, errorToHandle.getSecond()), -1);
}
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 a0ac57d1..099aa180 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
@@ -29,7 +29,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
-import org.springframework.util.SerializationUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@@ -85,32 +84,23 @@ public class ProtocolFinalizationController extends AbstractController {
log.debug("Searching exception with internal error-token: {}", errorId);
// load stored exception from database
- final byte[] containerSerialized = transactionStorage.get(errorId, byte[].class);
- if (containerSerialized != null) {
+ final ExceptionContainer container = transactionStorage.get(errorId, ExceptionContainer.class);
+ if (container != null) {
// remove exception if it was found
transactionStorage.remove(errorId);
log.trace("Find exception with internal error-token: {}", errorId);
- //final Object containerObj = EaafSerializationUtils.deserialize(containerSerialized,
- // Arrays.asList(
- // ExceptionContainer.class.getName()
- // ));
- final Object containerObj = SerializationUtils.deserialize(containerSerialized);
-
- if (containerObj instanceof ExceptionContainer) {
- final ExceptionContainer container = (ExceptionContainer) containerObj;
- final Throwable throwable = container.getExceptionThrown();
- pendingReq = container.getPendingRequest();
-
- if (pendingReq != null) {
- IModulInfo handlingModule = ProtocolAuthenticationService
- .extractShibbolethHandling(pendingReq, applicationContext);
- if (!handlingModule.generateErrorMessage(throwable, req, resp, pendingReq)) {
- protAuthService.handleErrorNoRedirect(new EaafException("process.90", null), req, resp, false);
-
- }
+ final Throwable throwable = container.getExceptionThrown();
+ pendingReq = container.getPendingRequest();
+
+ if (pendingReq != null) {
+ IModulInfo handlingModule = ProtocolAuthenticationService
+ .extractShibbolethHandling(pendingReq, applicationContext);
+ if (!handlingModule.generateErrorMessage(throwable, req, resp, pendingReq)) {
+ protAuthService.handleErrorNoRedirect(new EaafException("process.90", null), req, resp, false);
+
}
- }
+ }
} else {
log.info("Find no exception with internal error-token: {}", errorId);
protAuthService
@@ -162,45 +152,29 @@ public class ProtocolFinalizationController extends AbstractController {
log.debug("Searching exception with internal error-token: {}", errorId);
// load stored exception from database
- final byte[] containerSerialized = transactionStorage.get(errorId, byte[].class);
- if (containerSerialized != null) {
+ final ExceptionContainer container = transactionStorage.get(errorId, ExceptionContainer.class);
+ if (container != null) {
// remove exception if it was found
transactionStorage.remove(errorId);
log.trace("Find exception with internal error-token: {}", errorId);
- //final Object containerObj = EaafSerializationUtils.deserialize(containerSerialized,
- // Arrays.asList(
- // ExceptionContainer.class.getName()
- // ));
- final Object containerObj = SerializationUtils.deserialize(containerSerialized);
-
- if (containerObj instanceof ExceptionContainer) {
- final ExceptionContainer container = (ExceptionContainer) containerObj;
- final Throwable throwable = container.getExceptionThrown();
- pendingReq = container.getPendingRequest();
+ final Throwable throwable = container.getExceptionThrown();
+ pendingReq = container.getPendingRequest();
- if (pendingReq != null) {
- //set MDC variables
- TransactionIdUtils.setAllLoggingVariables(pendingReq);
+ if (pendingReq != null) {
+ // set MDC variables
+ TransactionIdUtils.setAllLoggingVariables(pendingReq);
- // build protocol-specific error message if possible
- protAuthService.buildProtocolSpecificErrorResponse(throwable, req, resp, pendingReq);
+ // build protocol-specific error message if possible
+ protAuthService.buildProtocolSpecificErrorResponse(throwable, req, resp, pendingReq);
- // remove active user-session
- transactionStorage.remove(pendingReq.getPendingRequestId());
-
- } else {
- protAuthService.handleErrorNoRedirect(throwable, req, resp, true);
-
- }
+ // remove active user-session
+ transactionStorage.remove(pendingReq.getPendingRequestId());
} else {
- protAuthService
- .handleErrorNoRedirect(new EaafException(IStatusMessenger.CODES_INTERNAL_ERROR_GENERIC, null), req,
- resp, false);
+ protAuthService.handleErrorNoRedirect(throwable, req, resp, true);
}
-
} else {
log.info("Find no exception with internal error-token: {}", errorId);
protAuthService