cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1132699 - /cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/tokenstore/SecurityToken.java
Date Mon, 06 Jun 2011 16:52:54 GMT
Author: coheigea
Date: Mon Jun  6 16:52:53 2011
New Revision: 1132699

URL: http://svn.apache.org/viewvc?rev=1132699&view=rev
Log:
Adding a default expires value of 5 minutes for a SecurityToken

Modified:
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/tokenstore/SecurityToken.java

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/tokenstore/SecurityToken.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/tokenstore/SecurityToken.java?rev=1132699&r1=1132698&r2=1132699&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/tokenstore/SecurityToken.java
(original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/tokenstore/SecurityToken.java
Mon Jun  6 16:52:53 2011
@@ -91,7 +91,7 @@ public class SecurityToken {
     /**
      * A bag to hold any other properties
      */
-    private Properties  properties;
+    private Properties properties;
 
     /**
      * A flag to assist the TokenStorage
@@ -145,12 +145,16 @@ public class SecurityToken {
     
     public SecurityToken(String id) {
         this.id = id;
+        createDefaultExpires();
     }
 
     public SecurityToken(String id, Date created, Date expires) {
         this.id = id;
         this.created = created;
         this.expires = expires;
+        if (expires == null) {
+            createDefaultExpires();
+        }
     }
     
     public SecurityToken(String id,
@@ -161,6 +165,9 @@ public class SecurityToken {
         this.token = cloneElement(tokenElem);
         this.created = created;
         this.expires = expires;
+        if (expires == null) {
+            createDefaultExpires();
+        }
     }
 
     public SecurityToken(String id,
@@ -171,7 +178,11 @@ public class SecurityToken {
         if (lifetimeElem != null) {
             processLifeTime(lifetimeElem);
         }
+        if (expires == null) {
+            createDefaultExpires();
+        }
     }
+    
     private static Element cloneElement(Element el) {
         try {
             W3CDOMStreamWriter writer = new W3CDOMStreamWriter();
@@ -445,5 +456,14 @@ public class SecurityToken {
     public int getAssociatedHash() {
         return associatedHash;
     }
+    
+    /**
+     * Create a default Expires date 5 minutes in the future
+     */
+    private void createDefaultExpires() {
+        expires = new Date();
+        long currentTime = expires.getTime();
+        expires.setTime(currentTime + 300 * 1000);
+    }
 
 } 



Mime
View raw message