[java-shib-idp2 COMMIT] in /branches/REL_2: doc/RELEASE-NOTES.txt src/main/java/edu/internet2/middleware/shibboleth/i...
noreply at shibboleth.net
noreply at shibboleth.net
Thu Jun 21 13:03:54 BST 2012
Author: lajoie
Date: Thu Jun 21 08:03:54 2012
New Revision: 3110
URL: http://svn.shibboleth.net/view/java-shib-idp2?rev=3110&view=rev
Log:
set HTTP response character encoding in case container - SIDP-552
Modified:
branches/REL_2/doc/RELEASE-NOTES.txt
branches/REL_2/src/main/java/edu/internet2/middleware/shibboleth/idp/profile/SAMLMetadataProfileHandler.java
Modified: branches/REL_2/doc/RELEASE-NOTES.txt
URL: http://svn.shibboleth.net/view/java-shib-idp2/branches/REL_2/doc/RELEASE-NOTES.txt?rev=3110&r1=3109&r2=3110&view=diff
==============================================================================
--- branches/REL_2/doc/RELEASE-NOTES.txt (original)
+++ branches/REL_2/doc/RELEASE-NOTES.txt Thu Jun 21 08:03:54 2012
@@ -3,6 +3,7 @@
[SIDP-547] - VelocityEngine initialization was not effectively using UTF-8 input and output encoding
[SIDP-549] - Incorrect handling of returned authn error in SSO profile handlers
[SIDP-550] - Default IdP metadata provider uses an undocumented plugin
+[SIDP-552] - IdP-Metadata containing german umlauts shows encoding-problems on Microsoft Windows
Changes in Release 2.3.6
=============================================
Modified: branches/REL_2/src/main/java/edu/internet2/middleware/shibboleth/idp/profile/SAMLMetadataProfileHandler.java
URL: http://svn.shibboleth.net/view/java-shib-idp2/branches/REL_2/src/main/java/edu/internet2/middleware/shibboleth/idp/profile/SAMLMetadataProfileHandler.java?rev=3110&r1=3109&r2=3110&view=diff
==============================================================================
--- branches/REL_2/src/main/java/edu/internet2/middleware/shibboleth/idp/profile/SAMLMetadataProfileHandler.java (original)
+++ branches/REL_2/src/main/java/edu/internet2/middleware/shibboleth/idp/profile/SAMLMetadataProfileHandler.java Thu Jun 21 08:03:54 2012
@@ -18,7 +18,8 @@
package edu.internet2.middleware.shibboleth.idp.profile;
import java.io.File;
-import java.io.OutputStreamWriter;
+import java.io.OutputStream;
+import java.nio.charset.Charset;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -36,6 +37,10 @@
import org.opensaml.xml.util.XMLHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.w3c.dom.Node;
+import org.w3c.dom.ls.DOMImplementationLS;
+import org.w3c.dom.ls.LSOutput;
+import org.w3c.dom.ls.LSSerializer;
import edu.internet2.middleware.shibboleth.common.profile.ProfileException;
import edu.internet2.middleware.shibboleth.common.profile.provider.AbstractRequestURIMappedProfileHandler;
@@ -73,19 +78,19 @@
public void processRequest(InTransport in, OutTransport out) throws ProfileException {
XMLObject metadata;
- HttpServletRequest httpRequest = ((HttpServletRequestAdapter)in).getWrappedRequest();
- HttpServletResponse httpResponse = ((HttpServletResponseAdapter)out).getWrappedResponse();
-
+ HttpServletRequest httpRequest = ((HttpServletRequestAdapter) in).getWrappedRequest();
+ HttpServletResponse httpResponse = ((HttpServletResponseAdapter) out).getWrappedResponse();
+
String acceptHeder = DatatypeHelper.safeTrimOrNullString(httpRequest.getHeader("Accept"));
- if(acceptHeder != null && !acceptHeder.contains("application/samlmetadata+xml")){
+ if (acceptHeder != null && !acceptHeder.contains("application/samlmetadata+xml")) {
httpResponse.setContentType("application/xml");
- }else{
+ } else {
httpResponse.setContentType("application/samlmetadata+xml");
}
-
+
try {
- String requestedEntity = DatatypeHelper.safeTrimOrNullString(((HttpServletRequestAdapter) in)
- .getParameterValue("entity"));
+ String requestedEntity =
+ DatatypeHelper.safeTrimOrNullString(((HttpServletRequestAdapter) in).getParameterValue("entity"));
if (requestedEntity != null) {
metadata = metadataProvider.getEntityDescriptor(requestedEntity);
} else {
@@ -94,11 +99,29 @@
if (metadata != null) {
Marshaller marshaller = Configuration.getMarshallerFactory().getMarshaller(metadata);
- XMLHelper.writeNode(marshaller.marshall(metadata), new OutputStreamWriter(out.getOutgoingStream()));
+ writeNode(marshaller.marshall(metadata), out.getOutgoingStream(), Charset.forName("UTF-8"));
}
} catch (Exception e) {
log.error("Unable to retrieve and return metadata", e);
throw new ProfileException(e);
}
}
+
+ /**
+ * Writes out the DOM node to a given output stream using a given output encoding.
+ *
+ * @param node node to write out
+ * @param output output stream to which the node is written
+ * @param outputEncoding character encoding used by the serializer
+ */
+ private void writeNode(Node node, OutputStream output, Charset outputEncoding) {
+ DOMImplementationLS domImplLS = XMLHelper.getLSDOMImpl(node);
[... 10 lines stripped ...]
More information about the commits
mailing list