use of javax.xml.ws.Service in project cxf by apache.
the class AsymmetricBindingTest method testUsernameTokenSAML1.
@org.junit.Test
public void testUsernameTokenSAML1() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = AsymmetricBindingTest.class.getResource("cxf-client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = AsymmetricBindingTest.class.getResource("DoubleIt.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricSAML1Port");
DoubleItPortType asymmetricSaml1Port = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(asymmetricSaml1Port, test.getPort());
TokenTestUtils.updateSTSPort((BindingProvider) asymmetricSaml1Port, test.getStsPort());
if (test.isStreaming()) {
SecurityTestUtil.enableStreaming(asymmetricSaml1Port);
}
doubleIt(asymmetricSaml1Port, 25);
((java.io.Closeable) asymmetricSaml1Port).close();
bus.shutdown(true);
}
use of javax.xml.ws.Service in project cxf by apache.
the class AsymmetricBindingTest method testUsernameTokenSAML1Encrypted.
@org.junit.Test
public void testUsernameTokenSAML1Encrypted() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = AsymmetricBindingTest.class.getResource("cxf-client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = AsymmetricBindingTest.class.getResource("DoubleIt.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricSAML1EncryptedPort");
DoubleItPortType asymmetricSaml1EncryptedPort = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(asymmetricSaml1EncryptedPort, test.getPort());
TokenTestUtils.updateSTSPort((BindingProvider) asymmetricSaml1EncryptedPort, test.getStsPort());
if (test.isStreaming()) {
SecurityTestUtil.enableStreaming(asymmetricSaml1EncryptedPort);
}
// Set the X509Certificate manually on the STSClient (just to test that we can)
BindingProvider bindingProvider = (BindingProvider) asymmetricSaml1EncryptedPort;
STSClient stsClient = (STSClient) bindingProvider.getRequestContext().get(SecurityConstants.STS_CLIENT);
if (stsClient == null) {
stsClient = (STSClient) bindingProvider.getRequestContext().get("ws-" + SecurityConstants.STS_CLIENT);
}
Crypto crypto = CryptoFactory.getInstance("clientKeystore.properties");
CryptoType cryptoType = new CryptoType(CryptoType.TYPE.ALIAS);
cryptoType.setAlias("myclientkey");
X509Certificate[] certs = crypto.getX509Certificates(cryptoType);
stsClient.setUseKeyCertificate(certs[0]);
doubleIt(asymmetricSaml1EncryptedPort, 40);
((java.io.Closeable) asymmetricSaml1EncryptedPort).close();
bus.shutdown(true);
}
use of javax.xml.ws.Service in project cxf by apache.
the class BearerTest method testSAML2Bearer.
@org.junit.Test
public void testSAML2Bearer() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = BearerTest.class.getResource("cxf-client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = BearerTest.class.getResource("DoubleIt.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItTransportSAML2BearerPort");
DoubleItPortType transportSaml2Port = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(transportSaml2Port, test.getPort());
TokenTestUtils.updateSTSPort((BindingProvider) transportSaml2Port, test.getStsPort());
if (test.isStreaming()) {
SecurityTestUtil.enableStreaming(transportSaml2Port);
}
doubleIt(transportSaml2Port, 45);
((java.io.Closeable) transportSaml2Port).close();
bus.shutdown(true);
}
use of javax.xml.ws.Service in project cxf by apache.
the class IntermediaryCachingPortTypeImpl method doubleIt.
public int doubleIt(int numberToDouble) {
if (transportPort == null) {
// Re-use the same proxy
URL wsdl = IntermediaryCachingPortTypeImpl.class.getResource("DoubleIt.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItTransportSAML2Port");
transportPort = service.getPort(portQName, DoubleItPortType.class);
try {
updateAddressPort(transportPort, IntermediaryTransformationCachingTest.PORT2);
} catch (Exception ex) {
ex.printStackTrace();
}
if ("standalone".equals(System.getProperty("sts.deployment"))) {
Map<String, Object> context = ((BindingProvider) transportPort).getRequestContext();
STSClient stsClient = (STSClient) context.get(SecurityConstants.STS_CLIENT);
if (stsClient == null) {
stsClient = (STSClient) context.get("ws-" + SecurityConstants.STS_CLIENT);
}
if (stsClient != null) {
String location = stsClient.getWsdlLocation();
if (location.contains("8080")) {
stsClient.setWsdlLocation(location.replace("8080", IntermediaryTransformationCachingTest.STSPORT2));
} else if (location.contains("8443")) {
stsClient.setWsdlLocation(location.replace("8443", IntermediaryTransformationCachingTest.STSPORT));
}
}
}
}
Principal pr = wsc.getUserPrincipal();
Assert.assertNotNull("Principal must not be null", pr);
Assert.assertNotNull("Principal.getName() must not return null", pr.getName());
// Disable the STSClient after the second invocation
if (i > 1) {
BindingProvider p = (BindingProvider) transportPort;
STSClient stsClient = new STSClient(null);
stsClient.setOnBehalfOf(new ReceivedTokenCallbackHandler());
p.getRequestContext().put(SecurityConstants.STS_CLIENT, stsClient);
}
i++;
return transportPort.doubleIt(numberToDouble);
}
use of javax.xml.ws.Service in project cxf by apache.
the class IntermediaryPortTypeImpl method doubleIt.
public int doubleIt(int numberToDouble) {
Principal pr = wsc.getUserPrincipal();
Assert.assertNotNull("Principal must not be null", pr);
Assert.assertNotNull("Principal.getName() must not return null", pr.getName());
URL wsdl = IntermediaryPortTypeImpl.class.getResource("DoubleIt.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItTransportSAML2Port");
DoubleItPortType transportPort = service.getPort(portQName, DoubleItPortType.class);
try {
updateAddressPort(transportPort, IntermediaryTransformationTest.PORT2);
} catch (Exception ex) {
ex.printStackTrace();
}
if ("standalone".equals(System.getProperty("sts.deployment"))) {
Map<String, Object> context = ((BindingProvider) transportPort).getRequestContext();
STSClient stsClient = (STSClient) context.get(SecurityConstants.STS_CLIENT);
if (stsClient == null) {
stsClient = (STSClient) context.get("ws-" + SecurityConstants.STS_CLIENT);
}
if (stsClient != null) {
String location = stsClient.getWsdlLocation();
if (location.contains("8080")) {
stsClient.setWsdlLocation(location.replace("8080", IntermediaryTransformationTest.STSPORT2));
} else if (location.contains("8443")) {
stsClient.setWsdlLocation(location.replace("8443", IntermediaryTransformationTest.STSPORT));
}
}
}
return transportPort.doubleIt(numberToDouble);
}
Aggregations