use of org.apache.cxf.systest.ws.common.KeystorePasswordCallback in project cxf by apache.
the class StaxServer method doPublish.
private void doPublish(String url, Object obj) {
Endpoint ep = Endpoint.create(obj);
ep.getProperties().put(SecurityConstants.ENABLE_STREAMING_SECURITY, "true");
ep.getProperties().put(SecurityConstants.CALLBACK_HANDLER + ".sct", new KeystorePasswordCallback());
ep.getProperties().put(SecurityConstants.ENCRYPT_PROPERTIES + ".sct", "bob.properties");
if (url.contains("X10_I")) {
ep.getProperties().put(SecurityConstants.SIGNATURE_PROPERTIES + ".sct", "bob.properties");
ep.getProperties().put(SecurityConstants.ENCRYPT_PROPERTIES + ".sct", "alice.properties");
} else if (url.contains("MutualCert")) {
ep.getProperties().put(SecurityConstants.ENCRYPT_PROPERTIES + ".sct", "bob.properties");
ep.getProperties().put(SecurityConstants.SIGNATURE_PROPERTIES + ".sct", "alice.properties");
ep.getProperties().put(SecurityConstants.CALLBACK_HANDLER, new KeystorePasswordCallback());
} else if (url.contains("UserNameOverTransport")) {
ep.getProperties().put(SecurityConstants.CALLBACK_HANDLER + ".sct", new UTPasswordCallback());
}
ep.publish(url);
}
use of org.apache.cxf.systest.ws.common.KeystorePasswordCallback in project cxf by apache.
the class AbstractServerRestricted method doPublish.
private void doPublish(String url, Object obj) {
Endpoint ep = Endpoint.create(obj);
ep.getProperties().put(SecurityConstants.CALLBACK_HANDLER, new KeystorePasswordCallback());
ep.getProperties().put(SecurityConstants.ENCRYPT_PROPERTIES, "restricted/bob.properties");
if (streaming) {
ep.getProperties().put(SecurityConstants.ENABLE_STREAMING_SECURITY, "true");
}
ep.publish(url);
}
use of org.apache.cxf.systest.ws.common.KeystorePasswordCallback in project cxf by apache.
the class SecurityPolicyTest method testFault.
@Test
public void testFault() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = SecurityPolicyTest.class.getResource("https_config_client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = SecurityPolicyTest.class.getResource("DoubleIt.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItFaultPortSignThenEncrypt");
DoubleItPortType pt = service.getPort(portQName, DoubleItPortType.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, "bob.properties");
// DOM
try {
pt.doubleIt(5);
fail("SOAPFaultException expected!");
} catch (SOAPFaultException e) {
assertEquals("Foo", e.getFault().getFaultString());
} finally {
((java.io.Closeable) pt).close();
bus.shutdown(true);
}
}
use of org.apache.cxf.systest.ws.common.KeystorePasswordCallback 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);
}
use of org.apache.cxf.systest.ws.common.KeystorePasswordCallback in project cxf by apache.
the class SecurityPolicyTest method testDispatchClient.
@Test
public void testDispatchClient() 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);
QName portQName = new QName(NAMESPACE, "DoubleItPortEncryptThenSign");
Dispatch<Source> disp = service.createDispatch(portQName, Source.class, Mode.PAYLOAD);
disp.getRequestContext().put(SecurityConstants.CALLBACK_HANDLER, new KeystorePasswordCallback());
disp.getRequestContext().put(SecurityConstants.SIGNATURE_PROPERTIES, "alice.properties");
disp.getRequestContext().put(SecurityConstants.ENCRYPT_PROPERTIES, "bob.properties");
updateAddressPort(disp, PORT);
String req = "<ns2:DoubleIt xmlns:ns2=\"http://www.example.org/schema/DoubleIt\">" + "<numberToDouble>25</numberToDouble></ns2:DoubleIt>";
Source source = new StreamSource(new StringReader(req));
source = disp.invoke(source);
Node nd = StaxUtils.read(source);
if (nd instanceof Document) {
nd = ((Document) nd).getDocumentElement();
}
Map<String, String> ns = new HashMap<>();
ns.put("ns2", "http://www.example.org/schema/DoubleIt");
XPathUtils xp = new XPathUtils(ns);
Object o = xp.getValue("//ns2:DoubleItResponse/doubledNumber", nd, XPathConstants.STRING);
assertEquals(StaxUtils.toString(nd), "50", o);
bus.shutdown(true);
}
Aggregations