Java Code Examples for org.apache.cxf.binding.soap.SoapMessage#getExchange()
The following examples show how to use
org.apache.cxf.binding.soap.SoapMessage#getExchange() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WSS4JInInterceptor.java From cxf with Apache License 2.0 | 6 votes |
public void handleMessage(SoapMessage msg) throws Fault { if (msg.containsKey(SECURITY_PROCESSED) || isGET(msg) || msg.getExchange() == null) { return; } Object provider = msg.getExchange().get(Provider.class); final boolean useCustomProvider = provider != null && ThreadLocalSecurityProvider.isInstalled(); try { if (useCustomProvider) { ThreadLocalSecurityProvider.setProvider((Provider)provider); } handleMessageInternal(msg); } finally { if (useCustomProvider) { ThreadLocalSecurityProvider.unsetProvider(); } } }
Example 2
Source File: SOAPHandlerInterceptor.java From cxf with Apache License 2.0 | 5 votes |
@Override protected MessageContext createProtocolMessageContext(SoapMessage message) { SOAPMessageContextImpl sm = new SOAPMessageContextImpl(message); Exchange exch = message.getExchange(); setupBindingOperationInfo(exch, sm); SOAPMessage msg = sm.getMessage(); if (msg != null) { try { List<SOAPElement> params = new ArrayList<>(); message.put(MessageContext.REFERENCE_PARAMETERS, params); SOAPHeader head = SAAJUtils.getHeader(msg); if (head != null) { Iterator<Node> it = CastUtils.cast(head.getChildElements()); while (it != null && it.hasNext()) { Node nd = it.next(); if (nd instanceof SOAPElement) { SOAPElement el = (SOAPElement) nd; if (el.hasAttributeNS(Names.WSA_NAMESPACE_NAME, "IsReferenceParameter") && ("1".equals(el.getAttributeNS(Names.WSA_NAMESPACE_NAME, "IsReferenceParameter")) || Boolean.parseBoolean(el.getAttributeNS(Names.WSA_NAMESPACE_NAME, "IsReferenceParameter")))) { params.add(el); } } } } if (isRequestor(message) && msg.getSOAPPart().getEnvelope().getBody() != null && msg.getSOAPPart().getEnvelope().getBody().hasFault()) { return null; } } catch (SOAPException e) { throw new Fault(e); } } return sm; }
Example 3
Source File: SwAOutInterceptor.java From cxf with Apache License 2.0 | 5 votes |
public void handleMessage(SoapMessage message) throws Fault { Exchange ex = message.getExchange(); BindingOperationInfo bop = ex.getBindingOperationInfo(); if (bop == null) { return; } if (bop.isUnwrapped()) { bop = bop.getWrappedOperation(); } boolean client = isRequestor(message); BindingMessageInfo bmi = client ? bop.getInput() : bop.getOutput(); if (bmi == null) { return; } SoapBodyInfo sbi = bmi.getExtensor(SoapBodyInfo.class); if (sbi == null || sbi.getAttachments() == null || sbi.getAttachments().isEmpty()) { Service s = ex.getService(); DataBinding db = s.getDataBinding(); if (db instanceof JAXBDataBinding && hasSwaRef((JAXBDataBinding) db)) { setupAttachmentOutput(message); } return; } processAttachments(message, sbi); }
Example 4
Source File: NegotiationUtils.java From steady with Apache License 2.0 | 4 votes |
static void recalcEffectivePolicy( SoapMessage message, String namespace, Policy policy, Invoker invoker, boolean secConv ) { Exchange ex = message.getExchange(); Bus bus = ex.getBus(); PolicyEngine pe = bus.getExtension(PolicyEngine.class); if (null == pe) { return; } Destination destination = ex.getDestination(); try { Endpoint endpoint = message.getExchange().getEndpoint(); TokenStore store = getTokenStore(message); if (secConv) { endpoint = STSUtils.createSCEndpoint(bus, namespace, endpoint.getEndpointInfo().getTransportId(), destination.getAddress().getAddress().getValue(), message.getVersion().getBindingId(), policy); } else { endpoint = STSUtils.createSTSEndpoint(bus, namespace, endpoint.getEndpointInfo().getTransportId(), destination.getAddress().getAddress().getValue(), message.getVersion().getBindingId(), policy, null); } endpoint.getEndpointInfo().setProperty(TokenStore.class.getName(), store); message.getExchange().put(TokenStore.class.getName(), store); EndpointPolicy ep = pe.getServerEndpointPolicy(endpoint.getEndpointInfo(), destination); List<Interceptor<? extends Message>> interceptors = ep.getInterceptors(); for (Interceptor<? extends Message> i : interceptors) { message.getInterceptorChain().add(i); } Collection<Assertion> assertions = ep.getVocabulary(); if (null != assertions) { message.put(AssertionInfoMap.class, new AssertionInfoMap(assertions)); } endpoint.getService().setInvoker(invoker); ex.put(Endpoint.class, endpoint); ex.put(Service.class, endpoint.getService()); ex.put(org.apache.cxf.binding.Binding.class, endpoint.getBinding()); ex.remove(BindingOperationInfo.class); message.put(MAPAggregator.ACTION_VERIFIED, Boolean.TRUE); } catch (Exception exc) { throw new Fault(exc); } }
Example 5
Source File: NegotiationUtils.java From steady with Apache License 2.0 | 4 votes |
static void recalcEffectivePolicy( SoapMessage message, String namespace, Policy policy, Invoker invoker, boolean secConv ) { Exchange ex = message.getExchange(); Bus bus = ex.getBus(); PolicyEngine pe = bus.getExtension(PolicyEngine.class); if (null == pe) { return; } Destination destination = ex.getDestination(); try { Endpoint endpoint = message.getExchange().getEndpoint(); TokenStore store = getTokenStore(message); if (secConv) { endpoint = STSUtils.createSCEndpoint(bus, namespace, endpoint.getEndpointInfo().getTransportId(), destination.getAddress().getAddress().getValue(), message.getVersion().getBindingId(), policy); } else { endpoint = STSUtils.createSTSEndpoint(bus, namespace, endpoint.getEndpointInfo().getTransportId(), destination.getAddress().getAddress().getValue(), message.getVersion().getBindingId(), policy, null); } endpoint.getEndpointInfo().setProperty(TokenStore.class.getName(), store); message.getExchange().put(TokenStore.class.getName(), store); EndpointPolicy ep = pe.getServerEndpointPolicy(endpoint.getEndpointInfo(), destination); List<Interceptor<? extends Message>> interceptors = ep.getInterceptors(); for (Interceptor<? extends Message> i : interceptors) { message.getInterceptorChain().add(i); } Collection<Assertion> assertions = ep.getVocabulary(); if (null != assertions) { message.put(AssertionInfoMap.class, new AssertionInfoMap(assertions)); } endpoint.getService().setInvoker(invoker); ex.put(Endpoint.class, endpoint); ex.put(Service.class, endpoint.getService()); ex.put(org.apache.cxf.binding.Binding.class, endpoint.getBinding()); ex.remove(BindingOperationInfo.class); message.put(MAPAggregator.ACTION_VERIFIED, Boolean.TRUE); } catch (Exception exc) { throw new Fault(exc); } }
Example 6
Source File: NegotiationUtils.java From steady with Apache License 2.0 | 4 votes |
static void recalcEffectivePolicy( SoapMessage message, String namespace, Policy policy, Invoker invoker, boolean secConv ) { Exchange ex = message.getExchange(); Bus bus = ex.getBus(); PolicyEngine pe = bus.getExtension(PolicyEngine.class); if (null == pe) { return; } Destination destination = ex.getDestination(); try { Endpoint endpoint = message.getExchange().getEndpoint(); TokenStore store = getTokenStore(message); if (secConv) { endpoint = STSUtils.createSCEndpoint(bus, namespace, endpoint.getEndpointInfo().getTransportId(), destination.getAddress().getAddress().getValue(), message.getVersion().getBindingId(), policy); } else { endpoint = STSUtils.createSTSEndpoint(bus, namespace, endpoint.getEndpointInfo().getTransportId(), destination.getAddress().getAddress().getValue(), message.getVersion().getBindingId(), policy, null); } endpoint.getEndpointInfo().setProperty(TokenStore.class.getName(), store); message.getExchange().put(TokenStore.class.getName(), store); EndpointPolicy ep = pe.getServerEndpointPolicy(endpoint.getEndpointInfo(), destination); List<Interceptor<? extends Message>> interceptors = ep.getInterceptors(); for (Interceptor<? extends Message> i : interceptors) { message.getInterceptorChain().add(i); } Collection<Assertion> assertions = ep.getVocabulary(); if (null != assertions) { message.put(AssertionInfoMap.class, new AssertionInfoMap(assertions)); } endpoint.getService().setInvoker(invoker); ex.put(Endpoint.class, endpoint); ex.put(Service.class, endpoint.getService()); ex.put(org.apache.cxf.binding.Binding.class, endpoint.getBinding()); ex.remove(BindingOperationInfo.class); message.put(MAPAggregator.ACTION_VERIFIED, Boolean.TRUE); } catch (Exception exc) { throw new Fault(exc); } }
Example 7
Source File: NegotiationUtils.java From steady with Apache License 2.0 | 4 votes |
static void recalcEffectivePolicy( SoapMessage message, String namespace, Policy policy, Invoker invoker, boolean secConv ) { Exchange ex = message.getExchange(); Bus bus = ex.getBus(); PolicyEngine pe = bus.getExtension(PolicyEngine.class); if (null == pe) { return; } Destination destination = ex.getDestination(); try { Endpoint endpoint = message.getExchange().getEndpoint(); TokenStore store = getTokenStore(message); if (secConv) { endpoint = STSUtils.createSCEndpoint(bus, namespace, endpoint.getEndpointInfo().getTransportId(), destination.getAddress().getAddress().getValue(), message.getVersion().getBindingId(), policy); } else { endpoint = STSUtils.createSTSEndpoint(bus, namespace, endpoint.getEndpointInfo().getTransportId(), destination.getAddress().getAddress().getValue(), message.getVersion().getBindingId(), policy, null); } endpoint.getEndpointInfo().setProperty(TokenStore.class.getName(), store); message.getExchange().put(TokenStore.class.getName(), store); EndpointPolicy ep = pe.getServerEndpointPolicy(endpoint.getEndpointInfo(), destination); List<Interceptor<? extends Message>> interceptors = ep.getInterceptors(); for (Interceptor<? extends Message> i : interceptors) { message.getInterceptorChain().add(i); } Collection<Assertion> assertions = ep.getVocabulary(); if (null != assertions) { message.put(AssertionInfoMap.class, new AssertionInfoMap(assertions)); } endpoint.getService().setInvoker(invoker); ex.put(Endpoint.class, endpoint); ex.put(Service.class, endpoint.getService()); ex.put(org.apache.cxf.binding.Binding.class, endpoint.getBinding()); ex.remove(BindingOperationInfo.class); message.put(MAPAggregator.ACTION_VERIFIED, Boolean.TRUE); } catch (Exception exc) { throw new Fault(exc); } }
Example 8
Source File: NegotiationUtils.java From cxf with Apache License 2.0 | 4 votes |
static void recalcEffectivePolicy( SoapMessage message, String namespace, Policy policy, Invoker invoker, boolean secConv ) { Exchange ex = message.getExchange(); Bus bus = ex.getBus(); PolicyEngine pe = bus.getExtension(PolicyEngine.class); if (null == pe) { return; } Destination destination = ex.getDestination(); try { Endpoint endpoint = message.getExchange().getEndpoint(); TokenStore store = TokenStoreUtils.getTokenStore(message); if (secConv) { endpoint = STSUtils.createSCEndpoint(bus, namespace, endpoint.getEndpointInfo().getTransportId(), destination.getAddress().getAddress().getValue(), message.getVersion().getBindingId(), policy); } else { endpoint = STSUtils.createSTSEndpoint(bus, namespace, endpoint.getEndpointInfo().getTransportId(), destination.getAddress().getAddress().getValue(), message.getVersion().getBindingId(), policy, null); } endpoint.getEndpointInfo().setProperty(TokenStore.class.getName(), store); message.getExchange().put(TokenStore.class.getName(), store); EndpointPolicy ep = pe.getServerEndpointPolicy(endpoint.getEndpointInfo(), destination, message); List<Interceptor<? extends Message>> interceptors = ep.getInterceptors(message); message.getInterceptorChain().add(interceptors); Collection<Assertion> assertions = ep.getVocabulary(message); if (null != assertions) { message.put(AssertionInfoMap.class, new AssertionInfoMap(assertions)); } endpoint.getService().setInvoker(invoker); ex.put(Endpoint.class, endpoint); ex.put(Service.class, endpoint.getService()); ex.put(org.apache.cxf.binding.Binding.class, endpoint.getBinding()); ex.remove(BindingOperationInfo.class); message.put(MAPAggregator.ACTION_VERIFIED, Boolean.TRUE); } catch (Exception exc) { throw new Fault(exc); } }
Example 9
Source File: SoapActionInInterceptor.java From cxf with Apache License 2.0 | 4 votes |
public static void getAndSetOperation(SoapMessage message, String action, boolean strict) { if (StringUtils.isEmpty(action)) { return; } Exchange ex = message.getExchange(); Endpoint ep = ex.getEndpoint(); if (ep == null) { return; } BindingOperationInfo bindingOp = null; Collection<BindingOperationInfo> bops = ep.getEndpointInfo() .getBinding().getOperations(); if (bops != null) { for (BindingOperationInfo boi : bops) { if (isActionMatch(message, boi, action)) { if (bindingOp != null) { //more than one op with the same action, will need to parse normally return; } bindingOp = boi; } if (matchWSAAction(boi, action)) { if (bindingOp != null && bindingOp != boi) { //more than one op with the same action, will need to parse normally return; } bindingOp = boi; } } } if (bindingOp == null) { if (strict) { //we didn't match the an operation, we'll try again later to make //sure the incoming message did end up matching an operation. //This could occur in some cases like WS-RM and WS-SecConv that will //intercept the message with a new endpoint/operation message.getInterceptorChain().add(new SoapActionInAttemptTwoInterceptor(action)); } return; } ex.put(BindingOperationInfo.class, bindingOp); }