cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject [4/4] cxf-fediz git commit: Some improvements to the WFreshParser
Date Thu, 21 Jan 2016 12:01:03 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/ae1cbece
Tree: http://git-wip-us.apache.org/repos/asf/cxf-fediz/tree/ae1cbece
Diff: http://git-wip-us.apache.org/repos/asf/cxf-fediz/diff/ae1cbece

Branch: refs/heads/master
Commit: ae1cbece32c66a6fef5a8d2e3ff26ce91674cd5d
Parents: 18f40e3
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:00:56 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/ae1cbece/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 d7f03d6..a72be8f 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
@@ -42,6 +42,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;
@@ -60,12 +64,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()
@@ -77,7 +84,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