Search in sources :

Example 11 with WrapThreadContextClassLoader

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);
    }
}
Also used : Bus(org.apache.cxf.Bus) ActAsServiceIface(org.jboss.test.ws.jaxws.samples.wsse.policy.trust.actas.ActAsServiceIface) QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) URL(java.net.URL) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) JBossWSTest(org.jboss.wsf.test.JBossWSTest) WrapThreadContextClassLoader(org.jboss.wsf.test.WrapThreadContextClassLoader)

Example 12 with WrapThreadContextClassLoader

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);
    }
}
Also used : Bus(org.apache.cxf.Bus) ServiceIface(org.jboss.test.ws.jaxws.samples.wsse.policy.trust.service.ServiceIface) ActAsServiceIface(org.jboss.test.ws.jaxws.samples.wsse.policy.trust.actas.ActAsServiceIface) OnBehalfOfServiceIface(org.jboss.test.ws.jaxws.samples.wsse.policy.trust.onbehalfof.OnBehalfOfServiceIface) QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) URL(java.net.URL) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) JBossWSTest(org.jboss.wsf.test.JBossWSTest) WrapThreadContextClassLoader(org.jboss.wsf.test.WrapThreadContextClassLoader)

Example 13 with WrapThreadContextClassLoader

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);
    }
}
Also used : Bus(org.apache.cxf.Bus) ServiceIface(org.jboss.test.ws.jaxws.samples.wsse.policy.trust.service.ServiceIface) ActAsServiceIface(org.jboss.test.ws.jaxws.samples.wsse.policy.trust.actas.ActAsServiceIface) OnBehalfOfServiceIface(org.jboss.test.ws.jaxws.samples.wsse.policy.trust.onbehalfof.OnBehalfOfServiceIface) QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) URL(java.net.URL) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) JBossWSTest(org.jboss.wsf.test.JBossWSTest) WrapThreadContextClassLoader(org.jboss.wsf.test.WrapThreadContextClassLoader)

Example 14 with WrapThreadContextClassLoader

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();
    }
}
Also used : Bus(org.apache.cxf.Bus) UseThreadBusFeature(org.jboss.wsf.stack.cxf.client.UseThreadBusFeature) QName(javax.xml.namespace.QName) LoggingInInterceptor(org.apache.cxf.interceptor.LoggingInInterceptor) Service(javax.xml.ws.Service) ByteArrayOutputStream(java.io.ByteArrayOutputStream) URL(java.net.URL) PrintWriter(java.io.PrintWriter) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) JBossWSTest(org.jboss.wsf.test.JBossWSTest) WrapThreadContextClassLoader(org.jboss.wsf.test.WrapThreadContextClassLoader)

Example 15 with WrapThreadContextClassLoader

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();
    }
}
Also used : Bus(org.apache.cxf.Bus) UseThreadBusFeature(org.jboss.wsf.stack.cxf.client.UseThreadBusFeature) QName(javax.xml.namespace.QName) LoggingInInterceptor(org.apache.cxf.interceptor.LoggingInInterceptor) Service(javax.xml.ws.Service) ByteArrayOutputStream(java.io.ByteArrayOutputStream) URL(java.net.URL) PrintWriter(java.io.PrintWriter) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) JBossWSTest(org.jboss.wsf.test.JBossWSTest) WrapThreadContextClassLoader(org.jboss.wsf.test.WrapThreadContextClassLoader)

Aggregations

QName (javax.xml.namespace.QName)41 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)41 JBossWSTest (org.jboss.wsf.test.JBossWSTest)41 WrapThreadContextClassLoader (org.jboss.wsf.test.WrapThreadContextClassLoader)41 Test (org.junit.Test)41 URL (java.net.URL)40 Service (javax.xml.ws.Service)39 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)15 Bus (org.apache.cxf.Bus)13 BindingProvider (javax.xml.ws.BindingProvider)6 ActAsServiceIface (org.jboss.test.ws.jaxws.samples.wsse.policy.trust.actas.ActAsServiceIface)6 OnBehalfOfServiceIface (org.jboss.test.ws.jaxws.samples.wsse.policy.trust.onbehalfof.OnBehalfOfServiceIface)6 ServiceIface (org.jboss.test.ws.jaxws.samples.wsse.policy.trust.service.ServiceIface)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 PrintWriter (java.io.PrintWriter)2 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)2 LoggingInInterceptor (org.apache.cxf.interceptor.LoggingInInterceptor)2 UseThreadBusFeature (org.jboss.wsf.stack.cxf.client.UseThreadBusFeature)2 Endpoint (javax.xml.ws.Endpoint)1 HelloResponse (org.jboss.test.ws.jaxws.samples.schemavalidation.types.HelloResponse)1