Example usage for javax.xml.ws Service create

List of usage examples for javax.xml.ws Service create

Introduction

In this page you can find the example usage for javax.xml.ws Service create.

Prototype

public static Service create(QName serviceName, WebServiceFeature... features) 

Source Link

Document

Creates a Service instance.

Usage

From source file:org.jboss.as.test.integration.ws.wsse.trust.WSBearerElytronSecurityPropagationTestCase.java

@Test
@RunAsClient//from   w w w. j a v  a2s  . co m
@OperateOnDeployment(BEARER_SERVER_DEP)
@WrapThreadContextClassLoader
public void testBearer() throws Exception {
    // TLSv1.2 seems buggy on JDK-11 (Invalid ECDH ServerKeyExchange signature)
    String originalProtocols = System.getProperty("https.protocols");
    System.setProperty("https.protocols", "TLSv1.1");

    Bus bus = BusFactory.newInstance().createBus();
    try {
        BusFactory.setThreadDefaultBus(bus);

        final QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/bearerwssecuritypolicy",
                "BearerService");
        Service service = Service.create(new URL(serviceURL + "BearerService?wsdl"), serviceName);
        BearerIface proxy = (BearerIface) service.getPort(BearerIface.class);

        WSTrustTestUtils.setupWsseAndSTSClientBearer((BindingProvider) proxy, bus);
        assertEquals("alice&alice", proxy.sayHello());

    } finally {
        bus.shutdown(true);
        if (originalProtocols == null) {
            System.clearProperty("https.protocols");
        } else {
            System.setProperty("https.protocols", originalProtocols);
        }
    }
}

From source file:org.jboss.as.test.integration.ws.wsse.trust.WSTrustTestCase.java

/**
 * WS-Trust test with the STS information programmatically provided
 *
 * @throws Exception//  ww w. j a v a 2  s.  co m
 */

@Test
@RunAsClient
@OperateOnDeployment(SERVER_DEP)
@WrapThreadContextClassLoader
public void test() 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.setupWsseAndSTSClient(proxy, bus, stsURL.toString(), stsServiceName, stsPortName);

        try {
            assertEquals("WS-Trust Hello World!", proxy.sayHello());
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
    } finally {
        bus.shutdown(true);
    }
}

From source file:org.jboss.as.test.integration.ws.wsse.trust.WSTrustTestCase.java

/**
 * WS-Trust test with the STS information coming from EPR specified in service endpoint contract policy
 *
 * @throws Exception// w w w  . java2s.  c  o m
 */
@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);
    }
}

From source file:org.jboss.as.test.integration.ws.wsse.trust.WSTrustTestCase.java

/**
 * No CallbackHandler is provided in STSCLient.  Username and password provided instead.
 *
 * @throws Exception//from   ww  w  . j a v  a 2  s  . co m
 */
@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);
    }
}

From source file:org.jboss.as.test.integration.ws.wsse.trust.WSTrustTestCase.java

/**
 * No SIGNATURE_USERNAME is provided to the service.  Service will use the
 * client's keystore alias in its place.
 *
 * @throws Exception/* w  w w  .  ja  v  a 2  s  .c om*/
 */
@Test
@RunAsClient
@OperateOnDeployment(SERVER_DEP)
@WrapThreadContextClassLoader
public void testNoSignatureUsername() 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.setupWsseAndSTSClientNoSignatureUsername(proxy, bus, stsURL.toString(), stsServiceName,
                stsPortName);

        assertEquals("WS-Trust Hello World!", proxy.sayHello());
    } finally {
        bus.shutdown(true);
    }
}

From source file:org.jboss.as.test.integration.ws.wsse.trust.WSTrustTestCase.java

/**
 * Request a security token that allows it to act as if it were somebody else.
 *
 * @throws Exception/* w  ww . ja va 2  s  . c o m*/
 */
@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);
    }
}

From source file:org.jboss.as.test.integration.ws.wsse.trust.WSTrustTestCase.java

/**
 * Request a security token that allows it to act on behalf of somebody else.
 *
 * @throws Exception/*ww  w. j a  va2s  .  c o  m*/
 */
@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);
    }
}

From source file:org.jboss.as.test.integration.ws.wsse.trust.WSTrustTestCase.java

@Test
@RunAsClient//from   w  ww  .  j  a v a 2s. com
@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);
    }
}

From source file:org.jboss.as.test.integration.ws.wsse.trust.WSTrustTestCase.java

@Test
@RunAsClient//  ww  w  .j  a v a  2 s  .  co  m
@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 e;
        }
    } finally {
        bus.shutdown(true);
    }
}

From source file:org.jboss.as.test.integration.ws.wsse.trust.WSTrustTestCase.java

@Test
@RunAsClient/*  www. j a  v  a 2 s .c o  m*/
@OperateOnDeployment(BEARER_SERVER_DEP)
@WrapThreadContextClassLoader
public void testBearer() throws Exception {
    Bus bus = BusFactory.newInstance().createBus();
    try {
        BusFactory.setThreadDefaultBus(bus);

        final QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/bearerwssecuritypolicy",
                "BearerService");
        Service service = Service.create(new URL(serviceURL + "BearerService?wsdl"), serviceName);
        BearerIface proxy = (BearerIface) service.getPort(BearerIface.class);

        WSTrustTestUtils.setupWsseAndSTSClientBearer((BindingProvider) proxy, bus);
        assertEquals("Bearer WS-Trust Hello World!", proxy.sayHello());

    } catch (Exception e) {
        throw e;
    } finally {
        bus.shutdown(true);
    }
}