aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas <>2021-03-12 10:46:59 +0100
committerThomas <>2021-03-12 10:46:59 +0100
commit7a1196805baad8fe055f92cfa8746c67684749b9 (patch)
tree7a48d0d78a446026c319211b2754a5b0ce80910d
parentf1aa50e7284b982c8ffa48a1783bdb5600efa3d7 (diff)
downloadNational_eIDAS_Gateway-7a1196805baad8fe055f92cfa8746c67684749b9.tar.gz
National_eIDAS_Gateway-7a1196805baad8fe055f92cfa8746c67684749b9.tar.bz2
National_eIDAS_Gateway-7a1196805baad8fe055f92cfa8746c67684749b9.zip
update StatusMessageProvider for better distiguish between internal and external errorCodes
-rw-r--r--connector/src/main/java/at/asitplus/eidas/specific/connector/provider/StatusMessageProvider.java14
-rw-r--r--connector/src/test/java/at/asitplus/eidas/specific/connector/test/utils/AuthenticationDataBuilderTest.java2
2 files changed, 11 insertions, 5 deletions
diff --git a/connector/src/main/java/at/asitplus/eidas/specific/connector/provider/StatusMessageProvider.java b/connector/src/main/java/at/asitplus/eidas/specific/connector/provider/StatusMessageProvider.java
index 073f7513..e83d9d49 100644
--- a/connector/src/main/java/at/asitplus/eidas/specific/connector/provider/StatusMessageProvider.java
+++ b/connector/src/main/java/at/asitplus/eidas/specific/connector/provider/StatusMessageProvider.java
@@ -28,6 +28,7 @@ import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
+import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
@@ -94,11 +95,10 @@ public class StatusMessageProvider implements IStatusMessenger {
public String getResponseErrorCode(Throwable throwable) {
String errorCode = IStatusMessenger.CODES_EXTERNAL_ERROR_GENERIC;
if (throwable instanceof EaafException) {
- errorCode = mapInternalErrorToExternalError(((EaafException) throwable).getErrorId());
+ errorCode = ((EaafException) throwable).getErrorId();
}
- // TODO: maybe more internal switches are required
-
+
return errorCode;
}
@@ -120,7 +120,13 @@ public class StatusMessageProvider implements IStatusMessenger {
} else {
try {
- return externalError.getString(intErrorCode);
+ if (StringUtils.isNotEmpty(intErrorCode)) {
+ return externalError.getString(intErrorCode);
+
+ } else {
+ return IStatusMessenger.CODES_EXTERNAL_ERROR_GENERIC;
+
+ }
} catch (final MissingResourceException e2) {
log.info(MessageFormat.format(ERROR_NO_EXTERNALERROR_CODE, new Object[] { intErrorCode }));
diff --git a/connector/src/test/java/at/asitplus/eidas/specific/connector/test/utils/AuthenticationDataBuilderTest.java b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/utils/AuthenticationDataBuilderTest.java
index 52932c8c..cea20f04 100644
--- a/connector/src/test/java/at/asitplus/eidas/specific/connector/test/utils/AuthenticationDataBuilderTest.java
+++ b/connector/src/test/java/at/asitplus/eidas/specific/connector/test/utils/AuthenticationDataBuilderTest.java
@@ -169,7 +169,7 @@ public class AuthenticationDataBuilderTest {
public void moaIdMode() throws EaafAuthenticationException, EaafBuilderException {
//initialize state
boolean isTestIdentity = RandomUtils.nextBoolean();
- pendingReq.getSessionData(EidAuthProcessDataWrapper.class).setTestIdentity(true);
+ pendingReq.getSessionData(EidAuthProcessDataWrapper.class).setTestIdentity(isTestIdentity);
pendingReq.getSessionData(AuthProcessDataWrapper.class).setEidProcess(false);
IIdentityLink idl = buildDummyIdl();
pendingReq.getSessionData(AuthProcessDataWrapper.class).setIdentityLink(idl);