use of org.apache.cxf.systest.ws.saml.client.SamlCallbackHandler in project cxf by apache.
the class SamlTokenTest method testSaml2EndorsingPKOverTransport.
@org.junit.Test
public void testSaml2EndorsingPKOverTransport() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = SamlTokenTest.class.getResource("client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = SamlTokenTest.class.getResource("DoubleItSaml.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItSaml2EndorsingTransportPort");
DoubleItPortType saml2Port = service.getPort(portQName, DoubleItPortType.class);
String portNumber = PORT2;
if (STAX_PORT.equals(test.getPort())) {
portNumber = STAX_PORT2;
}
updateAddressPort(saml2Port, portNumber);
if (test.isStreaming()) {
SecurityTestUtil.enableStreaming(saml2Port);
}
SamlCallbackHandler callbackHandler = new SamlCallbackHandler(true, true);
callbackHandler.setConfirmationMethod(SAML2Constants.CONF_HOLDER_KEY);
callbackHandler.setKeyInfoIdentifier(CERT_IDENTIFIER.KEY_VALUE);
((BindingProvider) saml2Port).getRequestContext().put(SecurityConstants.SAML_CALLBACK_HANDLER, callbackHandler);
int result = saml2Port.doubleIt(25);
assertTrue(result == 50);
((java.io.Closeable) saml2Port).close();
bus.shutdown(true);
}
Aggregations