summaryrefslogtreecommitdiff
path: root/eaaf_modules/eaaf_module_pvp2_idp
diff options
context:
space:
mode:
authorThomas <>2021-03-12 10:46:26 +0100
committerThomas <>2021-03-12 10:46:26 +0100
commit391bc8546bf5bc9a6396378ebec50a7e35031adc (patch)
treecce119ccb5028b42571196e9aa0cc5bfb54c91e4 /eaaf_modules/eaaf_module_pvp2_idp
parent16fcf9a762e4ee145e6f276061dc1c5d6c20b73c (diff)
downloadEAAF-Components-391bc8546bf5bc9a6396378ebec50a7e35031adc.tar.gz
EAAF-Components-391bc8546bf5bc9a6396378ebec50a7e35031adc.tar.bz2
EAAF-Components-391bc8546bf5bc9a6396378ebec50a7e35031adc.zip
update errorMessage generation for SAML2 authentication protocol to return external error-codes only
Diffstat (limited to 'eaaf_modules/eaaf_module_pvp2_idp')
-rw-r--r--eaaf_modules/eaaf_module_pvp2_idp/src/main/java/at/gv/egiz/eaaf/modules/pvp2/idp/impl/AbstractPvp2XProtocol.java32
1 files changed, 19 insertions, 13 deletions
diff --git a/eaaf_modules/eaaf_module_pvp2_idp/src/main/java/at/gv/egiz/eaaf/modules/pvp2/idp/impl/AbstractPvp2XProtocol.java b/eaaf_modules/eaaf_module_pvp2_idp/src/main/java/at/gv/egiz/eaaf/modules/pvp2/idp/impl/AbstractPvp2XProtocol.java
index 50fd0f44..afef878b 100644
--- a/eaaf_modules/eaaf_module_pvp2_idp/src/main/java/at/gv/egiz/eaaf/modules/pvp2/idp/impl/AbstractPvp2XProtocol.java
+++ b/eaaf_modules/eaaf_module_pvp2_idp/src/main/java/at/gv/egiz/eaaf/modules/pvp2/idp/impl/AbstractPvp2XProtocol.java
@@ -129,7 +129,7 @@ public abstract class AbstractPvp2XProtocol extends AbstractController implement
final StatusCode statusCode = Saml2Utils.createSamlObject(StatusCode.class);
final StatusMessage statusMessage = Saml2Utils.createSamlObject(StatusMessage.class);
- String moaError = null;
+ String internalErrorCode = null;
if (e instanceof NoPassivAuthenticationException) {
statusCode.setValue(StatusCode.NO_PASSIVE);
@@ -149,29 +149,35 @@ public abstract class AbstractPvp2XProtocol extends AbstractController implement
final String statusMessageValue = ex.getStatusMessageValue();
if (statusMessageValue != null) {
statusMessage.setMessage(StringEscapeUtils.escapeXml(statusMessageValue));
+
}
- moaError = statusMessager.mapInternalErrorToExternalError(ex.getErrorId());
+
+ internalErrorCode = ex.getErrorId();
} else {
statusCode.setValue(StatusCode.RESPONDER);
statusMessage.setMessage(StringEscapeUtils.escapeXml(e.getLocalizedMessage()));
- moaError = statusMessager.getResponseErrorCode(e);
+ internalErrorCode = statusMessager.getResponseErrorCode(e);
+
}
- if (StringUtils.isNotEmpty(moaError)) {
- final StatusCode moaStatusCode = Saml2Utils.createSamlObject(StatusCode.class);
- moaStatusCode.setValue(moaError);
- statusCode.setStatusCode(moaStatusCode);
+ //set external sub-statusCode if one was selected
+ if (StringUtils.isNotEmpty(internalErrorCode)) {
+ final StatusCode externalStatusCode = Saml2Utils.createSamlObject(StatusCode.class);
+ externalStatusCode.setValue(
+ statusMessager.mapInternalErrorToExternalError(internalErrorCode));
+ statusCode.setStatusCode(externalStatusCode);
+
}
- status.setStatusCode(statusCode);
+ //set status-message if availabe
if (statusMessage.getMessage() != null) {
status.setStatusMessage(statusMessage);
- }
- samlResponse.setStatus(status);
- final String remoteSessionID = Saml2Utils.getSecureIdentifier();
- samlResponse.setID(remoteSessionID);
-
+ }
+ status.setStatusCode(statusCode);
+
+ samlResponse.setStatus(status);
+ samlResponse.setID(Saml2Utils.getSecureIdentifier());
samlResponse.setIssueInstant(new DateTime());
final Issuer nissuer = Saml2Utils.createSamlObject(Issuer.class);
nissuer.setValue(pvpBasicConfiguration.getIdpEntityId(pvpRequest.getAuthUrl()));