You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2011/10/17 18:15:09 UTC
svn commit: r1185276 [1/6] - in /cxf/trunk/services/sts/systests: ./ basic/
basic/src/ basic/src/test/ basic/src/test/java/ basic/src/test/java/org/
basic/src/test/java/org/apache/ basic/src/test/java/org/apache/cxf/
basic/src/test/java/org/apache/cxf/...
Author: coheigea
Date: Mon Oct 17 16:15:04 2011
New Revision: 1185276
URL: http://svn.apache.org/viewvc?rev=1185276&view=rev
Log:
[CXF-3811] - Adding first batch of systests for the STS. These are not run by default at the moment as there is still some work to be done.
Added:
cxf/trunk/services/sts/systests/
cxf/trunk/services/sts/systests/basic/
cxf/trunk/services/sts/systests/basic/pom.xml
cxf/trunk/services/sts/systests/basic/src/
cxf/trunk/services/sts/systests/basic/src/test/
cxf/trunk/services/sts/systests/basic/src/test/java/
cxf/trunk/services/sts/systests/basic/src/test/java/org/
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/asymmetric/
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/asymmetric/AsymmetricBindingTest.java
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/asymmetric/Server.java
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/bearer/
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/bearer/BearerTest.java
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/bearer/Saml2CallbackHandler.java
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/bearer/Server.java
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/common/
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/common/CommonCallbackHandler.java
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/common/DoubleItPortTypeImpl.java
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/common/TokenTestUtils.java
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/deployment/
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/deployment/STSServer.java
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/Intermediary.java
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/IntermediaryCaching.java
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/IntermediaryCachingPortTypeImpl.java
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/IntermediaryPortTypeImpl.java
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/IntermediaryTransformationCachingTest.java
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/IntermediaryTransformationTest.java
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/OnBehalfOfValidator.java
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/Server.java
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/issueunit/
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/issueunit/IssueUnitTest.java
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/sendervouches/
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/sendervouches/DoubleItPortTypeImpl.java
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/sendervouches/Intermediary.java
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/sendervouches/Saml2CallbackHandler.java
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/sendervouches/SenderVouchesTest.java
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/sendervouches/Server.java
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/symmetric/
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/symmetric/Server.java
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/symmetric/SymmetricBindingTest.java
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/transport/
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/transport/Server.java
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/transport/TransportBindingTest.java
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_actas/
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_actas/ActAsValidator.java
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_actas/Server.java
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_actas/UsernameActAsTest.java
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_onbehalfof/
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_onbehalfof/Server.java
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/username_onbehalfof/UsernameOnBehalfOfTest.java
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/x509_symmetric/
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/x509_symmetric/Server.java
cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/x509_symmetric/X509SymmetricBindingTest.java
cxf/trunk/services/sts/systests/basic/src/test/resources/
cxf/trunk/services/sts/systests/basic/src/test/resources/DoubleItLogical.wsdl
cxf/trunk/services/sts/systests/basic/src/test/resources/clientKeystore.properties
cxf/trunk/services/sts/systests/basic/src/test/resources/clientstore.jks
cxf/trunk/services/sts/systests/basic/src/test/resources/eve.jks
cxf/trunk/services/sts/systests/basic/src/test/resources/eveKeystore.properties
cxf/trunk/services/sts/systests/basic/src/test/resources/logging.properties
cxf/trunk/services/sts/systests/basic/src/test/resources/org/
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/asymmetric/
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/asymmetric/DoubleIt.wsdl
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/asymmetric/cxf-client.xml
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/asymmetric/cxf-service.xml
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/bearer/
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/bearer/DoubleIt.wsdl
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/bearer/cxf-client.xml
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/bearer/cxf-service.xml
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/bearer/cxf-unsigned-client.xml
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/deployment/
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-servlet.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
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/deployment/cxf-x509.xml
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/deployment/ws-trust-1.4-service.wsdl
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/intermediary_transformation/
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/intermediary_transformation/DoubleIt.wsdl
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/intermediary_transformation/cxf-bad-client.xml
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/intermediary_transformation/cxf-client.xml
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/intermediary_transformation/cxf-intermediary-caching.xml
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/intermediary_transformation/cxf-intermediary.xml
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/intermediary_transformation/cxf-service.xml
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/issueunit/
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/issueunit/cxf-client.xml
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/sendervouches/
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/sendervouches/DoubleIt.wsdl
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/sendervouches/cxf-client.xml
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/sendervouches/cxf-intermediary.xml
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/sendervouches/cxf-service.xml
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/symmetric/
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/symmetric/DoubleIt.wsdl
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/symmetric/cxf-client.xml
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/symmetric/cxf-service.xml
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/transport/
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/transport/DoubleIt.wsdl
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/transport/cxf-bad-client.xml
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/transport/cxf-client.xml
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/transport/cxf-service.xml
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/username_actas/
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/username_actas/DoubleIt.wsdl
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/username_actas/cxf-client.xml
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/username_actas/cxf-service.xml
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/username_onbehalfof/
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/username_onbehalfof/DoubleIt.wsdl
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/username_onbehalfof/cxf-client.xml
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/username_onbehalfof/cxf-service.xml
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/x509_symmetric/
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/x509_symmetric/DoubleIt.wsdl
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/x509_symmetric/cxf-client.xml
cxf/trunk/services/sts/systests/basic/src/test/resources/org/apache/cxf/systest/sts/x509_symmetric/cxf-service.xml
cxf/trunk/services/sts/systests/basic/src/test/resources/serviceKeystore.properties
cxf/trunk/services/sts/systests/basic/src/test/resources/servicestore.jks
cxf/trunk/services/sts/systests/basic/src/test/resources/stsKeystore.properties
cxf/trunk/services/sts/systests/basic/src/test/resources/stsstore.jks
cxf/trunk/services/sts/systests/pom.xml
Added: cxf/trunk/services/sts/systests/basic/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/basic/pom.xml?rev=1185276&view=auto
==============================================================================
--- cxf/trunk/services/sts/systests/basic/pom.xml (added)
+++ cxf/trunk/services/sts/systests/basic/pom.xml Mon Oct 17 16:15:04 2011
@@ -0,0 +1,243 @@
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.cxf.services.sts.systests</groupId>
+ <artifactId>cxf-services-sts-systests-basic</artifactId>
+ <packaging>jar</packaging>
+ <name>Apache CXF STS basic systests</name>
+ <url>http://cxf.apache.org</url>
+
+ <parent>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-parent</artifactId>
+ <version>2.5.0-SNAPSHOT</version>
+ <relativePath>../../../../parent/pom.xml</relativePath>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf.services.sts</groupId>
+ <artifactId>cxf-services-sts-core</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-transports-http-jetty</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-frontend-jaxrs</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-frontend-jaxws</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-ws-policy</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-ws-security</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-testutils</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-databinding-jaxb</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-jdk14</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <testSourceDirectory>${basedir}/src/test/java</testSourceDirectory>
+ <testResources>
+ <testResource>
+ <directory>src/test/java</directory>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </testResource>
+ <testResource>
+ <directory>src/test/resources</directory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </testResource>
+ </testResources>
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-codegen-plugin</artifactId>
+ <version>${project.version}</version>
+ <executions>
+ <execution>
+ <phase>generate-sources</phase>
+ <configuration>
+ <sourceRoot>
+ ${basedir}/target/generated-sources
+ </sourceRoot>
+ <wsdlOptions>
+ <wsdlOption>
+ <wsdl>
+ ${basedir}/src/test/resources/DoubleItLogical.wsdl
+ </wsdl>
+ </wsdlOption>
+ </wsdlOptions>
+ </configuration>
+ <goals>
+ <goal>wsdl2java</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <properties>
+ <cxf.surefire.fork.mode>pertest</cxf.surefire.fork.mode>
+ </properties>
+
+ <profiles>
+ <profile>
+ <id>standalone</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemPropertyVariables>
+ <sts.deployment>standalone</sts.deployment>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>war</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemPropertyVariables>
+ <sts.deployment>war</sts.deployment>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>jdk15</id>
+ <activation>
+ <jdk>1.5</jdk>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-ws-metadata_2.0_spec</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jaxws_2.2_spec</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>create-endorsed-dir</id>
+ <phase>validate</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ <outputDirectory>${basedir}/target/endorsed</outputDirectory>
+ </artifactItem>
+ <artifactItem>
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis</artifactId>
+ <version>1.3.04</version>
+ <outputDirectory>${basedir}/target/endorsed</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <argLine>-Djava.endorsed.dirs=${basedir}/target/endorsed</argLine>
+ <systemPropertyVariables>
+ <sts.deployment>standalone</sts.deployment>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
Added: cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/asymmetric/AsymmetricBindingTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/asymmetric/AsymmetricBindingTest.java?rev=1185276&view=auto
==============================================================================
--- cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/asymmetric/AsymmetricBindingTest.java (added)
+++ cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/asymmetric/AsymmetricBindingTest.java Mon Oct 17 16:15:04 2011
@@ -0,0 +1,133 @@
+/**
+ * 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.systest.sts.asymmetric;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.systest.sts.common.TokenTestUtils;
+import org.apache.cxf.systest.sts.deployment.STSServer;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+
+import org.example.contract.doubleit.DoubleItPortType;
+import org.junit.BeforeClass;
+
+/**
+ * Test the Asymmetric binding. The CXF client gets a token from the STS by authenticating via a
+ * Username Token over the symmetric binding, and then sends it to the CXF endpoint using
+ * the asymmetric binding.
+ */
+public class AsymmetricBindingTest extends AbstractBusClientServerTestBase {
+
+ private static final String NAMESPACE = "http://www.example.org/contract/DoubleIt";
+ private static final QName SERVICE_QNAME = new QName(NAMESPACE, "DoubleItService");
+
+ private static final String PORT = allocatePort(Server.class);
+
+ @BeforeClass
+ public static void startServers() throws Exception {
+ assertTrue(
+ "Server failed to launch",
+ // run the server in the same process
+ // set this to false to fork
+ launchServer(Server.class, true)
+ );
+ String deployment = System.getProperty("sts.deployment");
+ if ("standalone".equals(deployment)) {
+ assertTrue(
+ "Server failed to launch",
+ // run the server in the same process
+ // set this to false to fork
+ launchServer(STSServer.class, true)
+ );
+ }
+ }
+
+ @org.junit.Test
+ public void testUsernameTokenSAML1() throws Exception {
+
+ SpringBusFactory bf = new SpringBusFactory();
+ URL busFile = AsymmetricBindingTest.class.getResource("cxf-client.xml");
+
+ Bus bus = bf.createBus(busFile.toString());
+ SpringBusFactory.setDefaultBus(bus);
+ SpringBusFactory.setThreadDefaultBus(bus);
+
+ URL wsdl = AsymmetricBindingTest.class.getResource("DoubleIt.wsdl");
+ Service service = Service.create(wsdl, SERVICE_QNAME);
+ QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricSAML1Port");
+ DoubleItPortType asymmetricSaml1Port =
+ service.getPort(portQName, DoubleItPortType.class);
+
+ updateAddressPort(asymmetricSaml1Port, PORT);
+ doubleIt(asymmetricSaml1Port, 25);
+ }
+
+ @org.junit.Test
+ public void testUsernameTokenSAML2() throws Exception {
+
+ SpringBusFactory bf = new SpringBusFactory();
+ URL busFile = AsymmetricBindingTest.class.getResource("cxf-client.xml");
+
+ Bus bus = bf.createBus(busFile.toString());
+ SpringBusFactory.setDefaultBus(bus);
+ SpringBusFactory.setThreadDefaultBus(bus);
+
+ URL wsdl = AsymmetricBindingTest.class.getResource("DoubleIt.wsdl");
+ Service service = Service.create(wsdl, SERVICE_QNAME);
+ QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricSAML2Port");
+ DoubleItPortType asymmetricSaml2Port =
+ service.getPort(portQName, DoubleItPortType.class);
+
+ updateAddressPort(asymmetricSaml2Port, PORT);
+ doubleIt(asymmetricSaml2Port, 30);
+
+ TokenTestUtils.verifyToken(asymmetricSaml2Port);
+ }
+
+ @org.junit.Test
+ public void testUsernameTokenSAML1Encrypted() throws Exception {
+
+ SpringBusFactory bf = new SpringBusFactory();
+ URL busFile = AsymmetricBindingTest.class.getResource("cxf-client.xml");
+
+ Bus bus = bf.createBus(busFile.toString());
+ SpringBusFactory.setDefaultBus(bus);
+ SpringBusFactory.setThreadDefaultBus(bus);
+
+ URL wsdl = AsymmetricBindingTest.class.getResource("DoubleIt.wsdl");
+ Service service = Service.create(wsdl, SERVICE_QNAME);
+ QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricSAML1EncryptedPort");
+ DoubleItPortType asymmetricSaml1EncryptedPort =
+ service.getPort(portQName, DoubleItPortType.class);
+
+ updateAddressPort(asymmetricSaml1EncryptedPort, PORT);
+ doubleIt(asymmetricSaml1EncryptedPort, 40);
+ }
+
+ private static void doubleIt(DoubleItPortType port, int numToDouble) {
+ int resp = port.doubleIt(numToDouble);
+ System.out.println("The number " + numToDouble + " doubled is " + resp);
+ }
+}
Added: cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/asymmetric/Server.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/asymmetric/Server.java?rev=1185276&view=auto
==============================================================================
--- cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/asymmetric/Server.java (added)
+++ cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/asymmetric/Server.java Mon Oct 17 16:15:04 2011
@@ -0,0 +1,46 @@
+/**
+ * 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.systest.sts.asymmetric;
+
+import java.net.URL;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+
+public class Server extends AbstractBusTestServerBase {
+
+ public Server() {
+
+ }
+
+ protected void run() {
+ URL busFile = Server.class.getResource("cxf-service.xml");
+ Bus busLocal = new SpringBusFactory().createBus(busFile);
+ BusFactory.setDefaultBus(busLocal);
+ setBus(busLocal);
+
+ try {
+ new Server();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
Added: cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/bearer/BearerTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/bearer/BearerTest.java?rev=1185276&view=auto
==============================================================================
--- cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/bearer/BearerTest.java (added)
+++ cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/bearer/BearerTest.java Mon Oct 17 16:15:04 2011
@@ -0,0 +1,146 @@
+/**
+ * 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.systest.sts.bearer;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.ws.Service;
+
+import org.w3c.dom.Element;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.frontend.ClientProxy;
+import org.apache.cxf.systest.sts.deployment.STSServer;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.cxf.ws.security.SecurityConstants;
+import org.apache.cxf.ws.security.tokenstore.MemoryTokenStore;
+import org.apache.cxf.ws.security.tokenstore.SecurityToken;
+import org.apache.cxf.ws.security.tokenstore.TokenStore;
+import org.apache.ws.security.WSConstants;
+import org.apache.ws.security.saml.ext.AssertionWrapper;
+import org.apache.ws.security.saml.ext.SAMLParms;
+
+import org.example.contract.doubleit.DoubleItPortType;
+import org.junit.BeforeClass;
+
+/**
+ * Test the Bearer TokenType over TLS.
+ */
+public class BearerTest extends AbstractBusClientServerTestBase {
+
+ private static final String NAMESPACE = "http://www.example.org/contract/DoubleIt";
+ private static final QName SERVICE_QNAME = new QName(NAMESPACE, "DoubleItService");
+
+ private static final String PORT = allocatePort(Server.class);
+
+ @BeforeClass
+ public static void startServers() throws Exception {
+ assertTrue(
+ "Server failed to launch",
+ // run the server in the same process
+ // set this to false to fork
+ launchServer(Server.class, true)
+ );
+ String deployment = System.getProperty("sts.deployment");
+ if ("standalone".equals(deployment)) {
+ assertTrue(
+ "Server failed to launch",
+ // run the server in the same process
+ // set this to false to fork
+ launchServer(STSServer.class, true)
+ );
+ }
+ }
+
+ @org.junit.Test
+ public void testSAML2Bearer() throws Exception {
+
+ SpringBusFactory bf = new SpringBusFactory();
+ URL busFile = BearerTest.class.getResource("cxf-client.xml");
+
+ Bus bus = bf.createBus(busFile.toString());
+ SpringBusFactory.setDefaultBus(bus);
+ SpringBusFactory.setThreadDefaultBus(bus);
+
+ URL wsdl = BearerTest.class.getResource("DoubleIt.wsdl");
+ Service service = Service.create(wsdl, SERVICE_QNAME);
+ QName portQName = new QName(NAMESPACE, "DoubleItTransportSAML2BearerPort");
+ DoubleItPortType transportSaml2Port =
+ service.getPort(portQName, DoubleItPortType.class);
+
+ updateAddressPort(transportSaml2Port, PORT);
+ doubleIt(transportSaml2Port, 45);
+ }
+
+ @org.junit.Test
+ public void testSAML2UnsignedBearer() throws Exception {
+
+ SpringBusFactory bf = new SpringBusFactory();
+ URL busFile = BearerTest.class.getResource("cxf-unsigned-client.xml");
+
+ Bus bus = bf.createBus(busFile.toString());
+ SpringBusFactory.setDefaultBus(bus);
+ SpringBusFactory.setThreadDefaultBus(bus);
+
+ URL wsdl = BearerTest.class.getResource("DoubleIt.wsdl");
+ Service service = Service.create(wsdl, SERVICE_QNAME);
+ QName portQName = new QName(NAMESPACE, "DoubleItTransportSAML2BearerPort");
+ DoubleItPortType transportSaml2Port =
+ service.getPort(portQName, DoubleItPortType.class);
+ updateAddressPort(transportSaml2Port, PORT);
+
+ //
+ // Create a SAML2 Bearer Assertion and add it to the TokenStore so that the
+ // IssuedTokenInterceptorProvider does not invoke on the STS
+ //
+ Client client = ClientProxy.getClient(transportSaml2Port);
+ Endpoint ep = client.getEndpoint();
+ String id = "1234";
+ ep.getEndpointInfo().setProperty(TokenStore.class.getName(), new MemoryTokenStore());
+ ep.getEndpointInfo().setProperty(SecurityConstants.TOKEN_ID, id);
+ TokenStore store = (TokenStore)ep.getEndpointInfo().getProperty(TokenStore.class.getName());
+
+ SAMLParms samlParms = new SAMLParms();
+ samlParms.setCallbackHandler(new Saml2CallbackHandler());
+ AssertionWrapper assertion = new AssertionWrapper(samlParms);
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setNamespaceAware(true);
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ Element assertionElement = assertion.toDOM(db.newDocument());
+
+ SecurityToken tok = new SecurityToken(id);
+ tok.setTokenType(WSConstants.WSS_SAML2_TOKEN_TYPE);
+ tok.setToken(assertionElement);
+ store.add(tok);
+
+ doubleIt(transportSaml2Port, 50);
+ }
+
+
+ private static void doubleIt(DoubleItPortType port, int numToDouble) {
+ int resp = port.doubleIt(numToDouble);
+ System.out.println("The number " + numToDouble + " doubled is " + resp);
+ }
+}
Added: cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/bearer/Saml2CallbackHandler.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/bearer/Saml2CallbackHandler.java?rev=1185276&view=auto
==============================================================================
--- cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/bearer/Saml2CallbackHandler.java (added)
+++ cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/bearer/Saml2CallbackHandler.java Mon Oct 17 16:15:04 2011
@@ -0,0 +1,68 @@
+/**
+ * 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.systest.sts.bearer;
+
+import java.io.IOException;
+import java.util.Collections;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+import org.apache.ws.security.saml.ext.SAMLCallback;
+import org.apache.ws.security.saml.ext.bean.AttributeBean;
+import org.apache.ws.security.saml.ext.bean.AttributeStatementBean;
+import org.apache.ws.security.saml.ext.bean.SubjectBean;
+import org.apache.ws.security.saml.ext.builder.SAML2Constants;
+import org.opensaml.common.SAMLVersion;
+
+/**
+ * Create a SAML2 Bearer Assertion.
+ */
+public class Saml2CallbackHandler implements CallbackHandler {
+
+ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
+ for (int i = 0; i < callbacks.length; i++) {
+ if (callbacks[i] instanceof SAMLCallback) {
+
+ SAMLCallback callback = (SAMLCallback) callbacks[i];
+ callback.setSamlVersion(SAMLVersion.VERSION_20);
+
+ callback.setIssuer("sts");
+ String subjectName = "uid=alice";
+ String confirmationMethod = SAML2Constants.CONF_BEARER;
+
+ SubjectBean subjectBean =
+ new SubjectBean(subjectName, null, confirmationMethod);
+ callback.setSubject(subjectBean);
+
+ AttributeStatementBean attrBean = new AttributeStatementBean();
+ if (subjectBean != null) {
+ attrBean.setSubject(subjectBean);
+ }
+ AttributeBean attributeBean = new AttributeBean();
+ attributeBean.setSimpleName("role");
+ attributeBean.setAttributeValues(Collections.singletonList("user"));
+ attrBean.setSamlAttributes(Collections.singletonList(attributeBean));
+ callback.setAttributeStatementData(Collections.singletonList(attrBean));
+ }
+ }
+ }
+
+}
Added: cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/bearer/Server.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/bearer/Server.java?rev=1185276&view=auto
==============================================================================
--- cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/bearer/Server.java (added)
+++ cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/bearer/Server.java Mon Oct 17 16:15:04 2011
@@ -0,0 +1,46 @@
+/**
+ * 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.systest.sts.bearer;
+
+import java.net.URL;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+
+public class Server extends AbstractBusTestServerBase {
+
+ public Server() {
+
+ }
+
+ protected void run() {
+ URL busFile = Server.class.getResource("cxf-service.xml");
+ Bus busLocal = new SpringBusFactory().createBus(busFile);
+ BusFactory.setDefaultBus(busLocal);
+ setBus(busLocal);
+
+ try {
+ new Server();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
Added: cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/common/CommonCallbackHandler.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/common/CommonCallbackHandler.java?rev=1185276&view=auto
==============================================================================
--- cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/common/CommonCallbackHandler.java (added)
+++ cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/common/CommonCallbackHandler.java Mon Oct 17 16:15:04 2011
@@ -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.systest.sts.common;
+
+import java.io.IOException;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import org.apache.ws.security.WSPasswordCallback;
+
+public class CommonCallbackHandler implements CallbackHandler {
+
+ public void handle(Callback[] callbacks) throws IOException,
+ UnsupportedCallbackException {
+ for (int i = 0; i < callbacks.length; i++) {
+ if (callbacks[i] instanceof WSPasswordCallback) { // CXF
+ WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
+ if ("myclientkey".equals(pc.getIdentifier())) {
+ pc.setPassword("ckpass");
+ break;
+ } else if ("myservicekey".equals(pc.getIdentifier())) {
+ pc.setPassword("skpass");
+ break;
+ } else if ("alice".equals(pc.getIdentifier())) {
+ pc.setPassword("clarinet");
+ break;
+ } else if ("bob".equals(pc.getIdentifier())) {
+ pc.setPassword("trombone");
+ break;
+ } else if ("eve".equals(pc.getIdentifier())) {
+ pc.setPassword("evekpass");
+ break;
+ } else if ("mystskey".equals(pc.getIdentifier())) {
+ pc.setPassword("stskpass");
+ break;
+ }
+ }
+ }
+ }
+}
Added: cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/common/DoubleItPortTypeImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/common/DoubleItPortTypeImpl.java?rev=1185276&view=auto
==============================================================================
--- cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/common/DoubleItPortTypeImpl.java (added)
+++ cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/common/DoubleItPortTypeImpl.java Mon Oct 17 16:15:04 2011
@@ -0,0 +1,49 @@
+/**
+ * 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.systest.sts.common;
+
+import java.security.Principal;
+
+import javax.annotation.Resource;
+import javax.jws.WebService;
+import javax.xml.ws.WebServiceContext;
+
+import org.apache.cxf.feature.Features;
+import org.example.contract.doubleit.DoubleItPortType;
+import org.junit.Assert;
+
+@WebService(targetNamespace = "http://www.example.org/contract/DoubleIt",
+ serviceName = "DoubleItService",
+ endpointInterface = "org.example.contract.doubleit.DoubleItPortType")
+@Features(features = "org.apache.cxf.feature.LoggingFeature")
+public class DoubleItPortTypeImpl implements DoubleItPortType {
+
+ @Resource
+ WebServiceContext wsContext;
+
+ public int doubleIt(int numberToDouble) {
+ Principal pr = wsContext.getUserPrincipal();
+
+ Assert.assertNotNull("Principal must not be null", pr);
+ Assert.assertNotNull("Principal.getName() must not return null", pr.getName());
+
+ return numberToDouble * 2;
+ }
+
+}
Added: cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/common/TokenTestUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/common/TokenTestUtils.java?rev=1185276&view=auto
==============================================================================
--- cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/common/TokenTestUtils.java (added)
+++ cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/common/TokenTestUtils.java Mon Oct 17 16:15:04 2011
@@ -0,0 +1,74 @@
+/**
+ * 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.systest.sts.common;
+
+import java.util.List;
+
+import org.w3c.dom.Element;
+
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.frontend.ClientProxy;
+import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.ws.security.SecurityConstants;
+import org.apache.cxf.ws.security.tokenstore.SecurityToken;
+import org.apache.cxf.ws.security.tokenstore.TokenStore;
+import org.apache.cxf.ws.security.trust.STSClient;
+import org.example.contract.doubleit.DoubleItPortType;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+public final class TokenTestUtils {
+
+ private TokenTestUtils() {
+ // complete
+ }
+
+ public static void verifyToken(DoubleItPortType port) throws Exception {
+ Client client = ClientProxy.getClient(port);
+ Endpoint ep = client.getEndpoint();
+ String id = (String)ep.get(SecurityConstants.TOKEN_ID);
+ TokenStore store = (TokenStore)ep.getEndpointInfo().getProperty(TokenStore.class.getName());
+ org.apache.cxf.ws.security.tokenstore.SecurityToken tok = store.getToken(id);
+ assertNotNull(tok);
+ STSClient sts = (STSClient)ep.get(SecurityConstants.STS_CLIENT);
+
+ List<SecurityToken> validTokens = sts.validateSecurityToken(tok);
+ assertTrue(validTokens != null && !validTokens.isEmpty());
+
+ //mess with the token a bit to force it to fail to validate
+ Element e = tok.getToken();
+ Element e2 = DOMUtils.getFirstChildWithName(e, e.getNamespaceURI(), "Conditions");
+ String nb = e2.getAttribute("NotBefore");
+ String noa = e2.getAttribute("NotOnOrAfter");
+ nb = "2010" + nb.substring(4);
+ noa = "2010" + noa.substring(4);
+ e2.setAttribute("NotBefore", nb);
+ e2.setAttribute("NotOnOrAfter", noa);
+ try {
+ sts.validateSecurityToken(tok);
+ fail("Failure expected on an invalid token");
+ } catch (org.apache.cxf.ws.security.trust.TrustException ex) {
+ // expected
+ }
+ }
+
+}
Added: cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/deployment/STSServer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/deployment/STSServer.java?rev=1185276&view=auto
==============================================================================
--- cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/deployment/STSServer.java (added)
+++ cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/deployment/STSServer.java Mon Oct 17 16:15:04 2011
@@ -0,0 +1,46 @@
+/**
+ * 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.systest.sts.deployment;
+
+import java.net.URL;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+
+public class STSServer extends AbstractBusTestServerBase {
+
+ public STSServer() {
+
+ }
+
+ protected void run() {
+ URL busFile = STSServer.class.getResource("cxf-servlet.xml");
+ Bus busLocal = new SpringBusFactory().createBus(busFile);
+ BusFactory.setDefaultBus(busLocal);
+ setBus(busLocal);
+
+ try {
+ new STSServer();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
Added: cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/Intermediary.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/Intermediary.java?rev=1185276&view=auto
==============================================================================
--- cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/Intermediary.java (added)
+++ cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/Intermediary.java Mon Oct 17 16:15:04 2011
@@ -0,0 +1,46 @@
+/**
+ * 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.systest.sts.intermediary_transformation;
+
+import java.net.URL;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+
+public class Intermediary extends AbstractBusTestServerBase {
+
+ public Intermediary() {
+
+ }
+
+ protected void run() {
+ URL busFile = Intermediary.class.getResource("cxf-intermediary.xml");
+ Bus busLocal = new SpringBusFactory().createBus(busFile);
+ BusFactory.setDefaultBus(busLocal);
+ setBus(busLocal);
+
+ try {
+ new Intermediary();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
Added: cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/IntermediaryCaching.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/IntermediaryCaching.java?rev=1185276&view=auto
==============================================================================
--- cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/IntermediaryCaching.java (added)
+++ cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/IntermediaryCaching.java Mon Oct 17 16:15:04 2011
@@ -0,0 +1,46 @@
+/**
+ * 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.systest.sts.intermediary_transformation;
+
+import java.net.URL;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+
+public class IntermediaryCaching extends AbstractBusTestServerBase {
+
+ public IntermediaryCaching() {
+
+ }
+
+ protected void run() {
+ URL busFile = IntermediaryCaching.class.getResource("cxf-intermediary-caching.xml");
+ Bus busLocal = new SpringBusFactory().createBus(busFile);
+ BusFactory.setDefaultBus(busLocal);
+ setBus(busLocal);
+
+ try {
+ new IntermediaryCaching();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
Added: cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/IntermediaryCachingPortTypeImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/IntermediaryCachingPortTypeImpl.java?rev=1185276&view=auto
==============================================================================
--- cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/IntermediaryCachingPortTypeImpl.java (added)
+++ cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/IntermediaryCachingPortTypeImpl.java Mon Oct 17 16:15:04 2011
@@ -0,0 +1,86 @@
+/**
+ * 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.systest.sts.intermediary_transformation;
+
+import java.net.URL;
+import java.security.Principal;
+
+import javax.annotation.Resource;
+import javax.jws.WebService;
+import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Service;
+import javax.xml.ws.WebServiceContext;
+
+import org.apache.cxf.feature.Features;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.cxf.ws.security.SecurityConstants;
+import org.apache.cxf.ws.security.trust.STSClient;
+import org.apache.cxf.ws.security.trust.delegation.ReceivedTokenCallbackHandler;
+import org.example.contract.doubleit.DoubleItPortType;
+import org.junit.Assert;
+
+@WebService(targetNamespace = "http://www.example.org/contract/DoubleIt",
+ serviceName = "DoubleItService",
+ endpointInterface = "org.example.contract.doubleit.DoubleItPortType")
+@Features(features = "org.apache.cxf.feature.LoggingFeature")
+public class IntermediaryCachingPortTypeImpl extends AbstractBusClientServerTestBase
+ implements DoubleItPortType {
+
+ private static final String NAMESPACE = "http://www.example.org/contract/DoubleIt";
+ private static final QName SERVICE_QNAME = new QName(NAMESPACE, "DoubleItService");
+
+ @Resource
+ private WebServiceContext wsc;
+
+ private int i;
+
+ private DoubleItPortType transportPort;
+
+ public int doubleIt(int numberToDouble) {
+ if (transportPort == null) {
+ // Re-use the same proxy
+ URL wsdl = IntermediaryCachingPortTypeImpl.class.getResource("DoubleIt.wsdl");
+ Service service = Service.create(wsdl, SERVICE_QNAME);
+ QName portQName = new QName(NAMESPACE, "DoubleItTransportSAML2Port");
+ transportPort = service.getPort(portQName, DoubleItPortType.class);
+ try {
+ updateAddressPort(transportPort, IntermediaryTransformationCachingTest.PORT2);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+ Principal pr = wsc.getUserPrincipal();
+
+ Assert.assertNotNull("Principal must not be null", pr);
+ Assert.assertNotNull("Principal.getName() must not return null", pr.getName());
+
+ // Disable the STSClient after the first invocation
+ if (i > 0) {
+ BindingProvider p = (BindingProvider)transportPort;
+ STSClient stsClient = new STSClient(null);
+ stsClient.setOnBehalfOf(new ReceivedTokenCallbackHandler());
+ p.getRequestContext().put(SecurityConstants.STS_CLIENT, stsClient);
+ }
+
+ i++;
+ return transportPort.doubleIt(numberToDouble);
+ }
+
+}
Added: cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/IntermediaryPortTypeImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/IntermediaryPortTypeImpl.java?rev=1185276&view=auto
==============================================================================
--- cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/IntermediaryPortTypeImpl.java (added)
+++ cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/IntermediaryPortTypeImpl.java Mon Oct 17 16:15:04 2011
@@ -0,0 +1,67 @@
+/**
+ * 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.systest.sts.intermediary_transformation;
+
+import java.net.URL;
+import java.security.Principal;
+
+import javax.annotation.Resource;
+import javax.jws.WebService;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import javax.xml.ws.WebServiceContext;
+
+import org.apache.cxf.feature.Features;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.example.contract.doubleit.DoubleItPortType;
+import org.junit.Assert;
+
+@WebService(targetNamespace = "http://www.example.org/contract/DoubleIt",
+ serviceName = "DoubleItService",
+ endpointInterface = "org.example.contract.doubleit.DoubleItPortType")
+@Features(features = "org.apache.cxf.feature.LoggingFeature")
+public class IntermediaryPortTypeImpl extends AbstractBusClientServerTestBase implements DoubleItPortType {
+
+ private static final String NAMESPACE = "http://www.example.org/contract/DoubleIt";
+ private static final QName SERVICE_QNAME = new QName(NAMESPACE, "DoubleItService");
+
+ @Resource
+ WebServiceContext wsc;
+
+ public int doubleIt(int numberToDouble) {
+ Principal pr = wsc.getUserPrincipal();
+
+ Assert.assertNotNull("Principal must not be null", pr);
+ Assert.assertNotNull("Principal.getName() must not return null", pr.getName());
+
+ URL wsdl = IntermediaryPortTypeImpl.class.getResource("DoubleIt.wsdl");
+ Service service = Service.create(wsdl, SERVICE_QNAME);
+ QName portQName = new QName(NAMESPACE, "DoubleItTransportSAML2Port");
+ DoubleItPortType transportPort =
+ service.getPort(portQName, DoubleItPortType.class);
+ try {
+ updateAddressPort(transportPort, IntermediaryTransformationTest.PORT2);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+
+ return transportPort.doubleIt(numberToDouble);
+ }
+
+}
Added: cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/IntermediaryTransformationCachingTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/IntermediaryTransformationCachingTest.java?rev=1185276&view=auto
==============================================================================
--- cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/IntermediaryTransformationCachingTest.java (added)
+++ cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/IntermediaryTransformationCachingTest.java Mon Oct 17 16:15:04 2011
@@ -0,0 +1,105 @@
+/**
+ * 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.systest.sts.intermediary_transformation;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.systest.sts.deployment.STSServer;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.example.contract.doubleit.DoubleItPortType;
+import org.junit.BeforeClass;
+
+/**
+ * In this test case, a CXF client sends a Username Token via (1-way) TLS to a STS instance, and
+ * receives a (HOK) SAML 1.1 Assertion. This is then sent via (1-way) TLS to an Intermediary
+ * service provider. The intermediary service provider validates the token, and then the
+ * Intermediary client uses delegation to dispatch the received token (via OnBehalfOf) to another
+ * STS instance. After this point, the STSClient is disabled, meaning that the Intermediary client must rely
+ * on its cache to get tokens. The retrieved token is sent to the service provider via (2-way) TLS.
+ */
+public class IntermediaryTransformationCachingTest extends AbstractBusClientServerTestBase {
+
+ static final String PORT2 = allocatePort(Server.class, 2);
+
+ private static final String NAMESPACE = "http://www.example.org/contract/DoubleIt";
+ private static final QName SERVICE_QNAME = new QName(NAMESPACE, "DoubleItService");
+
+ private static final String PORT = allocatePort(Intermediary.class);
+
+ @BeforeClass
+ public static void startServers() throws Exception {
+ assertTrue(
+ "Intermediary failed to launch",
+ // run the Intermediary in the same process
+ // set this to false to fork
+ launchServer(IntermediaryCaching.class, true)
+ );
+ assertTrue(
+ "Server failed to launch",
+ // run the server in the same process
+ // set this to false to fork
+ launchServer(Server.class, true)
+ );
+ String deployment = System.getProperty("sts.deployment");
+ if ("standalone".equals(deployment)) {
+ assertTrue(
+ "Server failed to launch",
+ // run the server in the same process
+ // set this to false to fork
+ launchServer(STSServer.class, true)
+ );
+ }
+ }
+
+ @org.junit.Test
+ public void testIntermediaryTransformationCaching() throws Exception {
+
+ SpringBusFactory bf = new SpringBusFactory();
+ URL busFile = IntermediaryTransformationCachingTest.class.getResource("cxf-client.xml");
+
+ Bus bus = bf.createBus(busFile.toString());
+ SpringBusFactory.setDefaultBus(bus);
+ SpringBusFactory.setThreadDefaultBus(bus);
+
+ URL wsdl = IntermediaryTransformationCachingTest.class.getResource("DoubleIt.wsdl");
+ Service service = Service.create(wsdl, SERVICE_QNAME);
+ QName portQName = new QName(NAMESPACE, "DoubleItTransportSAML1EndorsingPort");
+ DoubleItPortType transportPort =
+ service.getPort(portQName, DoubleItPortType.class);
+ updateAddressPort(transportPort, PORT);
+
+ // Make initial successful invocation
+ doubleIt(transportPort, 25);
+
+ // Make another invocation - this should work as the intermediary caches the token
+ // even though its STSClient is disabled after the first invocation
+ doubleIt(transportPort, 30);
+ }
+
+ private static void doubleIt(DoubleItPortType port, int numToDouble) {
+ int resp = port.doubleIt(numToDouble);
+ System.out.println("The number " + numToDouble + " doubled is " + resp);
+ assertTrue(resp == 2 * numToDouble);
+ }
+}
Added: cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/IntermediaryTransformationTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/IntermediaryTransformationTest.java?rev=1185276&view=auto
==============================================================================
--- cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/IntermediaryTransformationTest.java (added)
+++ cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/IntermediaryTransformationTest.java Mon Oct 17 16:15:04 2011
@@ -0,0 +1,126 @@
+/**
+ * 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.systest.sts.intermediary_transformation;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.systest.sts.deployment.STSServer;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+
+import org.example.contract.doubleit.DoubleItPortType;
+import org.junit.BeforeClass;
+
+/**
+ * In this test case, a CXF client sends a Username Token via (1-way) TLS to a STS instance, and
+ * receives a (HOK) SAML 1.1 Assertion. This is then sent via (1-way) TLS to an Intermediary
+ * service provider. The intermediary service provider validates the token, and then the
+ * Intermediary client uses delegation to dispatch the received token (via OnBehalfOf) to another
+ * STS instance. This returns another (HOK) SAML 2 Assertion which is sent to the service provider
+ * via (2-way) TLS.
+ */
+public class IntermediaryTransformationTest extends AbstractBusClientServerTestBase {
+
+ static final String PORT2 = allocatePort(Server.class, 2);
+
+ private static final String NAMESPACE = "http://www.example.org/contract/DoubleIt";
+ private static final QName SERVICE_QNAME = new QName(NAMESPACE, "DoubleItService");
+
+ private static final String PORT = allocatePort(Intermediary.class);
+
+ @BeforeClass
+ public static void startServers() throws Exception {
+ assertTrue(
+ "Intermediary failed to launch",
+ // run the Intermediary in the same process
+ // set this to false to fork
+ launchServer(Intermediary.class, true)
+ );
+ assertTrue(
+ "Server failed to launch",
+ // run the server in the same process
+ // set this to false to fork
+ launchServer(Server.class, true)
+ );
+ String deployment = System.getProperty("sts.deployment");
+ if ("standalone".equals(deployment)) {
+ assertTrue(
+ "Server failed to launch",
+ // run the server in the same process
+ // set this to false to fork
+ launchServer(STSServer.class, true)
+ );
+ }
+ }
+
+ @org.junit.Test
+ public void testIntermediaryTransformation() throws Exception {
+
+ SpringBusFactory bf = new SpringBusFactory();
+ URL busFile = IntermediaryTransformationTest.class.getResource("cxf-client.xml");
+
+ Bus bus = bf.createBus(busFile.toString());
+ SpringBusFactory.setDefaultBus(bus);
+ SpringBusFactory.setThreadDefaultBus(bus);
+
+ URL wsdl = IntermediaryTransformationTest.class.getResource("DoubleIt.wsdl");
+ Service service = Service.create(wsdl, SERVICE_QNAME);
+ QName portQName = new QName(NAMESPACE, "DoubleItTransportSAML1EndorsingPort");
+ DoubleItPortType transportPort =
+ service.getPort(portQName, DoubleItPortType.class);
+ updateAddressPort(transportPort, PORT);
+
+ doubleIt(transportPort, 25);
+ }
+
+ @org.junit.Test
+ public void testIntermediaryTransformationBadClient() throws Exception {
+
+ SpringBusFactory bf = new SpringBusFactory();
+ URL busFile = IntermediaryTransformationTest.class.getResource("cxf-bad-client.xml");
+
+ Bus bus = bf.createBus(busFile.toString());
+ SpringBusFactory.setDefaultBus(bus);
+ SpringBusFactory.setThreadDefaultBus(bus);
+
+ URL wsdl = IntermediaryTransformationTest.class.getResource("DoubleIt.wsdl");
+ Service service = Service.create(wsdl, SERVICE_QNAME);
+ QName portQName = new QName(NAMESPACE, "DoubleItTransportSAML1EndorsingPort");
+ DoubleItPortType transportPort =
+ service.getPort(portQName, DoubleItPortType.class);
+ updateAddressPort(transportPort, PORT);
+
+ try {
+ doubleIt(transportPort, 30);
+ fail("Expected failure on a bad user");
+ } catch (Exception ex) {
+ // expected
+ }
+ }
+
+ private static void doubleIt(DoubleItPortType port, int numToDouble) {
+ int resp = port.doubleIt(numToDouble);
+ System.out.println("The number " + numToDouble + " doubled is " + resp);
+ assertTrue(resp == 2 * numToDouble);
+ }
+}
Added: cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/OnBehalfOfValidator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/OnBehalfOfValidator.java?rev=1185276&view=auto
==============================================================================
--- cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/OnBehalfOfValidator.java (added)
+++ cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/OnBehalfOfValidator.java Mon Oct 17 16:15:04 2011
@@ -0,0 +1,75 @@
+/**
+ * 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.systest.sts.intermediary_transformation;
+
+import java.util.List;
+
+import org.w3c.dom.Element;
+
+import org.apache.ws.security.WSSecurityException;
+import org.apache.ws.security.handler.RequestData;
+import org.apache.ws.security.saml.ext.AssertionWrapper;
+import org.apache.ws.security.validate.Credential;
+import org.apache.ws.security.validate.SamlAssertionValidator;
+import org.opensaml.saml2.core.Assertion;
+import org.opensaml.saml2.core.Attribute;
+import org.opensaml.saml2.core.AttributeStatement;
+import org.opensaml.xml.XMLObject;
+
+/**
+ * This class validates a SAML 2 Assertion and checks that it has an OnBehalfOf Attribute with
+ * a value containing "alice" or "bob".
+ */
+public class OnBehalfOfValidator extends SamlAssertionValidator {
+
+ @Override
+ public Credential validate(Credential credential, RequestData data) throws WSSecurityException {
+ Credential validatedCredential = super.validate(credential, data);
+ AssertionWrapper assertion = validatedCredential.getAssertion();
+
+ Assertion saml2Assertion = assertion.getSaml2();
+ if (saml2Assertion == null) {
+ throw new WSSecurityException(WSSecurityException.FAILURE, "invalidSAMLsecurity");
+ }
+
+ List<AttributeStatement> attributeStatements = saml2Assertion.getAttributeStatements();
+ if (attributeStatements == null || attributeStatements.isEmpty()) {
+ throw new WSSecurityException(WSSecurityException.FAILURE, "invalidSAMLsecurity");
+ }
+
+ for (AttributeStatement statement : attributeStatements) {
+ List<Attribute> attributes = statement.getAttributes();
+ for (Attribute attribute : attributes) {
+ if (!"OnBehalfOf".equals(attribute.getName())) {
+ continue;
+ }
+ for (XMLObject attributeValue : attribute.getAttributeValues()) {
+ Element attributeValueElement = attributeValue.getDOM();
+ String text = attributeValueElement.getTextContent();
+ if (text.contains("alice") || text.contains("bob")) {
+ return validatedCredential;
+ }
+ }
+ }
+ }
+
+ throw new WSSecurityException(WSSecurityException.FAILURE, "invalidSAMLsecurity");
+ }
+
+}
Added: cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/Server.java
URL: http://svn.apache.org/viewvc/cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/Server.java?rev=1185276&view=auto
==============================================================================
--- cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/Server.java (added)
+++ cxf/trunk/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/intermediary_transformation/Server.java Mon Oct 17 16:15:04 2011
@@ -0,0 +1,46 @@
+/**
+ * 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.systest.sts.intermediary_transformation;
+
+import java.net.URL;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+
+public class Server extends AbstractBusTestServerBase {
+
+ public Server() {
+
+ }
+
+ protected void run() {
+ URL busFile = Server.class.getResource("cxf-service.xml");
+ Bus busLocal = new SpringBusFactory().createBus(busFile);
+ BusFactory.setDefaultBus(busLocal);
+ setBus(busLocal);
+
+ try {
+ new Server();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}