summaryrefslogtreecommitdiff
path: root/eaaf_core/src
diff options
context:
space:
mode:
Diffstat (limited to 'eaaf_core/src')
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/DefaultErrorService.java2
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/ProtocolAuthenticationService.java21
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/ProtocolFinalizationController.java16
-rw-r--r--eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/controller/ProtocolFinalizationControllerTest.java304
-rw-r--r--eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/dummy/DummyDefaultErrorService.java115
-rw-r--r--eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/module/gui/DummyGuiFormBuilder.java37
-rw-r--r--eaaf_core/src/test/resources/SpringTest-context_eaaf_auth.xml69
7 files changed, 557 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);
+
}
}
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
new file mode 100644
index 00000000..8aa3e8a9
--- /dev/null
+++ b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/controller/ProtocolFinalizationControllerTest.java
@@ -0,0 +1,304 @@
+package at.gv.egiz.eaaf.core.impl.idp.auth.controller;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.lang3.RandomStringUtils;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.mock.web.MockHttpServletResponse;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.util.SerializationUtils;
+
+import at.gv.egiz.eaaf.core.api.data.EaafConfigConstants;
+import at.gv.egiz.eaaf.core.api.data.EaafConstants;
+import at.gv.egiz.eaaf.core.api.data.ExceptionContainer;
+import at.gv.egiz.eaaf.core.api.gui.GroupDefinition;
+import at.gv.egiz.eaaf.core.api.gui.ModifyableGuiBuilderConfiguration;
+import at.gv.egiz.eaaf.core.api.idp.IConfiguration;
+import at.gv.egiz.eaaf.core.api.storage.ITransactionStorage;
+import at.gv.egiz.eaaf.core.api.utils.IPendingRequestIdGenerationStrategy;
+import at.gv.egiz.eaaf.core.exceptions.EaafException;
+import at.gv.egiz.eaaf.core.impl.gui.AbstractGuiFormBuilderConfiguration;
+import at.gv.egiz.eaaf.core.impl.idp.auth.dummy.DummyDefaultErrorService;
+import at.gv.egiz.eaaf.core.impl.idp.auth.services.IErrorService.ActionType;
+import at.gv.egiz.eaaf.core.impl.idp.auth.services.IErrorService.LogLevel;
+import at.gv.egiz.eaaf.core.impl.idp.controller.ProtocolFinalizationController;
+import at.gv.egiz.eaaf.core.impl.idp.module.gui.DummyGuiBuilderConfigurationFactory;
+import at.gv.egiz.eaaf.core.impl.idp.module.gui.DummyGuiFormBuilder;
+import at.gv.egiz.eaaf.core.impl.idp.module.test.DummySpConfiguration;
+import at.gv.egiz.eaaf.core.impl.idp.module.test.TestRequestImpl;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration({"/SpringTest-context_eaaf_core.xml", "/SpringTest-context_eaaf_auth.xml"})
+public class ProtocolFinalizationControllerTest {
+
+ @Autowired IConfiguration config;
+ @Autowired ProtocolFinalizationController controller;
+ @Autowired DummyGuiBuilderConfigurationFactory guiConfigFactory;
+ @Autowired DummyGuiFormBuilder guiBuilder;
+ @Autowired IPendingRequestIdGenerationStrategy requestIdValidationStragegy;
+ @Autowired ITransactionStorage storage;
+ @Autowired DummyDefaultErrorService errorService;
+
+ /**
+ * jUnit test initializer.
+ */
+ @Before
+ public void initialize() {
+ errorService.setErrorIdTokenForRedirect(null);
+ errorService.setLogLevel(LogLevel.WARN);
+ errorService.setTicketType(ActionType.NO_TICKET);
+
+ }
+
+ @Test
+ public void performErrorRedirectNoToken() 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"));
+
+ // perform test
+ controller.errorRedirect(httpReq, httpResp);
+
+ //validate state
+ 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", "auth.26", params.get("errorCode"));
+ assertTrue("wrong extErrorCode", ((String) params.get("extErrorCode")).contains("auth.26"));
+
+ assertFalse("GUI sp redirect", guiBuilder.getConfig().getViewParameters()
+ .containsKey(DummyDefaultErrorService.JUNIT_EL_SPREDIRECT));
+
+ }
+
+ @Test
+ public void performErrorRedirect() 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));
+ Throwable throwable = new EaafException("internal.00");
+ final ExceptionContainer exceptionContainer = new ExceptionContainer(protocolRequest, throwable);
+ final byte[] serialized = SerializationUtils.serialize(exceptionContainer);
+ storage.put(token, serialized, -1);
+
+ // perform test
+ controller.errorRedirect(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"));
+
+ assertFalse("GUI sp redirect", guiBuilder.getConfig().getViewParameters()
+ .containsKey(DummyDefaultErrorService.JUNIT_EL_SPREDIRECT));
+
+ }
+
+ @Test
+ public void performErrorHandlingNoToken() 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"));
+
+ // perform test
+ controller.errorHandling(httpReq, httpResp);
+
+ //validate state
+ 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", "auth.26", params.get("errorCode"));
+ assertTrue("wrong extErrorCode", ((String) params.get("extErrorCode")).contains("auth.26"));
+
+ assertFalse("GUI sp redirect", guiBuilder.getConfig().getViewParameters()
+ .containsKey(DummyDefaultErrorService.JUNIT_EL_SPREDIRECT));
+
+ }
+
+ @Test
+ public void performErrorHandlingWithToken() 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));
+ Throwable throwable = new EaafException("internal.00");
+ final ExceptionContainer exceptionContainer = new ExceptionContainer(protocolRequest, throwable);
+ final byte[] serialized = SerializationUtils.serialize(exceptionContainer);
+ storage.put(token, serialized, -1);
+
+ // 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"));
+
+
+ assertFalse("GUI sp redirect", guiBuilder.getConfig().getViewParameters()
+ .containsKey(DummyDefaultErrorService.JUNIT_EL_SPREDIRECT));
+ }
+
+ @Test
+ public void performErrorHandlingWithTokenAndRedirect() 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.TICKET);
+
+
+ // 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 {
+
+ /**
+ * DummyGuiBuilderConfiguration.
+ *
+ * @param authUrl AuthUrl
+ * @param viewName viewName
+ * @param formSubmitEndpoint submit endpoint
+ */
+ DummyGuiBuilderConfig(String authUrl, String viewName, String formSubmitEndpoint) {
+ super(authUrl, viewName, formSubmitEndpoint);
+
+ }
+
+ @Override
+ public String getDefaultContentType() {
+ return null;
+
+ }
+
+ @Override
+ protected void putSpecificViewParameters() {
+
+
+ }
+
+ @Override
+ protected GroupDefinition getFromGroup() {
+ return null;
+
+ }
+
+ @Override
+ public void putCustomParameterWithOutEscaption(GroupDefinition group, String key, Object value) {
+ setViewParameter(group, key, value);
+
+ }
+
+ @Override
+ public void putCustomParameter(GroupDefinition group, String key, String value) {
+ setViewParameter(group, key, value);
+
+ }
+ };
+
+}
diff --git a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/dummy/DummyDefaultErrorService.java b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/dummy/DummyDefaultErrorService.java
new file mode 100644
index 00000000..347f9b5c
--- /dev/null
+++ b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/auth/dummy/DummyDefaultErrorService.java
@@ -0,0 +1,115 @@
+package at.gv.egiz.eaaf.core.impl.idp.auth.dummy;
+
+import java.text.MessageFormat;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.springframework.beans.factory.annotation.Autowired;
+
+import at.gv.egiz.eaaf.core.api.IStatusMessenger;
+import at.gv.egiz.eaaf.core.api.gui.ModifyableGuiBuilderConfiguration;
+import at.gv.egiz.eaaf.core.api.idp.IConfiguration;
+import at.gv.egiz.eaaf.core.exceptions.EaafException;
+import at.gv.egiz.eaaf.core.exceptions.TaskExecutionException;
+import at.gv.egiz.eaaf.core.impl.idp.auth.services.IErrorService;
+import lombok.Builder;
+import lombok.Getter;
+import lombok.Setter;
+
+public class DummyDefaultErrorService implements IErrorService {
+ private static final String TECH_LOG_MSG = "errorCode={0} Message={1}";
+
+ public static final String JUNIT_EL_SPREDIRECT = "spRedirect";
+
+ @Autowired IConfiguration basicConfig;
+ @Autowired IStatusMessenger statusMessager;
+
+ @Setter
+ private ActionType ticketType = ActionType.NO_TICKET;
+
+ @Setter
+ private LogLevel logLevel = LogLevel.WARN;
+
+ @Setter
+ private String errorIdTokenForRedirect;
+
+ @Override
+ public String getExternalCodeFromInternal(String internalCode) {
+ return statusMessager.mapInternalErrorToExternalError(internalCode);
+
+ }
+
+ @Override
+ public IHandleData createHandleData(Throwable throwable, boolean supportRedirctToSp) throws EaafException {
+ String internalErrorId = extractInternalErrorCode(throwable);
+
+ return HandleData.builder()
+ .throwable(throwable)
+ .internalErrorCode(internalErrorId)
+ .actionType(ticketType)
+ .logLevel(logLevel)
+ .errorIdTokenForRedirect(errorIdTokenForRedirect)
+ .allowSpRedirct(supportRedirctToSp)
+ .build();
+
+ }
+
+ @Override
+ public void displayErrorData(ModifyableGuiBuilderConfiguration c, IHandleData errorData,
+ HttpServletRequest httpReq) throws EaafException {
+ if (((HandleData)errorData).isAllowSpRedirct()) {
+ c.putCustomParameter(null, JUNIT_EL_SPREDIRECT, "toSpWithToken:" + errorData.getErrorIdTokenForRedirect());
+
+ }
+
+
+ }
+
+ private String extractInternalErrorCode(Throwable throwable) {
+ Throwable originalException;
+ if (throwable instanceof TaskExecutionException
+ && ((TaskExecutionException) throwable).getOriginalException() != null) {
+ originalException = ((TaskExecutionException) throwable).getOriginalException();
+
+ } else {
+ originalException = throwable;
+
+ }
+
+ if (!(originalException instanceof EaafException)) {
+ return IStatusMessenger.CODES_INTERNAL_ERROR_GENERIC;
+
+ } else {
+ return ((EaafException) originalException).getErrorId();
+
+ }
+ }
+
+ @Builder
+ static class HandleData implements IHandleData {
+
+ @Getter
+ private boolean allowSpRedirct;
+
+ @Getter
+ private String errorIdTokenForRedirect;
+
+ @Getter
+ private final Throwable throwable;
+
+ @Getter
+ private String internalErrorCode;
+
+ @Getter
+ private ActionType actionType;
+
+ @Getter
+ private LogLevel logLevel;
+
+ public String getPreFormatedErrorMessage() {
+ return MessageFormat.format(TECH_LOG_MSG, internalErrorCode, throwable.getMessage());
+
+ }
+
+ }
+}
diff --git a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/module/gui/DummyGuiFormBuilder.java b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/module/gui/DummyGuiFormBuilder.java
new file mode 100644
index 00000000..bd81169d
--- /dev/null
+++ b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/module/gui/DummyGuiFormBuilder.java
@@ -0,0 +1,37 @@
+package at.gv.egiz.eaaf.core.impl.idp.module.gui;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import at.gv.egiz.eaaf.core.api.gui.IGuiBuilderConfiguration;
+import at.gv.egiz.eaaf.core.api.gui.IGuiFormBuilder;
+import at.gv.egiz.eaaf.core.exceptions.GuiBuildException;
+import lombok.Getter;
+
+@Getter
+public class DummyGuiFormBuilder implements IGuiFormBuilder {
+
+ private String loggerName;
+
+ private IGuiBuilderConfiguration config;
+
+ private String contentType;
+
+ @Override
+ public void build(HttpServletRequest httpReq, HttpServletResponse httpResp, IGuiBuilderConfiguration config,
+ String loggerName) throws GuiBuildException {
+ this.loggerName = loggerName;
+ this.config = config;
+
+ }
+
+ @Override
+ public void build(HttpServletRequest httpReq, HttpServletResponse httpResp, IGuiBuilderConfiguration config,
+ String contentType, String loggerName) throws GuiBuildException {
+ this.loggerName = loggerName;
+ this.config = config;
+ this.contentType = contentType;
+
+ }
+
+}
diff --git a/eaaf_core/src/test/resources/SpringTest-context_eaaf_auth.xml b/eaaf_core/src/test/resources/SpringTest-context_eaaf_auth.xml
new file mode 100644
index 00000000..0cb8fa24
--- /dev/null
+++ b/eaaf_core/src/test/resources/SpringTest-context_eaaf_auth.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xmlns:tx="http://www.springframework.org/schema/tx"
+ xmlns:aop="http://www.springframework.org/schema/aop"
+ xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
+ http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
+
+ <import resource="classpath:/spring/eaaf_utils.beans.xml"/>
+
+ <bean id="protocolAuthService"
+ class="at.gv.egiz.eaaf.core.impl.idp.auth.services.ProtocolAuthenticationService">
+ <property name="guiBuilder" ref="dummyGuiFormBuilder" />
+
+ </bean>
+
+ <bean id="protocolFinalizationController"
+ class="at.gv.egiz.eaaf.core.impl.idp.controller.ProtocolFinalizationController" />
+
+ <bean id="dummyErrorService"
+ class="at.gv.egiz.eaaf.core.impl.idp.auth.dummy.DummyDefaultErrorService" />
+
+ <!-- Dummy services for testing -->
+ <bean id="dummyGuiBuilderConfigFactory"
+ class="at.gv.egiz.eaaf.core.impl.idp.module.gui.DummyGuiBuilderConfigurationFactory"/>
+
+ <bean id="dummyGuiFormBuilder"
+ class="at.gv.egiz.eaaf.core.impl.idp.module.gui.DummyGuiFormBuilder"/>
+
+ <bean id="dummyAuthManager"
+ class="at.gv.egiz.eaaf.core.impl.idp.auth.DummyAuthManager" />
+
+ <bean id="dummyRevisionLogger"
+ class="at.gv.egiz.eaaf.core.impl.logging.DummyRevisionsLogger" />
+
+ <bean id="dummyStatisticLogger"
+ class="at.gv.egiz.eaaf.core.impl.logging.DummyStatisticLogger" />
+
+ <bean id="DummyTransactionStorage"
+ class="at.gv.egiz.eaaf.core.impl.idp.process.spring.test.DummyTransactionStorage" />
+
+ <bean id="DummyStatusMessager"
+ class="at.gv.egiz.eaaf.core.impl.logging.DummyStatusMessager" />
+
+ <bean id="springElAwareExpressionEvaluator"
+ class="at.gv.egiz.eaaf.core.impl.idp.process.spring.SpringExpressionEvaluator" />
+
+ <bean id="processEngine"
+ class="at.gv.egiz.eaaf.core.impl.idp.process.ProcessEngineImpl">
+ <property name="transitionConditionExpressionEvaluator"
+ ref="springElAwareExpressionEvaluator" />
+ </bean>
+
+ <bean id="moduleRegistration"
+ class="at.gv.egiz.eaaf.core.impl.idp.auth.modules.ModuleRegistration" />
+
+ <bean id="ProcessInstanceStoreage"
+ class="at.gv.egiz.eaaf.core.impl.idp.process.dao.ProcessInstanceStoreDaoImpl" />
+
+ <bean id="RequestStorage"
+ class="at.gv.egiz.eaaf.core.impl.idp.auth.RequestStorage" />
+
+ <bean id="simplePendingRequestIdGenerationStrategy"
+ class="at.gv.egiz.eaaf.core.impl.utils.SimplePendingRequestIdGenerationStrategy" />
+
+</beans>