You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2016/01/21 13:01:02 UTC

[3/4] cxf-fediz git commit: Checkstyle fix

Checkstyle fix


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

Branch: refs/heads/master
Commit: 669232ddc1f9602c6fbec94af88fa1de89932e7a
Parents: ae1cbec
Author: Colm O hEigeartaigh <co...@apache.org>
Authored: Thu Jan 21 11:56:24 2016 +0000
Committer: Colm O hEigeartaigh <co...@apache.org>
Committed: Thu Jan 21 12:00:56 2016 +0000

----------------------------------------------------------------------
 .../fediz/service/idp/beans/WfreshParser.java   | 26 ++++++++++++++------
 1 file changed, 18 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/669232dd/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 a72be8f..792b4fd 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
@@ -40,14 +40,7 @@ public class WfreshParser {
     public boolean authenticationRequired(String wfresh, String whr, RequestContext context)
         throws Exception {
         
-        SecurityToken idpToken = 
-            (SecurityToken) WebUtils.getAttributeFromExternalContext(context, whr);
-        if (idpToken == null) {
-            return true;
-        }
-        
-        if (tokenExpirationValidation && idpToken.isExpired()) {
-            LOG.info("[IDP_TOKEN=" + idpToken.getId() + "] is expired.");
+        if (checkIsIdpTokenExpired(whr, context)) {
             return true;
         }
 
@@ -69,6 +62,8 @@ public class WfreshParser {
         long ttlMs = ttl * 60L * 1000L;
         if (ttlMs > 0) {
 
+            SecurityToken idpToken = 
+                (SecurityToken) WebUtils.getAttributeFromExternalContext(context, whr);
             Date createdDate = idpToken.getCreated();
             if (createdDate != null) {
                 Date expiryDate = new Date();
@@ -88,6 +83,21 @@ public class WfreshParser {
         }
         return false;
     }
+    
+    private boolean checkIsIdpTokenExpired(String whr, RequestContext context) {
+        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;
+        }
+
+        return false;
+    }
 
     public boolean isTokenExpirationValidation() {
         return tokenExpirationValidation;