cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1522901 - in /cxf/branches/2.6.x-fixes/services/sts/sts-core/src: main/java/org/apache/cxf/sts/operation/ main/java/org/apache/cxf/sts/token/provider/ main/java/org/apache/cxf/sts/token/renewer/ test/java/org/apache/cxf/sts/token/provider/...
Date Fri, 13 Sep 2013 12:42:00 GMT
Author: coheigea
Date: Fri Sep 13 12:42:00 2013
New Revision: 1522901

URL: http://svn.apache.org/r1522901
Log:
Merged revisions 1522896 via  git cherry-pick from
https://svn.apache.org/repos/asf/cxf/branches/2.7.x-fixes

........
  r1522896 | coheigea | 2013-09-13 13:34:54 +0100 (Fri, 13 Sep 2013) | 11 lines

  Merged revisions 1522895 via  git cherry-pick from
  https://svn.apache.org/repos/asf/cxf/trunk

  ........
    r1522895 | coheigea | 2013-09-13 13:31:32 +0100 (Fri, 13 Sep 2013) | 3 lines

    [CXF-5278][CXF-3932] - STS Renew returns incorrect lifetime
     - RSTR Lifetime element sets current time in Created element

  ........

........

Modified:
    cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/AbstractOperation.java
    cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenIssueOperation.java
    cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenRenewOperation.java
    cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenValidateOperation.java
    cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/SAMLTokenProvider.java
    cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/SCTProvider.java
    cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/TokenProviderResponse.java
    cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/renewer/SAMLTokenRenewer.java
    cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/renewer/TokenRenewerResponse.java
    cxf/branches/2.6.x-fixes/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/provider/SAMLProviderLifetimeTest.java
    cxf/branches/2.6.x-fixes/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/renewer/SAMLTokenRenewerLifetimeTest.java

Modified: cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/AbstractOperation.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/AbstractOperation.java?rev=1522901&r1=1522900&r2=1522901&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/AbstractOperation.java
(original)
+++ cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/AbstractOperation.java
Fri Sep 13 12:42:00 2013
@@ -275,18 +275,29 @@ public abstract class AbstractOperation 
     }
     
     /**
-     * Create a LifetimeType object given a lifetime in seconds
+     * Create a LifetimeType object given a created + expires Dates
      */
-    protected static LifetimeType createLifetime(long lifetime) {
+    protected static LifetimeType createLifetime(
+        Date tokenCreated, 
+        Date tokenExpires,
+        long lifetime
+    ) {
         AttributedDateTime created = QNameConstants.UTIL_FACTORY.createAttributedDateTime();
         AttributedDateTime expires = QNameConstants.UTIL_FACTORY.createAttributedDateTime();
         
-        Date creationTime = new Date();
-        Date expirationTime = new Date();
-        if (lifetime <= 0) {
-            lifetime = 300L;
+        Date creationTime = tokenCreated;
+        if (creationTime == null) {
+            creationTime = new Date();
+        }
+        Date expirationTime = tokenExpires;
+        if (expirationTime == null) {
+            expirationTime = new Date();
+            long lifeTimeOfToken = lifetime;
+            if (lifeTimeOfToken <= 0) {
+                lifeTimeOfToken = 300L;
+            }
+            expirationTime.setTime(creationTime.getTime() + (lifeTimeOfToken * 1000L));
         }
-        expirationTime.setTime(creationTime.getTime() + (lifetime * 1000L));
 
         XmlSchemaDateFormat fmt = new XmlSchemaDateFormat();
         created.setValue(fmt.format(creationTime));

Modified: cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenIssueOperation.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenIssueOperation.java?rev=1522901&r1=1522900&r2=1522901&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenIssueOperation.java
(original)
+++ cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenIssueOperation.java
Fri Sep 13 12:42:00 2013
@@ -300,7 +300,9 @@ public class TokenIssueOperation extends
         }
 
         // Lifetime
-        LifetimeType lifetime = createLifetime(tokenResponse.getLifetime());
+        LifetimeType lifetime = 
+            createLifetime(tokenResponse.getCreated(), tokenResponse.getExpires(),
+                           tokenResponse.getLifetime());
         JAXBElement<LifetimeType> lifetimeType = QNameConstants.WS_TRUST_FACTORY.createLifetime(lifetime);
         response.getAny().add(lifetimeType);
 

Modified: cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenRenewOperation.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenRenewOperation.java?rev=1522901&r1=1522900&r2=1522901&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenRenewOperation.java
(original)
+++ cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenRenewOperation.java
Fri Sep 13 12:42:00 2013
@@ -253,7 +253,9 @@ public class TokenRenewOperation extends
         response.getAny().add(tokenRequirements.getAppliesTo());
 
         // Lifetime
-        LifetimeType lifetime = createLifetime(tokenRenewerResponse.getLifetime());
+        LifetimeType lifetime = 
+            createLifetime(tokenRenewerResponse.getCreated(), tokenRenewerResponse.getExpires(),
+                           tokenRenewerResponse.getLifetime());
         JAXBElement<LifetimeType> lifetimeType = QNameConstants.WS_TRUST_FACTORY.createLifetime(lifetime);
         response.getAny().add(lifetimeType);
 

Modified: cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenValidateOperation.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenValidateOperation.java?rev=1522901&r1=1522900&r2=1522901&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenValidateOperation.java
(original)
+++ cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/operation/TokenValidateOperation.java
Fri Sep 13 12:42:00 2013
@@ -201,7 +201,9 @@ public class TokenValidateOperation exte
             response.getAny().add(requestedToken);
             
             // Lifetime
-            LifetimeType lifetime = createLifetime(tokenProviderResponse.getLifetime());
+            LifetimeType lifetime = 
+                createLifetime(tokenProviderResponse.getCreated(), tokenProviderResponse.getExpires(),
+                               tokenProviderResponse.getLifetime());
             JAXBElement<LifetimeType> lifetimeType =
                 QNameConstants.WS_TRUST_FACTORY.createLifetime(lifetime);
             response.getAny().add(lifetimeType);

Modified: cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/SAMLTokenProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/SAMLTokenProvider.java?rev=1522901&r1=1522900&r2=1522901&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/SAMLTokenProvider.java
(original)
+++ cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/SAMLTokenProvider.java
Fri Sep 13 12:42:00 2013
@@ -178,17 +178,15 @@ public class SAMLTokenProvider implement
             
             DateTime validFrom = null;
             DateTime validTill = null;
-            long lifetime = 0;
             if (assertion.getSamlVersion().equals(SAMLVersion.VERSION_20)) {
                 validFrom = assertion.getSaml2().getConditions().getNotBefore();
                 validTill = assertion.getSaml2().getConditions().getNotOnOrAfter();
-                lifetime = validTill.getMillis() - validFrom.getMillis();
             } else {
                 validFrom = assertion.getSaml1().getConditions().getNotBefore();
                 validTill = assertion.getSaml1().getConditions().getNotOnOrAfter();
-                lifetime = validTill.getMillis() - validFrom.getMillis();
             }
-            response.setLifetime(lifetime / 1000);
+            response.setCreated(validFrom.toDate());
+            response.setExpires(validTill.toDate());
             
             response.setEntropy(entropyBytes);
             if (keySize > 0) {

Modified: cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/SCTProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/SCTProvider.java?rev=1522901&r1=1522900&r2=1522901&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/SCTProvider.java
(original)
+++ cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/SCTProvider.java
Fri Sep 13 12:42:00 2013
@@ -132,14 +132,17 @@ public class SCTProvider implements Toke
             response.setComputedKey(keyHandler.isComputedKey());
             
             // putting the secret key into the cache
+            Date currentDate = new Date();
+            response.setCreated(currentDate);
             Date expires = null;
             if (lifetime > 0) {
                 expires = new Date();
-                long currentTime = expires.getTime();
+                long currentTime = currentDate.getTime();
                 expires.setTime(currentTime + (lifetime * 1000L));
             }
+            response.setExpires(expires);
             
-            SecurityToken token = new SecurityToken(sct.getIdentifier(), null, expires);
+            SecurityToken token = new SecurityToken(sct.getIdentifier(), currentDate, expires);
             token.setSecret(keyHandler.getSecret());
             token.setPrincipal(tokenParameters.getPrincipal());
             
@@ -183,8 +186,6 @@ public class SCTProvider implements Toke
             unAttachedReference.setWsseValueType(tokenRequirements.getTokenType());
             response.setUnattachedReference(unAttachedReference);
             
-            response.setLifetime(lifetime);
-            
             return response;
         } catch (Exception e) {
             LOG.log(Level.WARNING, "", e);

Modified: cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/TokenProviderResponse.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/TokenProviderResponse.java?rev=1522901&r1=1522900&r2=1522901&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/TokenProviderResponse.java
(original)
+++ cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/provider/TokenProviderResponse.java
Fri Sep 13 12:42:00 2013
@@ -19,6 +19,8 @@
 
 package org.apache.cxf.sts.token.provider;
 
+import java.util.Date;
+
 import org.w3c.dom.Element;
 
 /**
@@ -28,12 +30,14 @@ public class TokenProviderResponse {
 
     private Element token;
     private String tokenId;
-    private long lifetime;
     private byte[] entropy;
     private long keySize;
     private boolean computedKey;
     private TokenReference attachedReference;
     private TokenReference unAttachedReference;
+    private Date created;
+    private Date expires;
+    private long lifetime;
     
     /**
      * Return true if the entropy represents a Computed Key.
@@ -96,22 +100,6 @@ public class TokenProviderResponse {
     }
     
     /**
-     * Set the lifetime of the Token to be returned in seconds
-     * @param lifetime the lifetime of the Token to be returned in seconds
-     */
-    public void setLifetime(long lifetime) {
-        this.lifetime = lifetime;
-    }
-    
-    /**
-     * Get the lifetime of the Token to be returned in seconds
-     * @return the lifetime of the Token to be returned in seconds
-     */
-    public long getLifetime() {
-        return lifetime;
-    }
-    
-    /**
      * Set the entropy associated with the token.
      * @param entropy the entropy associated with the token.
      */
@@ -159,4 +147,54 @@ public class TokenProviderResponse {
         return unAttachedReference;
     }
 
+    /**
+     * Get the Date that this Token was Created 
+     * @return the Date that this Token was Created 
+     */
+    public Date getCreated() {
+        return created;
+    }
+
+    /**
+     * Set the Date that this Token was Created 
+     * @param created the Date that this Token was Created
+     */
+    public void setCreated(Date created) {
+        this.created = created;
+    }
+
+    /**
+     * Get the Date that this Token expires
+     * @return the Date that this Token expires
+     */
+    public Date getExpires() {
+        return expires;
+    }
+
+    /**
+     * Set the Date that this Token expires
+     * @param expires the Date that this Token expires
+     */
+    public void setExpires(Date expires) {
+        this.expires = expires;
+    }
+
+    /**
+     * Set the lifetime of the Token to be returned in seconds.
+     * @deprecated use setCreated/setExpires instead
+     * @param lifetime the lifetime of the Token to be returned in seconds
+     */
+    public void setLifetime(long lifetime) {
+        this.lifetime = lifetime;
+    }
+
+    /**
+     * Get the lifetime of the Token to be returned in seconds
+     * @deprecated use getCreated/getExpires instead
+     * @return the lifetime of the Token to be returned in seconds
+     */
+    public long getLifetime() {
+        return lifetime;
+    }
+    
 }

Modified: cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/renewer/SAMLTokenRenewer.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/renewer/SAMLTokenRenewer.java?rev=1522901&r1=1522900&r2=1522901&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/renewer/SAMLTokenRenewer.java
(original)
+++ cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/renewer/SAMLTokenRenewer.java
Fri Sep 13 12:42:00 2013
@@ -219,17 +219,15 @@ public class SAMLTokenRenewer implements
             
             DateTime validFrom = null;
             DateTime validTill = null;
-            long lifetime = 0;
             if (renewedAssertion.getSamlVersion().equals(SAMLVersion.VERSION_20)) {
                 validFrom = renewedAssertion.getSaml2().getConditions().getNotBefore();
                 validTill = renewedAssertion.getSaml2().getConditions().getNotOnOrAfter();
-                lifetime = validTill.getMillis() - validFrom.getMillis();
             } else {
                 validFrom = renewedAssertion.getSaml1().getConditions().getNotBefore();
                 validTill = renewedAssertion.getSaml1().getConditions().getNotOnOrAfter();
-                lifetime = validTill.getMillis() - validFrom.getMillis();
             }
-            response.setLifetime(lifetime / 1000);
+            response.setCreated(validFrom.toDate());
+            response.setExpires(validTill.toDate());
 
             return response;
             

Modified: cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/renewer/TokenRenewerResponse.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/renewer/TokenRenewerResponse.java?rev=1522901&r1=1522900&r2=1522901&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/renewer/TokenRenewerResponse.java
(original)
+++ cxf/branches/2.6.x-fixes/services/sts/sts-core/src/main/java/org/apache/cxf/sts/token/renewer/TokenRenewerResponse.java
Fri Sep 13 12:42:00 2013
@@ -18,6 +18,8 @@
  */
 package org.apache.cxf.sts.token.renewer;
 
+import java.util.Date;
+
 import org.w3c.dom.Element;
 import org.apache.cxf.sts.token.provider.TokenReference;
 
@@ -29,9 +31,11 @@ public class TokenRenewerResponse {
 
     private Element token;
     private String tokenId;
-    private long lifetime;
     private TokenReference attachedReference;
     private TokenReference unAttachedReference;
+    private Date created;
+    private Date expires;
+    private long lifetime;
     
     /**
      * Set the token
@@ -66,22 +70,6 @@ public class TokenRenewerResponse {
     }
     
     /**
-     * Set the lifetime of the Token to be returned in seconds
-     * @param lifetime the lifetime of the Token to be returned in seconds
-     */
-    public void setLifetime(long lifetime) {
-        this.lifetime = lifetime;
-    }
-    
-    /**
-     * Get the lifetime of the Token to be returned in seconds
-     * @return the lifetime of the Token to be returned in seconds
-     */
-    public long getLifetime() {
-        return lifetime;
-    }
-    
-    /**
      * Set the attached TokenReference
      * @param attachtedReference the attached TokenReference
      */
@@ -113,5 +101,54 @@ public class TokenRenewerResponse {
         return unAttachedReference;
     }
 
+    /**
+     * Get the Date that this Token was Created 
+     * @return the Date that this Token was Created 
+     */
+    public Date getCreated() {
+        return created;
+    }
+
+    /**
+     * Set the Date that this Token was Created 
+     * @param created the Date that this Token was Created
+     */
+    public void setCreated(Date created) {
+        this.created = created;
+    }
+
+    /**
+     * Get the Date that this Token expires
+     * @return the Date that this Token expires
+     */
+    public Date getExpires() {
+        return expires;
+    }
+
+    /**
+     * Set the Date that this Token expires
+     * @param expires the Date that this Token expires
+     */
+    public void setExpires(Date expires) {
+        this.expires = expires;
+    }
+    
+    /**
+     * Set the lifetime of the Token to be returned in seconds.
+     * @deprecated use setCreated/setExpires instead
+     * @param lifetime the lifetime of the Token to be returned in seconds
+     */
+    public void setLifetime(long lifetime) {
+        this.lifetime = lifetime;
+    }
+
+    /**
+     * Get the lifetime of the Token to be returned in seconds
+     * @deprecated use getCreated/getExpires instead
+     * @return the lifetime of the Token to be returned in seconds
+     */
+    public long getLifetime() {
+        return lifetime;
+    }
     
 }

Modified: cxf/branches/2.6.x-fixes/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/provider/SAMLProviderLifetimeTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/provider/SAMLProviderLifetimeTest.java?rev=1522901&r1=1522900&r2=1522901&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/provider/SAMLProviderLifetimeTest.java
(original)
+++ cxf/branches/2.6.x-fixes/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/provider/SAMLProviderLifetimeTest.java
Fri Sep 13 12:42:00 2013
@@ -78,7 +78,8 @@ public class SAMLProviderLifetimeTest ex
         TokenProviderResponse providerResponse = samlTokenProvider.createToken(providerParameters);
         assertTrue(providerResponse != null);
         assertTrue(providerResponse.getToken() != null && providerResponse.getTokenId()
!= null);
-        assertEquals(providerResponse.getLifetime(), requestedLifetime);
+        assertEquals(requestedLifetime * 1000L, providerResponse.getExpires().getTime() 
+                     - providerResponse.getCreated().getTime());
         Element token = providerResponse.getToken();
         String tokenString = DOM2Writer.nodeToString(token);
         assertTrue(tokenString.contains(providerResponse.getTokenId()));
@@ -108,7 +109,8 @@ public class SAMLProviderLifetimeTest ex
         TokenProviderResponse providerResponse = samlTokenProvider.createToken(providerParameters);
         assertTrue(providerResponse != null);
         assertTrue(providerResponse.getToken() != null && providerResponse.getTokenId()
!= null);
-        assertEquals(providerResponse.getLifetime(), providerLifetime);
+        assertEquals(providerLifetime * 1000L, providerResponse.getExpires().getTime() 
+                     - providerResponse.getCreated().getTime());
         Element token = providerResponse.getToken();
         String tokenString = DOM2Writer.nodeToString(token);
         assertTrue(tokenString.contains(providerResponse.getTokenId()));
@@ -229,7 +231,8 @@ public class SAMLProviderLifetimeTest ex
         TokenProviderResponse providerResponse = samlTokenProvider.createToken(providerParameters);
         assertTrue(providerResponse != null);
         assertTrue(providerResponse.getToken() != null && providerResponse.getTokenId()
!= null);
-        assertEquals(providerResponse.getLifetime(), maxLifetime);
+        assertEquals(maxLifetime * 1000L, providerResponse.getExpires().getTime() 
+                     - providerResponse.getCreated().getTime());
         Element token = providerResponse.getToken();
         String tokenString = DOM2Writer.nodeToString(token);
         assertTrue(tokenString.contains(providerResponse.getTokenId()));
@@ -268,7 +271,8 @@ public class SAMLProviderLifetimeTest ex
         TokenProviderResponse providerResponse = samlTokenProvider.createToken(providerParameters);
         assertTrue(providerResponse != null);
         assertTrue(providerResponse.getToken() != null && providerResponse.getTokenId()
!= null);
-        assertEquals(providerResponse.getLifetime(), 60 - 10);
+        assertEquals(50L * 1000L, providerResponse.getExpires().getTime() 
+                     - providerResponse.getCreated().getTime());
         Element token = providerResponse.getToken();
         String tokenString = DOM2Writer.nodeToString(token);
         assertTrue(tokenString.contains(providerResponse.getTokenId()));
@@ -352,7 +356,8 @@ public class SAMLProviderLifetimeTest ex
         TokenProviderResponse providerResponse = samlTokenProvider.createToken(providerParameters);
         assertTrue(providerResponse != null);
         assertTrue(providerResponse.getToken() != null && providerResponse.getTokenId()
!= null);
-        assertEquals(providerResponse.getLifetime(), conditionsProvider.getLifetime());
+        assertEquals(conditionsProvider.getLifetime() * 1000L, providerResponse.getExpires().getTime()

+                     - providerResponse.getCreated().getTime());
         Element token = providerResponse.getToken();
         String tokenString = DOM2Writer.nodeToString(token);
         assertTrue(tokenString.contains(providerResponse.getTokenId()));

Modified: cxf/branches/2.6.x-fixes/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/renewer/SAMLTokenRenewerLifetimeTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/renewer/SAMLTokenRenewerLifetimeTest.java?rev=1522901&r1=1522900&r2=1522901&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/renewer/SAMLTokenRenewerLifetimeTest.java
(original)
+++ cxf/branches/2.6.x-fixes/services/sts/sts-core/src/test/java/org/apache/cxf/sts/token/renewer/SAMLTokenRenewerLifetimeTest.java
Fri Sep 13 12:42:00 2013
@@ -111,7 +111,8 @@ public class SAMLTokenRenewerLifetimeTes
         TokenRenewerResponse renewerResponse = samlTokenRenewer.renewToken(renewerParameters);
         assertTrue(renewerResponse != null);
         assertTrue(renewerResponse.getToken() != null);
-        assertEquals(renewerResponse.getLifetime(), requestedLifetime);
+        assertEquals(requestedLifetime * 1000L, renewerResponse.getExpires().getTime() 
+                     - renewerResponse.getCreated().getTime());
     }
     
     
@@ -151,7 +152,8 @@ public class SAMLTokenRenewerLifetimeTes
         TokenRenewerResponse renewerResponse = samlTokenRenewer.renewToken(renewerParameters);
         assertTrue(renewerResponse != null);
         assertTrue(renewerResponse.getToken() != null);
-        assertEquals(renewerResponse.getLifetime(), providerLifetime);
+        assertEquals(providerLifetime * 1000L, renewerResponse.getExpires().getTime() 
+                     - renewerResponse.getCreated().getTime());
     }
     
     
@@ -310,7 +312,8 @@ public class SAMLTokenRenewerLifetimeTes
         TokenRenewerResponse renewerResponse = samlTokenRenewer.renewToken(renewerParameters);
         assertTrue(renewerResponse != null);
         assertTrue(renewerResponse.getToken() != null);
-        assertEquals(renewerResponse.getLifetime(), maxLifetime);
+        assertEquals(maxLifetime * 1000L, renewerResponse.getExpires().getTime() 
+                     - renewerResponse.getCreated().getTime());
     }
     
     



Mime
View raw message