cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject [3/5] cxf-fediz git commit: Some improvements to the WFreshParser
Date Thu, 21 Jan 2016 12:10:46 GMT
Some improvements to the WFreshParser


Project: http://git-wip-us.apache.org/repos/asf/cxf-fediz/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf-fediz/commit/dfc6a99d
Tree: http://git-wip-us.apache.org/repos/asf/cxf-fediz/tree/dfc6a99d
Diff: http://git-wip-us.apache.org/repos/asf/cxf-fediz/diff/dfc6a99d

Branch: refs/heads/1.2.x-fixes
Commit: dfc6a99d5a073004de604240d18d113fa6f5415d
Parents: c23eb87
Author: Colm O hEigeartaigh <coheigea@apache.org>
Authored: Thu Jan 21 11:51:43 2016 +0000
Committer: Colm O hEigeartaigh <coheigea@apache.org>
Committed: Thu Jan 21 12:10:15 2016 +0000

----------------------------------------------------------------------
 .../cxf/fediz/service/idp/beans/WfreshParser.java      | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/dfc6a99d/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/WfreshParser.java
----------------------------------------------------------------------
diff --git a/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/WfreshParser.java
b/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/WfreshParser.java
index 3fba1c8..a428553 100644
--- a/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/WfreshParser.java
+++ b/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/WfreshParser.java
@@ -41,6 +41,10 @@ public class WfreshParser {
         
         SecurityToken idpToken = 
             (SecurityToken) WebUtils.getAttributeFromExternalContext(context, whr);
+        if (idpToken == null) {
+            return true;
+        }
+        
         if (tokenExpirationValidation && idpToken.isExpired()) {
             LOG.info("[IDP_TOKEN=" + idpToken.getId() + "] is expired.");
             return true;
@@ -59,12 +63,15 @@ public class WfreshParser {
         }
         if (ttl == 0) {
             return true;
-        } else if (ttl > 0) {
+        }
+        
+        long ttlMs = ttl * 60L * 1000L;
+        if (ttlMs > 0) {
 
             Date createdDate = idpToken.getCreated();
             if (createdDate != null) {
                 Date expiryDate = new Date();
-                expiryDate.setTime(createdDate.getTime() + (ttl * 60L * 1000L));
+                expiryDate.setTime(createdDate.getTime() + ttlMs);
                 if (expiryDate.before(new Date())) {
                     LOG.info("[IDP_TOKEN="
                             + idpToken.getId()
@@ -76,7 +83,7 @@ public class WfreshParser {
                 LOG.info("token creation date not set. Unable to check wfresh is outdated.");
             }
         } else {
-            LOG.info("ttl value '" + ttl + "' is negative.");
+            LOG.info("ttl value '" + ttl + "' is negative or is too large.");
         }
         return false;
     }


Mime
View raw message