You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by co...@apache.org on 2016/09/28 14:26:28 UTC
svn commit: r1762671 - in /webservices/wss4j/branches/2_1_x-fixes:
ws-security-common/src/test/java/org/apache/wss4j/common/attachment/
ws-security-dom/src/main/java/org/apache/wss4j/dom/transform/
ws-security-stax/src/main/java/org/apache/wss4j/stax/i...
Author: coheigea
Date: Wed Sep 28 14:26:27 2016
New Revision: 1762671
URL: http://svn.apache.org/viewvc?rev=1762671&view=rev
Log:
[WSS-590] - WSS4J relies on deafult locale
Modified:
webservices/wss4j/branches/2_1_x-fixes/ws-security-common/src/test/java/org/apache/wss4j/common/attachment/AttachmentTest.java
webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/transform/AttachmentContentSignatureTransform.java
webservices/wss4j/branches/2_1_x-fixes/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/transformer/AttachmentContentSignatureTransform.java
Modified: webservices/wss4j/branches/2_1_x-fixes/ws-security-common/src/test/java/org/apache/wss4j/common/attachment/AttachmentTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/2_1_x-fixes/ws-security-common/src/test/java/org/apache/wss4j/common/attachment/AttachmentTest.java?rev=1762671&r1=1762670&r2=1762671&view=diff
==============================================================================
--- webservices/wss4j/branches/2_1_x-fixes/ws-security-common/src/test/java/org/apache/wss4j/common/attachment/AttachmentTest.java (original)
+++ webservices/wss4j/branches/2_1_x-fixes/ws-security-common/src/test/java/org/apache/wss4j/common/attachment/AttachmentTest.java Wed Sep 28 14:26:27 2016
@@ -23,6 +23,16 @@ import org.junit.Test;
import org.apache.wss4j.common.util.AttachmentUtils;
public class AttachmentTest {
+
+ @Test
+ public void testMatch() {
+ Assert.assertTrue("text/xml".matches("(?i)(text/xml).*"));
+ Assert.assertTrue("TEXT/XML".matches("(?i)(text/xml).*"));
+ Assert.assertTrue("application/xml".matches("(?i)(application/xml).*"));
+ Assert.assertTrue("APPLICATION/XML".matches("(?i)(application/xml).*"));
+ Assert.assertTrue("text/plain".matches("(?i)(text/).*"));
+ Assert.assertTrue("TEXT/PLAIN".matches("(?i)(text/).*"));
+ }
@Test
public void testMimeHeaderUncomment_1() throws Exception {
Modified: webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/transform/AttachmentContentSignatureTransform.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/transform/AttachmentContentSignatureTransform.java?rev=1762671&r1=1762670&r2=1762671&view=diff
==============================================================================
--- webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/transform/AttachmentContentSignatureTransform.java (original)
+++ webservices/wss4j/branches/2_1_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/transform/AttachmentContentSignatureTransform.java Wed Sep 28 14:26:27 2016
@@ -176,15 +176,11 @@ public class AttachmentContentSignatureT
}
String mimeType = attachment.getMimeType();
- String lowerCaseMimeType = null;
- if (mimeType != null) {
- lowerCaseMimeType = mimeType.toLowerCase();
- }
- if (lowerCaseMimeType != null
- && (lowerCaseMimeType.startsWith("text/xml")
- || lowerCaseMimeType.startsWith("application/xml")
- || lowerCaseMimeType.matches("(application|image)/.*\\+xml.*"))) {
+ if (mimeType != null
+ && (mimeType.matches("(?i)(text/xml).*")
+ || mimeType.matches("(?i)(application/xml).*")
+ || mimeType.matches("(?i)(application|image)/.*\\+xml.*"))) {
/* 5.4.2:
* Content of an XML Content-Type MUST be XML canonicalized using
* Exclusive XML Canonicalization without comments,as specified by
@@ -201,7 +197,7 @@ public class AttachmentContentSignatureT
XMLSignatureInput xmlSignatureInput = new XMLSignatureInput(inputStream);
canon.canonicalizeXPathNodeSet(xmlSignatureInput.getNodeSet());
- } else if (lowerCaseMimeType != null && lowerCaseMimeType.startsWith("text/")) {
+ } else if (mimeType != null && mimeType.matches("(?i)(text/).*")) {
CRLFOutputStream crlfOutputStream = new CRLFOutputStream(outputStream);
int numBytes;
byte[] buf = new byte[8192];
Modified: webservices/wss4j/branches/2_1_x-fixes/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/transformer/AttachmentContentSignatureTransform.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/branches/2_1_x-fixes/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/transformer/AttachmentContentSignatureTransform.java?rev=1762671&r1=1762670&r2=1762671&view=diff
==============================================================================
--- webservices/wss4j/branches/2_1_x-fixes/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/transformer/AttachmentContentSignatureTransform.java (original)
+++ webservices/wss4j/branches/2_1_x-fixes/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/transformer/AttachmentContentSignatureTransform.java Wed Sep 28 14:26:27 2016
@@ -74,15 +74,11 @@ public class AttachmentContentSignatureT
@Override
public void transform(InputStream inputStream) throws XMLStreamException {
String mimeType = getAttachment().getMimeType();
- String lowerCaseMimeType = null;
- if (mimeType != null) {
- lowerCaseMimeType = mimeType.toLowerCase();
- }
- if (lowerCaseMimeType != null
- && (lowerCaseMimeType.startsWith("text/xml")
- || lowerCaseMimeType.startsWith("application/xml")
- || lowerCaseMimeType.matches("(application|image)/.*\\+xml.*"))) {
+ if (mimeType != null
+ && (mimeType.matches("(?i)(text/xml).*")
+ || mimeType.matches("(?i)(application/xml).*")
+ || mimeType.matches("(?i)(application|image)/.*\\+xml.*"))) {
/* 5.4.2:
* Content of an XML Content-Type MUST be XML canonicalized using
* Exclusive XML Canonicalization without comments,as specified by
@@ -102,7 +98,7 @@ public class AttachmentContentSignatureT
}
canon.transform(inputStream);
- } else if (lowerCaseMimeType != null && lowerCaseMimeType.startsWith("text/")) {
+ } else if (mimeType != null && mimeType.matches("(?i)(text/).*")) {
CRLFOutputStream crlfOutputStream = new CRLFOutputStream(getOutputStream());
try {
setOutputStream(crlfOutputStream);