use of org.example.contract.doubleit.DoubleItPortType in project cxf by apache.
the class CrossDomainTest method testCrossDomain.
// In this test, a CXF client checks to see that the location defined on its STSClient is different
// from that configured in the Issuer of the IssuedToken policy supplied in the WSDL of the
// service provider. It obtains a SAML Token from the configured STS first, and then sends it in
// the security header to the second STS. The returned token is then sent to the service provider.
// This illustrates cross-domain SSO: https://issues.apache.org/jira/browse/CXF-3520
@org.junit.Test
@org.junit.Ignore
public void testCrossDomain() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = CrossDomainTest.class.getResource("cxf-client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = CrossDomainTest.class.getResource("DoubleIt.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItCrossDomainPort");
DoubleItPortType transportPort = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(transportPort, PORT);
// Transport port
doubleIt(transportPort, 25);
((java.io.Closeable) transportPort).close();
bus.shutdown(true);
}
use of org.example.contract.doubleit.DoubleItPortType in project cxf by apache.
the class CrossDomainTest method testCrossDomainMEX.
// The Service references STS "b". The WSDL of STS "b" has an IssuedToken that references STS "a".
// So the client gets the WSDL of "b" via WS-MEX, which in turn has an IssuedToken policy.
// The client has a configured STSClient for this + uses it to get a token from "a", and in
// turn to use the returned token to get a token from "b", to access the service.
@org.junit.Test
public void testCrossDomainMEX() throws Exception {
if (!portFree) {
return;
}
SpringBusFactory bf = new SpringBusFactory();
URL busFile = CrossDomainTest.class.getResource("cxf-client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = CrossDomainTest.class.getResource("DoubleIt.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItCrossDomainMEXPort");
DoubleItPortType transportPort = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(transportPort, PORT);
// Transport port
doubleIt(transportPort, 25);
((java.io.Closeable) transportPort).close();
bus.shutdown(true);
}
use of org.example.contract.doubleit.DoubleItPortType in project cxf by apache.
the class CustomParameterTest method testCustomParameterInRST2Validator.
// Here the custom parameter in the RST is parsed by the CustomUTValidator
@org.junit.Test
public void testCustomParameterInRST2Validator() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = CustomParameterTest.class.getResource("cxf-client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = CustomParameterTest.class.getResource("DoubleIt.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItTransportCustomParameterPort");
DoubleItPortType transportClaimsPort = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(transportClaimsPort, PORT);
TokenTestUtils.updateSTSPort((BindingProvider) transportClaimsPort, STSPORT);
STSClient stsClient = new STSClient(bus);
stsClient.setWsdlLocation("https://localhost:" + STSPORT + "/SecurityTokenService/UT?wsdl");
stsClient.setServiceName("{http://docs.oasis-open.org/ws-sx/ws-trust/200512/}SecurityTokenService");
stsClient.setEndpointName("{http://docs.oasis-open.org/ws-sx/ws-trust/200512/}UT_Port");
Map<String, Object> properties = new HashMap<>();
properties.put(SecurityConstants.USERNAME, "alice");
properties.put(SecurityConstants.CALLBACK_HANDLER, "org.apache.cxf.systest.sts.common.CommonCallbackHandler");
properties.put("security.sts.token.username", "myclientkey");
properties.put("security.sts.token.properties", "clientKeystore.properties");
properties.put("security.sts.token.usecert", "true");
stsClient.setProperties(properties);
((BindingProvider) transportClaimsPort).getRequestContext().put(SecurityConstants.STS_CLIENT, stsClient);
// Failing test
// Add custom content to the RST
stsClient.setCustomContent("<realm xmlns=\"http://cxf.apache.org/custom\">custom-unknown-realm</realm>");
try {
doubleIt(transportClaimsPort, 25);
fail("Failure expected on the wrong realm");
} catch (Exception ex) {
// expected
}
((java.io.Closeable) transportClaimsPort).close();
bus.shutdown(true);
}
use of org.example.contract.doubleit.DoubleItPortType in project cxf by apache.
the class CustomParameterTest method testCustomParameterInRSTClaimsHandler.
// Here the custom parameter in the RST is parsed by the CustomClaimsHandler
@org.junit.Test
public void testCustomParameterInRSTClaimsHandler() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = CustomParameterTest.class.getResource("cxf-client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = CustomParameterTest.class.getResource("DoubleIt.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItTransportCustomParameterClaimsPort");
DoubleItPortType transportClaimsPort = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(transportClaimsPort, PORT);
TokenTestUtils.updateSTSPort((BindingProvider) transportClaimsPort, STSPORT);
STSClient stsClient = new STSClient(bus);
stsClient.setWsdlLocation("https://localhost:" + STSPORT + "/SecurityTokenService/Transport?wsdl");
stsClient.setServiceName("{http://docs.oasis-open.org/ws-sx/ws-trust/200512/}SecurityTokenService");
stsClient.setEndpointName("{http://docs.oasis-open.org/ws-sx/ws-trust/200512/}Transport_Port");
Map<String, Object> properties = new HashMap<>();
properties.put(SecurityConstants.USERNAME, "alice");
properties.put(SecurityConstants.CALLBACK_HANDLER, "org.apache.cxf.systest.sts.common.CommonCallbackHandler");
properties.put("security.sts.token.username", "myclientkey");
properties.put("security.sts.token.properties", "clientKeystore.properties");
properties.put("security.sts.token.usecert", "true");
stsClient.setProperties(properties);
((BindingProvider) transportClaimsPort).getRequestContext().put(SecurityConstants.STS_CLIENT, stsClient);
// Successful test
// Add custom content to the RST
stsClient.setCustomContent("<realm xmlns=\"http://cxf.apache.org/custom\">custom-realm</realm>");
doubleIt(transportClaimsPort, 25);
((java.io.Closeable) transportClaimsPort).close();
bus.shutdown(true);
}
use of org.example.contract.doubleit.DoubleItPortType in project cxf by apache.
the class CustomParameterTest method testCustomParameterInRSTValidator.
// Here the custom parameter in the RST is parsed by the CustomUTValidator
@org.junit.Test
public void testCustomParameterInRSTValidator() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = CustomParameterTest.class.getResource("cxf-client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = CustomParameterTest.class.getResource("DoubleIt.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItTransportCustomParameterPort");
DoubleItPortType transportClaimsPort = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(transportClaimsPort, PORT);
TokenTestUtils.updateSTSPort((BindingProvider) transportClaimsPort, STSPORT);
STSClient stsClient = new STSClient(bus);
stsClient.setWsdlLocation("https://localhost:" + STSPORT + "/SecurityTokenService/UT?wsdl");
stsClient.setServiceName("{http://docs.oasis-open.org/ws-sx/ws-trust/200512/}SecurityTokenService");
stsClient.setEndpointName("{http://docs.oasis-open.org/ws-sx/ws-trust/200512/}UT_Port");
Map<String, Object> properties = new HashMap<>();
properties.put(SecurityConstants.USERNAME, "alice");
properties.put(SecurityConstants.CALLBACK_HANDLER, "org.apache.cxf.systest.sts.common.CommonCallbackHandler");
properties.put("security.sts.token.username", "myclientkey");
properties.put("security.sts.token.properties", "clientKeystore.properties");
properties.put("security.sts.token.usecert", "true");
stsClient.setProperties(properties);
((BindingProvider) transportClaimsPort).getRequestContext().put(SecurityConstants.STS_CLIENT, stsClient);
// Successful test
// Add custom content to the RST
stsClient.setCustomContent("<realm xmlns=\"http://cxf.apache.org/custom\">custom-realm</realm>");
doubleIt(transportClaimsPort, 25);
((java.io.Closeable) transportClaimsPort).close();
bus.shutdown(true);
}
Aggregations