summaryrefslogtreecommitdiff
path: root/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/ProtocolFinalizationController.java
diff options
context:
space:
mode:
authorlalber <lukas.alber@iaik.tugraz.at>2021-03-08 18:27:55 +0100
committerThomas <>2021-03-30 20:21:12 +0200
commit4e9499a1c39498f8646799e947e38f5f491c1428 (patch)
treeaf66cf75dde01b62a62e3ddac77c0fb168ffcdaa /eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/ProtocolFinalizationController.java
parente89b787f7ce726180424d1ea775a225ea532a187 (diff)
downloadEAAF-Components-4e9499a1c39498f8646799e947e38f5f491c1428.tar.gz
EAAF-Components-4e9499a1c39498f8646799e947e38f5f491c1428.tar.bz2
EAAF-Components-4e9499a1c39498f8646799e947e38f5f491c1428.zip
First version of feature
Diffstat (limited to 'eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/ProtocolFinalizationController.java')
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/ProtocolFinalizationController.java60
1 files changed, 60 insertions, 0 deletions
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 b2130fb4..13a93e73 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
@@ -56,11 +56,70 @@ public class ProtocolFinalizationController extends AbstractController {
EaafConstants.ENDPOINT_PREFIX_SECURED + "/finalizeAuthProtocol";
public static final String ENDPOINT_ERRORHANDLING =
EaafConstants.ENDPOINT_PREFIX_SECURED + "/errorHandling";
+ public static final String ENDPOINT_ERROR_REDIRECT =
+ EaafConstants.ENDPOINT_PREFIX_SECURED + "errorRedirect";
+
@Autowired(required = true)
IRequestStorage requestStorage;
@Autowired IPendingRequestIdGenerationStrategy requestIdValidationStragegy;
+ @RequestMapping(value = ENDPOINT_ERROR_REDIRECT, method = { RequestMethod.GET, RequestMethod.POST })
+ public void errorRedirect(final HttpServletRequest req, final HttpServletResponse resp)
+ throws EaafException, IOException {
+
+ final String errorToken =
+ StringEscapeUtils.escapeHtml4(req.getParameter(EaafConstants.PARAM_HTTP_ERROR_CODE));
+ if (errorToken != null) {
+ IRequest pendingReq = null;
+ try {
+ String errorId = requestIdValidationStragegy.validateAndGetPendingRequestId(errorToken);
+ 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) {
+ // 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) {
+
+ }
+ }
+ }
+ } catch (Exception e) {
+ }
+ }
+
+ //TODO finish
+// final Class<?> clazz = Class.forName(req.requestedModule());
+//
+// if (clazz == null || !IModulInfo.class.isAssignableFrom(clazz)) {
+// 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.");
+//
+// }
+//
+// final IModulInfo handlingModule = (IModulInfo) applicationContext.getBean(clazz);
+//
+// handlingModule.generateErrorMessage(throwable, req, resp, protocolRequest);
+
+ }
+
/**
* End-Point to handle errors.
*
@@ -69,6 +128,7 @@ 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 {