Search in sources :

Example 31 with WrapThreadContextClassLoader

use of org.jboss.wsf.test.WrapThreadContextClassLoader in project jbossws-cxf by jbossws.

the class WSSecurityPolicyExamples22xTestCase method test223.

/**
 * 2.2.3  (WSS1.1) Anonymous with X.509 Certificate, Sign, Encrypt
 *
 * In this use case the Request is signed using DerivedKeyToken1(K), then encrypted using a DerivedKeyToken2(K) where K is ephemeral key
 * protected for the server's certificate. Response is signed using DKT3(K), (if needed) encrypted using DKT4(K). The requestor does no
 * wish to identify himself; the message exchange is protected using derived symmetric keys. As a simpler, but less secure, alternative,
 * ephemeral key K (instead of derived keys) could be used for message protection by simply omitting the sp:RequireDerivedKeys assertion.
 *
 * @throws Exception
 */
@Test
@RunAsClient
@WrapThreadContextClassLoader
public void test223() throws Exception {
    Service service = Service.create(new URL(baseURL + "SecurityService223?wsdl"), serviceName);
    ServiceIface proxy = (ServiceIface) service.getPort(new QName(NS, "SecurityService223Port"), ServiceIface.class);
    setupWsse(proxy, true);
    try {
        assertTrue(proxy.sayHello().equals("Hello - (WSS1.1) Anonymous with X.509 Certificates, Sign, Encrypt"));
    } catch (Exception e) {
        throw CryptoCheckHelper.checkAndWrapException(e);
    }
}
Also used : QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) URL(java.net.URL) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) JBossWSTest(org.jboss.wsf.test.JBossWSTest) WrapThreadContextClassLoader(org.jboss.wsf.test.WrapThreadContextClassLoader)

Example 32 with WrapThreadContextClassLoader

use of org.jboss.wsf.test.WrapThreadContextClassLoader in project jbossws-cxf by jbossws.

the class WSSecurityPolicyExamples23xTestCase method test2322.

/**
 * 2.3.2.2 (WSS1.1) SAML2.0 Sender Vouches over SSL
 *
 * @throws Exception
 */
@Test
@RunAsClient
@WrapThreadContextClassLoader
public void test2322() throws Exception {
    Service service = Service.create(new URL(serviceURLHttps + "SecurityService2322?wsdl"), serviceName);
    ServiceIface proxy = (ServiceIface) service.getPort(new QName(NS, "SecurityService2322Port"), ServiceIface.class);
    SamlCallbackHandler cbh = new SamlCallbackHandler();
    cbh.setConfirmationMethod("urn:oasis:names:tc:SAML:2.0:cm:sender-vouches");
    cbh.setSaml2(true);
    ((BindingProvider) proxy).getRequestContext().put(SecurityConstants.SAML_CALLBACK_HANDLER, cbh);
    assertTrue(proxy.sayHello().equals("Hello - (WSS1.1) SAML2.0 Sender Vouches over SSL"));
}
Also used : QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) URL(java.net.URL) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) JBossWSTest(org.jboss.wsf.test.JBossWSTest) WrapThreadContextClassLoader(org.jboss.wsf.test.WrapThreadContextClassLoader)

Example 33 with WrapThreadContextClassLoader

use of org.jboss.wsf.test.WrapThreadContextClassLoader in project jbossws-cxf by jbossws.

the class WSSecurityPolicyExamples23xTestCase method test2311.

/**
 * 2.3.1.1 (WSS1.0) SAML1.1 Assertion (Bearer)
 *
 * @throws Exception
 */
@Test
@RunAsClient
@WrapThreadContextClassLoader
@OperateOnDeployment(DEPLOYMENT)
public void test2311() throws Exception {
    Service service = Service.create(new URL(serviceURL + "SecurityService2311?wsdl"), serviceName);
    ServiceIface proxy = (ServiceIface) service.getPort(new QName(NS, "SecurityService2311Port"), ServiceIface.class);
    ((BindingProvider) proxy).getRequestContext().put(SecurityConstants.SAML_CALLBACK_HANDLER, new SamlCallbackHandler());
    assertTrue(proxy.sayHello().equals("Hello - (WSS1.0) SAML1.1 Assertion (Bearer)"));
}
Also used : QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) URL(java.net.URL) OperateOnDeployment(org.jboss.arquillian.container.test.api.OperateOnDeployment) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) JBossWSTest(org.jboss.wsf.test.JBossWSTest) WrapThreadContextClassLoader(org.jboss.wsf.test.WrapThreadContextClassLoader)

Example 34 with WrapThreadContextClassLoader

use of org.jboss.wsf.test.WrapThreadContextClassLoader in project jbossws-cxf by jbossws.

the class WSSecurityPolicyExamples23xTestCase method test2315.

/**
 * 2.3.1.5 (WSS1.0) SAML1.1 Holder of Key, Sign, Optional Encrypt
 *
 * @throws Exception
 */
@Test
@RunAsClient
@WrapThreadContextClassLoader
public void test2315() throws Exception {
    Service service = Service.create(new URL(serviceURL + "SecurityService2315?wsdl"), serviceName);
    ServiceIface proxy = (ServiceIface) service.getPort(new QName(NS, "SecurityService2315Port"), ServiceIface.class);
    Map<String, Object> reqCtx = ((BindingProvider) proxy).getRequestContext();
    SamlCallbackHandler cbh = new SamlCallbackHandler();
    cbh.setConfirmationMethod("urn:oasis:names:tc:SAML:1.0:cm:holder-of-key");
    cbh.setSigned(true);
    reqCtx.put(SecurityConstants.SAML_CALLBACK_HANDLER, cbh);
    reqCtx.put(SecurityConstants.CALLBACK_HANDLER, new KeystorePasswordCallback());
    reqCtx.put(SecurityConstants.SIGNATURE_PROPERTIES, Thread.currentThread().getContextClassLoader().getResource("META-INF/alice.properties"));
    reqCtx.put(SecurityConstants.ENCRYPT_PROPERTIES, Thread.currentThread().getContextClassLoader().getResource("META-INF/alice.properties"));
    reqCtx.put(SecurityConstants.SIGNATURE_USERNAME, "alice");
    reqCtx.put(SecurityConstants.ENCRYPT_USERNAME, "bob");
    try {
        assertTrue(proxy.sayHello().equals("Hello - (WSS1.0) SAML1.1 Holder of Key, Sign, Optional Encrypt"));
    } catch (Exception e) {
        throw CryptoCheckHelper.checkAndWrapException(e);
    }
}
Also used : QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) BindingProvider(javax.xml.ws.BindingProvider) URL(java.net.URL) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) JBossWSTest(org.jboss.wsf.test.JBossWSTest) WrapThreadContextClassLoader(org.jboss.wsf.test.WrapThreadContextClassLoader)

Example 35 with WrapThreadContextClassLoader

use of org.jboss.wsf.test.WrapThreadContextClassLoader in project jbossws-cxf by jbossws.

the class WSSecurityPolicyExamples23xTestCase method test2321.

/**
 * 2.3.2.1 (WSS1.1) SAML 2.0 Bearer
 *
 * @throws Exception
 */
@Test
@RunAsClient
@WrapThreadContextClassLoader
public void test2321() throws Exception {
    Service service = Service.create(new URL(serviceURL + "SecurityService2321?wsdl"), serviceName);
    ServiceIface proxy = (ServiceIface) service.getPort(new QName(NS, "SecurityService2321Port"), ServiceIface.class);
    SamlCallbackHandler cbh = new SamlCallbackHandler();
    cbh.setConfirmationMethod("urn:oasis:names:tc:SAML:2.0:cm:bearer");
    cbh.setSaml2(true);
    Map<String, Object> reqCtx = ((BindingProvider) proxy).getRequestContext();
    reqCtx.put(SecurityConstants.SAML_CALLBACK_HANDLER, cbh);
    reqCtx.put(SecurityConstants.CALLBACK_HANDLER, new KeystorePasswordCallback());
    reqCtx.put(SecurityConstants.SIGNATURE_PROPERTIES, Thread.currentThread().getContextClassLoader().getResource("META-INF/alice.properties"));
    reqCtx.put(SecurityConstants.ENCRYPT_PROPERTIES, Thread.currentThread().getContextClassLoader().getResource("META-INF/alice.properties"));
    reqCtx.put(SecurityConstants.SIGNATURE_USERNAME, "alice");
    reqCtx.put(SecurityConstants.ENCRYPT_USERNAME, "bob");
    assertTrue(proxy.sayHello().equals("Hello - (WSS1.1) SAML 2.0 Bearer"));
}
Also used : QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) BindingProvider(javax.xml.ws.BindingProvider) URL(java.net.URL) RunAsClient(org.jboss.arquillian.container.test.api.RunAsClient) Test(org.junit.Test) JBossWSTest(org.jboss.wsf.test.JBossWSTest) WrapThreadContextClassLoader(org.jboss.wsf.test.WrapThreadContextClassLoader)

Aggregations

QName (javax.xml.namespace.QName)41 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)41 JBossWSTest (org.jboss.wsf.test.JBossWSTest)41 WrapThreadContextClassLoader (org.jboss.wsf.test.WrapThreadContextClassLoader)41 Test (org.junit.Test)41 URL (java.net.URL)40 Service (javax.xml.ws.Service)39 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)15 Bus (org.apache.cxf.Bus)13 BindingProvider (javax.xml.ws.BindingProvider)6 ActAsServiceIface (org.jboss.test.ws.jaxws.samples.wsse.policy.trust.actas.ActAsServiceIface)6 OnBehalfOfServiceIface (org.jboss.test.ws.jaxws.samples.wsse.policy.trust.onbehalfof.OnBehalfOfServiceIface)6 ServiceIface (org.jboss.test.ws.jaxws.samples.wsse.policy.trust.service.ServiceIface)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 PrintWriter (java.io.PrintWriter)2 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)2 LoggingInInterceptor (org.apache.cxf.interceptor.LoggingInInterceptor)2 UseThreadBusFeature (org.jboss.wsf.stack.cxf.client.UseThreadBusFeature)2 Endpoint (javax.xml.ws.Endpoint)1 HelloResponse (org.jboss.test.ws.jaxws.samples.schemavalidation.types.HelloResponse)1