summaryrefslogtreecommitdiff
path: root/eaaf_core/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'eaaf_core/src/main')
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/DefaultErrorService.java14
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/IErrorService.java27
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/IErrorServiceModelHandler.java26
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/ProtocolAuthenticationService.java5
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/TicketErrorService.java48
5 files changed, 107 insertions, 13 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 e41905a6..cd89f8a5 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
@@ -1,13 +1,16 @@
package at.gv.egiz.eaaf.core.impl.idp.auth.services;
import java.text.MessageFormat;
+import java.util.Collections;
import java.util.HashSet;
+import java.util.Map;
import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
+import at.gv.egiz.eaaf.core.api.IRequest;
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;
@@ -35,7 +38,7 @@ public class DefaultErrorService implements IErrorService {
}
@Override
- public IHandleData createHandleData(Throwable throwable, boolean supportRedirctToSp) throws EaafException {
+ public IHandleData createHandleData(Throwable throwable, IRequest protocolRequest) throws EaafException {
String internalErrorId = extractInternalErrorCode(throwable);
return HandleData.builder()
@@ -101,11 +104,16 @@ public class DefaultErrorService implements IErrorService {
@Getter
private LogLevel logLevel;
+
+ @Override
+ public Map<String, String> getAdditionalGuiModelElements() {
+ return Collections.emptyMap();
+
+ }
public String getPreFormatedErrorMessage() {
return MessageFormat.format(TECH_LOG_MSG, internalErrorCode, throwable.getMessage());
-
+
}
-
}
}
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 b6bc1056..45b1cfe8 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
@@ -1,8 +1,12 @@
package at.gv.egiz.eaaf.core.impl.idp.auth.services;
+import java.util.Map;
+
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import javax.servlet.http.HttpServletRequest;
+import at.gv.egiz.eaaf.core.api.IRequest;
import at.gv.egiz.eaaf.core.api.gui.ModifyableGuiBuilderConfiguration;
import at.gv.egiz.eaaf.core.exceptions.EaafException;
@@ -94,14 +98,19 @@ public interface IErrorService {
/**
* Creates error handling data.
*
- * @param throwable Error that should be handled
- * @param supportRedirctToSp <code>true</code> if the current process-state supports redirect
- * to Service-Provider, otherwise <code>false</code>
- * @return Information how the error should be handled
+ * <p>
+ * Redirect to Service-Provider is supported in case of an available
+ * pendingRequest.
+ * </p>
+ *
+ * @param throwable Error that should be handled
+ * @param protocolRequest Current pendingRequest if available
+ * @return Information how the error should be handled
* @throws EaafException In case of an internal error
*/
@Nonnull
- IHandleData createHandleData(@Nonnull Throwable throwable, boolean supportRedirctToSp) throws EaafException;
+ IHandleData createHandleData(@Nonnull Throwable throwable, @Nullable IRequest protocolRequest)
+ throws EaafException;
/**
* Displays the error using suitable errordata.
@@ -160,5 +169,13 @@ public interface IErrorService {
* @return log message
*/
String getPreFormatedErrorMessage();
+
+ /**
+ * Get additional elements for error GUI model.
+ *
+ * @return Map of GUI model elements.
+ */
+ Map<String, String> getAdditionalGuiModelElements();
+
}
}
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/IErrorServiceModelHandler.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/IErrorServiceModelHandler.java
new file mode 100644
index 00000000..7faf173d
--- /dev/null
+++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/IErrorServiceModelHandler.java
@@ -0,0 +1,26 @@
+package at.gv.egiz.eaaf.core.impl.idp.auth.services;
+
+import java.util.Map;
+
+import javax.annotation.Nonnull;
+
+import at.gv.egiz.eaaf.core.api.IRequest;
+
+/**
+ * Extension point to add GUI model parameters into error-handling.
+ *
+ * @author tlenz
+ *
+ */
+public interface IErrorServiceModelHandler {
+
+ /**
+ * Get GUI model elements that should be added into error model.
+ *
+ * @param pendingReq Current pendingRequest, but never <code>null</code>
+ * @return Model elements to add, but never <code>null</code>
+ */
+ @Nonnull
+ Map<String, String> elementsForErrorModel(@Nonnull IRequest pendingReq);
+
+}
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 de0b6f6a..76687749 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
@@ -229,7 +229,8 @@ public class ProtocolAuthenticationService implements IProtocolAuthenticationSer
final HttpServletResponse resp, final IRequest protocolRequest) throws EaafException, IOException {
try {
- final IErrorService.IHandleData errorData = errorTicketService.createHandleData(throwable, true);
+ final IErrorService.IHandleData errorData =
+ errorTicketService.createHandleData(throwable, protocolRequest);
// log Error to technical log
logExceptionToTechnicalLog(errorData);
@@ -311,7 +312,7 @@ public class ProtocolAuthenticationService implements IProtocolAuthenticationSer
final HttpServletResponse resp, final boolean writeExceptionToStatisticLog) throws EaafException,
IOException {
- final IErrorService.IHandleData errorData = errorTicketService.createHandleData(throwable, false);
+ final IErrorService.IHandleData errorData = errorTicketService.createHandleData(throwable, null);
// log Exception into statistic database
if (writeExceptionToStatisticLog) {
diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/TicketErrorService.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/TicketErrorService.java
index 557614e6..e5f7a5ea 100644
--- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/TicketErrorService.java
+++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/services/TicketErrorService.java
@@ -5,7 +5,11 @@ import java.io.InputStream;
import java.net.URISyntaxException;
import java.text.MessageFormat;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import javax.annotation.PostConstruct;
@@ -22,6 +26,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.type.CollectionType;
import com.fasterxml.jackson.databind.type.TypeFactory;
+import at.gv.egiz.eaaf.core.api.IRequest;
import at.gv.egiz.eaaf.core.api.IStatusMessenger;
import at.gv.egiz.eaaf.core.api.data.EaafConstants;
import at.gv.egiz.eaaf.core.api.gui.ModifyableGuiBuilderConfiguration;
@@ -58,6 +63,9 @@ public abstract class TicketErrorService implements IErrorService {
@Autowired
IPendingRequestIdGenerationStrategy requestIdValidationStragegy;
+ @Autowired(required = false)
+ Set<IErrorServiceModelHandler> modelExtensionHandlers;
+
@Override
public String getExternalCodeFromInternal(String internalCode) {
ErrorConfig errorConfig = findByInternalCode(internalCode);
@@ -70,7 +78,7 @@ public abstract class TicketErrorService implements IErrorService {
}
@Override
- public IHandleData createHandleData(Throwable throwable, boolean supportRedirctToSp) throws EaafException {
+ public IHandleData createHandleData(Throwable throwable, IRequest protocolRequest) throws EaafException {
String internalErrorId = extractInternalErrorCode(throwable);
ErrorConfig errorFlowConfig = findByInternalCode(internalErrorId);
ActionType errorHandlingFlow = errorFlowConfig.getActionType();
@@ -82,7 +90,8 @@ public abstract class TicketErrorService implements IErrorService {
.logLevel(LogLevel.fromString(errorFlowConfig.getLogLevel()))
.supportTicket(ActionType.TICKET.equals(errorHandlingFlow) ? generateSupportTicket() : null)
.errorIdTokenForRedirect(
- supportRedirctToSp ? requestIdValidationStragegy.generateExternalPendingRequestId() : null)
+ protocolRequest != null ? requestIdValidationStragegy.generateExternalPendingRequestId() : null)
+ .additionalGuiModelElements(readAdditionalGuiModelInfos(protocolRequest))
.build();
}
@@ -95,6 +104,11 @@ public abstract class TicketErrorService implements IErrorService {
}
var ed = (TicketErrorService.HandleData) errorData;
+ // inject all additional model parameters
+ errorData.getAdditionalGuiModelElements().entrySet().forEach(
+ el -> c.putCustomParameter(
+ AbstractGuiFormBuilderConfiguration.PARAM_GROUP_MSG, el.getKey(), el.getValue()));
+
// set SupportTicket
c.putCustomParameter(AbstractGuiFormBuilderConfiguration.PARAM_GROUP_MSG, PARAM_GUI_TICKET, ed.getSupportTicket());
@@ -134,6 +148,20 @@ public abstract class TicketErrorService implements IErrorService {
}
+ private Map<String, String> readAdditionalGuiModelInfos(IRequest protocolRequest) {
+ if (protocolRequest != null) {
+ log.trace("Searching for additional GUI model elements to inject ... ");
+ return modelExtensionHandlers.stream()
+ .map(el -> el.elementsForErrorModel(protocolRequest))
+ .flatMap(m -> m.entrySet().stream())
+ .collect(Collectors.toUnmodifiableMap(Map.Entry::getKey, Map.Entry::getValue));
+
+ }
+
+ return Collections.emptyMap();
+
+ }
+
private String extractInternalErrorCode(Throwable throwable) {
Throwable originalException;
if (throwable instanceof TaskExecutionException
@@ -188,6 +216,17 @@ public abstract class TicketErrorService implements IErrorService {
new Object[]{CONFIG_PROP_ERROR_HANDLING_CONFIG_PATH, "Error reading Configurations file"});
}
+ // log currently loaded GUI model extension handlers
+ if (modelExtensionHandlers != null) {
+ modelExtensionHandlers.forEach(el -> log.info(
+ "Register Consent Attribute-Parameter handler: {} into Consent-RequestedAttributes Handler",
+ el.getClass().getName()));
+
+ } else {
+ modelExtensionHandlers = Collections.emptySet();
+
+ }
+
}
private byte[] readFromFile(final String filePath) throws URISyntaxException, IOException {
@@ -219,6 +258,9 @@ public abstract class TicketErrorService implements IErrorService {
@Getter
private LogLevel logLevel;
+
+ @Getter
+ private Map<String, String> additionalGuiModelElements;
public String getPreFormatedErrorMessage() {
if (supportTicket != null) {
@@ -228,7 +270,7 @@ public abstract class TicketErrorService implements IErrorService {
return MessageFormat.format(TECH_LOG_MSG, internalErrorCode, throwable.getMessage());
}
- }
+ }
}
}