Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 59D2AFE06 for ; Tue, 2 Apr 2013 20:24:31 +0000 (UTC) Received: (qmail 55498 invoked by uid 500); 2 Apr 2013 20:24:31 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 55392 invoked by uid 500); 2 Apr 2013 20:24:31 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 55385 invoked by uid 99); 2 Apr 2013 20:24:31 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Apr 2013 20:24:31 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Apr 2013 20:24:26 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id DE9D723888CD; Tue, 2 Apr 2013 20:24:04 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1463740 - in /cxf/fediz/trunk/services/idp/src/main: java/org/apache/cxf/fediz/service/idp/beans/STSClientAction.java webapp/WEB-INF/federation-webflow.xml webapp/WEB-INF/idp-servlet.xml Date: Tue, 02 Apr 2013 20:24:04 -0000 To: commits@cxf.apache.org From: owulff@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130402202404.DE9D723888CD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: owulff Date: Tue Apr 2 20:24:04 2013 New Revision: 1463740 URL: http://svn.apache.org/r1463740 Log: Merged missing changes of pull request Modified: cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/STSClientAction.java cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/federation-webflow.xml cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/idp-servlet.xml Modified: cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/STSClientAction.java URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/STSClientAction.java?rev=1463740&r1=1463739&r2=1463740&view=diff ============================================================================== --- cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/STSClientAction.java (original) +++ cxf/fediz/trunk/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/STSClientAction.java Tue Apr 2 20:24:04 2013 @@ -75,12 +75,15 @@ public class STSClientAction { protected String wsdlEndpoint; protected String appliesTo; - + protected String tokenType; + + protected boolean useWfreshForTTL = true; - protected boolean claimsRequired = true; + private boolean claimsRequired = true; + + private boolean isPortSet; - protected boolean isPortSet; public String getWsdlLocation() { return wsdlLocation; @@ -131,6 +134,14 @@ public class STSClientAction { this.claimsRequired = claimsRequired; } + public boolean isUseWfreshForTTL() { + return useWfreshForTTL; + } + + public void setUseWfreshForTTL(boolean useWfreshForTTL) { + this.useWfreshForTTL = useWfreshForTTL; + } + /** * @param credentials * : username and password provided by user @@ -147,18 +158,7 @@ public class STSClientAction { paramTokenType(sts); sts.setKeyType(HTTP_DOCS_OASIS_OPEN_ORG_WS_SX_WS_TRUST_200512_BEARER); - if (!isPortSet) { - try { - URL url = new URL(this.wsdlLocation); - URL updatedUrl = new URL(url.getProtocol(), url.getHost(), - WebUtils.getHttpServletRequest(context).getLocalPort(), url.getFile()); - - setSTSWsdlUrl(updatedUrl.toString()); - LOG.info("STS WSDL URL updated to " + updatedUrl.toString()); - } catch (MalformedURLException e) { - LOG.error("Invalid Url '" + this.wsdlLocation + "': " + e.getMessage()); - } - } + processWsdlLocation(context); sts.setWsdlLocation(this.wsdlLocation); sts.setServiceQName(new QName( HTTP_DOCS_OASIS_OPEN_ORG_WS_SX_WS_TRUST_200512, @@ -167,7 +167,11 @@ public class STSClientAction { HTTP_DOCS_OASIS_OPEN_ORG_WS_SX_WS_TRUST_200512, this.wsdlEndpoint)); - if (this.claimsRequired) { + if (isUseWfreshForTTL()) { + configureTTL(sts, context); + } + + if (isClaimsRequired()) { addClaims(this.appliesTo, bus, sts); } @@ -182,6 +186,36 @@ public class STSClientAction { return idpToken; } + private void processWsdlLocation(RequestContext context) { + if (!isPortSet) { + try { + URL url = new URL(this.wsdlLocation); + URL updatedUrl = new URL(url.getProtocol(), url.getHost(), + WebUtils.getHttpServletRequest(context).getLocalPort(), url.getFile()); + + setSTSWsdlUrl(updatedUrl.toString()); + LOG.info("STS WSDL URL updated to " + updatedUrl.toString()); + } catch (MalformedURLException e) { + LOG.error("Invalid Url '" + this.wsdlLocation + "': " + e.getMessage()); + } + } + } + + /** + * Usage of 'wfresh' parameter, picked up from the webflow context, + * like time-to-live of security token to be issued.. + */ + private void configureTTL(IdpSTSClient sts, RequestContext requestContext) { + String wfresh = (String)WebUtils.getAttributeFromExternalContext(requestContext, "wfresh"); + if (wfresh != null) { + int ttl = Integer.parseInt(wfresh); + if (ttl > 0) { + sts.setTtl(ttl * 60); + sts.setEnableLifetime(true); + } + } + } + /** * @param credentials * {@link SecurityToken} @@ -190,7 +224,7 @@ public class STSClientAction { * @return a serialized RP security token * @throws Exception */ - public String submit(SecurityToken credentials, String wtrealm) + public String submit(SecurityToken credentials, String wtrealm, RequestContext context) throws Exception { Bus bus = BusFactory.getDefaultBus(); @@ -200,6 +234,7 @@ public class STSClientAction { paramTokenType(sts); sts.setKeyType(HTTP_DOCS_OASIS_OPEN_ORG_WS_SX_WS_TRUST_200512_BEARER); + processWsdlLocation(context); sts.setWsdlLocation(wsdlLocation); sts.setServiceQName(new QName( HTTP_DOCS_OASIS_OPEN_ORG_WS_SX_WS_TRUST_200512, Modified: cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/federation-webflow.xml URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/federation-webflow.xml?rev=1463740&r1=1463739&r2=1463740&view=diff ============================================================================== --- cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/federation-webflow.xml (original) +++ cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/federation-webflow.xml Tue Apr 2 20:24:04 2013 @@ -14,41 +14,61 @@ + + + + - + + + + + + + + + + + + + + + - + + - - - - - - - - - - - - - + + + + + + + + + + + + + + + @@ -78,7 +98,7 @@ - @@ -91,13 +111,14 @@ - + + - Modified: cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/idp-servlet.xml URL: http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/idp-servlet.xml?rev=1463740&r1=1463739&r2=1463740&view=diff ============================================================================== --- cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/idp-servlet.xml (original) +++ cxf/fediz/trunk/services/idp/src/main/webapp/WEB-INF/idp-servlet.xml Tue Apr 2 20:24:04 2013 @@ -7,7 +7,7 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/webflow-config http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.0.xsd"> - @@ -51,11 +51,12 @@ + - + @@ -63,10 +64,11 @@ - - + + + + -