public void testUsernameTokenSAML1Encrypted() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = AsymmetricBindingTest.class.getResource("cxf-client.xml");
Bus bus = bf.createBus(busFile.toString());
SpringBusFactory.setDefaultBus(bus);
SpringBusFactory.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, PORT);
if (standalone) {
TokenTestUtils.updateSTSPort((BindingProvider)asymmetricSaml1EncryptedPort, STSPORT2);
}
// 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);
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);
}