Search in sources :

Example 1 with DoubleIt

use of org.example.schema.doubleit.DoubleIt in project cxf by apache.

the class SecurityPolicyTest method testCXF4119.

@Test
public void testCXF4119() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    Bus bus = bf.createBus();
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = SecurityPolicyTest.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    DoubleItPortTypeHeader pt;
    QName portQName = new QName(NAMESPACE, "DoubleItPortCXF4119");
    pt = service.getPort(portQName, DoubleItPortTypeHeader.class);
    updateAddressPort(pt, PORT);
    ((BindingProvider) pt).getRequestContext().put(SecurityConstants.CALLBACK_HANDLER, new KeystorePasswordCallback());
    ((BindingProvider) pt).getRequestContext().put(SecurityConstants.SIGNATURE_PROPERTIES, "alice.properties");
    ((BindingProvider) pt).getRequestContext().put(SecurityConstants.ENCRYPT_PROPERTIES, "revocation.properties");
    ((BindingProvider) pt).getRequestContext().put(SecurityConstants.ENABLE_REVOCATION, "true");
    DoubleIt di = new DoubleIt();
    di.setNumberToDouble(5);
    try {
        pt.doubleIt(di, 1);
        fail("Failure expected on a revoked certificate");
    } catch (Exception ex) {
    // expected
    }
    ((java.io.Closeable) pt).close();
    bus.shutdown(true);
}
Also used : Bus(org.apache.cxf.Bus) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) QName(javax.xml.namespace.QName) DoubleItPortTypeHeader(org.example.contract.doubleit.DoubleItPortTypeHeader) Service(javax.xml.ws.Service) URL(java.net.URL) KeystorePasswordCallback(org.apache.cxf.systest.ws.common.KeystorePasswordCallback) DoubleIt(org.example.schema.doubleit.DoubleIt) UnsupportedCallbackException(javax.security.auth.callback.UnsupportedCallbackException) IOException(java.io.IOException) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) Test(org.junit.Test)

Example 2 with DoubleIt

use of org.example.schema.doubleit.DoubleIt in project cxf by apache.

the class SecurityPolicyTest method testCXF3452.

@Test
public void testCXF3452() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    Bus bus = bf.createBus();
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    URL wsdl = SecurityPolicyTest.class.getResource("DoubleIt.wsdl");
    Service service = Service.create(wsdl, SERVICE_QNAME);
    DoubleItPortTypeHeader pt;
    QName portQName = new QName(NAMESPACE, "DoubleItPortCXF3452");
    pt = service.getPort(portQName, DoubleItPortTypeHeader.class);
    updateAddressPort(pt, PORT);
    ((BindingProvider) pt).getRequestContext().put(SecurityConstants.CALLBACK_HANDLER, new KeystorePasswordCallback());
    ((BindingProvider) pt).getRequestContext().put(SecurityConstants.SIGNATURE_PROPERTIES, "alice.properties");
    ((BindingProvider) pt).getRequestContext().put(SecurityConstants.ENCRYPT_PROPERTIES, "alice.properties");
    DoubleIt di = new DoubleIt();
    di.setNumberToDouble(5);
    assertEquals(10, pt.doubleIt(di, 1).getDoubledNumber());
    ((java.io.Closeable) pt).close();
    bus.shutdown(true);
}
Also used : Bus(org.apache.cxf.Bus) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) QName(javax.xml.namespace.QName) DoubleItPortTypeHeader(org.example.contract.doubleit.DoubleItPortTypeHeader) Service(javax.xml.ws.Service) URL(java.net.URL) KeystorePasswordCallback(org.apache.cxf.systest.ws.common.KeystorePasswordCallback) DoubleIt(org.example.schema.doubleit.DoubleIt) Test(org.junit.Test)

Aggregations

URL (java.net.URL)2 QName (javax.xml.namespace.QName)2 Service (javax.xml.ws.Service)2 Bus (org.apache.cxf.Bus)2 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)2 KeystorePasswordCallback (org.apache.cxf.systest.ws.common.KeystorePasswordCallback)2 DoubleItPortTypeHeader (org.example.contract.doubleit.DoubleItPortTypeHeader)2 DoubleIt (org.example.schema.doubleit.DoubleIt)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 UnsupportedCallbackException (javax.security.auth.callback.UnsupportedCallbackException)1 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)1