Author: rsearls
Date: 2014-01-30 17:44:04 -0500 (Thu, 30 Jan 2014)
New Revision: 18298
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-samples-jars-jaxws.xml
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/trust/ActAsCallbackHandler.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/trust/ActAsOutInterceptor.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/trust/ActAsServiceImpl.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/trust/ServiceImpl.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/trust/WSTrustActAsTestCase.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/trust/WSTrustTestUtils.java
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/trust/WEB-INF/jbossws-roles.properties
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/trust/WEB-INF/jbossws-users.properties
Log:
[JBWS-3738] Working ActAs test.
Modified: stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-samples-jars-jaxws.xml
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-samples-jars-jaxws.xml 2014-01-30
17:50:25 UTC (rev 18297)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/scripts/cxf-samples-jars-jaxws.xml 2014-01-30
22:44:04 UTC (rev 18298)
@@ -475,15 +475,11 @@
needxmlfile='false'>
<classes dir="${tests.output.dir}/test-classes">
<include
-
name="org/jboss/test/ws/jaxws/samples/wsse/policy/trust/ActAsServiceIface.class"/>
+
name="org/jboss/test/ws/jaxws/samples/wsse/policy/trust/ActAs*.class"/>
<include
-
name="org/jboss/test/ws/jaxws/samples/wsse/policy/trust/ActAsServiceImpl.class"/>
- <include
-
name="org/jboss/test/ws/jaxws/samples/wsse/policy/trust/ActAsOutInterceptor.class"/>
- <include
name="org/jboss/test/ws/jaxws/samples/wsse/policy/jaxws/Say*.class"/>
<include
-
name="org/jboss/test/ws/jaxws/samples/wsse/policy/trust/ActAsCallbackHandler.class"/>
+
name="org/jboss/test/ws/jaxws/samples/wsse/policy/trust/ServiceIface.class"/>
</classes>
<webinf
dir="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/trust/WEB-INF">
@@ -495,9 +491,15 @@
<include name="actasstore.jks"/>
<include name="actasKeystore.properties"/>
</zipfileset>
+ <zipfileset
+
dir="${tests.output.dir}/test-resources/jaxws/samples/wsse/policy/trust/META-INF"
+ prefix="META-INF">
+ <include name="clientstore.jks"/>
+ <include name="clientKeystore.properties"/>
+ </zipfileset>
<manifest>
<attribute name="Dependencies"
- value="org.jboss.ws.cxf.jbossws-cxf-client"/>
+ value="org.jboss.ws.cxf.jbossws-cxf-client,
org.apache.cxf.impl"/>
</manifest>
</war>
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/trust/ActAsCallbackHandler.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/trust/ActAsCallbackHandler.java 2014-01-30
17:50:25 UTC (rev 18297)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/trust/ActAsCallbackHandler.java 2014-01-30
22:44:04 UTC (rev 18298)
@@ -37,7 +37,7 @@
{
Map<String, String> passwords = new HashMap<String, String>();
passwords.put("myactaskey", "aspass");
- passwords.put("alice", "aspass");
+ passwords.put("alice", "clarinet");
return passwords;
}
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/trust/ActAsOutInterceptor.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/trust/ActAsOutInterceptor.java 2014-01-30
17:50:25 UTC (rev 18297)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/trust/ActAsOutInterceptor.java 2014-01-30
22:44:04 UTC (rev 18298)
@@ -27,6 +27,9 @@
import org.apache.cxf.message.Message;
import org.apache.cxf.interceptor.Fault;
+import java.util.ArrayList;
+import java.util.Set;
+
/**
* User: rsearls(a)redhat.com
* Date: 1/26/14
@@ -34,14 +37,13 @@
public class ActAsOutInterceptor extends AbstractPhaseInterceptor<Message> {
public ActAsOutInterceptor () {
- // This can be in any stage before the WS-SP interceptors
- // setup the STS client and issued token interceptor.
super(Phase.SETUP);
}
@Override
public void handleMessage(Message message) throws Fault {
- String tmpStr = "<wst:ActAs
xmlns:wst=\"http://docs.oasis-open.org/ws-sx/ws-trust/200512\"&...;
+
+ String tmpStr = "<wst:ActAs
xmlns:wst=\"http://docs.oasis-open.org/ws-sx/ws-trust/200512\"&...;
message.put(SecurityConstants.STS_TOKEN_ACT_AS, tmpStr);
}
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/trust/ActAsServiceImpl.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/trust/ActAsServiceImpl.java 2014-01-30
17:50:25 UTC (rev 18297)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/trust/ActAsServiceImpl.java 2014-01-30
22:44:04 UTC (rev 18298)
@@ -21,11 +21,23 @@
*/
package org.jboss.test.ws.jaxws.samples.wsse.policy.trust;
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
import org.apache.cxf.annotations.EndpointProperties;
import org.apache.cxf.annotations.EndpointProperty;
-import org.apache.cxf.interceptor.InInterceptors;
+import org.apache.cxf.interceptor.OutInterceptors;
+import org.apache.cxf.ws.security.SecurityConstants;
+import org.apache.cxf.ws.security.trust.STSClient;
import javax.jws.WebService;
+import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Service;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.*;
+import java.util.Map;
/**
* User: rsearls(a)redhat.com
@@ -47,11 +59,98 @@
@EndpointProperty(key = "ws-security.encryption.properties", value =
"actasKeystore.properties"),
@EndpointProperty(key = "ws-security.callback-handler", value =
"org.jboss.test.ws.jaxws.samples.wsse.policy.trust.ActAsCallbackHandler")
})
-//---@InInterceptors(interceptors =
{"org.jboss.test.ws.jaxws.samples.wsse.policy.trust.ActAsOutInterceptor"})
+@OutInterceptors(interceptors =
{"org.jboss.test.ws.jaxws.samples.wsse.policy.trust.ActAsOutInterceptor"})
public class ActAsServiceImpl implements ActAsServiceIface
{
- public String sayHello()
+ public String sayHello() {
+ try {
+ ServiceIface proxy = setupService();
+ return "ActAs " + proxy.sayHello();
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ private ServiceIface setupService()throws MalformedURLException {
+ ServiceIface proxy = null;
+ Bus bus = BusFactory.newInstance().createBus();
+
+ try {
+ BusFactory.setThreadDefaultBus(bus);
+
+ final String serviceURL = "http://" + getServerHost() +
":8080/jaxws-samples-wsse-policy-trust/SecurityService";
+ final QName serviceName = new
QName("http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy",
"SecurityService");
+ final URL wsdlURL = new URL(serviceURL + "?wsdl");
+ Service service = Service.create(wsdlURL, serviceName);
+ proxy = (ServiceIface) service.getPort(ServiceIface.class);
+
+ Map<String, Object> ctx = ((BindingProvider) proxy).getRequestContext();
+ ctx.put(SecurityConstants.CALLBACK_HANDLER, new ActAsCallbackHandler());
+
+
+ ctx.put(SecurityConstants.SIGNATURE_PROPERTIES,
+
Thread.currentThread().getContextClassLoader().getResource("actasKeystore.properties"
));
+ ctx.put(SecurityConstants.SIGNATURE_USERNAME, "myactaskey" );
+ ctx.put(SecurityConstants.ENCRYPT_PROPERTIES,
+
Thread.currentThread().getContextClassLoader().getResource("../../META-INF/clientKeystore.properties"
));
+ ctx.put(SecurityConstants.ENCRYPT_USERNAME, "myservicekey");
+
+
+ STSClient stsClient = new STSClient(bus);
+ Map<String, Object> props = stsClient.getProperties();
+ props.put(SecurityConstants.USERNAME, "alice");
+ //- these are not needed. They are provided by the above (ctx) map.
+ // props.put(SecurityConstants.CALLBACK_HANDLER, new ActAsCallbackHandler());
+ // props.put(SecurityConstants.ENCRYPT_PROPERTIES,
+ //
Thread.currentThread().getContextClassLoader().getResource("../../META-INF/clientKeystore.properties"
));
+ props.put(SecurityConstants.ENCRYPT_USERNAME, "mystskey");
+ props.put(SecurityConstants.STS_TOKEN_USERNAME, "myactaskey" );
+ props.put(SecurityConstants.STS_TOKEN_PROPERTIES,
+
Thread.currentThread().getContextClassLoader().getResource("actasKeystore.properties"
));
+ props.put(SecurityConstants.STS_TOKEN_USE_CERT_FOR_KEYINFO, "true");
+
+ ctx.put(SecurityConstants.STS_CLIENT, stsClient);
+
+ } finally {
+ bus.shutdown(true);
+ }
+
+ return proxy;
+ }
+
+ private String getServerHost()
{
- return "ActAs WS-Trust Hello World!";
+ final String host = System.getProperty("jboss.bind.address",
"localhost");
+ return toIPv6URLFormat(host);
}
+
+ private String toIPv6URLFormat(final String host)
+ {
+ try
+ {
+ if (host.startsWith(":"))
+ {
+ throw new IllegalArgumentException("JBossWS test suite requires IPv6
addresses to be wrapped with [] brackets. Expected format is: [" + host +
"]");
+ }
+ if (host.startsWith("["))
+ {
+ if (System.getProperty("java.net.preferIPv4Stack") == null)
+ {
+ throw new IllegalStateException("always provide
java.net.preferIPv4Stack JVM property when using IPv6 address format");
+ }
+ if (System.getProperty("java.net.preferIPv6Addresses") == null)
+ {
+ throw new IllegalStateException("always provide
java.net.preferIPv6Addresses JVM property when using IPv6 address format");
+ }
+ }
+ final boolean isIPv6Address = InetAddress.getByName(host) instanceof
Inet6Address;
+ final boolean isIPv6Formatted = isIPv6Address &&
host.startsWith("[");
+ return isIPv6Address && !isIPv6Formatted ? "[" + host +
"]" : host;
+ }
+ catch (final UnknownHostException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
}
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/trust/ServiceImpl.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/trust/ServiceImpl.java 2014-01-30
17:50:25 UTC (rev 18297)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/trust/ServiceImpl.java 2014-01-30
22:44:04 UTC (rev 18298)
@@ -25,6 +25,7 @@
import org.apache.cxf.annotations.EndpointProperties;
import org.apache.cxf.annotations.EndpointProperty;
+import org.apache.cxf.interceptor.InInterceptors;
@WebService
(
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/trust/WSTrustActAsTestCase.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/trust/WSTrustActAsTestCase.java 2014-01-30
17:50:25 UTC (rev 18297)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/trust/WSTrustActAsTestCase.java 2014-01-30
22:44:04 UTC (rev 18298)
@@ -74,7 +74,6 @@
WSTrustTestUtils.setupWsseAndSTSClientActAs((BindingProvider) proxy, bus);
assertEquals("ActAs WS-Trust Hello World!", proxy.sayHello());
-
}
finally
{
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/trust/WSTrustTestUtils.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/trust/WSTrustTestUtils.java 2014-01-30
17:50:25 UTC (rev 18297)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/samples/wsse/policy/trust/WSTrustTestUtils.java 2014-01-30
22:44:04 UTC (rev 18298)
@@ -21,6 +21,8 @@
*/
package org.jboss.test.ws.jaxws.samples.wsse.policy.trust;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
@@ -145,7 +147,7 @@
STSClient stsClient = new STSClient(bus);
Map<String, Object> props = stsClient.getProperties();
- props.put(SecurityConstants.USERNAME, "alice");
+ props.put(SecurityConstants.USERNAME, "bob" /*"alice"*/);
props.put(SecurityConstants.CALLBACK_HANDLER, new ClientCallbackHandler());
props.put(SecurityConstants.ENCRYPT_PROPERTIES,
Thread.currentThread().getContextClassLoader().getResource("META-INF/clientKeystore.properties"));
props.put(SecurityConstants.ENCRYPT_USERNAME, "mystskey");
@@ -156,6 +158,7 @@
ctx.put(SecurityConstants.STS_CLIENT, stsClient);
}
+
private static String appendIssuedTokenSuffix(String prop)
{
return prop + ".it";
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/trust/WEB-INF/jbossws-roles.properties
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/trust/WEB-INF/jbossws-roles.properties 2014-01-30
17:50:25 UTC (rev 18297)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/trust/WEB-INF/jbossws-roles.properties 2014-01-30
22:44:04 UTC (rev 18298)
@@ -1,2 +1,3 @@
# A sample roles.properties file for use with the UsersRolesLoginModule
-alice=friend
\ No newline at end of file
+alice=friend
+bob=friend
\ No newline at end of file
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/trust/WEB-INF/jbossws-users.properties
===================================================================
---
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/trust/WEB-INF/jbossws-users.properties 2014-01-30
17:50:25 UTC (rev 18297)
+++
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/resources/jaxws/samples/wsse/policy/trust/WEB-INF/jbossws-users.properties 2014-01-30
22:44:04 UTC (rev 18298)
@@ -1,2 +1,3 @@
# A sample users.properties file for use with the UsersRolesLoginModule
alice=clarinet
+bob=trombone