use of org.apache.cxf.ws.security.trust.delegation.ReceivedTokenCallbackHandler 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);
}
Aggregations