From a529607d426a8cc70bec83abc2b861442f0030c8 Mon Sep 17 00:00:00 2001 From: Josh Cummings Date: Fri, 21 Jun 2024 12:56:38 -0600 Subject: [PATCH] Add samlmetadata Qualifier to Content Type Closes gh-15147 --- .../saml2/provider/service/web/Saml2MetadataFilter.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/saml2/saml2-service-provider/src/main/java/org/springframework/security/saml2/provider/service/web/Saml2MetadataFilter.java b/saml2/saml2-service-provider/src/main/java/org/springframework/security/saml2/provider/service/web/Saml2MetadataFilter.java index 723acfeba7..129f1d0498 100644 --- a/saml2/saml2-service-provider/src/main/java/org/springframework/security/saml2/provider/service/web/Saml2MetadataFilter.java +++ b/saml2/saml2-service-provider/src/main/java/org/springframework/security/saml2/provider/service/web/Saml2MetadataFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2024 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,7 +26,6 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import org.springframework.http.HttpHeaders; -import org.springframework.http.MediaType; import org.springframework.security.saml2.Saml2Exception; import org.springframework.security.saml2.provider.service.metadata.Saml2MetadataResolver; import org.springframework.security.saml2.provider.service.metadata.Saml2MetadataResponse; @@ -103,7 +102,7 @@ public final class Saml2MetadataFilter extends OncePerRequestFilter { private void writeMetadataToResponse(HttpServletResponse response, Saml2MetadataResponse metadata) throws IOException { - response.setContentType(MediaType.APPLICATION_XML_VALUE); + response.setContentType("application/samlmetadata+xml"); String format = "attachment; filename=\"%s\"; filename*=UTF-8''%s"; String fileName = metadata.getFileName(); String encodedFileName = URLEncoder.encode(fileName, StandardCharsets.UTF_8);