|
1 | 1 | /* |
2 | | - * Copyright 2002-2022 the original author or authors. |
| 2 | + * Copyright 2002-2024 the original author or authors. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
|
55 | 55 | import org.opensaml.saml.saml2.core.EncryptedID; |
56 | 56 | import org.opensaml.saml.saml2.core.NameID; |
57 | 57 | import org.opensaml.saml.saml2.core.OneTimeUse; |
| 58 | +import org.opensaml.saml.saml2.core.ProxyRestriction; |
58 | 59 | import org.opensaml.saml.saml2.core.Response; |
59 | 60 | import org.opensaml.saml.saml2.core.StatusCode; |
60 | 61 | import org.opensaml.saml.saml2.core.SubjectConfirmation; |
|
63 | 64 | import org.opensaml.saml.saml2.core.impl.EncryptedAssertionBuilder; |
64 | 65 | import org.opensaml.saml.saml2.core.impl.EncryptedIDBuilder; |
65 | 66 | import org.opensaml.saml.saml2.core.impl.NameIDBuilder; |
| 67 | +import org.opensaml.saml.saml2.core.impl.ProxyRestrictionBuilder; |
66 | 68 | import org.opensaml.xmlsec.encryption.impl.EncryptedDataBuilder; |
67 | 69 | import org.opensaml.xmlsec.signature.support.SignatureConstants; |
68 | 70 | import org.w3c.dom.Element; |
@@ -777,6 +779,19 @@ public void authenticateWhenAssertionIssuerNotValidThenFailsWithInvalidIssuer() |
777 | 779 | .withMessageContaining("did not match any valid issuers"); |
778 | 780 | } |
779 | 781 |
|
| 782 | + // gh-14931 |
| 783 | + @Test |
| 784 | + public void authenticateWhenAssertionHasProxyRestrictionThenParses() { |
| 785 | + OpenSaml4AuthenticationProvider provider = new OpenSaml4AuthenticationProvider(); |
| 786 | + Response response = response(); |
| 787 | + Assertion assertion = assertion(); |
| 788 | + ProxyRestriction condition = new ProxyRestrictionBuilder().buildObject(); |
| 789 | + assertion.getConditions().getConditions().add(condition); |
| 790 | + response.getAssertions().add(assertion); |
| 791 | + Saml2AuthenticationToken token = token(signed(response), verifying(registration())); |
| 792 | + provider.authenticate(token); |
| 793 | + } |
| 794 | + |
780 | 795 | private <T extends XMLObject> T build(QName qName) { |
781 | 796 | return (T) XMLObjectProviderRegistrySupport.getBuilderFactory().getBuilder(qName).buildObject(qName); |
782 | 797 | } |
|
0 commit comments