use of javax.xml.ws.handler.MessageContext in project cxf by apache.
the class BaseGreeterImpl method greetMe.
public String greetMe(String me) {
if ("secure".equals(me)) {
MessageContext ctx = getContext().getMessageContext();
return "Hello " + ctx.get(BindingProvider.USERNAME_PROPERTY);
}
if ("principal".equals(me)) {
return "Hello " + getContext().getUserPrincipal().getName();
}
LOG.info("Invoking greetMe " + prefix + me);
invocationCount++;
return "Hello " + me;
}
use of javax.xml.ws.handler.MessageContext in project cxf by apache.
the class DoubleItPortTypeImpl method doubleIt.
/**
* Disable the STSClient after the first successful invocation
*/
public int doubleIt(int numberToDouble) {
MessageContext context = wsc.getMessageContext();
WrappedMessageContext wmc = (WrappedMessageContext) context;
Exchange exchange = wmc.getWrappedMessage().getExchange();
exchange.getEndpoint().put(SecurityConstants.STS_CLIENT, new STSClient(exchange.getBus()));
return numberToDouble * 2;
}
use of javax.xml.ws.handler.MessageContext 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, KerberosDelegationTokenTest.PORT);
} catch (Exception ex) {
ex.printStackTrace();
}
// Retrieve delegated credential + set it on the outbound message
MessageContext messageContext = wsc.getMessageContext();
GSSCredential delegatedCredential = (GSSCredential) messageContext.get(SecurityConstants.DELEGATED_CREDENTIAL);
Map<String, Object> context = ((BindingProvider) transportPort).getRequestContext();
context.put(SecurityConstants.DELEGATED_CREDENTIAL, delegatedCredential);
STSClient stsClient = (STSClient) context.get(SecurityConstants.STS_CLIENT);
if (stsClient != null) {
String location = stsClient.getWsdlLocation();
if (location.contains("8443")) {
stsClient.setWsdlLocation(location.replace("8443", KerberosDelegationTokenTest.STSPORT));
}
}
return transportPort.doubleIt(numberToDouble);
}
use of javax.xml.ws.handler.MessageContext in project cxf by apache.
the class DoubleItPortTypeImpl method doubleIt.
public int doubleIt(int numberToDouble) {
//
// Get the transformed SAML Assertion from the STS and check it
//
MessageContext context = wsc.getMessageContext();
final List<WSHandlerResult> handlerResults = CastUtils.cast((List<?>) context.get(WSHandlerConstants.RECV_RESULTS));
WSSecurityEngineResult actionResult = handlerResults.get(0).getActionResults().get(WSConstants.UT).get(0);
SamlAssertionWrapper assertion = (SamlAssertionWrapper) actionResult.get(WSSecurityEngineResult.TAG_TRANSFORMED_TOKEN);
Assert.assertTrue(assertion != null && "DoubleItSTSIssuer".equals(assertion.getIssuerString()));
return numberToDouble * 2;
}
use of javax.xml.ws.handler.MessageContext in project cxf by apache.
the class TwoWayJMSImplBase method greetMe.
public String greetMe(String me) {
if (me.startsWith("PauseForTwoSecs")) {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
// ignore
}
me = me.substring("PauseForTwoSecs".length()).trim();
}
MessageContext mc = wsContext.getMessageContext();
JMSMessageHeadersType responseHeaders = (JMSMessageHeadersType) mc.get(JMSConstants.JMS_SERVER_RESPONSE_HEADERS);
responseHeaders.putProperty("Test_Prop", "some return value " + me);
return "Hello " + me;
}
Aggregations