use of org.example.contract.doubleit.DoubleItPortType in project cxf by apache.
the class IntermediaryTransformationCachingTest method testIntermediaryTransformationCaching.
@org.junit.Test
public void testIntermediaryTransformationCaching() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = IntermediaryTransformationCachingTest.class.getResource("cxf-client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = IntermediaryTransformationCachingTest.class.getResource("DoubleIt.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItTransportSAML1EndorsingPort");
DoubleItPortType alicePort = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(alicePort, PORT);
TokenTestUtils.updateSTSPort((BindingProvider) alicePort, STSPORT);
((BindingProvider) alicePort).getRequestContext().put(SecurityConstants.USERNAME, "alice");
// Make initial successful invocation (for "alice")
doubleIt(alicePort, 25);
// Make another successful invocation for "bob"
DoubleItPortType bobPort = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(bobPort, PORT);
TokenTestUtils.updateSTSPort((BindingProvider) bobPort, STSPORT);
((BindingProvider) bobPort).getRequestContext().put(SecurityConstants.USERNAME, "bob");
doubleIt(bobPort, 30);
// Make another invocation for "bob" - this should work as the intermediary caches the token
// even though its STSClient is disabled after the second invocation
doubleIt(bobPort, 35);
// Make another invocation for "alice" - this should work as the intermediary caches the token
// even though its STSClient is disabled after the first invocation
doubleIt(alicePort, 40);
// Now make an invocation for "myservicekey"
DoubleItPortType servicePort = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(servicePort, PORT);
TokenTestUtils.updateSTSPort((BindingProvider) servicePort, STSPORT);
((BindingProvider) servicePort).getRequestContext().put(SecurityConstants.USERNAME, "myservicekey");
// Make invocation for "myservicekey"...this should fail as the intermediary's STS client is disabled
try {
doubleIt(servicePort, 45);
fail("Expected failure on a cache retrieval failure");
} catch (SOAPFaultException ex) {
// expected
}
((java.io.Closeable) alicePort).close();
((java.io.Closeable) bobPort).close();
((java.io.Closeable) servicePort).close();
bus.shutdown(true);
}
use of org.example.contract.doubleit.DoubleItPortType in project cxf by apache.
the class IntermediaryTransformationTest method testIntermediaryTransformationBadClient.
@org.junit.Test
public void testIntermediaryTransformationBadClient() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = IntermediaryTransformationTest.class.getResource("cxf-bad-client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = IntermediaryTransformationTest.class.getResource("DoubleIt.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItTransportSAML1EndorsingPort");
DoubleItPortType transportPort = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(transportPort, PORT);
TokenTestUtils.updateSTSPort((BindingProvider) transportPort, STSPORT);
try {
doubleIt(transportPort, 30);
fail("Expected failure on a bad user");
} catch (Exception ex) {
// expected
}
((java.io.Closeable) transportPort).close();
bus.shutdown(true);
}
use of org.example.contract.doubleit.DoubleItPortType in project cxf by apache.
the class IssuerTest method testSAML2MEXSoap12.
// Test getting the STS details via WS-MEX + SOAP 1.2
@org.junit.Test
public void testSAML2MEXSoap12() throws Exception {
if (!portFree) {
return;
}
SpringBusFactory bf = new SpringBusFactory();
URL busFile = IssuerTest.class.getResource("cxf-client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = IssuerTest.class.getResource("DoubleIt.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItTransportSAML2Soap12Port");
DoubleItPortType transportSaml2Port = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(transportSaml2Port, PORT);
doubleIt(transportSaml2Port, 25);
((java.io.Closeable) transportSaml2Port).close();
bus.shutdown(true);
}
use of org.example.contract.doubleit.DoubleItPortType in project cxf by apache.
the class JAASTest method testSuccessfulInvocationConfig.
// Here the service config has no TLS settings for the call to the STS...it's configured
// separately via the JAAS configuration
@org.junit.Test
@org.junit.Ignore
public void testSuccessfulInvocationConfig() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = JAASTest.class.getResource("cxf-client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = JAASTest.class.getResource("DoubleIt.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItUTPort");
DoubleItPortType utPort = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(utPort, PORT2);
((BindingProvider) utPort).getRequestContext().put(SecurityConstants.USERNAME, "alice");
((BindingProvider) utPort).getRequestContext().put(SecurityConstants.PASSWORD, "clarinet");
doubleIt(utPort, 25);
((java.io.Closeable) utPort).close();
bus.shutdown(true);
}
use of org.example.contract.doubleit.DoubleItPortType in project cxf by apache.
the class JAASTest method testSuccessfulInvocationWithProperties.
@org.junit.Test
public void testSuccessfulInvocationWithProperties() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = JAASTest.class.getResource("cxf-client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = JAASTest.class.getResource("DoubleIt.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItUTPort2");
DoubleItPortType utPort = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(utPort, PORT);
((BindingProvider) utPort).getRequestContext().put(SecurityConstants.USERNAME, "alice");
((BindingProvider) utPort).getRequestContext().put(SecurityConstants.PASSWORD, "clarinet");
doubleIt(utPort, 25);
// Note that the UsernameToken should be cached for the second invocation
doubleIt(utPort, 35);
((java.io.Closeable) utPort).close();
bus.shutdown(true);
}
Aggregations