cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1345046 - in /cxf/trunk/services/sts: sts-core/src/main/java/org/apache/cxf/sts/provider/ sts-war/src/main/webapp/WEB-INF/ systests/basic/src/test/resources/org/apache/cxf/systest/sts/deployment/
Date Fri, 01 Jun 2012 10:58:23 GMT
Author: coheigea
Date: Fri Jun  1 10:58:22 2012
New Revision: 1345046

URL: http://svn.apache.org/viewvc?rev=1345046&view=rev
Log:
[CXF-4344] - Provide simplifications and shortcuts in CXF STS configuration

Added:
    cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/provider/
    cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/provider/DefaultSecurityTokenServiceProvider.java
Modified:
    cxf/trunk/services/sts/sts-war/src/main/webapp/WEB-INF/cxf-encrypted-ut.xml
    cxf/trunk/services/sts/sts-war/src/main/webapp/WEB-INF/cxf-transport.xml
    cxf/trunk/services/sts/sts-war/src/main/webapp/WEB-INF/cxf-ut.xml
    cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/deployment/cxf-encrypted-ut.xml
    cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/deployment/cxf-transport.xml
    cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/deployment/cxf-ut.xml

Added: cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/provider/DefaultSecurityTokenServiceProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/provider/DefaultSecurityTokenServiceProvider.java?rev=1345046&view=auto
==============================================================================
--- cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/provider/DefaultSecurityTokenServiceProvider.java
(added)
+++ cxf/trunk/services/sts/sts-core/src/main/java/org/apache/cxf/sts/provider/DefaultSecurityTokenServiceProvider.java
Fri Jun  1 10:58:22 2012
@@ -0,0 +1,127 @@
+/**
+ * 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.sts.provider;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.transform.Source;
+
+import org.apache.cxf.sts.STSPropertiesMBean;
+import org.apache.cxf.sts.claims.ClaimsManager;
+import org.apache.cxf.sts.operation.AbstractOperation;
+import org.apache.cxf.sts.operation.TokenIssueOperation;
+import org.apache.cxf.sts.operation.TokenValidateOperation;
+import org.apache.cxf.sts.service.ServiceMBean;
+import org.apache.cxf.sts.token.provider.SAMLTokenProvider;
+import org.apache.cxf.sts.token.provider.TokenProvider;
+import org.apache.cxf.sts.token.validator.SAMLTokenValidator;
+import org.apache.cxf.sts.token.validator.TokenValidator;
+import org.apache.cxf.sts.token.validator.UsernameTokenValidator;
+import org.apache.cxf.sts.token.validator.X509TokenValidator;
+import org.apache.cxf.ws.security.sts.provider.SecurityTokenServiceProvider;
+import org.apache.cxf.ws.security.tokenstore.TokenStore;
+
+/**
+ * A "default" SecurityTokenServiceProvider implementation that defines the Issue and Validate
+ * Operations of the STS and adds support for issuing and validating SAML Assertions, and
+ * validating UsernameTokens and X.509 Tokens.
+ */
+public class DefaultSecurityTokenServiceProvider extends SecurityTokenServiceProvider {
+    
+    private STSPropertiesMBean stsProperties;
+    private boolean encryptIssuedToken;
+    private List<ServiceMBean> services;
+    private boolean returnReferences = true;
+    private TokenStore tokenStore;
+    private ClaimsManager claimsManager = new ClaimsManager();
+
+    public DefaultSecurityTokenServiceProvider() throws Exception {
+        super();
+    }
+    
+    public void setReturnReferences(boolean returnReferences) {
+        this.returnReferences = returnReferences;
+    }
+    
+    public void setTokenStore(TokenStore tokenStore) {
+        this.tokenStore = tokenStore;
+    }
+
+    public void setStsProperties(STSPropertiesMBean stsProperties) {
+        this.stsProperties = stsProperties;
+    }
+    
+    public void setEncryptIssuedToken(boolean encryptIssuedToken) {
+        this.encryptIssuedToken = encryptIssuedToken;
+    }
+    
+    public void setServices(List<ServiceMBean> services) {
+        this.services = services;
+    }
+    
+    public void setClaimsManager(ClaimsManager claimsManager) {
+        this.claimsManager = claimsManager;
+    }
+    
+    @Override
+    public Source invoke(Source request) {
+        if (getIssueOperation() == null) {
+            setIssueOperation(createTokenIssueOperation());
+        }
+        if (getValidateOperation() == null) {
+            setValidateOperation(createTokenValidateOperation());
+        }
+        return super.invoke(request);
+    }
+    
+    private TokenIssueOperation createTokenIssueOperation() {
+        TokenIssueOperation issueOperation = new TokenIssueOperation();
+        populateAbstractOperation(issueOperation);
+        
+        return issueOperation;
+    }
+
+    private TokenValidateOperation createTokenValidateOperation() {
+        TokenValidateOperation validateOperation = new TokenValidateOperation();
+        populateAbstractOperation(validateOperation);
+        
+        return validateOperation;
+    }
+    
+    private void populateAbstractOperation(AbstractOperation abstractOperation) {
+        List<TokenProvider> tokenProviders = new ArrayList<TokenProvider>();
+        tokenProviders.add(new SAMLTokenProvider());
+        
+        List<TokenValidator> tokenValidators = new ArrayList<TokenValidator>();
+        tokenValidators.add(new SAMLTokenValidator());
+        tokenValidators.add(new UsernameTokenValidator());
+        tokenValidators.add(new X509TokenValidator());
+        
+        abstractOperation.setTokenProviders(tokenProviders);
+        abstractOperation.setTokenValidators(tokenValidators);
+        abstractOperation.setStsProperties(stsProperties);
+        abstractOperation.setEncryptIssuedToken(encryptIssuedToken);
+        abstractOperation.setServices(services);
+        abstractOperation.setReturnReferences(returnReferences);
+        abstractOperation.setTokenStore(tokenStore);
+        abstractOperation.setClaimsManager(claimsManager);
+    }
+}
\ No newline at end of file

Modified: cxf/trunk/services/sts/sts-war/src/main/webapp/WEB-INF/cxf-encrypted-ut.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-war/src/main/webapp/WEB-INF/cxf-encrypted-ut.xml?rev=1345046&r1=1345045&r2=1345046&view=diff
==============================================================================
--- cxf/trunk/services/sts/sts-war/src/main/webapp/WEB-INF/cxf-encrypted-ut.xml (original)
+++ cxf/trunk/services/sts/sts-war/src/main/webapp/WEB-INF/cxf-encrypted-ut.xml Fri Jun  1
10:58:22 2012
@@ -40,22 +40,10 @@
     </cxf:bus>
 
 	<bean id="encryptedUtSTSProviderBean"
-		class="org.apache.cxf.ws.security.sts.provider.SecurityTokenServiceProvider">
-		<property name="issueOperation" ref="encryptedUtIssueDelegate" />
-		<property name="validateOperation" ref="encryptedUtValidateDelegate" />
-	</bean>
-
-	<bean id="encryptedUtIssueDelegate" class="org.apache.cxf.sts.operation.TokenIssueOperation">
-		<property name="tokenProviders" ref="encryptedUtSamlTokenProvider" />
-		<property name="services" ref="encryptedUtService" />
+	    class="org.apache.cxf.sts.provider.DefaultSecurityTokenServiceProvider">
+	    <property name="services" ref="encryptedUtService" />
 		<property name="stsProperties" ref="encryptedUtSTSProperties" />
-	</bean>
-
-	<bean id="encryptedUtValidateDelegate" class="org.apache.cxf.sts.operation.TokenValidateOperation">
-	</bean>
-
-	<bean id="encryptedUtSamlTokenProvider" class="org.apache.cxf.sts.token.provider.SAMLTokenProvider">
-	</bean>
+    </bean>
 
 	<bean id="encryptedUtService" class="org.apache.cxf.sts.service.StaticService">
 		<property name="endpoints" ref="encryptedUtEndpoints" />

Modified: cxf/trunk/services/sts/sts-war/src/main/webapp/WEB-INF/cxf-transport.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-war/src/main/webapp/WEB-INF/cxf-transport.xml?rev=1345046&r1=1345045&r2=1345046&view=diff
==============================================================================
--- cxf/trunk/services/sts/sts-war/src/main/webapp/WEB-INF/cxf-transport.xml (original)
+++ cxf/trunk/services/sts/sts-war/src/main/webapp/WEB-INF/cxf-transport.xml Fri Jun  1 10:58:22
2012
@@ -40,45 +40,10 @@
     </cxf:bus>
 
 	<bean id="transportSTSProviderBean"
-		class="org.apache.cxf.ws.security.sts.provider.SecurityTokenServiceProvider">
-		<property name="issueOperation" ref="transportIssueDelegate" />
-		<property name="validateOperation" ref="transportValidateDelegate" />
-	</bean>
-
-	<bean id="transportIssueDelegate" class="org.apache.cxf.sts.operation.TokenIssueOperation">
-		<property name="tokenProviders" ref="transportTokenProviders" />
-		<property name="tokenValidators" ref="transportTokenValidators" />
-		<property name="services" ref="transportService" />
-		<property name="stsProperties" ref="transportSTSProperties" />
-	</bean>
-
-	<bean id="transportValidateDelegate" class="org.apache.cxf.sts.operation.TokenValidateOperation">
-		<property name="tokenValidators" ref="transportTokenValidators" />
+	    class="org.apache.cxf.sts.provider.DefaultSecurityTokenServiceProvider">
+	    <property name="services" ref="transportService" />
 		<property name="stsProperties" ref="transportSTSProperties" />
-	</bean>
-
-	<util:list id="transportTokenProviders">
-		<ref bean="transportSamlTokenProvider" />
-	</util:list>
-
-	<util:list id="transportTokenValidators">
-		<ref bean="transportSamlTokenValidator" />
-		<ref bean="transportX509TokenValidator" />
-		<ref bean="transportUsernameTokenValidator" />
-	</util:list>
-
-	<bean id="transportSamlTokenProvider" class="org.apache.cxf.sts.token.provider.SAMLTokenProvider">
-	</bean>
-
-	<bean id="transportX509TokenValidator" class="org.apache.cxf.sts.token.validator.X509TokenValidator">
-	</bean>
-
-	<bean id="transportUsernameTokenValidator"
-		class="org.apache.cxf.sts.token.validator.UsernameTokenValidator">
-	</bean>
-
-	<bean id="transportSamlTokenValidator" class="org.apache.cxf.sts.token.validator.SAMLTokenValidator">
-	</bean>
+    </bean>
 
 	<bean id="transportService" class="org.apache.cxf.sts.service.StaticService">
 		<property name="endpoints" ref="transportEndpoints" />

Modified: cxf/trunk/services/sts/sts-war/src/main/webapp/WEB-INF/cxf-ut.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/sts-war/src/main/webapp/WEB-INF/cxf-ut.xml?rev=1345046&r1=1345045&r2=1345046&view=diff
==============================================================================
--- cxf/trunk/services/sts/sts-war/src/main/webapp/WEB-INF/cxf-ut.xml (original)
+++ cxf/trunk/services/sts/sts-war/src/main/webapp/WEB-INF/cxf-ut.xml Fri Jun  1 10:58:22
2012
@@ -40,27 +40,10 @@
     </cxf:bus>
 
 	<bean id="utSTSProviderBean"
-		class="org.apache.cxf.ws.security.sts.provider.SecurityTokenServiceProvider">
-		<property name="issueOperation" ref="utIssueDelegate" />
-		<property name="validateOperation" ref="utValidateDelegate" />
-	</bean>
-
-	<bean id="utIssueDelegate" class="org.apache.cxf.sts.operation.TokenIssueOperation">
-		<property name="tokenProviders" ref="utSamlTokenProvider" />
-		<property name="services" ref="utService" />
-		<property name="stsProperties" ref="utSTSProperties" />
-	</bean>
-
-	<bean id="utValidateDelegate" class="org.apache.cxf.sts.operation.TokenValidateOperation">
-		<property name="tokenValidators" ref="utSamlTokenValidator" />
+	    class="org.apache.cxf.sts.provider.DefaultSecurityTokenServiceProvider">
+	    <property name="services" ref="utService" />
 		<property name="stsProperties" ref="utSTSProperties" />
-	</bean>
-
-	<bean id="utSamlTokenProvider" class="org.apache.cxf.sts.token.provider.SAMLTokenProvider">
-	</bean>
-
-	<bean id="utSamlTokenValidator" class="org.apache.cxf.sts.token.validator.SAMLTokenValidator">
-	</bean>
+    </bean>
 
 	<bean id="utService" class="org.apache.cxf.sts.service.StaticService">
 		<property name="endpoints" ref="utEndpoints" />

Modified: cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/deployment/cxf-encrypted-ut.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/deployment/cxf-encrypted-ut.xml?rev=1345046&r1=1345045&r2=1345046&view=diff
==============================================================================
--- cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/deployment/cxf-encrypted-ut.xml
(original)
+++ cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/deployment/cxf-encrypted-ut.xml
Fri Jun  1 10:58:22 2012
@@ -41,23 +41,11 @@
         </cxf:features>
     </cxf:bus>
 
-	<bean id="encryptedUtSTSProviderBean"
-		class="org.apache.cxf.ws.security.sts.provider.SecurityTokenServiceProvider">
-		<property name="issueOperation" ref="encryptedUtIssueDelegate" />
-		<property name="validateOperation" ref="encryptedUtValidateDelegate" />
-	</bean>
-
-	<bean id="encryptedUtIssueDelegate" class="org.apache.cxf.sts.operation.TokenIssueOperation">
-		<property name="tokenProviders" ref="encryptedUtSamlTokenProvider" />
-		<property name="services" ref="encryptedUtService" />
+    <bean id="encryptedUtSTSProviderBean"
+	    class="org.apache.cxf.sts.provider.DefaultSecurityTokenServiceProvider">
+	    <property name="services" ref="encryptedUtService" />
 		<property name="stsProperties" ref="encryptedUtSTSProperties" />
-	</bean>
-
-	<bean id="encryptedUtValidateDelegate" class="org.apache.cxf.sts.operation.TokenValidateOperation">
-	</bean>
-
-	<bean id="encryptedUtSamlTokenProvider" class="org.apache.cxf.sts.token.provider.SAMLTokenProvider">
-	</bean>
+    </bean>
 
 	<bean id="encryptedUtService" class="org.apache.cxf.sts.service.StaticService">
 		<property name="endpoints" ref="encryptedUtEndpoints" />

Modified: cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/deployment/cxf-transport.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/deployment/cxf-transport.xml?rev=1345046&r1=1345045&r2=1345046&view=diff
==============================================================================
--- cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/deployment/cxf-transport.xml
(original)
+++ cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/deployment/cxf-transport.xml
Fri Jun  1 10:58:22 2012
@@ -48,45 +48,10 @@
     </cxf:bus>
 
     <bean id="transportSTSProviderBean"
-	    class="org.apache.cxf.ws.security.sts.provider.SecurityTokenServiceProvider">
-	    <property name="issueOperation" ref="transportIssueDelegate" />
-	    <property name="validateOperation" ref="transportValidateDelegate" />
-    </bean>
-
-	<bean id="transportIssueDelegate" class="org.apache.cxf.sts.operation.TokenIssueOperation">
-		<property name="tokenProviders" ref="transportTokenProviders" />
-		<property name="tokenValidators" ref="transportTokenValidators" />
-		<property name="services" ref="transportService" />
-		<property name="stsProperties" ref="transportSTSProperties" />
-	</bean>
-
-	<bean id="transportValidateDelegate" class="org.apache.cxf.sts.operation.TokenValidateOperation">
-		<property name="tokenValidators" ref="transportTokenValidators" />
+	    class="org.apache.cxf.sts.provider.DefaultSecurityTokenServiceProvider">
+	    <property name="services" ref="transportService" />
 		<property name="stsProperties" ref="transportSTSProperties" />
-	</bean>
-
-	<util:list id="transportTokenProviders">
-		<ref bean="transportSamlTokenProvider" />
-	</util:list>
-
-	<util:list id="transportTokenValidators">
-		<ref bean="transportSamlTokenValidator" />
-		<ref bean="transportX509TokenValidator" />
-		<ref bean="transportUsernameTokenValidator" />
-	</util:list>
-
-	<bean id="transportSamlTokenProvider" class="org.apache.cxf.sts.token.provider.SAMLTokenProvider">
-	</bean>
-
-	<bean id="transportX509TokenValidator" class="org.apache.cxf.sts.token.validator.X509TokenValidator">
-	</bean>
-
-	<bean id="transportUsernameTokenValidator"
-		class="org.apache.cxf.sts.token.validator.UsernameTokenValidator">
-	</bean>
-
-	<bean id="transportSamlTokenValidator" class="org.apache.cxf.sts.token.validator.SAMLTokenValidator">
-	</bean>
+    </bean>
 
 	<bean id="transportService" class="org.apache.cxf.sts.service.StaticService">
 		<property name="endpoints" ref="transportEndpoints" />

Modified: cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/deployment/cxf-ut.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/deployment/cxf-ut.xml?rev=1345046&r1=1345045&r2=1345046&view=diff
==============================================================================
--- cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/deployment/cxf-ut.xml
(original)
+++ cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/deployment/cxf-ut.xml
Fri Jun  1 10:58:22 2012
@@ -42,27 +42,10 @@
     </cxf:bus>
 
     <bean id="utSTSProviderBean"
-	    class="org.apache.cxf.ws.security.sts.provider.SecurityTokenServiceProvider">
-	    <property name="issueOperation" ref="utIssueDelegate" />
-	    <property name="validateOperation" ref="utValidateDelegate" />
-    </bean>
-
-	<bean id="utIssueDelegate" class="org.apache.cxf.sts.operation.TokenIssueOperation">
-		<property name="tokenProviders" ref="utSamlTokenProvider" />
-		<property name="services" ref="utService" />
-		<property name="stsProperties" ref="utSTSProperties" />
-	</bean>
-
-	<bean id="utValidateDelegate" class="org.apache.cxf.sts.operation.TokenValidateOperation">
-		<property name="tokenValidators" ref="utSamlTokenValidator" />
+	    class="org.apache.cxf.sts.provider.DefaultSecurityTokenServiceProvider">
+	    <property name="services" ref="utService" />
 		<property name="stsProperties" ref="utSTSProperties" />
-	</bean>
-
-	<bean id="utSamlTokenProvider" class="org.apache.cxf.sts.token.provider.SAMLTokenProvider">
-	</bean>
-
-	<bean id="utSamlTokenValidator" class="org.apache.cxf.sts.token.validator.SAMLTokenValidator">
-	</bean>
+    </bean>
 
 	<bean id="utService" class="org.apache.cxf.sts.service.StaticService">
 		<property name="endpoints" ref="utEndpoints" />



Mime
View raw message