|
28 | 28 | import org.opensaml.core.xml.config.XMLObjectProviderRegistry;
|
29 | 29 | import org.opensaml.core.xml.io.Unmarshaller;
|
30 | 30 | import org.opensaml.saml.common.xml.SAMLConstants;
|
| 31 | +import org.opensaml.saml.ext.saml2alg.SigningMethod; |
31 | 32 | import org.opensaml.saml.saml2.metadata.EntitiesDescriptor;
|
32 | 33 | import org.opensaml.saml.saml2.metadata.EntityDescriptor;
|
| 34 | +import org.opensaml.saml.saml2.metadata.Extensions; |
33 | 35 | import org.opensaml.saml.saml2.metadata.IDPSSODescriptor;
|
34 | 36 | import org.opensaml.saml.saml2.metadata.KeyDescriptor;
|
35 | 37 | import org.opensaml.saml.saml2.metadata.SingleSignOnService;
|
@@ -98,6 +100,11 @@ RelyingPartyRegistration.Builder convert(InputStream inputStream) {
|
98 | 100 | .wantAuthnRequestsSigned(Boolean.TRUE.equals(idpssoDescriptor.getWantAuthnRequestsSigned()))
|
99 | 101 | .verificationX509Credentials((c) -> c.addAll(verification))
|
100 | 102 | .encryptionX509Credentials((c) -> c.addAll(encryption)));
|
| 103 | + List<SigningMethod> signingMethods = signingMethods(idpssoDescriptor); |
| 104 | + for (SigningMethod method : signingMethods) { |
| 105 | + builder.assertingPartyDetails( |
| 106 | + (party) -> party.signingAlgorithms((algorithms) -> algorithms.add(method.getAlgorithm()))); |
| 107 | + } |
101 | 108 | for (SingleSignOnService singleSignOnService : idpssoDescriptor.getSingleSignOnServices()) {
|
102 | 109 | Saml2MessageBinding binding;
|
103 | 110 | if (singleSignOnService.getBinding().equals(Saml2MessageBinding.POST.getUrn())) {
|
@@ -127,6 +134,17 @@ private List<X509Certificate> certificates(KeyDescriptor keyDescriptor) {
|
127 | 134 | }
|
128 | 135 | }
|
129 | 136 |
|
| 137 | + private List<SigningMethod> signingMethods(IDPSSODescriptor idpssoDescriptor) { |
| 138 | + Extensions extensions = idpssoDescriptor.getExtensions(); |
| 139 | + List<SigningMethod> result = signingMethods(extensions); |
| 140 | + if (!result.isEmpty()) { |
| 141 | + return result; |
| 142 | + } |
| 143 | + EntityDescriptor descriptor = (EntityDescriptor) idpssoDescriptor.getParent(); |
| 144 | + extensions = descriptor.getExtensions(); |
| 145 | + return signingMethods(extensions); |
| 146 | + } |
| 147 | + |
130 | 148 | private EntityDescriptor entityDescriptor(InputStream inputStream) {
|
131 | 149 | Document document = document(inputStream);
|
132 | 150 | Element element = document.getDocumentElement();
|
@@ -158,4 +176,11 @@ private Document document(InputStream inputStream) {
|
158 | 176 | }
|
159 | 177 | }
|
160 | 178 |
|
| 179 | + private <T> List<T> signingMethods(Extensions extensions) { |
| 180 | + if (extensions != null) { |
| 181 | + return (List<T>) extensions.getUnknownXMLObjects(SigningMethod.DEFAULT_ELEMENT_NAME); |
| 182 | + } |
| 183 | + return new ArrayList<>(); |
| 184 | + } |
| 185 | + |
161 | 186 | }
|
0 commit comments