Denote media type of metadata as application/xml if browser does not ask for applicat...
authorlajoie <lajoie@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Mon, 13 Sep 2010 17:29:31 +0000 (17:29 +0000)
committerlajoie <lajoie@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Mon, 13 Sep 2010 17:29:31 +0000 (17:29 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/branches/REL_2@2950 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

doc/RELEASE-NOTES.txt
src/main/java/edu/internet2/middleware/shibboleth/idp/profile/SAMLMetadataProfileHandler.java

index 751c7a9..b74325a 100644 (file)
@@ -3,6 +3,7 @@ Changes in Release 2.2.0
 [SIDP-411] - Check for loginContext != null at login.jsp
 [SIDP-409] - Pass IdP w/o authenticating
 [SIDP-407] - Shibboleth SSO profile handler sets incorrect protocol string in outbound message context
+[SIDP-403] - Use text/xml as the media type for returned metadata unless user agent request metadata media type
 [SIDP-402] - Update 3rd party libraries for 2.2 release
 [SIDP-397] - Remove any unit test that won't be fixed in the 2.X branch, fix the rest
 [SIDP-396] - Previous session LoginHandler used even if authentication method has expired
index 1fe38f6..3c0b5f4 100644 (file)
@@ -19,6 +19,7 @@ package edu.internet2.middleware.shibboleth.idp.profile;
 import java.io.File;
 import java.io.OutputStreamWriter;
 
+import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import org.opensaml.Configuration;
@@ -71,8 +72,15 @@ public class SAMLMetadataProfileHandler extends AbstractRequestURIMappedProfileH
     public void processRequest(InTransport in, OutTransport out) throws ProfileException {
         XMLObject metadata;
 
+        HttpServletRequest httpRequest = ((HttpServletRequestAdapter)in).getWrappedRequest();
         HttpServletResponse httpResponse = ((HttpServletResponseAdapter)out).getWrappedResponse();
-        httpResponse.setContentType("application/samlmetadata+xml");
+        
+        String acceptHeder = DatatypeHelper.safeTrimOrNullString(httpRequest.getHeader("Accept"));
+        if(acceptHeder != null && !acceptHeder.contains("application/samlmetadata+xml")){
+            httpResponse.setContentType("application/xml");
+        }else{
+            httpResponse.setContentType("application/samlmetadata+xml");
+        }
         
         try {
             String requestedEntity = DatatypeHelper.safeTrimOrNullString(((HttpServletRequestAdapter) in)