You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wss4j-dev@ws.apache.org by we...@apache.org on 2006/01/17 17:15:12 UTC

svn commit: r369830 - /webservices/wss4j/trunk/src/org/apache/ws/security/message/token/Timestamp.java

Author: werner
Date: Tue Jan 17 08:15:09 2006
New Revision: 369830

URL: http://svn.apache.org/viewcvs?rev=369830&view=rev
Log:
Apply patch from Christian to have a consistent behaviour when access created, expires fields.

Modified:
    webservices/wss4j/trunk/src/org/apache/ws/security/message/token/Timestamp.java

Modified: webservices/wss4j/trunk/src/org/apache/ws/security/message/token/Timestamp.java
URL: http://svn.apache.org/viewcvs/webservices/wss4j/trunk/src/org/apache/ws/security/message/token/Timestamp.java?rev=369830&r1=369829&r2=369830&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/org/apache/ws/security/message/token/Timestamp.java (original)
+++ webservices/wss4j/trunk/src/org/apache/ws/security/message/token/Timestamp.java Tue Jan 17 08:15:09 2006
@@ -45,8 +45,6 @@
 public class Timestamp {
 
     protected Element element = null;
-    protected Element elementCreated = null;
-    protected Element elementExpires = null;
     protected Vector customElements = null;
 
     protected Calendar created;
@@ -114,6 +112,7 @@
         }
     }
 
+
     /**
      * Constructs a <code>Timestamp</code> object according
      * to the defined parameters.
@@ -143,32 +142,42 @@
         	zulu = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
         	zulu.setTimeZone(TimeZone.getTimeZone("UTC"));
         }
-        Calendar rightNow = Calendar.getInstance();
+        created = getCurrentTime();
 
-        elementCreated =
+        Element elementCreated =
                 doc.createElementNS(WSConstants.WSU_NS,
                         WSConstants.WSU_PREFIX + ":" + WSConstants.CREATED_LN);
         WSSecurityUtil.setNamespace(elementCreated,
                 WSConstants.WSU_NS,
                 WSConstants.WSU_PREFIX);
-        elementCreated.appendChild(doc.createTextNode(zulu.format(rightNow.getTime())));
+        elementCreated.appendChild(doc.createTextNode(zulu.format(created.getTime())));
         element.appendChild(elementCreated);
         if (ttl != 0) {
-            long currentTime = rightNow.getTime().getTime();
+            long currentTime = created.getTimeInMillis();
             currentTime += ttl * 1000;
-            rightNow.setTime(new Date(currentTime));
+            expires = getCurrentTime();
+            expires.setTimeInMillis(currentTime);
 
-            elementExpires =
+            Element elementExpires =
                     doc.createElementNS(WSConstants.WSU_NS,
                             WSConstants.WSU_PREFIX + ":" + WSConstants.EXPIRES_LN);
             WSSecurityUtil.setNamespace(elementExpires,
                     WSConstants.WSU_NS,
                     WSConstants.WSU_PREFIX);
-            elementExpires.appendChild(doc.createTextNode(zulu.format(rightNow.getTime())));
+            elementExpires.appendChild(doc.createTextNode(zulu.format(expires.getTime())));
             element.appendChild(elementExpires);
         }
     }
 
+    /**
+     * Get the current time
+     * 
+     * @return calendar the current time
+     */
+    protected Calendar getCurrentTime() {
+    	return Calendar.getInstance();
+    }
+    
     /**
      * Returns the dom element of this <code>Timestamp</code> object.
      *



---------------------------------------------------------------------
To unsubscribe, e-mail: wss4j-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: wss4j-dev-help@ws.apache.org