Skip to content

Commit b451ede

Browse files
committed
Add Skipping Decryption Error Message
Closes gh-10220
1 parent c6e5781 commit b451ede

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,10 @@ private void process(Saml2AuthenticationToken token, Response response) {
491491
if (responseSigned) {
492492
this.responseElementsDecrypter.accept(responseToken);
493493
}
494+
else if (!response.getEncryptedAssertions().isEmpty()) {
495+
result = result.concat(new Saml2Error(Saml2ErrorCodes.INVALID_SIGNATURE,
496+
"Did not decrypt response [" + response.getID() + "] since it is not signed"));
497+
}
494498
result = result.concat(this.responseValidator.convert(responseToken));
495499
boolean allAssertionsSigned = true;
496500
for (Assertion assertion : response.getAssertions()) {

saml2/saml2-service-provider/src/opensaml4Test/java/org/springframework/security/saml2/provider/service/authentication/OpenSaml4AuthenticationProviderTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ public void authenticateWhenEncryptedAssertionWithoutSignatureThenItFails() {
280280
Saml2AuthenticationToken token = token(response, decrypting(verifying(registration())));
281281
assertThatExceptionOfType(Saml2AuthenticationException.class)
282282
.isThrownBy(() -> this.provider.authenticate(token))
283-
.satisfies(errorOf(Saml2ErrorCodes.MALFORMED_RESPONSE_DATA));
283+
.satisfies(errorOf(Saml2ErrorCodes.INVALID_SIGNATURE, "Did not decrypt response"));
284284
}
285285

286286
@Test

0 commit comments

Comments
 (0)