Search in sources :

Example 86 with BindingProvider

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

the class EJBEndpointNoClassLevelSecurityAnnotationAuthenticationTestCase method accessHelloForRolesWithInvalidRole.

@Test
public void accessHelloForRolesWithInvalidRole() 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.helloForRoles("World");
        Assert.fail("Test should fail, user shouldn't be allowed to invoke that method");
    } catch (WebServiceException e) {
        // failure is expected
        Assert.assertEquals(getNotAllowedExceptionMessage("helloForRoles"), 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 87 with BindingProvider

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

the class EJBEndpointNoClassLevelSecurityAnnotationAuthenticationTestCase method accessHelloForAllWithValidRole1.

// ------------------------------------------------------------------------------
//
// Tests for helloForAll method
//
@Test
public void accessHelloForAllWithValidRole1() 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");
    final String result = proxy.helloForAll("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 88 with BindingProvider

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

the class EJBEndpointNoClassLevelSecurityAnnotationAuthenticationTestCase method accessHelloForNoneWithValidRole1.

// ------------------------------------------------------------------------------
//
// Tests for helloForNone method
//
@Test
public void accessHelloForNoneWithValidRole1() 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.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 89 with BindingProvider

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

the class EJBEndpointNoClassLevelSecurityAnnotationAuthenticationTestCase method accessHelloForRolesWithValidRole1.

// ------------------------------------------------------------------------------
//
// Tests for helloForRoles method
//
@Test
public void accessHelloForRolesWithValidRole1() 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");
    final String result = proxy.helloForRoles("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 90 with BindingProvider

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

the class EJBEndpointAuthenticationTestCase method accessHelloForRolesWithInvalidRole.

@Test
public void accessHelloForRolesWithInvalidRole() throws Exception {
    URL wsdlURL = new URL(baseUrl, "/jaxws-authentication-ejb3/EJB3AuthService?wsdl");
    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.helloForRoles("World");
        Assert.fail("Test should fail, user shouldn't be allowed to invoke that method");
    } catch (WebServiceException e) {
        // failure is expected
        Assert.assertEquals(getNotAllowedExceptionMessage("helloForRoles"), 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)

Aggregations

BindingProvider (javax.xml.ws.BindingProvider)147 URL (java.net.URL)87 Test (org.junit.Test)74 Service (javax.xml.ws.Service)65 QName (javax.xml.namespace.QName)41 WebServiceException (javax.xml.ws.WebServiceException)24 Greeter (org.apache.hello_world_soap_http.Greeter)23 DoubleItPortType (org.example.contract.doubleit.DoubleItPortType)18 Bus (org.apache.cxf.Bus)17 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)15 InvocationHandler (java.lang.reflect.InvocationHandler)14 SOAPService (org.apache.hello_world_soap_http.SOAPService)14 UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)12 STSClient (org.apache.cxf.ws.security.trust.STSClient)11 Greeter (org.apache.cxf.greeter_control.Greeter)10 GreeterService (org.apache.cxf.greeter_control.GreeterService)10 SOAPBinding (javax.xml.ws.soap.SOAPBinding)9 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)9 Client (org.apache.cxf.endpoint.Client)9 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)8