summaryrefslogtreecommitdiff
path: root/eaaf_core
diff options
context:
space:
mode:
authorThomas <>2021-07-01 07:37:47 +0200
committerThomas <>2021-07-01 07:37:47 +0200
commita3088068b6d3f6d6719ca5943eec556d01c0655d (patch)
tree7344db320628814fd83fce7549e78506b6b56ca9 /eaaf_core
parent108df5e1cc640070d1b03fb2dfd99306e661b8fe (diff)
downloadEAAF-Components-a3088068b6d3f6d6719ca5943eec556d01c0655d.tar.gz
EAAF-Components-a3088068b6d3f6d6719ca5943eec556d01c0655d.tar.bz2
EAAF-Components-a3088068b6d3f6d6719ca5943eec556d01c0655d.zip
add new 'errorHandling' type that illustrate any error on application side before forwarding to SP
Diffstat (limited to 'eaaf_core')
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/IErrorService.java2
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/ProtocolAuthenticationService.java3
-rw-r--r--eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/controller/ProtocolFinalizationControllerTest.java57
3 files changed, 59 insertions, 3 deletions
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/IErrorService.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/IErrorService.java
index e545cb47..b6bc1056 100644
--- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/IErrorService.java
+++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/IErrorService.java
@@ -12,7 +12,7 @@ public interface IErrorService {
* Describes the kind of action that should be taken.
*/
enum ActionType {
- TICKET("ticket"), NO_TICKET("no_ticket");
+ TICKET("ticket"), NO_TICKET("no_ticket"), ERRORPAGE("errorpage");
private final String name;
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 635cfa0e..49acfadc 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
@@ -241,7 +241,8 @@ public class ProtocolAuthenticationService implements IProtocolAuthenticationSer
revisionsLogger.logEvent(protocolRequest, EventConstants.TRANSACTION_ERROR,
protocolRequest.getUniqueTransactionIdentifier());
- if (ActionType.TICKET.equals(errorData.getActionType())) {
+ if (ActionType.TICKET.equals(errorData.getActionType())
+ || ActionType.ERRORPAGE.equals(errorData.getActionType())) {
if (errorData.getErrorIdTokenForRedirect() != null) {
// Put pending request
diff --git a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/controller/ProtocolFinalizationControllerTest.java b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/controller/ProtocolFinalizationControllerTest.java
index 8aa3e8a9..4341d141 100644
--- a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/controller/ProtocolFinalizationControllerTest.java
+++ b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/controller/ProtocolFinalizationControllerTest.java
@@ -254,7 +254,62 @@ public class ProtocolFinalizationControllerTest {
}
-
+ @Test
+ public void performErrorHandlingWithoutTokenAndRedirect() throws EaafException, IOException {
+ MockHttpServletRequest httpReq = new MockHttpServletRequest("POST", "https://localhost/authhandler");
+ httpReq.addHeader("Accept", "application/json");
+ MockHttpServletResponse httpResp = new MockHttpServletResponse();
+ guiConfigFactory.setErrorGuiConfig(
+ new DummyGuiBuilderConfig("https://localhost/authhandler", "jUnitView", "/junitSubmit"));
+
+ String token = requestIdValidationStragegy.generateExternalPendingRequestId();
+ httpReq.setParameter(EaafConstants.PARAM_HTTP_ERROR_CODE, token);
+
+ TestRequestImpl protocolRequest = new TestRequestImpl();
+ Map<String, String> spConfig = new HashMap<>();
+ spConfig.put(EaafConfigConstants.SERVICE_UNIQUEIDENTIFIER, RandomStringUtils.randomAlphabetic(10));
+
+ protocolRequest.setSpConfig(new DummySpConfiguration(spConfig, config));
+ protocolRequest.setTransactionId(RandomStringUtils.randomAlphanumeric(10));
+
+ Throwable throwable = new EaafException("internal.00");
+ final ExceptionContainer exceptionContainer = new ExceptionContainer(protocolRequest, throwable);
+ final byte[] serialized = SerializationUtils.serialize(exceptionContainer);
+ storage.put(token, serialized, -1);
+
+ String secondErrorTicket = requestIdValidationStragegy.generateExternalPendingRequestId();
+ errorService.setErrorIdTokenForRedirect(secondErrorTicket);
+ errorService.setTicketType(ActionType.ERRORPAGE);
+
+ // perform test
+ controller.errorHandling(httpReq, httpResp);
+
+ //validate state
+ assertNull("Exception not removed from cache", storage.get(
+ requestIdValidationStragegy.getPendingRequestIdWithOutChecks(token)));
+
+ assertNotNull("No gui builder request", guiBuilder.getConfig());
+ assertFalse("No GUI form infos", guiBuilder.getConfig().getViewParameters().isEmpty());
+ assertTrue("No GUI form infos", guiBuilder.getConfig().getViewParameters().containsKey("msg"));
+ Map<String, Object> params = ((Map<String, Object>) guiBuilder.getConfig().getViewParameters().get("msg"));
+ assertFalse("No GUI form infos", params.isEmpty());
+ assertEquals("wrong intErrorCode", "internal.00", params.get("errorCode"));
+ assertTrue("wrong extErrorCode", ((String) params.get("extErrorCode")).contains("internal.00"));
+
+ byte[] secondErrorSerialized = storage.get(
+ requestIdValidationStragegy.getPendingRequestIdWithOutChecks(secondErrorTicket), byte[].class);
+ assertNotNull("Exception not removed from cache", secondErrorSerialized);
+ ExceptionContainer secondError = (ExceptionContainer) SerializationUtils.deserialize(secondErrorSerialized);
+ assertEquals("wrong pengingReq", protocolRequest.getUniqueTransactionIdentifier(),
+ secondError.getPendingRequest().getUniqueTransactionIdentifier());
+ assertEquals("wrong exception", throwable.getMessage(), secondError.getExceptionThrown().getMessage());
+
+ assertTrue("GUI sp redirect", guiBuilder.getConfig().getViewParameters()
+ .containsKey(DummyDefaultErrorService.JUNIT_EL_SPREDIRECT));
+
+ }
+
+
private class DummyGuiBuilderConfig extends AbstractGuiFormBuilderConfiguration
implements ModifyableGuiBuilderConfiguration {