|
32 | 32 |
|
33 | 33 | import javax.xml.namespace.QName;
|
34 | 34 |
|
| 35 | +import com.fasterxml.jackson.databind.ObjectMapper; |
35 | 36 | import net.shibboleth.utilities.java.support.xml.SerializeSupport;
|
36 | 37 | import org.junit.jupiter.api.Test;
|
37 | 38 | import org.opensaml.core.xml.XMLObject;
|
|
68 | 69 |
|
69 | 70 | import org.springframework.core.convert.converter.Converter;
|
70 | 71 | import org.springframework.security.core.Authentication;
|
| 72 | +import org.springframework.security.jackson2.SecurityJackson2Modules; |
71 | 73 | import org.springframework.security.saml2.Saml2Exception;
|
72 | 74 | import org.springframework.security.saml2.core.Saml2Error;
|
73 | 75 | import org.springframework.security.saml2.core.Saml2ErrorCodes;
|
@@ -349,6 +351,23 @@ public void authenticateWhenAssertionContainsAttributesThenItSucceeds() {
|
349 | 351 | assertThat(principal.getSessionIndexes()).contains("session-index");
|
350 | 352 | }
|
351 | 353 |
|
| 354 | + // gh-11785 |
| 355 | + @Test |
| 356 | + public void deserializeWhenAssertionContainsAttributesThenWorks() throws Exception { |
| 357 | + ObjectMapper mapper = new ObjectMapper(); |
| 358 | + ClassLoader loader = getClass().getClassLoader(); |
| 359 | + mapper.registerModules(SecurityJackson2Modules.getModules(loader)); |
| 360 | + Response response = response(); |
| 361 | + Assertion assertion = assertion(); |
| 362 | + List<AttributeStatement> attributes = TestOpenSamlObjects.attributeStatements(); |
| 363 | + assertion.getAttributeStatements().addAll(attributes); |
| 364 | + response.getAssertions().add(signed(assertion)); |
| 365 | + Saml2AuthenticationToken token = token(response, verifying(registration())); |
| 366 | + Authentication authentication = this.provider.authenticate(token); |
| 367 | + String result = mapper.writeValueAsString(authentication); |
| 368 | + mapper.readValue(result, Authentication.class); |
| 369 | + } |
| 370 | + |
352 | 371 | @Test
|
353 | 372 | public void authenticateWhenAssertionContainsCustomAttributesThenItSucceeds() {
|
354 | 373 | Response response = response();
|
|
0 commit comments