Author: coheigea
Date: Mon Jun 18 10:35:41 2012
New Revision: 1351280
URL: http://svn.apache.org/viewvc?rev=1351280&view=rev
Log:
Added a test-case for an Intermediary to the WS-Security systests
Added:
cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/server/DoubleItIntermediaryImpl.java
cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/server/Intermediary.java
cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/DoubleItIntermediary.wsdl
cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/client/intermediary-client.xml
cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/server/intermediary.xml
Modified:
cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/X509TokenTest.java
Modified:
cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/X509TokenTest.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/X509TokenTest.java?rev=1351280&r1=1351279&r2=1351280&view=diff
==============================================================================
---
cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/X509TokenTest.java
(original)
+++
cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/X509TokenTest.java
Mon Jun 18 10:35:41 2012
@@ -34,6 +34,7 @@ import org.apache.cxf.endpoint.Client;
import org.apache.cxf.frontend.ClientProxy;
import org.apache.cxf.systest.ws.common.SecurityTestUtil;
import org.apache.cxf.systest.ws.ut.SecurityHeaderCacheInterceptor;
+import org.apache.cxf.systest.ws.x509.server.Intermediary;
import org.apache.cxf.systest.ws.x509.server.Server;
import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
import org.apache.cxf.ws.security.SecurityConstants;
@@ -46,7 +47,8 @@ import org.junit.BeforeClass;
* A set of tests for X.509 Tokens.
*/
public class X509TokenTest extends AbstractBusClientServerTestBase {
- static final String PORT = allocatePort(Server.class);
+ public static final String PORT = allocatePort(Server.class);
+ public static final String INTERMEDIARY_PORT =
allocatePort(Intermediary.class);
static final String PORT2 = allocatePort(Server.class, 2);
private static final String NAMESPACE =
"http://www.example.org/contract/DoubleIt";
@@ -62,6 +64,12 @@ public class X509TokenTest extends Abstr
// set this to false to fork
launchServer(Server.class, true)
);
+ assertTrue(
+ "Intermediary failed to launch",
+ // run the server in the same process
+ // set this to false to fork
+ launchServer(Intermediary.class, true)
+ );
}
@org.junit.AfterClass
@@ -124,6 +132,31 @@ public class X509TokenTest extends Abstr
}
@org.junit.Test
+ public void testIntermediary() throws Exception {
+ if (!unrestrictedPoliciesInstalled) {
+ return;
+ }
+
+ SpringBusFactory bf = new SpringBusFactory();
+ URL busFile =
X509TokenTest.class.getResource("client/intermediary-client.xml");
+
+ Bus bus = bf.createBus(busFile.toString());
+ SpringBusFactory.setDefaultBus(bus);
+ SpringBusFactory.setThreadDefaultBus(bus);
+
+ URL wsdl =
X509TokenTest.class.getResource("DoubleItIntermediary.wsdl");
+ Service service = Service.create(wsdl, SERVICE_QNAME);
+ QName portQName = new QName(NAMESPACE, "DoubleItPort");
+ DoubleItPortType x509Port =
+ service.getPort(portQName, DoubleItPortType.class);
+ updateAddressPort(x509Port, INTERMEDIARY_PORT);
+
+ x509Port.doubleIt(25);
+
+ bus.shutdown(true);
+ }
+
+ @org.junit.Test
public void testIssuerSerial() throws Exception {
if (!unrestrictedPoliciesInstalled) {
return;
Added:
cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/server/DoubleItIntermediaryImpl.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/server/DoubleItIntermediaryImpl.java?rev=1351280&view=auto
==============================================================================
---
cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/server/DoubleItIntermediaryImpl.java
(added)
+++
cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/server/DoubleItIntermediaryImpl.java
Mon Jun 18 10:35:41 2012
@@ -0,0 +1,69 @@
+/**
+ * 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.ws.x509.server;
+
+import java.net.URL;
+
+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.systest.ws.x509.X509TokenTest;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.cxf.ws.security.SecurityConstants;
+import org.example.contract.doubleit.DoubleItFault;
+import org.example.contract.doubleit.DoubleItPortType;
+
+@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 DoubleItIntermediaryImpl 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) throws DoubleItFault {
+
+ URL wsdl = X509TokenTest.class.getResource("DoubleItX509.wsdl");
+ Service service = Service.create(wsdl, SERVICE_QNAME);
+ QName portQName = new QName(NAMESPACE, "DoubleItKeyIdentifierPort");
+ DoubleItPortType x509Port =
+ service.getPort(portQName, DoubleItPortType.class);
+ try {
+ updateAddressPort(x509Port, X509TokenTest.PORT);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+
+
((BindingProvider)x509Port).getRequestContext().put(SecurityConstants.ENCRYPT_PROPERTIES,
+ "org/apache/cxf/systest/ws/wssec10/client/bob.properties");
+
((BindingProvider)x509Port).getRequestContext().put(SecurityConstants.ENCRYPT_USERNAME,
"bob");
+
+ return x509Port.doubleIt(numberToDouble);
+ }
+
+}
Added:
cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/server/Intermediary.java
URL:
http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/server/Intermediary.java?rev=1351280&view=auto
==============================================================================
---
cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/server/Intermediary.java
(added)
+++
cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/x509/server/Intermediary.java
Mon Jun 18 10:35:41 2012
@@ -0,0 +1,41 @@
+/**
+ * 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.ws.x509.server;
+
+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("intermediary.xml");
+ Bus busLocal = new SpringBusFactory().createBus(busFile);
+ BusFactory.setDefaultBus(busLocal);
+ setBus(busLocal);
+ }
+}
Added:
cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/DoubleItIntermediary.wsdl
URL:
http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/DoubleItIntermediary.wsdl?rev=1351280&view=auto
==============================================================================
---
cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/DoubleItIntermediary.wsdl
(added)
+++
cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/DoubleItIntermediary.wsdl
Mon Jun 18 10:35:41 2012
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<wsdl:definitions name="DoubleIt"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://www.example.org/contract/DoubleIt"
+ targetNamespace="http://www.example.org/contract/DoubleIt"
+ xmlns:wsp="http://www.w3.org/ns/ws-policy"
+
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
+ xmlns:wsaws="http://www.w3.org/2005/08/addressing"
+ xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"
+ xmlns:sp13="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200802">
+
+ <wsdl:import location="src/test/resources/DoubleItLogical.wsdl"
+ namespace="http://www.example.org/contract/DoubleIt"/>
+
+ <wsdl:binding name="DoubleItBinding" type="tns:DoubleItPortType">
+ <soap:binding style="document"
+ transport="http://schemas.xmlsoap.org/soap/http" />
+ <wsdl:operation name="DoubleIt">
+ <soap:operation soapAction="" />
+ <wsdl:input>
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use="literal" />
+ </wsdl:output>
+ <wsdl:fault name="DoubleItFault">
+ <soap:body use="literal" name="DoubleItFault" />
+ </wsdl:fault>
+ </wsdl:operation>
+ </wsdl:binding>
+
+ <wsdl:service name="DoubleItService">
+ <wsdl:port name="DoubleItPort" binding="tns:DoubleItBinding">
+ <soap:address location="http://localhost:9001/DoubleItX509" />
+ </wsdl:port>
+ </wsdl:service>
+
+</wsdl:definitions>
Added:
cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/client/intermediary-client.xml
URL:
http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/client/intermediary-client.xml?rev=1351280&view=auto
==============================================================================
---
cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/client/intermediary-client.xml
(added)
+++
cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/client/intermediary-client.xml
Mon Jun 18 10:35:41 2012
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:http="http://cxf.apache.org/transports/http/configuration"
+ xmlns:jaxws="http://cxf.apache.org/jaxws"
+ xmlns:cxf="http://cxf.apache.org/core"
+ xmlns:p="http://cxf.apache.org/policy"
+ xmlns:sec="http://cxf.apache.org/configuration/security"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd
+ http://cxf.apache.org/transports/http/configuration
http://cxf.apache.org/schemas/configuration/http-conf.xsd
+ http://cxf.apache.org/configuration/security
http://cxf.apache.org/schemas/configuration/security.xsd
+ http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
+ http://cxf.apache.org/policy
http://cxf.apache.org/schemas/policy.xsd"
+>
+ <cxf:bus>
+ <cxf:features>
+ <p:policies/>
+ <cxf:logging/>
+ </cxf:features>
+ </cxf:bus>
+
+ <bean id="doubleitClient"
class="org.example.contract.doubleit.DoubleItPortType"
+ factory-bean="doubleitClientFactory" factory-method="create">
+ </bean>
+
+ <bean id="doubleitClientFactory"
class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
+ <property name="serviceClass"
value="org.example.contract.doubleit.DoubleItPortType"/>
+ <property name="address"
value="org/apache/cxf/systest/ws/x509/DoubleItIntermediary.wsdl"/>
+ <property name="bus" ref="cxf" />
+ </bean>
+
+</beans>
Added:
cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/server/intermediary.xml
URL:
http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/server/intermediary.xml?rev=1351280&view=auto
==============================================================================
---
cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/server/intermediary.xml
(added)
+++
cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/x509/server/intermediary.xml
Mon Jun 18 10:35:41 2012
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:http="http://cxf.apache.org/transports/http/configuration"
+ xmlns:jaxws="http://cxf.apache.org/jaxws"
+ xmlns:cxf="http://cxf.apache.org/core"
+ xmlns:p="http://cxf.apache.org/policy"
+ xmlns:sec="http://cxf.apache.org/configuration/security"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd
+ http://cxf.apache.org/transports/http/configuration
http://cxf.apache.org/schemas/configuration/http-conf.xsd
+ http://cxf.apache.org/configuration/security
http://cxf.apache.org/schemas/configuration/security.xsd
+ http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
+ http://cxf.apache.org/policy
http://cxf.apache.org/schemas/policy.xsd"
+>
+
+ <bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
+
+ <cxf:bus>
+ <cxf:features>
+ <p:policies/>
+ <cxf:logging/>
+ </cxf:features>
+ </cxf:bus>
+
+ <bean id="doubleitClient"
class="org.example.contract.doubleit.DoubleItPortType"
+ factory-bean="doubleitClientFactory" factory-method="create">
+ </bean>
+
+ <bean id="doubleitClientFactory"
class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
+ <property name="serviceClass"
value="org.example.contract.doubleit.DoubleItPortType"/>
+ <property name="address"
value="org/apache/cxf/systest/ws/x509/DoubleItX509.wsdl"/>
+ <property name="bus" ref="cxf" />
+ </bean>
+
+ <http:conduit name="https://localhost:.*">
+ <http:tlsClientParameters disableCNCheck="true">
+ <sec:trustManagers>
+ <sec:keyStore type="jks" password="password"
resource="org/apache/cxf/systest/ws/security/Truststore.jks"/>
+ </sec:trustManagers>
+ </http:tlsClientParameters>
+ </http:conduit>
+
+ <jaxws:endpoint
+ id="NoSecurity"
+ address="http://localhost:${testutil.ports.Intermediary}/DoubleItX509"
+ serviceName="s:DoubleItService"
+ endpointName="s:DoubleItPort"
+ xmlns:s="http://www.example.org/contract/DoubleIt"
+
implementor="org.apache.cxf.systest.ws.x509.server.DoubleItIntermediaryImpl"
+ wsdlLocation="org/apache/cxf/systest/ws/x509/DoubleItIntermediary.wsdl">
+
+ <jaxws:properties>
+ </jaxws:properties>
+
+ </jaxws:endpoint>
+
+</beans>