Search in sources :

Example 11 with BindingProvider

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

the class PojoEndpointAuthenticationTestCase method accessHelloWithValidUser2.

@Test
public void accessHelloWithValidUser2() throws Exception {
    URL wsdlURL = new URL(baseUrl, "/jaxws-authentication-pojo/POJOAuthService?wsdl");
    Service service = Service.create(wsdlURL, serviceName);
    PojoEndpointIface proxy = service.getPort(PojoEndpointIface.class);
    Map<String, Object> reqContext = ((BindingProvider) proxy).getRequestContext();
    reqContext.put(BindingProvider.USERNAME_PROPERTY, "user2");
    reqContext.put(BindingProvider.PASSWORD_PROPERTY, "password2");
    final String result = proxy.hello("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 12 with BindingProvider

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

the class EJBEndpointAuthenticationTestCase method accessHelloForNoneWithValidRole1.

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

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

the class EJBEndpointAuthenticationTestCase method accessHelloWithValidUser.

@Test
public void accessHelloWithValidUser() 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, "user1");
    reqContext.put(BindingProvider.PASSWORD_PROPERTY, "password1");
    final String result = proxy.hello("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 14 with BindingProvider

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

the class EJBEndpointAuthenticationTestCase method accessHelloForRoleWithInvalidRole.

// ------------------------------------------------------------------------------
//
// Tests for helloForRole method
//
@Test
public void accessHelloForRoleWithInvalidRole() 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, "user1");
    reqContext.put(BindingProvider.PASSWORD_PROPERTY, "password1");
    try {
        proxy.helloForRole("World");
        Assert.fail("Test should fail, user shouldn't be allowed to invoke that method");
    } catch (WebServiceException e) {
        // failure is expected
        Assert.assertEquals(getNotAllowedExceptionMessage("helloForRole"), 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 15 with BindingProvider

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

the class EJBEndpointAuthenticationTestCase method accessHelloWithBadPassword.

@Test
public void accessHelloWithBadPassword() 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, "user1");
    reqContext.put(BindingProvider.PASSWORD_PROPERTY, "password-XYZ");
    try {
        proxy.hello("World");
        Assert.fail("Test should fail, HTTP response '401: Unauthorized' was expected");
    } catch (WebServiceException e) {
        // failure is expected
        Assert.assertTrue("HTTPException '401: Unauthorized' was expected", e.getCause().getMessage().contains("401: Unauthorized"));
    }
}
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)58 URL (java.net.URL)40 Service (javax.xml.ws.Service)39 Test (org.junit.Test)31 WebServiceException (javax.xml.ws.WebServiceException)17 QName (javax.xml.namespace.QName)12 WSS4JOutInterceptor (org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor)7 ModelPortType (com.evolveum.midpoint.xml.ns._public.model.model_3.ModelPortType)6 ModelService (com.evolveum.midpoint.xml.ns._public.model.model_3.ModelService)6 HashMap (java.util.HashMap)6 File (java.io.File)4 LoggingInInterceptor (org.apache.cxf.interceptor.LoggingInInterceptor)4 LoggingOutInterceptor (org.apache.cxf.interceptor.LoggingOutInterceptor)4 InvocationHandler (java.lang.reflect.InvocationHandler)3 MalformedURLException (java.net.MalformedURLException)3 List (java.util.List)3 DocumentRepositoryService (ihe.iti.xds_b._2007.DocumentRepositoryService)2 ArrayList (java.util.ArrayList)2 SOAPBinding (javax.xml.ws.soap.SOAPBinding)2 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)2