Search in sources :

Example 41 with Service

use of javax.xml.ws.Service in project wildfly by wildfly.

the class EJBEndpointNoClassLevelSecurityAnnotationAuthenticationTestCase method accessHelloForNoneWithValidRole3.

@Test
public void accessHelloForNoneWithValidRole3() throws Exception {
    URL wsdlURL = new URL(baseUrl, deploymentWsdlURL);
    Service service = Service.create(wsdlURL, serviceName);
    EJBEndpointIface proxy = service.getPort(EJBEndpointIface.class);
    Map<String, Object> reqContext = ((BindingProvider) proxy).getRequestContext();
    reqContext.put(BindingProvider.USERNAME_PROPERTY, "user3");
    reqContext.put(BindingProvider.PASSWORD_PROPERTY, "password3");
    try {
        proxy.helloForNone("World");
        Assert.fail("Test should fail, user shouldn't be allowed to invoke that method");
    } catch (WebServiceException e) {
        // failure is expected
        Assert.assertEquals(getNotAllowedExceptionMessage("helloForNone"), e.getCause().getMessage());
    }
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) Service(javax.xml.ws.Service) BindingProvider(javax.xml.ws.BindingProvider) URL(java.net.URL) Test(org.junit.Test)

Example 42 with Service

use of javax.xml.ws.Service in project wildfly by wildfly.

the class EJBEndpointNoClassLevelSecurityAnnotationAuthenticationTestCase method accessHelloWithAuthenticatedUser.

// ------------------------------------------------------------------------------
//
// Tests for hello method
//
@Test
public void accessHelloWithAuthenticatedUser() throws Exception {
    URL wsdlURL = new URL(baseUrl, deploymentWsdlURL);
    Service service = Service.create(wsdlURL, serviceName);
    EJBEndpointIface proxy = service.getPort(EJBEndpointIface.class);
    Map<String, Object> reqContext = ((BindingProvider) proxy).getRequestContext();
    reqContext.put(BindingProvider.USERNAME_PROPERTY, "user1");
    reqContext.put(BindingProvider.PASSWORD_PROPERTY, "password1");
    try {
        proxy.hello("World");
        Assert.fail("Test should fail, user shouldn't be allowed to invoke hello method");
    } catch (WebServiceException e) {
        // failure is expected
        Assert.assertTrue("Invocation on hello method should not be allowed", e.getCause().getMessage().contains("not allowed"));
    }
}
Also used : WebServiceException(javax.xml.ws.WebServiceException) Service(javax.xml.ws.Service) BindingProvider(javax.xml.ws.BindingProvider) URL(java.net.URL) Test(org.junit.Test)

Example 43 with Service

use of javax.xml.ws.Service in project wildfly by wildfly.

the class EJBEndpointNoClassLevelSecurityAnnotationAuthenticationTestCase method accessHelloForRoleWithValidRole.

@Test
public void accessHelloForRoleWithValidRole() throws Exception {
    URL wsdlURL = new URL(baseUrl, deploymentWsdlURL);
    Service service = Service.create(wsdlURL, serviceName);
    EJBEndpointIface proxy = service.getPort(EJBEndpointIface.class);
    Map<String, Object> reqContext = ((BindingProvider) proxy).getRequestContext();
    reqContext.put(BindingProvider.USERNAME_PROPERTY, "user2");
    reqContext.put(BindingProvider.PASSWORD_PROPERTY, "password2");
    final String result = proxy.helloForRole("World");
    Assert.assertEquals("Hello World!", result);
}
Also used : Service(javax.xml.ws.Service) BindingProvider(javax.xml.ws.BindingProvider) URL(java.net.URL) Test(org.junit.Test)

Example 44 with Service

use of javax.xml.ws.Service in project wildfly by wildfly.

the class ATClient method newInstance.

public static AT newInstance(String serviceUrl, String serviceNamespaceName) throws Exception {
    URL wsdlLocation = new URL("http://" + NODE0_ADDR + ":" + NODE0_PORT + "/" + ATTestCase.ARCHIVE_NAME + "/" + serviceUrl + "?wsdl");
    log.trace("wsdlLocation for service: " + wsdlLocation);
    QName serviceName = new QName(TARGET_NAMESPACE, serviceNamespaceName);
    QName portName = new QName(TARGET_NAMESPACE, DEFAULT_PORT_NAME);
    Service service = Service.create(wsdlLocation, serviceName);
    AT atService = service.getPort(portName, AT.class);
    return atService;
}
Also used : AT(org.jboss.as.test.xts.wsat.service.AT) QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) URL(java.net.URL)

Example 45 with Service

use of javax.xml.ws.Service in project wildfly by wildfly.

the class BACoordinatorCompletionClient method newInstance.

public static BACoordinatorCompletion newInstance(String serviceUrl, String serviceNamespaceName) throws Exception {
    URL wsdlLocation = new URL("http://" + NODE0_ADDR + ":" + NODE0_PORT + "/" + BACoordinatorCompletionTestCase.ARCHIVE_NAME + "/" + serviceUrl + "?wsdl");
    log.trace("wsdlLocation for service: " + wsdlLocation);
    QName serviceName = new QName(TARGET_NAMESPACE, serviceNamespaceName);
    QName portName = new QName(TARGET_NAMESPACE, DEFAULT_PORT_NAME);
    Service service = Service.create(wsdlLocation, serviceName);
    BACoordinatorCompletion client = service.getPort(portName, BACoordinatorCompletion.class);
    return client;
}
Also used : QName(javax.xml.namespace.QName) BACoordinatorCompletion(org.jboss.as.test.xts.wsba.coordinatorcompletion.service.BACoordinatorCompletion) Service(javax.xml.ws.Service) URL(java.net.URL)

Aggregations

Service (javax.xml.ws.Service)598 URL (java.net.URL)547 QName (javax.xml.namespace.QName)524 Bus (org.apache.cxf.Bus)399 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)384 DoubleItPortType (org.example.contract.doubleit.DoubleItPortType)361 Test (org.junit.Test)143 BindingProvider (javax.xml.ws.BindingProvider)63 Client (org.apache.cxf.endpoint.Client)43 HashMap (java.util.HashMap)36 SamlCallbackHandler (org.apache.cxf.systest.ws.saml.client.SamlCallbackHandler)31 STSClient (org.apache.cxf.ws.security.trust.STSClient)28 WSS4JOutInterceptor (org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor)25 WebServiceException (javax.xml.ws.WebServiceException)20 WebService (javax.jws.WebService)18 IOException (java.io.IOException)16 File (java.io.File)15 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)15 Greeter (org.apache.hello_world_soap_http.Greeter)15 KeystorePasswordCallback (org.apache.cxf.systest.ws.common.KeystorePasswordCallback)14