use of org.jboss.wsf.test.WrapThreadContextClassLoader in project jbossws-cxf by jbossws.
the class WSTrustTestCase method testActAs.
/**
* Request a security token that allows it to act as if it were somebody else.
*
* @throws Exception
*/
@Test
@RunAsClient
@OperateOnDeployment(ACT_AS_SERVER_DEP)
@WrapThreadContextClassLoader
public void testActAs() throws Exception {
Bus bus = BusFactory.newInstance().createBus();
try {
BusFactory.setThreadDefaultBus(bus);
final QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/actaswssecuritypolicy", "ActAsService");
final URL wsdlURL = new URL(serviceURL + "ActAsService?wsdl");
Service service = Service.create(wsdlURL, serviceName);
ActAsServiceIface proxy = (ActAsServiceIface) service.getPort(ActAsServiceIface.class);
WSTrustTestUtils.setupWsseAndSTSClientActAs((BindingProvider) proxy, bus);
assertEquals("ActAs WS-Trust Hello World!", proxy.sayHello(getServerHost(), String.valueOf(getServerPort())));
} finally {
bus.shutdown(true);
}
}
use of org.jboss.wsf.test.WrapThreadContextClassLoader in project jbossws-cxf by jbossws.
the class WSTrustTestCase method testPicketLink.
@Test
@RunAsClient
@OperateOnDeployment(SERVER_DEP)
@WrapThreadContextClassLoader
public void testPicketLink() throws Exception {
Bus bus = BusFactory.newInstance().createBus();
try {
BusFactory.setThreadDefaultBus(bus);
final QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy", "SecurityService");
final URL wsdlURL = new URL(serviceURL + "SecurityService?wsdl");
Service service = Service.create(wsdlURL, serviceName);
ServiceIface proxy = (ServiceIface) service.getPort(ServiceIface.class);
final QName stsServiceName = new QName("urn:picketlink:identity-federation:sts", "PicketLinkSTS");
final QName stsPortName = new QName("urn:picketlink:identity-federation:sts", "PicketLinkSTSPort");
final URL stsURL = new URL(serviceURL.getProtocol(), serviceURL.getHost(), serviceURL.getPort(), "/jaxws-samples-wsse-policy-trustPicketLink-sts/PicketLinkSTS?wsdl");
WSTrustTestUtils.setupWsseAndSTSClient(proxy, bus, stsURL.toString(), stsServiceName, stsPortName);
try {
assertEquals("WS-Trust Hello World!", proxy.sayHello());
} catch (Exception e) {
throw CryptoCheckHelper.checkAndWrapException(e);
}
} finally {
bus.shutdown(true);
}
}
use of org.jboss.wsf.test.WrapThreadContextClassLoader in project jbossws-cxf by jbossws.
the class WSTrustTestCase method testNoClientCallback.
/**
* No CallbackHandler is provided in STSCLient. Username and password provided instead.
*
* @throws Exception
*/
@Test
@RunAsClient
@OperateOnDeployment(SERVER_DEP)
@WrapThreadContextClassLoader
public void testNoClientCallback() throws Exception {
Bus bus = BusFactory.newInstance().createBus();
try {
BusFactory.setThreadDefaultBus(bus);
final QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy", "SecurityService");
final URL wsdlURL = new URL(serviceURL + "SecurityService?wsdl");
Service service = Service.create(wsdlURL, serviceName);
ServiceIface proxy = (ServiceIface) service.getPort(ServiceIface.class);
final QName stsServiceName = new QName("http://docs.oasis-open.org/ws-sx/ws-trust/200512/", "SecurityTokenService");
final QName stsPortName = new QName("http://docs.oasis-open.org/ws-sx/ws-trust/200512/", "UT_Port");
URL stsURL = new URL(serviceURL.getProtocol(), serviceURL.getHost(), serviceURL.getPort(), "/jaxws-samples-wsse-policy-trust-sts/SecurityTokenService?wsdl");
WSTrustTestUtils.setupWsseAndSTSClientNoCallbackHandler(proxy, bus, stsURL.toString(), stsServiceName, stsPortName);
assertEquals("WS-Trust Hello World!", proxy.sayHello());
} finally {
bus.shutdown(true);
}
}
use of org.jboss.wsf.test.WrapThreadContextClassLoader in project jbossws-cxf by jbossws.
the class PolicyAttachmentTestCase method testEndpointWithCustomWSSEAndWSA.
@Test
@RunAsClient
@WrapThreadContextClassLoader
public void testEndpointWithCustomWSSEAndWSA() throws Exception {
Bus bus = BusFactory.newInstance().createBus();
BusFactory.setThreadDefaultBus(bus);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
PrintWriter pw = new PrintWriter(bos);
try {
bus.getInInterceptors().add(new LoggingInInterceptor(pw));
URL wsdlURL = new URL(baseURL + "/ServiceFour?wsdl");
QName serviceName = new QName("http://org.jboss.ws.jaxws.cxf/jbws3648", "ServiceFour");
Service service = Service.create(wsdlURL, serviceName, new UseThreadBusFeature());
EndpointFour proxy = (EndpointFour) service.getPort(EndpointFour.class);
setupWsse((BindingProvider) proxy);
try {
assertEquals("Foo4", proxy.echo("Foo4"));
} catch (Exception e) {
throw CryptoCheckHelper.checkAndWrapException(e);
}
final String m = bos.toString();
assertTrue("WS-Addressing was not enabled!", m.contains("http://www.w3.org/2005/08/addressing") && m.contains("http://www.w3.org/2005/08/addressing/anonymous"));
assertTrue("WS-Security was not enabled!", m.contains("http://www.w3.org/2001/04/xmlenc#rsa-1_5") && m.contains("http://www.w3.org/2001/04/xmlenc#aes256-cbc"));
} finally {
bus.shutdown(true);
pw.close();
bos.close();
}
}
use of org.jboss.wsf.test.WrapThreadContextClassLoader in project jbossws-cxf by jbossws.
the class PolicyAttachmentTestCase method testEndpointWithWSSEAndWSA.
@Test
@RunAsClient
@WrapThreadContextClassLoader
public void testEndpointWithWSSEAndWSA() throws Exception {
Bus bus = BusFactory.newInstance().createBus();
BusFactory.setThreadDefaultBus(bus);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
PrintWriter pw = new PrintWriter(bos);
try {
bus.getInInterceptors().add(new LoggingInInterceptor(pw));
URL wsdlURL = new URL(baseURL + "/ServiceThree?wsdl");
QName serviceName = new QName("http://org.jboss.ws.jaxws.cxf/jbws3648", "ServiceThree");
Service service = Service.create(wsdlURL, serviceName, new UseThreadBusFeature());
EndpointThree proxy = (EndpointThree) service.getPort(EndpointThree.class);
setupWsse((BindingProvider) proxy);
assertEquals("Foo3", proxy.echo("Foo3"));
final String m = bos.toString();
assertTrue("WS-Addressing was not enabled!", m.contains("http://www.w3.org/2005/08/addressing") && m.contains("http://www.w3.org/2005/08/addressing/anonymous"));
assertTrue("WS-Security was not enabled!", m.contains("http://www.w3.org/2001/04/xmlenc#rsa-1_5") && m.contains("http://www.w3.org/2001/04/xmlenc#tripledes-cbc"));
} finally {
bus.shutdown(true);
pw.close();
bos.close();
}
}
Aggregations