use of javax.xml.ws.BindingProvider in project wildfly by wildfly.
the class PojoEndpointAuthenticationTestCase method accessHelloWithUnauthorizedUser.
@Test
public void accessHelloWithUnauthorizedUser() 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, "user3");
reqContext.put(BindingProvider.PASSWORD_PROPERTY, "password3");
try {
proxy.hello("World");
Assert.fail("Test should fail, HTTP response '403: Forbidden' was expected");
} catch (WebServiceException e) {
// failure is expected
Assert.assertTrue("String '403: Forbidden' was expected in " + e.getCause().getMessage(), e.getCause().getMessage().contains("403: Forbidden"));
}
}
use of javax.xml.ws.BindingProvider in project wildfly by wildfly.
the class EJBEndpointAuthenticationTestCase method accessHelloForNoneWithValidRole2.
@Test
public void accessHelloForNoneWithValidRole2() 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, "user2");
reqContext.put(BindingProvider.PASSWORD_PROPERTY, "password2");
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());
}
}
use of javax.xml.ws.BindingProvider in project wildfly by wildfly.
the class EJBEndpointAuthenticationTestCase method accessHelloForAllWithValidRole1.
// ------------------------------------------------------------------------------
//
// Tests for helloForAll method
//
@Test
public void accessHelloForAllWithValidRole1() 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.helloForAll("World");
Assert.assertEquals("Hello World!", result);
}
use of javax.xml.ws.BindingProvider in project wildfly by wildfly.
the class EJBEndpointAuthenticationTestCase method accessHelloForAllWithValidRole2.
@Test
public void accessHelloForAllWithValidRole2() 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, "user2");
reqContext.put(BindingProvider.PASSWORD_PROPERTY, "password2");
final String result = proxy.helloForAll("World");
Assert.assertEquals("Hello World!", result);
}
use of javax.xml.ws.BindingProvider in project wildfly by wildfly.
the class EJBEndpointAuthenticationTestCase method accessHelloForRoleWithValidRole.
@Test
public void accessHelloForRoleWithValidRole() 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, "user2");
reqContext.put(BindingProvider.PASSWORD_PROPERTY, "password2");
final String result = proxy.helloForRole("World");
Assert.assertEquals("Hello World!", result);
}
Aggregations