Renaming CacheTokenForWAuthAction
Project: http://git-wip-us.apache.org/repos/asf/cxf-fediz/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf-fediz/commit/00087830 Tree: http://git-wip-us.apache.org/repos/asf/cxf-fediz/tree/00087830 Diff: http://git-wip-us.apache.org/repos/asf/cxf-fediz/diff/00087830 Branch: refs/heads/master Commit: 000878303c03fe705eb1022ffa311ccc2093c262 Parents: a1f6f20 Author: Colm O hEigeartaigh <cohei...@apache.org> Authored: Tue Mar 15 17:19:29 2016 +0000 Committer: Colm O hEigeartaigh <cohei...@apache.org> Committed: Tue Mar 15 17:19:29 2016 +0000 ---------------------------------------------------------------------- .../service/idp/beans/CacheSecurityToken.java | 56 +++++++++++++++++++ .../idp/beans/CacheTokenForWauthAction.java | 57 -------------------- .../WEB-INF/flows/federation-signin-request.xml | 6 +-- .../WEB-INF/flows/saml-signin-request.xml | 6 +-- 4 files changed, 62 insertions(+), 63 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/00087830/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/CacheSecurityToken.java ---------------------------------------------------------------------- diff --git a/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/CacheSecurityToken.java b/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/CacheSecurityToken.java new file mode 100644 index 0000000..2cd4bc7 --- /dev/null +++ b/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/CacheSecurityToken.java @@ -0,0 +1,56 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.cxf.fediz.service.idp.beans; + +import org.apache.cxf.fediz.service.idp.STSUserDetails; +import org.apache.cxf.fediz.service.idp.domain.Idp; +import org.apache.cxf.fediz.service.idp.util.WebUtils; +import org.apache.cxf.ws.security.tokenstore.SecurityToken; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.stereotype.Component; +import org.springframework.util.Assert; +import org.springframework.webflow.execution.RequestContext; + +/** + * This class is responsible to cache IDP token. + */ +@Component +public class CacheSecurityToken { + + private static final String IDP_CONFIG = "idpConfig"; + private static final Logger LOG = LoggerFactory.getLogger(CacheSecurityToken.class); + + public void submit(RequestContext context) { + + Authentication auth = SecurityContextHolder.getContext().getAuthentication(); + Assert.isInstanceOf(STSUserDetails.class, auth.getDetails()); + final STSUserDetails stsUserDetails = (STSUserDetails) auth.getDetails(); + SecurityToken securityToken = stsUserDetails.getSecurityToken(); + + Idp idpConfig = (Idp)WebUtils.getAttributeFromFlowScope(context, IDP_CONFIG); + + WebUtils.putAttributeInExternalContext(context, idpConfig.getRealm(), securityToken); + LOG.info("Token [IDP_TOKEN=" + securityToken.getId() + + "] for realm [" + + idpConfig.getRealm() + "] successfully cached."); + } +} http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/00087830/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/CacheTokenForWauthAction.java ---------------------------------------------------------------------- diff --git a/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/CacheTokenForWauthAction.java b/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/CacheTokenForWauthAction.java deleted file mode 100644 index 15e0589..0000000 --- a/services/idp/src/main/java/org/apache/cxf/fediz/service/idp/beans/CacheTokenForWauthAction.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.cxf.fediz.service.idp.beans; - -import org.apache.cxf.fediz.service.idp.STSUserDetails; -import org.apache.cxf.fediz.service.idp.domain.Idp; -import org.apache.cxf.fediz.service.idp.util.WebUtils; -import org.apache.cxf.ws.security.tokenstore.SecurityToken; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.stereotype.Component; -import org.springframework.util.Assert; -import org.springframework.webflow.execution.RequestContext; - -/** - * This class is responsible to cache IDP token. - */ -@Component -public class CacheTokenForWauthAction { - - private static final String IDP_CONFIG = "idpConfig"; - private static final Logger LOG = LoggerFactory.getLogger(CacheTokenForWauthAction.class); - - - public void submit(RequestContext context) { - - Authentication auth = SecurityContextHolder.getContext().getAuthentication(); - Assert.isInstanceOf(STSUserDetails.class, auth.getDetails()); - final STSUserDetails stsUserDetails = (STSUserDetails) auth.getDetails(); - SecurityToken securityToken = stsUserDetails.getSecurityToken(); - - Idp idpConfig = (Idp)WebUtils.getAttributeFromFlowScope(context, IDP_CONFIG); - - WebUtils.putAttributeInExternalContext(context, idpConfig.getRealm(), securityToken); - LOG.info("Token [IDP_TOKEN=" + securityToken.getId() - + "] for realm [" - + idpConfig.getRealm() + "] successfully cached."); - } -} http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/00087830/services/idp/src/main/webapp/WEB-INF/flows/federation-signin-request.xml ---------------------------------------------------------------------- diff --git a/services/idp/src/main/webapp/WEB-INF/flows/federation-signin-request.xml b/services/idp/src/main/webapp/WEB-INF/flows/federation-signin-request.xml index f064e7a..86f51b1 100644 --- a/services/idp/src/main/webapp/WEB-INF/flows/federation-signin-request.xml +++ b/services/idp/src/main/webapp/WEB-INF/flows/federation-signin-request.xml @@ -114,7 +114,7 @@ <decision-state id="checkIdpTokenWauth"> <!-- check presence of cached IDP token for THIS realm --> <if test="externalContext.sessionMap[flowScope.whr] == null" - then="cacheTokenForWauth" else="wfreshParserAction" /> + then="cacheSecurityToken" else="wfreshParserAction" /> </decision-state> <!-- parse wfresh parameter, provided by resource RP, overriding ttl @@ -137,9 +137,9 @@ <output name="whr" value="flowScope.whr" /> </end-state> - <action-state id="cacheTokenForWauth"> + <action-state id="cacheSecurityToken"> <secured attributes="IS_AUTHENTICATED_FULLY" /> - <evaluate expression="cacheTokenForWauthAction.submit(flowRequestContext)" /> + <evaluate expression="cacheSecurityToken.submit(flowRequestContext)" /> <transition to="requestRpToken"> <set name="flowScope.idpToken" value="externalContext.sessionMap[whr]" /> </transition> http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/00087830/services/idp/src/main/webapp/WEB-INF/flows/saml-signin-request.xml ---------------------------------------------------------------------- diff --git a/services/idp/src/main/webapp/WEB-INF/flows/saml-signin-request.xml b/services/idp/src/main/webapp/WEB-INF/flows/saml-signin-request.xml index 0af978f..909fb44 100644 --- a/services/idp/src/main/webapp/WEB-INF/flows/saml-signin-request.xml +++ b/services/idp/src/main/webapp/WEB-INF/flows/saml-signin-request.xml @@ -36,7 +36,7 @@ then="viewBadRequest" /> <!-- check presence of cached IDP token for THIS realm --> <if test="externalContext.sessionMap[flowScope.whr] == null" - then="cacheTokenForWauth" else="wfreshParserAction" /> + then="cacheSecurityToken" else="wfreshParserAction" /> </decision-state> <!-- parse wfresh parameter, provided by resource RP, overriding ttl @@ -58,9 +58,9 @@ <output name="whr" value="flowScope.whr" /> </end-state> - <action-state id="cacheTokenForWauth"> + <action-state id="cacheSecurityToken"> <secured attributes="IS_AUTHENTICATED_FULLY" /> - <evaluate expression="cacheTokenForWauthAction.submit(flowRequestContext)" /> + <evaluate expression="cacheSecurityToken.submit(flowRequestContext)" /> <transition to="requestRpToken"> <set name="flowScope.idpToken" value="externalContext.sessionMap[whr]" /> </transition>