Search in sources :

Example 91 with BindingProvider

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

the class EJBEndpointAuthenticationTestCase method accessHelloForRolesWithValidRole1.

// ------------------------------------------------------------------------------
//
// Tests for helloForRoles method
//
@Test
public void accessHelloForRolesWithValidRole1() 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.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 92 with BindingProvider

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

the class EJBEndpointAuthenticationTestCase method accessHelloForAllWithValidRole3.

@Test
public void accessHelloForAllWithValidRole3() 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");
    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 93 with BindingProvider

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

the class WSTrustTestUtils method setupWsse.

public static void setupWsse(ServiceIface proxy, Bus bus) {
    Map<String, Object> ctx = ((BindingProvider) proxy).getRequestContext();
    setServiceContextAttributes(ctx);
    ctx.put(appendIssuedTokenSuffix(SecurityConstants.USERNAME), "alice");
    ctx.put(appendIssuedTokenSuffix(SecurityConstants.CALLBACK_HANDLER), new ClientCallbackHandler());
    ctx.put(appendIssuedTokenSuffix(SecurityConstants.ENCRYPT_PROPERTIES), Thread.currentThread().getContextClassLoader().getResource("META-INF/clientKeystore.properties"));
    ctx.put(appendIssuedTokenSuffix(SecurityConstants.ENCRYPT_USERNAME), "mystskey");
    ctx.put(appendIssuedTokenSuffix(SecurityConstants.STS_TOKEN_USERNAME), "myclientkey");
    ctx.put(appendIssuedTokenSuffix(SecurityConstants.STS_TOKEN_PROPERTIES), Thread.currentThread().getContextClassLoader().getResource("META-INF/clientKeystore.properties"));
    ctx.put(appendIssuedTokenSuffix(SecurityConstants.STS_TOKEN_USE_CERT_FOR_KEYINFO), "true");
}
Also used : ClientCallbackHandler(org.jboss.as.test.integration.ws.wsse.trust.shared.ClientCallbackHandler) BindingProvider(javax.xml.ws.BindingProvider)

Example 94 with BindingProvider

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

the class WSTrustTestUtils method setupWsseAndSTSClientNoSignatureUsername.

/**
     * Uses the SIGNATURE_PROPERTIES keystore's  "alias name" as the SIGNATURE_USERNAME when
     * USERNAME and SIGNATURE_USERNAME is not provided.
     *
     * @param proxy
     * @param bus
     * @param stsWsdlLocation
     * @param stsService
     * @param stsPort
     * @see org.apache.cxf.ws.security.SecurityConstants#SIGNATURE_PROPERTIES
     */
public static void setupWsseAndSTSClientNoSignatureUsername(ServiceIface proxy, Bus bus, String stsWsdlLocation, QName stsService, QName stsPort) {
    Map<String, Object> ctx = ((BindingProvider) proxy).getRequestContext();
    ctx.put(SecurityConstants.CALLBACK_HANDLER, new ClientCallbackHandler());
    ctx.put(SecurityConstants.SIGNATURE_PROPERTIES, Thread.currentThread().getContextClassLoader().getResource("META-INF/clientKeystore.properties"));
    ctx.put(SecurityConstants.ENCRYPT_PROPERTIES, Thread.currentThread().getContextClassLoader().getResource("META-INF/clientKeystore.properties"));
    ctx.put(SecurityConstants.ENCRYPT_USERNAME, "myservicekey");
    ctx.put(SecurityConstants.STS_CLIENT, createSTSClient(bus, stsWsdlLocation, stsService, stsPort));
}
Also used : ClientCallbackHandler(org.jboss.as.test.integration.ws.wsse.trust.shared.ClientCallbackHandler) BindingProvider(javax.xml.ws.BindingProvider)

Example 95 with BindingProvider

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

the class WSTrustTestUtils method setupWsseAndSTSClientNoCallbackHandler.

/**
     * A PASSWORD is provided in place of the ClientCallbackHandler in the
     * STSClient.  A USERNAME and PASSWORD is required by CXF in the msg.
     *
     * @param proxy
     * @param bus
     * @param stsWsdlLocation
     * @param stsService
     * @param stsPort
     * @see org.apache.cxf.ws.security.SecurityConstants#PASSWORD
     */
public static void setupWsseAndSTSClientNoCallbackHandler(ServiceIface proxy, Bus bus, String stsWsdlLocation, QName stsService, QName stsPort) {
    Map<String, Object> ctx = ((BindingProvider) proxy).getRequestContext();
    setServiceContextAttributes(ctx);
    STSClient stsClient = new STSClient(bus);
    if (stsWsdlLocation != null) {
        stsClient.setWsdlLocation(stsWsdlLocation);
        stsClient.setServiceQName(stsService);
        stsClient.setEndpointQName(stsPort);
    }
    Map<String, Object> props = stsClient.getProperties();
    props.put(SecurityConstants.USERNAME, "alice");
    props.put(SecurityConstants.PASSWORD, "clarinet");
    props.put(SecurityConstants.ENCRYPT_PROPERTIES, Thread.currentThread().getContextClassLoader().getResource("META-INF/clientKeystore.properties"));
    props.put(SecurityConstants.ENCRYPT_USERNAME, "mystskey");
    props.put(SecurityConstants.STS_TOKEN_USERNAME, "myclientkey");
    props.put(SecurityConstants.STS_TOKEN_PROPERTIES, Thread.currentThread().getContextClassLoader().getResource("META-INF/clientKeystore.properties"));
    props.put(SecurityConstants.STS_TOKEN_USE_CERT_FOR_KEYINFO, "true");
    ctx.put(SecurityConstants.STS_CLIENT, stsClient);
}
Also used : STSClient(org.apache.cxf.ws.security.trust.STSClient) BindingProvider(javax.xml.ws.BindingProvider)

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