Author: jim.ma
Date: 2014-06-03 06:16:17 -0400 (Tue, 03 Jun 2014)
New Revision: 18711
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/oasis/WSSecurityPolicyExamples21xTestCase.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/oasis/WSSecurityPolicyExamples22xTestCase.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/secconv/SecureConversationTestCase.java
Log:
[JBWS-3789]:Enable WS-Security streaming (StAX) support for some tests
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/oasis/WSSecurityPolicyExamples21xTestCase.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/oasis/WSSecurityPolicyExamples21xTestCase.java 2014-06-03
09:12:40 UTC (rev 18710)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/oasis/WSSecurityPolicyExamples21xTestCase.java 2014-06-03
10:16:17 UTC (rev 18711)
@@ -78,7 +78,7 @@
{
Service service = Service.create(new URL(serviceURL +
"SecurityService2111?wsdl"), serviceName);
ServiceIface proxy = (ServiceIface)service.getPort(new QName(NS,
"SecurityService2111Port"), ServiceIface.class);
- setupWsse(proxy);
+ setupWsse(proxy, true);
assertTrue(proxy.sayHello().equals("Hello - UsernameToken with plain text
password"));
}
@@ -91,7 +91,7 @@
{
Service service = Service.create(new URL(serviceURL +
"SecurityService2112?wsdl"), serviceName);
ServiceIface proxy = (ServiceIface)service.getPort(new QName(NS,
"SecurityService2112Port"), ServiceIface.class);
- setupWsse(proxy);
+ setupWsse(proxy, false);
assertTrue(proxy.sayHello().equals("Hello - UsernameToken without
password"));
}
@@ -104,7 +104,7 @@
{
Service service = Service.create(new URL(serviceURL +
"SecurityService2113?wsdl"), serviceName);
ServiceIface proxy = (ServiceIface)service.getPort(new QName(NS,
"SecurityService2113Port"), ServiceIface.class);
- setupWsse(proxy);
+ setupWsse(proxy, true);
assertTrue(proxy.sayHello().equals("Hello - UsernameToken with timestamp,
nonce and password hash"));
}
@@ -117,7 +117,7 @@
{
Service service = Service.create(new URL(serviceURLHttps +
"SecurityService2121?wsdl"), serviceName);
ServiceIface proxy = (ServiceIface)service.getPort(new QName(NS,
"SecurityService2121Port"), ServiceIface.class);
- setupWsse(proxy);
+ setupWsse(proxy, false);
assertTrue(proxy.sayHello().equals("Hello - UsernameToken as supporting
token"));
}
@@ -130,7 +130,7 @@
{
Service service = Service.create(new URL(serviceURL +
"SecurityService213?wsdl"), serviceName);
ServiceIface proxy = (ServiceIface)service.getPort(new QName(NS,
"SecurityService213Port"), ServiceIface.class);
- setupWsse(proxy);
+ setupWsse(proxy, true);
assertTrue(proxy.sayHello().equals("Hello - (WSS 1.0) UsernameToken with
Mutual X.509v3 Authentication, Sign, Encrypt"));
}
@@ -143,11 +143,11 @@
{
Service service = Service.create(new URL(serviceURL +
"SecurityService214?wsdl"), serviceName);
ServiceIface proxy = (ServiceIface)service.getPort(new QName(NS,
"SecurityService214Port"), ServiceIface.class);
- setupWsse(proxy);
+ setupWsse(proxy, false);
assertTrue(proxy.sayHello().equals("Hello - (WSS 1.1) User Name with
Certificates, Sign, Encrypt"));
}
- private void setupWsse(ServiceIface proxy)
+ private void setupWsse(ServiceIface proxy, boolean streaming)
{
((BindingProvider)proxy).getRequestContext().put(SecurityConstants.USERNAME,
"kermit");
((BindingProvider)proxy).getRequestContext().put(SecurityConstants.CALLBACK_HANDLER, new
UsernamePasswordCallback());
@@ -155,5 +155,10 @@
((BindingProvider)proxy).getRequestContext().put(SecurityConstants.ENCRYPT_PROPERTIES,
Thread.currentThread().getContextClassLoader().getResource("META-INF/alice.properties"));
((BindingProvider)proxy).getRequestContext().put(SecurityConstants.SIGNATURE_USERNAME,
"alice");
((BindingProvider)proxy).getRequestContext().put(SecurityConstants.ENCRYPT_USERNAME,
"bob");
+ if (streaming)
+ {
+
((BindingProvider)proxy).getRequestContext().put(SecurityConstants.ENABLE_STREAMING_SECURITY,
"true");
+
((BindingProvider)proxy).getResponseContext().put(SecurityConstants.ENABLE_STREAMING_SECURITY,
"true");
+ }
}
}
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/oasis/WSSecurityPolicyExamples22xTestCase.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/oasis/WSSecurityPolicyExamples22xTestCase.java 2014-06-03
09:12:40 UTC (rev 18710)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/oasis/WSSecurityPolicyExamples22xTestCase.java 2014-06-03
10:16:17 UTC (rev 18711)
@@ -68,7 +68,7 @@
{
Service service = Service.create(new URL(serviceURL +
"SecurityService221?wsdl"), serviceName);
ServiceIface proxy = (ServiceIface)service.getPort(new QName(NS,
"SecurityService221Port"), ServiceIface.class);
- setupWsse(proxy);
+ setupWsse(proxy, true);
try {
assertTrue(proxy.sayHello().equals("Hello - (WSS1.0) X.509 Certificates,
Sign, Encrypt"));
} catch (Exception e) {
@@ -90,7 +90,7 @@
{
Service service = Service.create(new URL(serviceURL +
"SecurityService222?wsdl"), serviceName);
ServiceIface proxy = (ServiceIface)service.getPort(new QName(NS,
"SecurityService222Port"), ServiceIface.class);
- setupWsse(proxy);
+ setupWsse(proxy, true);
try {
assertTrue(proxy.sayHello().equals("Hello - (WSS1.0) Mutual Authentication
with X.509 Certificates, Sign, Encrypt"));
} catch (Exception e) {
@@ -112,7 +112,7 @@
{
Service service = Service.create(new URL(serviceURL +
"SecurityService223?wsdl"), serviceName);
ServiceIface proxy = (ServiceIface)service.getPort(new QName(NS,
"SecurityService223Port"), ServiceIface.class);
- setupWsse(proxy);
+ setupWsse(proxy, true);
try {
assertTrue(proxy.sayHello().equals("Hello - (WSS1.1) Anonymous with X.509
Certificates, Sign, Encrypt"));
} catch (Exception e) {
@@ -134,7 +134,7 @@
{
Service service = Service.create(new URL(serviceURL +
"SecurityService224?wsdl"), serviceName);
ServiceIface proxy = (ServiceIface)service.getPort(new QName(NS,
"SecurityService224Port"), ServiceIface.class);
- setupWsse(proxy);
+ setupWsse(proxy, false);
try {
assertTrue(proxy.sayHello().equals("Hello - (WSS1.1) Mutual Authentication
with X.509 Certificates, Sign, Encrypt"));
} catch (Exception e) {
@@ -142,12 +142,17 @@
}
}
- private void setupWsse(ServiceIface proxy)
+ private void setupWsse(ServiceIface proxy, boolean streaming)
{
((BindingProvider)proxy).getRequestContext().put(SecurityConstants.CALLBACK_HANDLER, new
KeystorePasswordCallback());
((BindingProvider)proxy).getRequestContext().put(SecurityConstants.SIGNATURE_PROPERTIES,
Thread.currentThread().getContextClassLoader().getResource("META-INF/alice.properties"));
((BindingProvider)proxy).getRequestContext().put(SecurityConstants.ENCRYPT_PROPERTIES,
Thread.currentThread().getContextClassLoader().getResource("META-INF/alice.properties"));
((BindingProvider)proxy).getRequestContext().put(SecurityConstants.SIGNATURE_USERNAME,
"alice");
((BindingProvider)proxy).getRequestContext().put(SecurityConstants.ENCRYPT_USERNAME,
"bob");
+ if (streaming)
+ {
+
((BindingProvider)proxy).getRequestContext().put(SecurityConstants.ENABLE_STREAMING_SECURITY,
"true");
+
((BindingProvider)proxy).getResponseContext().put(SecurityConstants.ENABLE_STREAMING_SECURITY,
"true");
+ }
}
}
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/secconv/SecureConversationTestCase.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/secconv/SecureConversationTestCase.java 2014-06-03
09:12:40 UTC (rev 18710)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/secconv/SecureConversationTestCase.java 2014-06-03
10:16:17 UTC (rev 18711)
@@ -29,6 +29,7 @@
import junit.framework.Test;
+import org.apache.cxf.ws.security.SecurityConstants;
import org.jboss.test.ws.jaxws.samples.wsse.policy.basic.KeystorePasswordCallback;
import org.jboss.wsf.test.JBossWSCXFTestSetup;
import org.jboss.wsf.test.JBossWSTest;
@@ -59,17 +60,22 @@
URL wsdlURL = new URL(serviceURL + "?wsdl");
Service service = Service.create(wsdlURL, serviceName);
ServiceIface proxy = (ServiceIface)service.getPort(ServiceIface.class);
- setupWsse(proxy);
+ setupWsse(proxy, true);
assertTrue(proxy.sayHello().startsWith("Secure Conversation Hello
World!"));
assertTrue(proxy.sayHello().startsWith("Secure Conversation Hello
World!"));
}
- private void setupWsse(ServiceIface proxy)
+ private void setupWsse(ServiceIface proxy, boolean streaming)
{
((BindingProvider)proxy).getRequestContext().put("ws-security.callback-handler.sct",
new KeystorePasswordCallback());
((BindingProvider)proxy).getRequestContext().put("ws-security.signature.properties.sct",
Thread.currentThread().getContextClassLoader().getResource("META-INF/alice.properties"));
((BindingProvider)proxy).getRequestContext().put("ws-security.encryption.properties.sct",
Thread.currentThread().getContextClassLoader().getResource("META-INF/alice.properties"));
((BindingProvider)proxy).getRequestContext().put("ws-security.signature.username.sct",
"alice");
((BindingProvider)proxy).getRequestContext().put("ws-security.encryption.username.sct",
"bob");
+ if (streaming)
+ {
+
((BindingProvider)proxy).getRequestContext().put(SecurityConstants.ENABLE_STREAMING_SECURITY,
"true");
+
((BindingProvider)proxy).getResponseContext().put(SecurityConstants.ENABLE_STREAMING_SECURITY,
"true");
+ }
}
}