Search in sources :

Example 1 with WrapThreadContextClassLoader

use of org.jboss.as.test.integration.ws.WrapThreadContextClassLoader in project wildfly by wildfly.

the class WSTrustTestCase method testHolderOfKey.

@Test
@RunAsClient
@OperateOnDeployment(HOLDER_OF_KEY_SERVER_DEP)
@WrapThreadContextClassLoader
public void testHolderOfKey() throws Exception {
    Bus bus = BusFactory.newInstance().createBus();
    try {
        BusFactory.setThreadDefaultBus(bus);
        final QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/holderofkeywssecuritypolicy", "HolderOfKeyService");
        final URL wsdlURL = new URL("https", serviceURL.getHost(), serviceURL.getPort() - 8080 + 8444, "/jaxws-samples-wsse-policy-trust-holderofkey/HolderOfKeyService?wsdl");
        Service service = Service.create(wsdlURL, serviceName);
        HolderOfKeyIface proxy = (HolderOfKeyIface) service.getPort(HolderOfKeyIface.class);
        WSTrustTestUtils.setupWsseAndSTSClientHolderOfKey((BindingProvider) proxy, bus);
        assertEquals("Holder-Of-Key WS-Trust Hello World!", proxy.sayHello());
    } finally {
        bus.shutdown(true);
    }
}
Also used : Bus(org.apache.cxf.Bus) QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) HolderOfKeyIface(org.jboss.as.test.integration.ws.wsse.trust.holderofkey.HolderOfKeyIface) URL(java.net.URL) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) WrapThreadContextClassLoader(org.jboss.as.test.integration.ws.WrapThreadContextClassLoader)

Example 2 with WrapThreadContextClassLoader

use of org.jboss.as.test.integration.ws.WrapThreadContextClassLoader in project wildfly by wildfly.

the class WSTrustTestCase method testUsingEPR.

/**
     * WS-Trust test with the STS information coming from EPR specified in service endpoint contract policy
     *
     * @throws Exception
     */
@Test
@RunAsClient
@OperateOnDeployment(SERVER_DEP)
@WrapThreadContextClassLoader
public void testUsingEPR() 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);
        WSTrustTestUtils.setupWsse(proxy, bus);
        try {
            assertEquals("WS-Trust Hello World!", proxy.sayHello());
        } catch (Exception e) {
            throw e;
        }
    } finally {
        bus.shutdown(true);
    }
}
Also used : Bus(org.apache.cxf.Bus) ActAsServiceIface(org.jboss.as.test.integration.ws.wsse.trust.actas.ActAsServiceIface) ServiceIface(org.jboss.as.test.integration.ws.wsse.trust.service.ServiceIface) OnBehalfOfServiceIface(org.jboss.as.test.integration.ws.wsse.trust.onbehalfof.OnBehalfOfServiceIface) QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) URL(java.net.URL) IOException(java.io.IOException) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) WrapThreadContextClassLoader(org.jboss.as.test.integration.ws.WrapThreadContextClassLoader)

Example 3 with WrapThreadContextClassLoader

use of org.jboss.as.test.integration.ws.WrapThreadContextClassLoader in project wildfly by wildfly.

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) ActAsServiceIface(org.jboss.as.test.integration.ws.wsse.trust.actas.ActAsServiceIface) ServiceIface(org.jboss.as.test.integration.ws.wsse.trust.service.ServiceIface) OnBehalfOfServiceIface(org.jboss.as.test.integration.ws.wsse.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) WrapThreadContextClassLoader(org.jboss.as.test.integration.ws.WrapThreadContextClassLoader)

Example 4 with WrapThreadContextClassLoader

use of org.jboss.as.test.integration.ws.WrapThreadContextClassLoader in project wildfly by wildfly.

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(serviceURL.getHost(), String.valueOf(serviceURL.getPort())));
    } finally {
        bus.shutdown(true);
    }
}
Also used : Bus(org.apache.cxf.Bus) ActAsServiceIface(org.jboss.as.test.integration.ws.wsse.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) WrapThreadContextClassLoader(org.jboss.as.test.integration.ws.WrapThreadContextClassLoader)

Example 5 with WrapThreadContextClassLoader

use of org.jboss.as.test.integration.ws.WrapThreadContextClassLoader in project wildfly by wildfly.

the class WSTrustTestCase method testOnBehalfOf.

/**
     * Request a security token that allows it to act on behalf of somebody else.
     *
     * @throws Exception
     */
@Test
@RunAsClient
@OperateOnDeployment(ON_BEHALF_OF_SERVER_DEP)
@WrapThreadContextClassLoader
public void testOnBehalfOf() throws Exception {
    Bus bus = BusFactory.newInstance().createBus();
    try {
        BusFactory.setThreadDefaultBus(bus);
        final QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/onbehalfofwssecuritypolicy", "OnBehalfOfService");
        final URL wsdlURL = new URL(serviceURL + "OnBehalfOfService?wsdl");
        Service service = Service.create(wsdlURL, serviceName);
        OnBehalfOfServiceIface proxy = (OnBehalfOfServiceIface) service.getPort(OnBehalfOfServiceIface.class);
        WSTrustTestUtils.setupWsseAndSTSClientOnBehalfOf((BindingProvider) proxy, bus);
        assertEquals("OnBehalfOf WS-Trust Hello World!", proxy.sayHello(serviceURL.getHost(), String.valueOf(serviceURL.getPort())));
    } finally {
        bus.shutdown(true);
    }
}
Also used : Bus(org.apache.cxf.Bus) QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) OnBehalfOfServiceIface(org.jboss.as.test.integration.ws.wsse.trust.onbehalfof.OnBehalfOfServiceIface) URL(java.net.URL) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) WrapThreadContextClassLoader(org.jboss.as.test.integration.ws.WrapThreadContextClassLoader)

Aggregations

URL (java.net.URL)9 QName (javax.xml.namespace.QName)9 Service (javax.xml.ws.Service)9 Bus (org.apache.cxf.Bus)9 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)9 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)9 WrapThreadContextClassLoader (org.jboss.as.test.integration.ws.WrapThreadContextClassLoader)9 Test (org.junit.Test)9 ActAsServiceIface (org.jboss.as.test.integration.ws.wsse.trust.actas.ActAsServiceIface)6 OnBehalfOfServiceIface (org.jboss.as.test.integration.ws.wsse.trust.onbehalfof.OnBehalfOfServiceIface)6 ServiceIface (org.jboss.as.test.integration.ws.wsse.trust.service.ServiceIface)5 IOException (java.io.IOException)4 BearerIface (org.jboss.as.test.integration.ws.wsse.trust.bearer.BearerIface)1 HolderOfKeyIface (org.jboss.as.test.integration.ws.wsse.trust.holderofkey.HolderOfKeyIface)1