|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2023 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.
|
|
53 | 53 | import org.opensaml.saml.saml2.core.EncryptedID;
|
54 | 54 | import org.opensaml.saml.saml2.core.NameID;
|
55 | 55 | import org.opensaml.saml.saml2.core.OneTimeUse;
|
| 56 | +import org.opensaml.saml.saml2.core.ProxyRestriction; |
56 | 57 | import org.opensaml.saml.saml2.core.Response;
|
57 | 58 | import org.opensaml.saml.saml2.core.StatusCode;
|
58 | 59 | import org.opensaml.saml.saml2.core.SubjectConfirmation;
|
|
61 | 62 | import org.opensaml.saml.saml2.core.impl.EncryptedAssertionBuilder;
|
62 | 63 | import org.opensaml.saml.saml2.core.impl.EncryptedIDBuilder;
|
63 | 64 | import org.opensaml.saml.saml2.core.impl.NameIDBuilder;
|
| 65 | +import org.opensaml.saml.saml2.core.impl.ProxyRestrictionBuilder; |
64 | 66 | import org.opensaml.xmlsec.encryption.impl.EncryptedDataBuilder;
|
65 | 67 | import org.opensaml.xmlsec.signature.support.SignatureConstants;
|
66 | 68 | import org.w3c.dom.Element;
|
@@ -741,6 +743,19 @@ public void authenticateWhenAssertionIssuerNotValidThenFailsWithInvalidIssuer()
|
741 | 743 | .withMessageContaining("did not match any valid issuers");
|
742 | 744 | }
|
743 | 745 |
|
| 746 | + // gh-14931 |
| 747 | + @Test |
| 748 | + public void authenticateWhenAssertionHasProxyRestrictionThenParses() { |
| 749 | + OpenSaml4AuthenticationProvider provider = new OpenSaml4AuthenticationProvider(); |
| 750 | + Response response = response(); |
| 751 | + Assertion assertion = assertion(); |
| 752 | + ProxyRestriction condition = new ProxyRestrictionBuilder().buildObject(); |
| 753 | + assertion.getConditions().getConditions().add(condition); |
| 754 | + response.getAssertions().add(assertion); |
| 755 | + Saml2AuthenticationToken token = token(signed(response), verifying(registration())); |
| 756 | + provider.authenticate(token); |
| 757 | + } |
| 758 | + |
744 | 759 | private <T extends XMLObject> T build(QName qName) {
|
745 | 760 | return (T) XMLObjectProviderRegistrySupport.getBuilderFactory().getBuilder(qName).buildObject(qName);
|
746 | 761 | }
|
|
0 commit comments