use of org.example.contract.doubleit.DoubleItPortType in project cxf by apache.
the class HTTPGetTest method testSOAPClientSecurityPolicy.
@org.junit.Test
public void testSOAPClientSecurityPolicy() throws Exception {
if (!unrestrictedPoliciesInstalled) {
return;
}
SpringBusFactory bf = new SpringBusFactory();
URL busFile = HTTPGetTest.class.getResource("client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = HTTPGetTest.class.getResource("DoubleItHTTPGet.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItKeyIdentifierPort");
DoubleItPortType x509Port = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(x509Port, PORT);
int result = x509Port.doubleIt(25);
assertEquals(result, 50);
bus.shutdown(true);
}
use of org.example.contract.doubleit.DoubleItPortType in project cxf by apache.
the class HttpsTokenTest method testNoClientCertRequirement.
@org.junit.Test
public void testNoClientCertRequirement() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = HttpsTokenTest.class.getResource("client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = HttpsTokenTest.class.getResource("DoubleItHttps.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItNoClientCertRequirementPort");
DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(port, test.getPort());
if (test.isStreaming()) {
SecurityTestUtil.enableStreaming(port);
}
try {
port.doubleIt(25);
fail("(Policy) Failure expected on not using a client cert");
} catch (Exception ex) {
// expected
}
// This should work, as we're disable the RequireClientCertificate check via a
// JAX-WS property
portQName = new QName(NAMESPACE, "DoubleItNoClientCertRequirementPort2");
port = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(port, test.getPort());
if (test.isStreaming()) {
SecurityTestUtil.enableStreaming(port);
}
assertEquals(50, port.doubleIt(25));
((java.io.Closeable) port).close();
bus.shutdown(true);
}
use of org.example.contract.doubleit.DoubleItPortType in project cxf by apache.
the class MTOMSecurityTest method testAsymmetricBytesInAttachment.
// Here we moving encrypted bytes to attachments instead, and referencing them via xop:Include
// This avoids the BASE-64 encoding/decoding step when the raw bytes are included in the SOAP Envelope
@org.junit.Test
public void testAsymmetricBytesInAttachment() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = MTOMSecurityTest.class.getResource("client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = MTOMSecurityTest.class.getResource("DoubleItMtom.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricPort");
DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(port, PORT);
int result = port.doubleIt(25);
assertEquals(result, 50);
((java.io.Closeable) port).close();
bus.shutdown(true);
}
use of org.example.contract.doubleit.DoubleItPortType in project cxf by apache.
the class PartsTest method testSignedElements.
@org.junit.Test
public void testSignedElements() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = PartsTest.class.getResource("client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = PartsTest.class.getResource("DoubleItParts.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
// Successful invocation
QName portQName = new QName(NAMESPACE, "DoubleItSignedElementsPort");
DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(port, test.getPort());
if (test.isStreaming()) {
SecurityTestUtil.enableStreaming(port);
}
assertEquals(50, port.doubleIt(25));
// This should fail, as the service requires that the To header must be signed
portQName = new QName(NAMESPACE, "DoubleItSignedElementsPort2");
port = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(port, test.getPort());
if (test.isStreaming()) {
SecurityTestUtil.enableStreaming(port);
}
try {
port.doubleIt(25);
fail("Failure expected on a header which isn't signed");
} catch (javax.xml.ws.soap.SOAPFaultException ex) {
String error = "SignedElements";
assertTrue(ex.getMessage().contains(error) || ex.getMessage().contains("To must be signed"));
}
((java.io.Closeable) port).close();
bus.shutdown(true);
}
use of org.example.contract.doubleit.DoubleItPortType in project cxf by apache.
the class PartsTest method testEncryptedParts.
@org.junit.Test
public void testEncryptedParts() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = PartsTest.class.getResource("client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = PartsTest.class.getResource("DoubleItParts.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
// Successful invocation
QName portQName = new QName(NAMESPACE, "DoubleItEncryptedPartsPort");
DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(port, test.getPort());
if (test.isStreaming()) {
SecurityTestUtil.enableStreaming(port);
}
assertEquals(50, port.doubleIt(25));
// This should fail, as the service requires that the Body must be encrypted
portQName = new QName(NAMESPACE, "DoubleItEncryptedPartsPort2");
port = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(port, test.getPort());
if (test.isStreaming()) {
SecurityTestUtil.enableStreaming(port);
}
try {
port.doubleIt(25);
fail("Failure expected on a body which isn't encrypted");
} catch (javax.xml.ws.soap.SOAPFaultException ex) {
String error = "EncryptedParts";
assertTrue(ex.getMessage().contains(error) || ex.getMessage().contains("Body must be encrypted"));
}
// This should fail, as the service requires that the To header must be encrypted
portQName = new QName(NAMESPACE, "DoubleItEncryptedPartsPort3");
port = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(port, test.getPort());
if (test.isStreaming()) {
SecurityTestUtil.enableStreaming(port);
}
try {
port.doubleIt(25);
fail("Failure expected on a header which isn't encrypted");
} catch (javax.xml.ws.soap.SOAPFaultException ex) {
String error = "EncryptedParts";
assertTrue(ex.getMessage().contains(error) || ex.getMessage().contains("To must be encrypted"));
}
((java.io.Closeable) port).close();
bus.shutdown(true);
}
Aggregations