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 2018/01/29 10:48:24 UTC
[cxf] branch master updated: Adding TLS test
This is an automated email from the ASF dual-hosted git repository.
coheigea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git
The following commit(s) were added to refs/heads/master by this push:
new e396b80 Adding TLS test
e396b80 is described below
commit e396b806bdf992896781e340e1102f1ea4fdd0c9
Author: Colm O hEigeartaigh <co...@apache.org>
AuthorDate: Mon Jan 29 10:48:15 2018 +0000
Adding TLS test
---
.../cxf/systest/ws/ut/UsernameTokenTest.java | 49 ++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/ut/UsernameTokenTest.java b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/ut/UsernameTokenTest.java
index c97d3c4..9eaf277 100644
--- a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/ut/UsernameTokenTest.java
+++ b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/ut/UsernameTokenTest.java
@@ -19,10 +19,13 @@
package org.apache.cxf.systest.ws.ut;
+import java.io.InputStream;
import java.net.URL;
+import java.security.KeyStore;
import java.util.Arrays;
import java.util.Collection;
+import javax.net.ssl.TrustManagerFactory;
import javax.xml.namespace.QName;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.Service;
@@ -30,11 +33,14 @@ import javax.xml.ws.Service;
import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
+import org.apache.cxf.configuration.jsse.TLSClientParameters;
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.common.TestParam;
import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.cxf.transport.http.HTTPConduit;
import org.apache.cxf.ws.security.SecurityConstants;
import org.apache.wss4j.common.ext.WSSecurityException;
import org.example.contract.doubleit.DoubleItPortType;
@@ -93,6 +99,48 @@ public class UsernameTokenTest extends AbstractBusClientServerTestBase {
}
@org.junit.Test
+ public void testPlaintextTLSConfigViaCode() throws Exception {
+
+ URL wsdl = UsernameTokenTest.class.getResource("DoubleItUt.wsdl");
+ // URL wsdl = new URL("https://localhost:" + PORT + "/DoubleItUTPlaintext?wsdl");
+ Service service = Service.create(wsdl, SERVICE_QNAME);
+ QName portQName = new QName(NAMESPACE, "DoubleItPlaintextPort");
+ DoubleItPortType utPort =
+ service.getPort(portQName, DoubleItPortType.class);
+ updateAddressPort(utPort, test.getPort());
+
+ if (test.isStreaming()) {
+ SecurityTestUtil.enableStreaming(utPort);
+ }
+
+ ((BindingProvider)utPort).getRequestContext().put(SecurityConstants.USERNAME, "Alice");
+
+ ((BindingProvider)utPort).getRequestContext().put(SecurityConstants.CALLBACK_HANDLER,
+ "org.apache.cxf.systest.ws.common.UTPasswordCallback");
+
+ TrustManagerFactory tmf =
+ TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
+ final KeyStore ts = KeyStore.getInstance("JKS");
+ try (InputStream trustStore =
+ ClassLoaderUtils.getResourceAsStream("keys/Truststore.jks", UsernameTokenTest.class)) {
+ ts.load(trustStore, "password".toCharArray());
+ }
+ tmf.init(ts);
+
+ TLSClientParameters tlsParams = new TLSClientParameters();
+ tlsParams.setTrustManagers(tmf.getTrustManagers());
+ tlsParams.setDisableCNCheck(true);
+
+ Client client = ClientProxy.getClient(utPort);
+ HTTPConduit http = (HTTPConduit) client.getConduit();
+ http.setTlsClientParameters(tlsParams);
+
+ utPort.doubleIt(25);
+
+ ((java.io.Closeable)utPort).close();
+ }
+
+ @org.junit.Test
public void testPlaintext() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
@@ -483,4 +531,5 @@ public class UsernameTokenTest extends AbstractBusClientServerTestBase {
((java.io.Closeable)utPort).close();
bus.shutdown(true);
}
+
}
--
To stop receiving notification emails like this one, please contact
coheigea@apache.org.