cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1443504 - in /cxf/fediz/trunk/services/idp/src/main: java/org/apache/cxf/fediz/service/idp/STSClientFilter.java webapp/WEB-INF/web.xml
Date Thu, 07 Feb 2013 14:34:34 GMT
Author: coheigea
Date: Thu Feb  7 14:34:34 2013
New Revision: 1443504

URL: http://svn.apache.org/viewvc?rev=1443504&view=rev
Log:
[FEDIZ-49] - Support using wfresh parameter in the IdP for TTL

Modified:
    cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/STSClientFilter.java
    cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/web.xml

Modified: cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/STSClientFilter.java
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/STSClientFilter.java?rev=1443504&r1=1443503&r2=1443504&view=diff
==============================================================================
--- cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/STSClientFilter.java
(original)
+++ cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/STSClientFilter.java
Thu Feb  7 14:34:34 2013
@@ -67,6 +67,8 @@ public class STSClientFilter extends Abs
     private static final String PARAM_RSTR_CONTENT_TYPE = "sts.rstr.content-type";
 
     private static final String PARAM_STS_ONBEHALFOF_TOKEN_NAME = "sts.onbehalfof.token.name";
+    
+    private static final String PARAM_STS_USE_WFRESH_FOR_TTL = "sts.use.wfresh.for.ttl";
 
     private static final Logger LOG = LoggerFactory.getLogger(STSClientFilter.class);
     
@@ -92,6 +94,7 @@ public class STSClientFilter extends Abs
     protected String appliesTo; // $wtrealm
     protected String contentType;  //token, rstr
     protected boolean isPortSet;
+    protected boolean useWfreshForTTL;
 
     protected Bus bus;
 
@@ -186,7 +189,21 @@ public class STSClientFilter extends Abs
                                        "Parameter '" + PARAM_RSTR_CONTENT_TYPE + "' not configured");
         }
         
-        
+        try {
+            String wfreshParam = filterConfig.getInitParameter(PARAM_STS_USE_WFRESH_FOR_TTL);
+            if (wfreshParam != null) {
+                useWfreshForTTL = Boolean.valueOf(wfreshParam).booleanValue();
+            } else if (contentType.equalsIgnoreCase("TOKEN")) {
+                useWfreshForTTL = true;
+            } else {
+                useWfreshForTTL = false;
+            }
+        } catch (Exception ex) {
+            LOG.error("Failed to parse parameter '" + PARAM_STS_USE_WFRESH_FOR_TTL + "':
" + ex.toString());
+            throw new ServletException(
+                                       "Failed to parse parameter '" + PARAM_STS_USE_WFRESH_FOR_TTL
+ "'");
+        }
+
 
     }
 
@@ -256,6 +273,10 @@ public class STSClientFilter extends Abs
                 sts.setTtl(ttl);
             }
             */
+            
+            if (useWfreshForTTL) {
+                configureTTL(sts, context);
+            }
 
             if (appliesTo.startsWith("$")) {
                 resolvedAppliesTo = (String)context.get(appliesTo.substring(1));
@@ -345,6 +366,21 @@ public class STSClientFilter extends Abs
         }
 
     }
+    
+    private void configureTTL(IdpSTSClient sts, AuthContext context) {
+        String wfresh = (String)context.get(FederationFilter.PARAM_WFRESH);
+        if (wfresh != null) {
+            try {
+                int ttl = Integer.parseInt(wfresh);
+                if (ttl > 0) {
+                    sts.setTtl(ttl * 60);                    
+                    sts.setEnableLifetime(true);
+                }
+            } catch (NumberFormatException ex) {
+                LOG.error("Invalid wfresh value '" + wfresh + "': "  + ex.getMessage());
+            }
+        }
+    }
 
     private Element createClaimsElement(List<String> realmClaims)
         throws Exception {

Modified: cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/web.xml?rev=1443504&r1=1443503&r2=1443504&view=diff
==============================================================================
--- cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/web.xml (original)
+++ cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/web.xml Thu Feb  7 14:34:34 2013
@@ -109,7 +109,11 @@
 		<init-param>
 			<param-name>sts.rstr.content-type</param-name>
 			<param-value>TOKEN</param-value>
-		</init-param>			
+		</init-param>	
+		<init-param>
+			<param-name>sts.use.wfresh.for.ttl</param-name>
+			<param-value>true</param-value>
+		</init-param>	
 	</filter>
 	
 	<filter>
@@ -158,7 +162,7 @@
 		<init-param>
 			<param-name>sts.claims.required</param-name>
 			<param-value>true</param-value>
-		</init-param>		
+		</init-param>
 	</filter>	
 
 	<filter>



Mime
View raw message