use of org.apache.cxf.jaxrs.security.KerberosAuthenticationFilter.KerberosSecurityContext in project cxf by apache.
the class JAXRSIntermediaryPortTypeImpl method doubleIt.
public int doubleIt(int numberToDouble) {
URL wsdl = JAXRSIntermediaryPortTypeImpl.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, KerberosDelegationTokenTest.PORT);
} catch (Exception ex) {
ex.printStackTrace();
}
// Retrieve delegated credential + set it on the outbound message
SecurityContext securityContext = PhaseInterceptorChain.getCurrentMessage().get(SecurityContext.class);
if (securityContext instanceof KerberosSecurityContext) {
KerberosSecurityContext ksc = (KerberosSecurityContext) securityContext;
try {
GSSCredential delegatedCredential = ksc.getGSSContext().getDelegCred();
Map<String, Object> context = ((BindingProvider) transportPort).getRequestContext();
context.put(SecurityConstants.DELEGATED_CREDENTIAL, delegatedCredential);
} catch (GSSException e) {
e.printStackTrace();
}
}
return transportPort.doubleIt(numberToDouble);
}
Aggregations