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:31:21 UTC

svn commit: r1762672 - in /webservices/wss4j/branches/2_0_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:31:21 2016
New Revision: 1762672

URL: http://svn.apache.org/viewvc?rev=1762672&view=rev
Log:
[WSS-590] - WSS4J relies on deafult locale

Modified:
    webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/test/java/org/apache/wss4j/common/attachment/AttachmentTest.java
    webservices/wss4j/branches/2_0_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/transform/AttachmentContentSignatureTransform.java
    webservices/wss4j/branches/2_0_x-fixes/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/transformer/AttachmentContentSignatureTransform.java

Modified: webservices/wss4j/branches/2_0_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_0_x-fixes/ws-security-common/src/test/java/org/apache/wss4j/common/attachment/AttachmentTest.java?rev=1762672&r1=1762671&r2=1762672&view=diff
==============================================================================
--- webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/test/java/org/apache/wss4j/common/attachment/AttachmentTest.java (original)
+++ webservices/wss4j/branches/2_0_x-fixes/ws-security-common/src/test/java/org/apache/wss4j/common/attachment/AttachmentTest.java Wed Sep 28 14:31:21 2016
@@ -22,6 +22,16 @@ import org.junit.Assert;
 import org.apache.wss4j.common.util.AttachmentUtils;
 
 public class AttachmentTest {
+    
+    @org.junit.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/).*"));
+    }
 
     @org.junit.Test
     public void testMimeHeaderUncomment_1() throws Exception {

Modified: webservices/wss4j/branches/2_0_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_0_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/transform/AttachmentContentSignatureTransform.java?rev=1762672&r1=1762671&r2=1762672&view=diff
==============================================================================
--- webservices/wss4j/branches/2_0_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/transform/AttachmentContentSignatureTransform.java (original)
+++ webservices/wss4j/branches/2_0_x-fixes/ws-security-dom/src/main/java/org/apache/wss4j/dom/transform/AttachmentContentSignatureTransform.java Wed Sep 28 14:31:21 2016
@@ -170,15 +170,10 @@ 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
@@ -195,7 +190,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_0_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_0_x-fixes/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/transformer/AttachmentContentSignatureTransform.java?rev=1762672&r1=1762671&r2=1762672&view=diff
==============================================================================
--- webservices/wss4j/branches/2_0_x-fixes/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/transformer/AttachmentContentSignatureTransform.java (original)
+++ webservices/wss4j/branches/2_0_x-fixes/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/transformer/AttachmentContentSignatureTransform.java Wed Sep 28 14:31:21 2016
@@ -74,15 +74,10 @@ 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 +97,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);