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/03/22 11:32:38 UTC

[cxf] branch master updated: CXF-7686 - Adding a 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 a27fb63  CXF-7686 - Adding a test
a27fb63 is described below

commit a27fb63514a483e45a838723969d76b2516deef6
Author: Colm O hEigeartaigh <co...@apache.org>
AuthorDate: Thu Mar 22 11:32:21 2018 +0000

    CXF-7686 - Adding a test
---
 .../apache/cxf/systest/ws/action/ActionTest.java   | 45 ++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/action/ActionTest.java b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/action/ActionTest.java
index 7e69c45..ed56cc4 100644
--- a/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/action/ActionTest.java
+++ b/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/action/ActionTest.java
@@ -21,8 +21,10 @@ package org.apache.cxf.systest.ws.action;
 
 import java.io.StringReader;
 import java.net.URL;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Properties;
 
 import javax.xml.namespace.QName;
 import javax.xml.transform.stream.StreamSource;
@@ -43,8 +45,13 @@ import org.apache.cxf.systest.ws.common.SecurityTestUtil;
 import org.apache.cxf.systest.ws.ut.SecurityHeaderCacheInterceptor;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor;
+import org.apache.cxf.ws.security.wss4j.WSS4JStaxOutInterceptor;
 import org.apache.wss4j.common.ConfigurationConstants;
+import org.apache.wss4j.common.crypto.CryptoFactory;
 import org.apache.wss4j.common.ext.WSSecurityException;
+import org.apache.wss4j.stax.ext.WSSConstants;
+import org.apache.wss4j.stax.ext.WSSSecurityProperties;
+import org.apache.wss4j.stax.securityToken.WSSecurityTokenConstants;
 import org.example.contract.doubleit.DoubleItPortType;
 
 import org.junit.BeforeClass;
@@ -489,6 +496,44 @@ public class ActionTest extends AbstractBusClientServerTestBase {
     }
 
     @org.junit.Test
+    public void testSignatureProgrammaticStAX() throws Exception {
+
+        SpringBusFactory bf = new SpringBusFactory();
+        URL busFile = ActionTest.class.getResource("client.xml");
+
+        Bus bus = bf.createBus(busFile.toString());
+        BusFactory.setDefaultBus(bus);
+        BusFactory.setThreadDefaultBus(bus);
+
+        URL wsdl = ActionTest.class.getResource("DoubleItAction.wsdl");
+        Service service = Service.create(wsdl, SERVICE_QNAME);
+        QName portQName = new QName(NAMESPACE, "DoubleItSignatureConfigPort");
+
+        DoubleItPortType port =
+                service.getPort(portQName, DoubleItPortType.class);
+        updateAddressPort(port, PORT);
+
+        // Programmatic interceptor
+        WSSSecurityProperties properties = new WSSSecurityProperties();
+        properties.setActions(Collections.singletonList(WSSConstants.SIGNATURE));
+        properties.setSignatureUser("alice");
+        properties.setCallbackHandler(new KeystorePasswordCallback());
+        properties.setSignatureKeyIdentifier(WSSecurityTokenConstants.KEYIDENTIFIER_SECURITY_TOKEN_DIRECT_REFERENCE);
+        Properties sigProperties =
+            CryptoFactory.getProperties("alice.properties", this.getClass().getClassLoader());
+        properties.setSignatureCryptoProperties(sigProperties);
+
+        WSS4JStaxOutInterceptor outInterceptor = new WSS4JStaxOutInterceptor(properties);
+        Client client = ClientProxy.getClient(port);
+        client.getOutInterceptors().add(outInterceptor);
+
+        assertEquals(50, port.doubleIt(25));
+
+        ((java.io.Closeable)port).close();
+        bus.shutdown(true);
+    }
+
+    @org.junit.Test
     public void testSignatureDispatchPayload() throws Exception {
 
         SpringBusFactory bf = new SpringBusFactory();

-- 
To stop receiving notification emails like this one, please contact
coheigea@apache.org.