瀏覽代碼

Add samlmetadata Qualifier to Content Type

Closes gh-15147
Josh Cummings 1 年之前
父節點
當前提交
a529607d42

+ 2 - 3
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);