Java Code Examples for org.apache.cxf.binding.soap.SoapMessage#containsKey()

The following examples show how to use org.apache.cxf.binding.soap.SoapMessage#containsKey() . 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: UsernameTokenInterceptor.java    From steady with Apache License 2.0 6 votes vote down vote up
public void handleMessage(SoapMessage message) throws Fault {

        boolean isReq = MessageUtils.isRequestor(message);
        boolean isOut = MessageUtils.isOutbound(message);
        if (isReq != isOut) {
            //outbound on server side and inbound on client side doesn't need
            //any username token stuff, assert policies and return
            assertUsernameTokens(message, null);
            return;
        }
        if (isReq) {
            if (message.containsKey(PolicyBasedWSS4JOutInterceptor.SECURITY_PROCESSED)) {
                //The full policy interceptors handled this
                return;
            }
            addUsernameToken(message);
        } else {
            if (message.containsKey(WSS4JInInterceptor.SECURITY_PROCESSED)) {
                //The full policy interceptors handled this
                return;
            }
            processUsernameToken(message);
        }
    }
 
Example 2
Source File: SamlTokenInterceptor.java    From steady with Apache License 2.0 6 votes vote down vote up
public void handleMessage(SoapMessage message) throws Fault {

        boolean isReq = MessageUtils.isRequestor(message);
        boolean isOut = MessageUtils.isOutbound(message);
        
        if (isReq != isOut) {
            //outbound on server side and inbound on client side doesn't need
            //any saml token stuff, assert policies and return
            assertSamlTokens(message);
            return;
        }
        if (isReq) {
            if (message.containsKey(PolicyBasedWSS4JOutInterceptor.SECURITY_PROCESSED)) {
                //The full policy interceptors handled this
                return;
            }
            addSamlToken(message);
        } else {
            if (message.containsKey(WSS4JInInterceptor.SECURITY_PROCESSED)) {
                //The full policy interceptors handled this
                return;
            }
            processSamlToken(message);
        }
    }
 
Example 3
Source File: UsernameTokenInterceptor.java    From steady with Apache License 2.0 6 votes vote down vote up
public void handleMessage(SoapMessage message) throws Fault {

        boolean isReq = MessageUtils.isRequestor(message);
        boolean isOut = MessageUtils.isOutbound(message);
        if (isReq != isOut) {
            //outbound on server side and inbound on client side doesn't need
            //any username token stuff, assert policies and return
            assertUsernameTokens(message, null);
            return;
        }
        if (isReq) {
            if (message.containsKey(PolicyBasedWSS4JOutInterceptor.SECURITY_PROCESSED)) {
                //The full policy interceptors handled this
                return;
            }
            addUsernameToken(message);
        } else {
            if (message.containsKey(WSS4JInInterceptor.SECURITY_PROCESSED)) {
                //The full policy interceptors handled this
                return;
            }
            processUsernameToken(message);
        }
    }
 
Example 4
Source File: SamlTokenInterceptor.java    From steady with Apache License 2.0 6 votes vote down vote up
public void handleMessage(SoapMessage message) throws Fault {

        boolean isReq = MessageUtils.isRequestor(message);
        boolean isOut = MessageUtils.isOutbound(message);
        
        if (isReq != isOut) {
            //outbound on server side and inbound on client side doesn't need
            //any saml token stuff, assert policies and return
            assertSamlTokens(message);
            return;
        }
        if (isReq) {
            if (message.containsKey(PolicyBasedWSS4JOutInterceptor.SECURITY_PROCESSED)) {
                //The full policy interceptors handled this
                return;
            }
            addSamlToken(message);
        } else {
            if (message.containsKey(WSS4JInInterceptor.SECURITY_PROCESSED)) {
                //The full policy interceptors handled this
                return;
            }
            processSamlToken(message);
        }
    }
 
Example 5
Source File: UsernameTokenInterceptor.java    From steady with Apache License 2.0 6 votes vote down vote up
public void handleMessage(SoapMessage message) throws Fault {

        boolean isReq = MessageUtils.isRequestor(message);
        boolean isOut = MessageUtils.isOutbound(message);
        if (isReq != isOut) {
            //outbound on server side and inbound on client side doesn't need
            //any username token stuff, assert policies and return
            assertUsernameTokens(message, null);
            return;
        }
        if (isReq) {
            if (message.containsKey(PolicyBasedWSS4JOutInterceptor.SECURITY_PROCESSED)) {
                //The full policy interceptors handled this
                return;
            }
            addUsernameToken(message);
        } else {
            if (message.containsKey(WSS4JInInterceptor.SECURITY_PROCESSED)) {
                //The full policy interceptors handled this
                return;
            }
            processUsernameToken(message);
        }
    }
 
Example 6
Source File: SamlTokenInterceptor.java    From steady with Apache License 2.0 6 votes vote down vote up
public void handleMessage(SoapMessage message) throws Fault {

        boolean isReq = MessageUtils.isRequestor(message);
        boolean isOut = MessageUtils.isOutbound(message);
        
        if (isReq != isOut) {
            //outbound on server side and inbound on client side doesn't need
            //any saml token stuff, assert policies and return
            assertSamlTokens(message);
            return;
        }
        if (isReq) {
            if (message.containsKey(PolicyBasedWSS4JOutInterceptor.SECURITY_PROCESSED)) {
                //The full policy interceptors handled this
                return;
            }
            addSamlToken(message);
        } else {
            if (message.containsKey(WSS4JInInterceptor.SECURITY_PROCESSED)) {
                //The full policy interceptors handled this
                return;
            }
            processSamlToken(message);
        }
    }
 
Example 7
Source File: UsernameTokenInterceptor.java    From steady with Apache License 2.0 6 votes vote down vote up
public void handleMessage(SoapMessage message) throws Fault {

        boolean isReq = MessageUtils.isRequestor(message);
        boolean isOut = MessageUtils.isOutbound(message);
        if (isReq != isOut) {
            //outbound on server side and inbound on client side doesn't need
            //any username token stuff, assert policies and return
            assertUsernameTokens(message, null);
            return;
        }
        if (isReq) {
            if (message.containsKey(PolicyBasedWSS4JOutInterceptor.SECURITY_PROCESSED)) {
                //The full policy interceptors handled this
                return;
            }
            addUsernameToken(message);
        } else {
            if (message.containsKey(WSS4JInInterceptor.SECURITY_PROCESSED)) {
                //The full policy interceptors handled this
                return;
            }
            processUsernameToken(message);
        }
    }
 
Example 8
Source File: SamlTokenInterceptor.java    From steady with Apache License 2.0 6 votes vote down vote up
public void handleMessage(SoapMessage message) throws Fault {

        boolean isReq = MessageUtils.isRequestor(message);
        boolean isOut = MessageUtils.isOutbound(message);
        
        if (isReq != isOut) {
            //outbound on server side and inbound on client side doesn't need
            //any saml token stuff, assert policies and return
            assertSamlTokens(message);
            return;
        }
        if (isReq) {
            if (message.containsKey(PolicyBasedWSS4JOutInterceptor.SECURITY_PROCESSED)) {
                //The full policy interceptors handled this
                return;
            }
            addSamlToken(message);
        } else {
            if (message.containsKey(WSS4JInInterceptor.SECURITY_PROCESSED)) {
                //The full policy interceptors handled this
                return;
            }
            processSamlToken(message);
        }
    }
 
Example 9
Source File: WSS4JInInterceptor.java    From cxf with Apache License 2.0 6 votes vote down vote up
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 10
Source File: AbstractTokenInterceptor.java    From cxf with Apache License 2.0 5 votes vote down vote up
public void handleMessage(SoapMessage message) throws Fault {

        boolean enableStax =
            MessageUtils.getContextualBoolean(message, SecurityConstants.ENABLE_STREAMING_SECURITY, false);
        if (enableStax) {
            return;
        }

        boolean isReq = MessageUtils.isRequestor(message);
        boolean isOut = MessageUtils.isOutbound(message);

        if (isReq != isOut) {
            //outbound on server side and inbound on client side doesn't need
            //any specific token stuff, assert policies and return
            assertTokens(message);
            return;
        }
        if (isReq) {
            if (message.containsKey(PolicyBasedWSS4JOutInterceptor.SECURITY_PROCESSED)) {
                //The full policy interceptors handled this
                return;
            }
            addToken(message);
        } else {
            if (message.containsKey(WSS4JInInterceptor.SECURITY_PROCESSED)) {
                //The full policy interceptors handled this
                return;
            }
            processToken(message);
        }
    }
 
Example 11
Source File: MAPCodec.java    From cxf with Apache License 2.0 5 votes vote down vote up
/**
 * Invoked when unwinding normal interceptor chain when a fault occurred.
 *
 * @param message the messsage message
 */
public void handleFault(SoapMessage message) {
    if (!message.getExchange().isOneWay()) {
        AddressingProperties maps = ContextUtils.retrieveMAPs(message, false, true, false);
        if (ContextUtils.isRequestor(message)
            && maps != null) {
            //fault occurred trying to send the message, remove it
            uncorrelatedExchanges.remove(maps.getMessageID().getValue());
        } else if (!ContextUtils.isRequestor(message)
            && maps == null
            && !message.containsKey(MAPAggregator.class.getName())) {
            //fault occurred while processing the incoming message, but possibly
            //before the MAPAggregator was called.   We need to see if we can
            //try and map this if at all possible so a FaultTo/ReplyTo can
            //be properly determined to get the fault back to the rightful
            //place.
            for (Interceptor<? extends Message> i : message.getInterceptorChain()) {
                if (i instanceof MAPAggregator) {
                    try {
                        MAPAggregator agg = (MAPAggregator)i;
                        agg.handleMessage(message);
                    } catch (Throwable t) {
                        //ignore
                    }
                    return;
                }
            }
        }
    }
    if (MessageUtils.getContextualBoolean(message, DECOUPLED_FAULT_SUPPORT, false)) {
        new DecoupledFaultHandler().handleFault(message);
    }
}
 
Example 12
Source File: SoapActionInInterceptor.java    From cxf with Apache License 2.0 4 votes vote down vote up
public static String getSoapAction(Message m) {
    if (!(m instanceof SoapMessage)) {
        return null;
    }
    SoapMessage message = (SoapMessage)m;
    if (message.getVersion() instanceof Soap11) {
        Map<String, List<String>> headers
            = CastUtils.cast((Map<?, ?>)message.get(Message.PROTOCOL_HEADERS));
        if (headers != null) {
            List<String> sa = headers.get(SoapBindingConstants.SOAP_ACTION);
            if (sa != null && !sa.isEmpty()) {
                String action = sa.get(0);
                if (action.startsWith("\"") || action.startsWith("\'")) {
                    action = action.substring(1, action.length() - 1);
                }
                return action;
            }
        }
    } else if (message.getVersion() instanceof Soap12) {
        String ct = (String) message.get(Message.CONTENT_TYPE);

        if (ct == null) {
            return null;
        }

        int start = ct.indexOf("action=");
        if (start == -1 && ct.indexOf("multipart/related") == 0 && ct.indexOf("start-info") == -1) {
            // the action property may not be found at the package's content-type for non-mtom multipart message
            // but skip searching if the start-info property is set
            List<String> cts = CastUtils.cast((List<?>)(((Map<?, ?>)
                message.get(AttachmentDeserializer.ATTACHMENT_PART_HEADERS)).get(Message.CONTENT_TYPE)));
            if (cts != null && !cts.isEmpty()) {
                ct = cts.get(0);
                start = ct.indexOf("action=");
            }
        }
        if (start != -1) {
            int end;
            char c = ct.charAt(start + 7);
            // handle the extraction robustly
            if (c == '\"') {
                start += 8;
                end = ct.indexOf('\"', start);
            } else if (c == '\\' && ct.charAt(start + 8) == '\"') {
                start += 9;
                end = ct.indexOf('\\', start);
            } else {
                start += 7;
                end = ct.indexOf(';', start);
                if (end == -1) {
                    end = ct.length();
                }
            }
            return ct.substring(start, end);
        }
    }

    // Return the Soap Action for the JMS Case
    if (message.containsKey(SoapJMSInInterceptor.JMS_SOAP_ACTION_VALUE)) {
        return (String)message.get(SoapJMSInInterceptor.JMS_SOAP_ACTION_VALUE);
    }

    return null;
}