Skip to content

Commit 5cda362

Browse files
committed
Collect All Validation Errors
- OpenSaml4AuthenticationProvider now collects all validation errors instead of treating some as their own exception Issue gh-10220
1 parent a99a04f commit 5cda362

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

saml2/saml2-service-provider/src/opensaml4Main/java/org/springframework/security/saml2/provider/service/authentication/OpenSaml4AuthenticationProvider.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,8 @@ public static Converter<ResponseToken, Saml2ResponseValidatorResult> createDefau
380380
result = result.concat(new Saml2Error(Saml2ErrorCodes.INVALID_ISSUER, message));
381381
}
382382
if (response.getAssertions().isEmpty()) {
383-
throw createAuthenticationException(Saml2ErrorCodes.MALFORMED_RESPONSE_DATA,
384-
"No assertions found in response.", null);
383+
result = result.concat(
384+
new Saml2Error(Saml2ErrorCodes.MALFORMED_RESPONSE_DATA, "No assertions found in response."));
385385
}
386386
return result;
387387
};
@@ -505,10 +505,10 @@ private void process(Saml2AuthenticationToken token, Response response) {
505505
if (!responseSigned && !allAssertionsSigned) {
506506
String description = "Either the response or one of the assertions is unsigned. "
507507
+ "Please either sign the response or all of the assertions.";
508-
throw createAuthenticationException(Saml2ErrorCodes.INVALID_SIGNATURE, description, null);
508+
result = result.concat(new Saml2Error(Saml2ErrorCodes.INVALID_SIGNATURE, description));
509509
}
510510
Assertion firstAssertion = CollectionUtils.firstElement(response.getAssertions());
511-
if (!hasName(firstAssertion)) {
511+
if (firstAssertion != null && !hasName(firstAssertion)) {
512512
Saml2Error error = new Saml2Error(Saml2ErrorCodes.SUBJECT_NOT_FOUND,
513513
"Assertion [" + firstAssertion.getID() + "] is missing a subject");
514514
result = result.concat(error);

0 commit comments

Comments
 (0)