ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1626724 - in /webservices/wss4j/trunk/ws-security-dom/src: main/java/org/apache/wss4j/dom/message/token/Timestamp.java main/java/org/apache/wss4j/dom/util/XmlSchemaDateFormat.java test/java/org/apache/wss4j/dom/message/TimestampTest.java
Date Mon, 22 Sep 2014 10:34:55 GMT
Author: coheigea
Date: Mon Sep 22 10:34:54 2014
New Revision: 1626724

URL: http://svn.apache.org/r1626724
Log:
[WSS-513] - Fails to parse Timestamp headers in Thai locale

Modified:
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/Timestamp.java
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/util/XmlSchemaDateFormat.java
    webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/TimestampTest.java

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/Timestamp.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/Timestamp.java?rev=1626724&r1=1626723&r2=1626724&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/Timestamp.java
(original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/Timestamp.java
Mon Sep 22 10:34:54 2014
@@ -24,6 +24,7 @@ import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.Locale;
 import java.util.TimeZone;
 
 import javax.xml.datatype.DatatypeConstants;
@@ -197,7 +198,7 @@ public class Timestamp {
         if (milliseconds) {
             zulu = new XmlSchemaDateFormat();
         } else {
-            zulu = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
+            zulu = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.ENGLISH);
             zulu.setTimeZone(TimeZone.getTimeZone("UTC"));
         }
         Element elementCreated =

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/util/XmlSchemaDateFormat.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/util/XmlSchemaDateFormat.java?rev=1626724&r1=1626723&r2=1626724&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/util/XmlSchemaDateFormat.java
(original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/util/XmlSchemaDateFormat.java
Mon Sep 22 10:34:54 2014
@@ -25,6 +25,7 @@ import java.text.ParsePosition;
 import java.text.SimpleDateFormat;
 import java.text.ParseException;
 import java.util.Date;
+import java.util.Locale;
 import java.util.TimeZone;
 
 /**
@@ -48,7 +49,7 @@ public class XmlSchemaDateFormat extends
      * DateFormat for Zulu (UTC) form of an XML Schema dateTime string.
      */
     private static final DateFormat DATEFORMAT_XSD_ZULU = new SimpleDateFormat(
-            "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
+            "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.ENGLISH);
 
     static {
         DATEFORMAT_XSD_ZULU.setTimeZone(TimeZone.getTimeZone("UTC"));

Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/TimestampTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/TimestampTest.java?rev=1626724&r1=1626723&r2=1626724&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/TimestampTest.java
(original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/message/TimestampTest.java
Mon Sep 22 10:34:54 2014
@@ -43,6 +43,7 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Date;
 import java.util.List;
+import java.util.Locale;
 
 /**
  * WS-Security Test Case for Timestamps.
@@ -821,6 +822,33 @@ public class TimestampTest extends org.j
         assertTrue(actionResult != null);
     }
     
+    @org.junit.Test
+    public void testThaiLocaleVerification() throws Exception {
+        
+        Locale defaultLocale = Locale.getDefault();
+        try {
+            Locale.setDefault(new Locale("th", "TH"));
+        
+            Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
+            WSSecHeader secHeader = new WSSecHeader();
+            secHeader.insertSecurityHeader(doc);
+            
+            WSSecTimestamp timestamp = new WSSecTimestamp();
+            timestamp.setTimeToLive(300);
+            Document createdDoc = timestamp.build(doc, secHeader);
+            
+            //
+            // Do some processing
+            //
+            List<WSSecurityEngineResult> wsResult = verify(createdDoc, WSSConfig.getNewInstance());
+            WSSecurityEngineResult actionResult = 
+                WSSecurityUtil.fetchActionResult(wsResult, WSConstants.TS);
+            assertTrue(actionResult != null);
+        } finally {
+            Locale.setDefault(defaultLocale);
+        }
+    }
+    
     /**
      * Verifies the soap envelope
      */



Mime
View raw message