Skip to content

Commit ff71fcb

Browse files
ClaudioConsolmagnojzheaux
authored andcommitted
Use 'md:' prefix in EntityDescriptor XML
Create the EntityDescriptor object with EntityDescriptor.DEFAULT_ELEMENT_NAME instead of EntityDescriptor.ELEMENT_QNAME. That ensures the EntityDescriptor tag is marshalled to xml with the 'md:' prefix, consistent with all other metadata tags. Closes #11283
1 parent 33b74c7 commit ff71fcb

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

saml2/saml2-service-provider/src/main/java/org/springframework/security/saml2/provider/service/metadata/OpenSamlMetadataResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public OpenSamlMetadataResolver() {
6969

7070
@Override
7171
public String resolve(RelyingPartyRegistration relyingPartyRegistration) {
72-
EntityDescriptor entityDescriptor = build(EntityDescriptor.ELEMENT_QNAME);
72+
EntityDescriptor entityDescriptor = build(EntityDescriptor.DEFAULT_ELEMENT_NAME);
7373
entityDescriptor.setEntityID(relyingPartyRegistration.getEntityId());
7474
SPSSODescriptor spSsoDescriptor = buildSpSsoDescriptor(relyingPartyRegistration);
7575
entityDescriptor.getRoleDescriptors(SPSSODescriptor.DEFAULT_ELEMENT_NAME).add(spSsoDescriptor);

saml2/saml2-service-provider/src/test/java/org/springframework/security/saml2/provider/service/metadata/OpenSamlMetadataResolverTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public void resolveWhenRelyingPartyThenMetadataMatches() {
3636
.assertionConsumerServiceBinding(Saml2MessageBinding.REDIRECT).build();
3737
OpenSamlMetadataResolver openSamlMetadataResolver = new OpenSamlMetadataResolver();
3838
String metadata = openSamlMetadataResolver.resolve(relyingPartyRegistration);
39-
assertThat(metadata).contains("<EntityDescriptor").contains("entityID=\"rp-entity-id\"")
39+
assertThat(metadata).contains("<md:EntityDescriptor").contains("entityID=\"rp-entity-id\"")
4040
.contains("WantAssertionsSigned=\"true\"").contains("<md:KeyDescriptor use=\"signing\">")
4141
.contains("<md:KeyDescriptor use=\"encryption\">")
4242
.contains("<ds:X509Certificate>MIICgTCCAeoCCQCuVzyqFgMSyDANBgkqhkiG9w0BAQsFADCBhDELMAkGA1UEBh")
@@ -52,7 +52,7 @@ public void resolveWhenRelyingPartyNoCredentialsThenMetadataMatches() {
5252
.build();
5353
OpenSamlMetadataResolver openSamlMetadataResolver = new OpenSamlMetadataResolver();
5454
String metadata = openSamlMetadataResolver.resolve(relyingPartyRegistration);
55-
assertThat(metadata).contains("<EntityDescriptor").contains("entityID=\"rp-entity-id\"")
55+
assertThat(metadata).contains("<md:EntityDescriptor").contains("entityID=\"rp-entity-id\"")
5656
.contains("WantAssertionsSigned=\"true\"").doesNotContain("<md:KeyDescriptor use=\"signing\">")
5757
.doesNotContain("<md:KeyDescriptor use=\"encryption\">")
5858
.contains("Binding=\"urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST\"")

0 commit comments

Comments
 (0)