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 B941D18F71 for ; Wed, 20 Jan 2016 05:28:56 +0000 (UTC) Received: (qmail 15216 invoked by uid 500); 20 Jan 2016 05:28:56 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 15147 invoked by uid 500); 20 Jan 2016 05:28:56 -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 15134 invoked by uid 99); 20 Jan 2016 05:28:56 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Jan 2016 05:28:56 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 39CCCE0203; Wed, 20 Jan 2016 05:28:56 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jbernhardt@apache.org To: commits@cxf.apache.org Date: Wed, 20 Jan 2016 05:28:56 -0000 Message-Id: <39f35ddd87a74bb5afdae51cedc08ff5@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/2] cxf-fediz git commit: [FEDIZ-144] Added Spring EL support for HomeRealm Discovery Repository: cxf-fediz Updated Branches: refs/heads/master 94dc9ec91 -> 7b2f203e1 [FEDIZ-144] Added Spring EL support for HomeRealm Discovery Project: http://git-wip-us.apache.org/repos/asf/cxf-fediz/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf-fediz/commit/7b2f203e Tree: http://git-wip-us.apache.org/repos/asf/cxf-fediz/tree/7b2f203e Diff: http://git-wip-us.apache.org/repos/asf/cxf-fediz/diff/7b2f203e Branch: refs/heads/master Commit: 7b2f203e13aedf9fbffeaae273222b7380f7e92b Parents: 3a723af Author: Jan Bernhardt Authored: Tue Jan 19 12:19:48 2016 +0100 Committer: Jan Bernhardt Committed: Wed Jan 20 06:27:33 2016 +0100 ---------------------------------------------------------------------- .../idp/beans/ProcessHRDSExpressionAction.java | 40 ++++++++++++++---- .../idp/src/main/resources/entities-realma.xml | 9 ++-- .../WEB-INF/flows/federation-signin-request.xml | 44 +++++--------------- 3 files changed, 48 insertions(+), 45 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/7b2f203e/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/ProcessHRDSExpressionAction.java ---------------------------------------------------------------------- diff --git a/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/ProcessHRDSExpressionAction.java b/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/ProcessHRDSExpressionAction.java index e7a9296..088af6c 100644 --- a/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/ProcessHRDSExpressionAction.java +++ b/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/ProcessHRDSExpressionAction.java @@ -18,10 +18,17 @@ */ package org.apache.cxf.fediz.service.idp.beans; +import javax.servlet.http.Cookie; + +import org.apache.cxf.fediz.core.FederationConstants; import org.apache.cxf.fediz.service.idp.domain.Idp; import org.apache.cxf.fediz.service.idp.util.WebUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.expression.Expression; +import org.springframework.expression.ExpressionParser; +import org.springframework.expression.spel.standard.SpelExpressionParser; import org.springframework.stereotype.Component; import org.springframework.webflow.execution.RequestContext; @@ -32,17 +39,36 @@ import org.springframework.webflow.execution.RequestContext; public class ProcessHRDSExpressionAction { private static final String IDP_CONFIG = "idpConfig"; + private static final Logger LOG = LoggerFactory.getLogger(ProcessHRDSExpressionAction.class); + @Autowired + private HomeRealmReminder homeRealmReminder; + public String submit(RequestContext context) { + // Check if home realm is known already + Cookie whrCookie = homeRealmReminder.readCookie(context); + if (whrCookie != null) { + LOG.debug("WHR Cookie set: {}", whrCookie); + return whrCookie.getValue(); + } + + // Check if custom HRDS is defined Idp idpConfig = (Idp)WebUtils.getAttributeFromFlowScope(context, IDP_CONFIG); String hrds = idpConfig.getHrds(); - //TODO - if (hrds == null) { - LOG.info("HRDS is null (Mock)."); - return ""; + + if (hrds != null) { + LOG.debug("HomeRealmDiscoveryService EL: {}", hrds); + ExpressionParser parser = new SpelExpressionParser(); + Expression exp = parser.parseExpression(hrds); + String result = exp.getValue(context, String.class); + LOG.info("Realm resolved by HomeRealmDiscoveryService: {}", result); + return result; } - LOG.info("HRDS is not null (Mock)."); - return "some-whr-value"; + + // Return whr parameter unchanged + String whr = (String)WebUtils.getAttributeFromFlowScope(context, FederationConstants.PARAM_HOME_REALM); + LOG.debug("No custom homeRealm handling, using whr parameter as provided in request: {}", whr); + return whr; } -} +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/7b2f203e/services/idp/src/main/resources/entities-realma.xml ---------------------------------------------------------------------- diff --git a/services/idp/src/main/resources/entities-realma.xml b/services/idp/src/main/resources/entities-realma.xml index a6b43d6..01969a6 100644 --- a/services/idp/src/main/resources/entities-realma.xml +++ b/services/idp/src/main/resources/entities-realma.xml @@ -38,10 +38,8 @@ - http://docs.oasis-open.org/wsfed/federation/200706 - - http://docs.oasis-open.org/ws-sx/ws-trust/200512 - + http://docs.oasis-open.org/wsfed/federation/200706 + http://docs.oasis-open.org/ws-sx/ws-trust/200512 @@ -52,7 +50,8 @@ - + - + - - + + - - + + + + + - - - - - - - - - - - - - - - - - - -