Modified: axis/site/axis2/java/rampart-staging/code-coverage/org.apache.rampart.util/RampartUtil.java.html URL: http://svn.apache.org/viewvc/axis/site/axis2/java/rampart-staging/code-coverage/org.apache.rampart.util/RampartUtil.java.html?rev=1725383&r1=1725382&r2=1725383&view=diff ============================================================================== --- axis/site/axis2/java/rampart-staging/code-coverage/org.apache.rampart.util/RampartUtil.java.html (original) +++ axis/site/axis2/java/rampart-staging/code-coverage/org.apache.rampart.util/RampartUtil.java.html Mon Jan 18 23:07:55 2016 @@ -128,7 +128,7 @@ import java.util.concurrent.ConcurrentHa CallbackHandler cbHandler; -<span class="pc bpc" id="L131" title="2 of 4 branches missed."> if (rpd.getRampartConfig() != null && rpd.getRampartConfig().getPwCbClass() != null) {</span> +<span class="pc bpc" id="L131" title="1 of 4 branches missed."> if (rpd.getRampartConfig() != null && rpd.getRampartConfig().getPwCbClass() != null) {</span> <span class="fc" id="L133"> String cbHandlerClass = rpd.getRampartConfig().getPwCbClass();</span> <span class="fc" id="L134"> ClassLoader classLoader = msgContext.getAxisService().getClassLoader();</span> @@ -151,12 +151,12 @@ import java.util.concurrent.ConcurrentHa new String[]{cbHandlerClass}, e); <span class="fc" id="L152"> }</span> <span class="fc" id="L153"> } else {</span> -<span class="nc" id="L154"> cbHandler = (CallbackHandler) msgContext.getProperty(</span> +<span class="fc" id="L154"> cbHandler = (CallbackHandler) msgContext.getProperty(</span> WSHandlerConstants.PW_CALLBACK_REF); -<span class="nc bnc" id="L156" title="All 2 branches missed."> if(cbHandler == null) {</span> -<span class="nc" id="L157"> Parameter param = msgContext.getParameter(</span> +<span class="fc bfc" id="L156" title="All 2 branches covered."> if(cbHandler == null) {</span> +<span class="fc" id="L157"> Parameter param = msgContext.getParameter(</span> WSHandlerConstants.PW_CALLBACK_REF); -<span class="nc bnc" id="L159" title="All 2 branches missed."> if(param != null) {</span> +<span class="pc bpc" id="L159" title="1 of 2 branches missed."> if(param != null) {</span> <span class="nc" id="L160"> cbHandler = (CallbackHandler)param.getValue();</span> } } @@ -177,7 +177,7 @@ import java.util.concurrent.ConcurrentHa PolicyValidatorCallbackHandler cbHandler; -<span class="pc bpc" id="L180" title="2 of 4 branches missed."> if (rpd.getRampartConfig() != null && rpd.getRampartConfig().getPolicyValidatorCbClass() != null) {</span> +<span class="pc bpc" id="L180" title="1 of 4 branches missed."> if (rpd.getRampartConfig() != null && rpd.getRampartConfig().getPolicyValidatorCbClass() != null) {</span> <span class="nc" id="L182"> String cbHandlerClass = rpd.getRampartConfig().getPolicyValidatorCbClass();</span> <span class="nc" id="L183"> ClassLoader classLoader = msgContext.getAxisService().getClassLoader();</span> @@ -212,7 +212,7 @@ import java.util.concurrent.ConcurrentHa RampartConfigCallbackHandler rampartConfigCB; -<span class="pc bpc" id="L215" title="1 of 4 branches missed."> if (rpd.getRampartConfig() != null && rpd.getRampartConfig().getRampartConfigCbClass() != null) {</span> +<span class="fc bfc" id="L215" title="All 4 branches covered."> if (rpd.getRampartConfig() != null && rpd.getRampartConfig().getRampartConfigCbClass() != null) {</span> <span class="fc" id="L217"> String cbHandlerClass = rpd.getRampartConfig().getRampartConfigCbClass();</span> <span class="fc" id="L218"> ClassLoader classLoader = msgContext.getAxisService().getClassLoader();</span> @@ -298,7 +298,7 @@ import java.util.concurrent.ConcurrentHa <span class="fc" id="L299"> Crypto crypto = null;</span> -<span class="pc bpc" id="L301" title="1 of 4 branches missed."> if (config != null && config.getEncrCryptoConfig() != null) {</span> +<span class="fc bfc" id="L301" title="All 4 branches covered."> if (config != null && config.getEncrCryptoConfig() != null) {</span> <span class="fc" id="L302"> CryptoConfig cryptoConfig = config.getEncrCryptoConfig();</span> <span class="fc" id="L303"> String provider = cryptoConfig.getProvider();</span> <span class="pc bpc" id="L304" title="1 of 2 branches missed."> if (log.isDebugEnabled()) {</span> @@ -366,7 +366,7 @@ import java.util.concurrent.ConcurrentHa <span class="fc" id="L367"> Crypto crypto = null;</span> -<span class="pc bpc" id="L369" title="1 of 4 branches missed."> if (config != null && config.getSigCryptoConfig() != null) {</span> +<span class="fc bfc" id="L369" title="All 4 branches covered."> if (config != null && config.getSigCryptoConfig() != null) {</span> <span class="fc" id="L370"> CryptoConfig cryptoConfig = config.getSigCryptoConfig();</span> <span class="fc" id="L371"> String provider = cryptoConfig.getProvider();</span> <span class="pc bpc" id="L372" title="1 of 2 branches missed."> if (log.isDebugEnabled()) {</span> @@ -548,7 +548,7 @@ import java.util.concurrent.ConcurrentHa public static int getTimeToLive(RampartMessageData messageData) { <span class="fc" id="L550"> RampartConfig rampartConfig = messageData.getPolicyData().getRampartConfig();</span> -<span class="pc bpc" id="L551" title="1 of 2 branches missed."> if (rampartConfig != null) {</span> +<span class="fc bfc" id="L551" title="All 2 branches covered."> if (rampartConfig != null) {</span> <span class="fc" id="L552"> String ttl = rampartConfig.getTimestampTTL();</span> <span class="fc" id="L553"> int ttl_i = 0;</span> <span class="pc bpc" id="L554" title="1 of 2 branches missed."> if (ttl != null) {</span> @@ -563,14 +563,14 @@ import java.util.concurrent.ConcurrentHa } <span class="fc" id="L564"> return ttl_i;</span> } else { -<span class="nc" id="L566"> return RampartConfig.DEFAULT_TIMESTAMP_TTL;</span> +<span class="fc" id="L566"> return RampartConfig.DEFAULT_TIMESTAMP_TTL;</span> } } public static int getTimestampMaxSkew(RampartMessageData messageData) { <span class="fc" id="L572"> RampartConfig rampartConfig = messageData.getPolicyData().getRampartConfig();</span> -<span class="pc bpc" id="L573" title="1 of 2 branches missed."> if (rampartConfig != null) {</span> +<span class="fc bfc" id="L573" title="All 2 branches covered."> if (rampartConfig != null) {</span> <span class="fc" id="L574"> String maxSkew = rampartConfig.getTimestampMaxSkew();</span> <span class="fc" id="L575"> int maxSkew_i = 0;</span> <span class="pc bpc" id="L576" title="1 of 2 branches missed."> if (maxSkew != null) {</span> @@ -585,7 +585,7 @@ import java.util.concurrent.ConcurrentHa } <span class="fc" id="L586"> return maxSkew_i;</span> } else { -<span class="nc" id="L588"> return RampartConfig.DEFAULT_TIMESTAMP_MAX_SKEW;</span> +<span class="fc" id="L588"> return RampartConfig.DEFAULT_TIMESTAMP_MAX_SKEW;</span> } } @@ -815,203 +815,221 @@ import java.util.concurrent.ConcurrentHa <span class="fc" id="L815"> return id;</span> } + /** + * Change the owner document of the given node. The method first attempts to move the node using + * {@link Document#adoptNode(Node)}. If that fails, it will import the node into the target + * document using {@link Document#importNode(Node, boolean)}. + * + * @param targetDocument + * the target document + * @param node + * the node to adopt or import + * @return the adopted or imported node + */ + public static Node adoptNode(Document targetDocument, Node node) { +<span class="fc" id="L830"> Node result = targetDocument.adoptNode(node);</span> +<span class="pc bpc" id="L831" title="1 of 2 branches missed."> if (result == null) {</span> +<span class="nc" id="L832"> result = targetDocument.importNode(node, true);</span> + } +<span class="fc" id="L834"> return result;</span> + } + public static Element appendChildToSecHeader(RampartMessageData rmd, OMElement elem) { -<span class="fc" id="L820"> return appendChildToSecHeader(rmd, (Element)elem);</span> +<span class="fc" id="L839"> return appendChildToSecHeader(rmd, (Element)elem);</span> } public static Element appendChildToSecHeader(RampartMessageData rmd, Element elem) { -<span class="fc" id="L825"> Element secHeaderElem = rmd.getSecHeader().getSecurityHeader();</span> -<span class="fc" id="L826"> Node node = secHeaderElem.getOwnerDocument().importNode(</span> - elem, true); -<span class="fc" id="L828"> return (Element)secHeaderElem.appendChild(node);</span> +<span class="fc" id="L844"> Element secHeaderElem = rmd.getSecHeader().getSecurityHeader();</span> +<span class="fc" id="L845"> Node node = adoptNode(secHeaderElem.getOwnerDocument(), elem);</span> +<span class="fc" id="L846"> return (Element)secHeaderElem.appendChild(node);</span> } public static Element insertSiblingAfter(RampartMessageData rmd, Element child, Element sibling) { -<span class="fc bfc" id="L833" title="All 2 branches covered."> if (child == null) {</span> -<span class="fc" id="L834"> return appendChildToSecHeader(rmd, sibling);</span> +<span class="fc bfc" id="L851" title="All 2 branches covered."> if (child == null) {</span> +<span class="fc" id="L852"> return appendChildToSecHeader(rmd, sibling);</span> } else { -<span class="fc bfc" id="L836" title="All 2 branches covered."> if (child.getOwnerDocument().equals(sibling.getOwnerDocument())) {</span> +<span class="fc bfc" id="L854" title="All 2 branches covered."> if (child.getOwnerDocument().equals(sibling.getOwnerDocument())) {</span> -<span class="pc bpc" id="L838" title="3 of 4 branches missed."> if (child.getParentNode() == null</span> +<span class="pc bpc" id="L856" title="3 of 4 branches missed."> if (child.getParentNode() == null</span> && !child.getLocalName().equals("UsernameToken")) { -<span class="nc" id="L840"> rmd.getSecHeader().getSecurityHeader().appendChild(child);</span> +<span class="nc" id="L858"> rmd.getSecHeader().getSecurityHeader().appendChild(child);</span> } -<span class="fc" id="L842"> ((OMElement) child).insertSiblingAfter((OMElement) sibling);</span> -<span class="fc" id="L843"> return sibling;</span> +<span class="fc" id="L860"> ((OMElement) child).insertSiblingAfter((OMElement) sibling);</span> +<span class="fc" id="L861"> return sibling;</span> } else { -<span class="fc" id="L845"> Element newSib = (Element) child.getOwnerDocument().importNode(</span> +<span class="fc" id="L863"> Element newSib = (Element) child.getOwnerDocument().importNode(</span> sibling, true); -<span class="fc" id="L847"> ((OMElement) child).insertSiblingAfter((OMElement) newSib);</span> -<span class="fc" id="L848"> return newSib;</span> +<span class="fc" id="L865"> ((OMElement) child).insertSiblingAfter((OMElement) newSib);</span> +<span class="fc" id="L866"> return newSib;</span> } } } public static Element insertSiblingBefore(RampartMessageData rmd, Element child, Element sibling) { -<span class="pc bpc" id="L854" title="1 of 2 branches missed."> if(child == null) {</span> -<span class="nc" id="L855"> return appendChildToSecHeader(rmd, sibling);</span> +<span class="pc bpc" id="L872" title="1 of 2 branches missed."> if(child == null) {</span> +<span class="nc" id="L873"> return appendChildToSecHeader(rmd, sibling);</span> } else { -<span class="pc bpc" id="L857" title="1 of 2 branches missed."> if(child.getOwnerDocument().equals(sibling.getOwnerDocument())) {</span> -<span class="fc" id="L858"> ((OMElement)child).insertSiblingBefore((OMElement)sibling);</span> -<span class="fc" id="L859"> return sibling;</span> +<span class="pc bpc" id="L875" title="1 of 2 branches missed."> if(child.getOwnerDocument().equals(sibling.getOwnerDocument())) {</span> +<span class="fc" id="L876"> ((OMElement)child).insertSiblingBefore((OMElement)sibling);</span> +<span class="fc" id="L877"> return sibling;</span> } else { -<span class="nc" id="L861"> Element newSib = (Element)child.getOwnerDocument().importNode(sibling, true);</span> -<span class="nc" id="L862"> ((OMElement)child).insertSiblingBefore((OMElement)newSib);</span> -<span class="nc" id="L863"> return newSib;</span> +<span class="nc" id="L879"> Element newSib = (Element)child.getOwnerDocument().importNode(sibling, true);</span> +<span class="nc" id="L880"> ((OMElement)child).insertSiblingBefore((OMElement)newSib);</span> +<span class="nc" id="L881"> return newSib;</span> } } } public static List<WSEncryptionPart> getEncryptedParts(RampartMessageData rmd) { -<span class="fc" id="L870"> RampartPolicyData rpd = rmd.getPolicyData();</span> -<span class="fc" id="L871"> SOAPEnvelope envelope = rmd.getMsgContext().getEnvelope();</span> -<span class="pc bpc" id="L872" title="1 of 4 branches missed."> List<WSEncryptionPart> encryptedPartsElements = getPartsAndElements(false, envelope,</span> +<span class="fc" id="L888"> RampartPolicyData rpd = rmd.getPolicyData();</span> +<span class="fc" id="L889"> SOAPEnvelope envelope = rmd.getMsgContext().getEnvelope();</span> +<span class="pc bpc" id="L890" title="1 of 4 branches missed."> List<WSEncryptionPart> encryptedPartsElements = getPartsAndElements(false, envelope,</span> rpd.isEncryptBody() && !rpd.isEncryptBodyOptional(), rpd .getEncryptedParts(), rpd.getEncryptedElements(), rpd .getDeclaredNamespaces()); -<span class="fc" id="L876"> return getContentEncryptedElements(encryptedPartsElements, envelope,</span> +<span class="fc" id="L894"> return getContentEncryptedElements(encryptedPartsElements, envelope,</span> rpd.getContentEncryptedElements(), rpd.getDeclaredNamespaces()); } public static List<WSEncryptionPart> getSignedParts(RampartMessageData rmd) { -<span class="fc" id="L881"> RampartPolicyData rpd = rmd.getPolicyData();</span> -<span class="fc" id="L882"> SOAPEnvelope envelope = rmd.getMsgContext().getEnvelope();</span> +<span class="fc" id="L899"> RampartPolicyData rpd = rmd.getPolicyData();</span> +<span class="fc" id="L900"> SOAPEnvelope envelope = rmd.getMsgContext().getEnvelope();</span> //"signAllHeaders" indicates that all the headers should be signed. -<span class="fc bfc" id="L885" title="All 2 branches covered."> if (rpd.isSignAllHeaders()) {</span> -<span class="fc" id="L886"> Iterator childHeaders = envelope.getHeader().getChildElements();</span> -<span class="fc bfc" id="L887" title="All 2 branches covered."> while (childHeaders.hasNext()) {</span> -<span class="fc" id="L888"> OMElement hb = (OMElement) childHeaders.next();</span> -<span class="pc bpc" id="L889" title="1 of 4 branches missed."> if (!(hb.getLocalName().equals(WSConstants.WSSE_LN)</span> +<span class="fc bfc" id="L903" title="All 2 branches covered."> if (rpd.isSignAllHeaders()) {</span> +<span class="fc" id="L904"> Iterator childHeaders = envelope.getHeader().getChildElements();</span> +<span class="fc bfc" id="L905" title="All 2 branches covered."> while (childHeaders.hasNext()) {</span> +<span class="fc" id="L906"> OMElement hb = (OMElement) childHeaders.next();</span> +<span class="pc bpc" id="L907" title="1 of 4 branches missed."> if (!(hb.getLocalName().equals(WSConstants.WSSE_LN)</span> && hb.getNamespace().getNamespaceURI().equals(WSConstants.WSSE_NS))) { -<span class="fc" id="L891"> rpd.addSignedPart(hb.getNamespace().getNamespaceURI(),hb.getLocalName());</span> +<span class="fc" id="L909"> rpd.addSignedPart(hb.getNamespace().getNamespaceURI(),hb.getLocalName());</span> } -<span class="fc" id="L893"> }</span> +<span class="fc" id="L911"> }</span> } -<span class="pc bpc" id="L896" title="1 of 4 branches missed."> return getPartsAndElements(true, envelope, rpd.isSignBody()</span> +<span class="pc bpc" id="L914" title="1 of 4 branches missed."> return getPartsAndElements(true, envelope, rpd.isSignBody()</span> && !rpd.isSignBodyOptional(), rpd.getSignedParts(), rpd .getSignedElements(), rpd.getDeclaredNamespaces()); } public static List<WSEncryptionPart> getSupportingEncryptedParts(RampartMessageData rmd, SupportingPolicyData rpd) { -<span class="fc" id="L903"> SOAPEnvelope envelope = rmd.getMsgContext().getEnvelope();</span> -<span class="pc bpc" id="L904" title="3 of 4 branches missed."> return getPartsAndElements(false, envelope, rpd.isEncryptBody()</span> +<span class="fc" id="L921"> SOAPEnvelope envelope = rmd.getMsgContext().getEnvelope();</span> +<span class="pc bpc" id="L922" title="3 of 4 branches missed."> return getPartsAndElements(false, envelope, rpd.isEncryptBody()</span> && !rpd.isEncryptBodyOptional(), rpd.getEncryptedParts(), rpd .getEncryptedElements(), rpd.getDeclaredNamespaces()); } public static List<WSEncryptionPart> getSupportingSignedParts(RampartMessageData rmd, SupportingPolicyData rpd) { -<span class="fc" id="L911"> SOAPEnvelope envelope = rmd.getMsgContext().getEnvelope();</span> -<span class="pc bpc" id="L912" title="3 of 4 branches missed."> return getPartsAndElements(true, envelope, rpd.isSignBody()</span> +<span class="fc" id="L929"> SOAPEnvelope envelope = rmd.getMsgContext().getEnvelope();</span> +<span class="pc bpc" id="L930" title="3 of 4 branches missed."> return getPartsAndElements(true, envelope, rpd.isSignBody()</span> && !rpd.isSignBodyOptional(), rpd.getSignedParts(), rpd .getSignedElements(), rpd.getDeclaredNamespaces()); } public static Set findAllPrefixNamespaces(OMElement currentElement, HashMap decNamespacess) { -<span class="fc" id="L919"> Set<OMNamespace> results = new HashSet<OMNamespace>();</span> +<span class="fc" id="L937"> Set<OMNamespace> results = new HashSet<OMNamespace>();</span> //Find declared namespaces -<span class="fc" id="L922"> findPrefixNamespaces(currentElement,results);</span> +<span class="fc" id="L940"> findPrefixNamespaces(currentElement,results);</span> //Get all default namespaces -<span class="fc" id="L925"> List defaultNamespaces = getDefaultPrefixNamespaces(currentElement.getOMFactory());</span> -<span class="fc bfc" id="L926" title="All 2 branches covered."> for (Object defaultNamespace : defaultNamespaces) {</span> -<span class="fc" id="L927"> OMNamespace ns = (OMNamespace) defaultNamespace;</span> -<span class="fc" id="L928"> results.add(ns);</span> -<span class="fc" id="L929"> }</span> - -<span class="fc bfc" id="L931" title="All 2 branches covered."> for (Object o : decNamespacess.keySet()) {</span> -<span class="fc" id="L932"> String prefix = (String) o;</span> -<span class="fc" id="L933"> String ns = (String) decNamespacess.get(prefix);</span> -<span class="fc" id="L934"> OMFactory omFactory = currentElement.getOMFactory();</span> -<span class="fc" id="L935"> OMNamespace namespace = omFactory.createOMNamespace(ns, prefix);</span> -<span class="fc" id="L936"> results.add(namespace);</span> +<span class="fc" id="L943"> List defaultNamespaces = getDefaultPrefixNamespaces(currentElement.getOMFactory());</span> +<span class="fc bfc" id="L944" title="All 2 branches covered."> for (Object defaultNamespace : defaultNamespaces) {</span> +<span class="fc" id="L945"> OMNamespace ns = (OMNamespace) defaultNamespace;</span> +<span class="fc" id="L946"> results.add(ns);</span> +<span class="fc" id="L947"> }</span> + +<span class="fc bfc" id="L949" title="All 2 branches covered."> for (Object o : decNamespacess.keySet()) {</span> +<span class="fc" id="L950"> String prefix = (String) o;</span> +<span class="fc" id="L951"> String ns = (String) decNamespacess.get(prefix);</span> +<span class="fc" id="L952"> OMFactory omFactory = currentElement.getOMFactory();</span> +<span class="fc" id="L953"> OMNamespace namespace = omFactory.createOMNamespace(ns, prefix);</span> +<span class="fc" id="L954"> results.add(namespace);</span> -<span class="fc" id="L938"> }</span> +<span class="fc" id="L956"> }</span> -<span class="fc" id="L940"> return results;</span> +<span class="fc" id="L958"> return results;</span> } private static void findPrefixNamespaces(OMElement e, Set<OMNamespace> results) { -<span class="fc" id="L945"> Iterator iterator = e.getAllDeclaredNamespaces();</span> +<span class="fc" id="L963"> Iterator iterator = e.getAllDeclaredNamespaces();</span> -<span class="pc bpc" id="L947" title="1 of 2 branches missed."> if (iterator != null) {</span> -<span class="fc bfc" id="L948" title="All 2 branches covered."> while (iterator.hasNext())</span> -<span class="fc" id="L949"> results.add((OMNamespace)iterator.next());</span> +<span class="pc bpc" id="L965" title="1 of 2 branches missed."> if (iterator != null) {</span> +<span class="fc bfc" id="L966" title="All 2 branches covered."> while (iterator.hasNext())</span> +<span class="fc" id="L967"> results.add((OMNamespace)iterator.next());</span> } -<span class="fc" id="L952"> Iterator children = e.getChildElements();</span> +<span class="fc" id="L970"> Iterator children = e.getChildElements();</span> -<span class="fc bfc" id="L954" title="All 2 branches covered."> while (children.hasNext()) {</span> -<span class="fc" id="L955"> findPrefixNamespaces((OMElement) children.next(), results);</span> +<span class="fc bfc" id="L972" title="All 2 branches covered."> while (children.hasNext()) {</span> +<span class="fc" id="L973"> findPrefixNamespaces((OMElement) children.next(), results);</span> } -<span class="fc" id="L957"> }</span> +<span class="fc" id="L975"> }</span> private static List getDefaultPrefixNamespaces(OMFactory factory) { -<span class="fc" id="L961"> List<OMNamespace> namespaces = new ArrayList<OMNamespace>();</span> +<span class="fc" id="L979"> List<OMNamespace> namespaces = new ArrayList<OMNamespace>();</span> // put default namespaces here (sp, soapenv, wsu, etc...) -<span class="fc" id="L964"> namespaces.add(factory.createOMNamespace(WSConstants.ENC_NS, WSConstants.ENC_PREFIX));</span> -<span class="fc" id="L965"> namespaces.add(factory.createOMNamespace(WSConstants.SIG_NS, WSConstants.SIG_PREFIX));</span> -<span class="fc" id="L966"> namespaces.add(factory.createOMNamespace(WSConstants.WSSE_NS, WSConstants.WSSE_PREFIX));</span> -<span class="fc" id="L967"> namespaces.add(factory.createOMNamespace(WSConstants.WSU_NS, WSConstants.WSU_PREFIX));</span> +<span class="fc" id="L982"> namespaces.add(factory.createOMNamespace(WSConstants.ENC_NS, WSConstants.ENC_PREFIX));</span> +<span class="fc" id="L983"> namespaces.add(factory.createOMNamespace(WSConstants.SIG_NS, WSConstants.SIG_PREFIX));</span> +<span class="fc" id="L984"> namespaces.add(factory.createOMNamespace(WSConstants.WSSE_NS, WSConstants.WSSE_PREFIX));</span> +<span class="fc" id="L985"> namespaces.add(factory.createOMNamespace(WSConstants.WSU_NS, WSConstants.WSU_PREFIX));</span> -<span class="fc" id="L969"> return namespaces;</span> +<span class="fc" id="L987"> return namespaces;</span> } public static List<WSEncryptionPart> getContentEncryptedElements (List<WSEncryptionPart> encryptedPartsElements, SOAPEnvelope envelope,List<String> elements, HashMap decNamespaces ) { -<span class="fc" id="L976"> Set namespaces = findAllPrefixNamespaces(envelope, decNamespaces);</span> +<span class="fc" id="L994"> Set namespaces = findAllPrefixNamespaces(envelope, decNamespaces);</span> -<span class="fc bfc" id="L978" title="All 2 branches covered."> for (String expression : elements) {</span> +<span class="fc bfc" id="L996" title="All 2 branches covered."> for (String expression : elements) {</span> try { -<span class="fc" id="L980"> XPath xp = new AXIOMXPath(expression);</span> +<span class="fc" id="L998"> XPath xp = new AXIOMXPath(expression);</span> -<span class="fc bfc" id="L982" title="All 2 branches covered."> for (Object objectNamespace : namespaces) {</span> -<span class="fc" id="L983"> OMNamespace tmpNs = (OMNamespace) objectNamespace;</span> -<span class="fc" id="L984"> xp.addNamespace(tmpNs.getPrefix(), tmpNs.getNamespaceURI());</span> -<span class="fc" id="L985"> }</span> +<span class="fc bfc" id="L1000" title="All 2 branches covered."> for (Object objectNamespace : namespaces) {</span> +<span class="fc" id="L1001"> OMNamespace tmpNs = (OMNamespace) objectNamespace;</span> +<span class="fc" id="L1002"> xp.addNamespace(tmpNs.getPrefix(), tmpNs.getNamespaceURI());</span> +<span class="fc" id="L1003"> }</span> -<span class="fc" id="L987"> List selectedNodes = xp.selectNodes(envelope);</span> +<span class="fc" id="L1005"> List selectedNodes = xp.selectNodes(envelope);</span> -<span class="fc bfc" id="L989" title="All 2 branches covered."> for (Object selectedNode : selectedNodes) {</span> -<span class="fc" id="L990"> OMElement e = (OMElement) selectedNode;</span> +<span class="fc bfc" id="L1007" title="All 2 branches covered."> for (Object selectedNode : selectedNodes) {</span> +<span class="fc" id="L1008"> OMElement e = (OMElement) selectedNode;</span> -<span class="fc" id="L992"> String localName = e.getLocalName();</span> -<span class="pc bpc" id="L993" title="1 of 2 branches missed."> String namespace = e.getNamespace() != null ? e.getNamespace().getNamespaceURI() : null;</span> +<span class="fc" id="L1010"> String localName = e.getLocalName();</span> +<span class="pc bpc" id="L1011" title="1 of 2 branches missed."> String namespace = e.getNamespace() != null ? e.getNamespace().getNamespaceURI() : null;</span> -<span class="fc" id="L995"> OMAttribute wsuIdAttribute = e.getAttribute(new QName(WSConstants.WSU_NS, "Id"));</span> +<span class="fc" id="L1013"> OMAttribute wsuIdAttribute = e.getAttribute(new QName(WSConstants.WSU_NS, "Id"));</span> -<span class="fc" id="L997"> String wsuId = null;</span> -<span class="pc bpc" id="L998" title="1 of 2 branches missed."> if (wsuIdAttribute != null) {</span> -<span class="nc" id="L999"> wsuId = wsuIdAttribute.getAttributeValue();</span> +<span class="fc" id="L1015"> String wsuId = null;</span> +<span class="pc bpc" id="L1016" title="1 of 2 branches missed."> if (wsuIdAttribute != null) {</span> +<span class="nc" id="L1017"> wsuId = wsuIdAttribute.getAttributeValue();</span> } -<span class="fc" id="L1002"> encryptedPartsElements.add(createEncryptionPart(localName,</span> +<span class="fc" id="L1020"> encryptedPartsElements.add(createEncryptionPart(localName,</span> wsuId, namespace, "Content", expression)); -<span class="fc" id="L1005"> }</span> +<span class="fc" id="L1023"> }</span> -<span class="nc" id="L1007"> } catch (JaxenException e) {</span> +<span class="nc" id="L1025"> } catch (JaxenException e) {</span> // This has to be changed to propagate an instance of a RampartException up -<span class="nc" id="L1009"> throw new RuntimeException(e);</span> -<span class="fc" id="L1010"> }</span> -<span class="fc" id="L1011"> }</span> +<span class="nc" id="L1027"> throw new RuntimeException(e);</span> +<span class="fc" id="L1028"> }</span> +<span class="fc" id="L1029"> }</span> -<span class="fc" id="L1014"> return encryptedPartsElements;</span> +<span class="fc" id="L1032"> return encryptedPartsElements;</span> } @@ -1024,7 +1042,7 @@ import java.util.concurrent.ConcurrentHa */ public static WSEncryptionPart createEncryptionPart (String name, String id) { -<span class="fc" id="L1027"> return createEncryptionPart(name, id, null, null, null);</span> +<span class="fc" id="L1045"> return createEncryptionPart(name, id, null, null, null);</span> } /** @@ -1038,7 +1056,7 @@ import java.util.concurrent.ConcurrentHa public static WSEncryptionPart createEncryptionPart(String name, String id, String namespace, String modifier) { -<span class="fc" id="L1041"> return createEncryptionPart(name, id, namespace, modifier, null);</span> +<span class="fc" id="L1059"> return createEncryptionPart(name, id, namespace, modifier, null);</span> } /** @@ -1054,138 +1072,138 @@ import java.util.concurrent.ConcurrentHa String namespace, String modifier,String xPath) { // The part name must not be null !! -<span class="pc bpc" id="L1057" title="1 of 4 branches missed."> assert name != null;</span> +<span class="pc bpc" id="L1075" title="1 of 4 branches missed."> assert name != null;</span> -<span class="fc" id="L1059"> WSEncryptionPart wsEncryptionPart = new WSEncryptionPart(name, namespace, modifier);</span> -<span class="fc" id="L1060"> wsEncryptionPart.setId(id);</span> -<span class="fc" id="L1061"> wsEncryptionPart.setXpath(xPath);</span> +<span class="fc" id="L1077"> WSEncryptionPart wsEncryptionPart = new WSEncryptionPart(name, namespace, modifier);</span> +<span class="fc" id="L1078"> wsEncryptionPart.setId(id);</span> +<span class="fc" id="L1079"> wsEncryptionPart.setXpath(xPath);</span> -<span class="fc" id="L1063"> return wsEncryptionPart;</span> +<span class="fc" id="L1081"> return wsEncryptionPart;</span> } public static List<WSEncryptionPart> getPartsAndElements(boolean sign, SOAPEnvelope envelope, boolean includeBody, List<WSEncryptionPart> parts, List<String> elements, HashMap decNamespaces) { -<span class="fc" id="L1070"> List<OMElement> found = new ArrayList<OMElement>();</span> -<span class="fc" id="L1071"> List<WSEncryptionPart> result = new ArrayList<WSEncryptionPart>();</span> +<span class="fc" id="L1088"> List<OMElement> found = new ArrayList<OMElement>();</span> +<span class="fc" id="L1089"> List<WSEncryptionPart> result = new ArrayList<WSEncryptionPart>();</span> // check body -<span class="fc bfc" id="L1074" title="All 2 branches covered."> if(includeBody) {</span> +<span class="fc bfc" id="L1092" title="All 2 branches covered."> if(includeBody) {</span> -<span class="fc" id="L1076"> String wsuId = addWsuIdToElement(envelope.getBody());</span> +<span class="fc" id="L1094"> String wsuId = addWsuIdToElement(envelope.getBody());</span> -<span class="fc bfc" id="L1078" title="All 2 branches covered."> if( sign ) {</span> -<span class="fc" id="L1079"> result.add(createEncryptionPart(envelope.getBody().getLocalName(), wsuId,</span> +<span class="fc bfc" id="L1096" title="All 2 branches covered."> if( sign ) {</span> +<span class="fc" id="L1097"> result.add(createEncryptionPart(envelope.getBody().getLocalName(), wsuId,</span> null, null)); } else { -<span class="fc" id="L1082"> result.add(createEncryptionPart(envelope.getBody().getLocalName(), wsuId, null, "Content"));</span> +<span class="fc" id="L1100"> result.add(createEncryptionPart(envelope.getBody().getLocalName(), wsuId, null, "Content"));</span> } // TODO can we remove this ? -<span class="fc" id="L1086"> found.add( envelope.getBody() );</span> +<span class="fc" id="L1104"> found.add( envelope.getBody() );</span> } // Search envelope header for 'parts' from Policy (SignedParts/EncryptedParts) -<span class="fc" id="L1091"> SOAPHeader header = envelope.getHeader();</span> +<span class="fc" id="L1109"> SOAPHeader header = envelope.getHeader();</span> -<span class="fc bfc" id="L1093" title="All 2 branches covered."> for (WSEncryptionPart part : parts) {</span> -<span class="pc bpc" id="L1094" title="1 of 2 branches missed."> if (part.getName() == null) {</span> +<span class="fc bfc" id="L1111" title="All 2 branches covered."> for (WSEncryptionPart part : parts) {</span> +<span class="pc bpc" id="L1112" title="1 of 2 branches missed."> if (part.getName() == null) {</span> // NO name - search by namespace -<span class="nc" id="L1096"> ArrayList headerList = header.getHeaderBlocksWithNSURI(part.getNamespace());</span> +<span class="nc" id="L1114"> ArrayList headerList = header.getHeaderBlocksWithNSURI(part.getNamespace());</span> -<span class="nc bnc" id="L1098" title="All 2 branches missed."> for (Object aHeaderList : headerList) {</span> -<span class="nc" id="L1099"> SOAPHeaderBlock shb = (SOAPHeaderBlock) aHeaderList;</span> +<span class="nc bnc" id="L1116" title="All 2 branches missed."> for (Object aHeaderList : headerList) {</span> +<span class="nc" id="L1117"> SOAPHeaderBlock shb = (SOAPHeaderBlock) aHeaderList;</span> // find reference in envelope -<span class="nc" id="L1102"> OMElement e = header.getFirstChildWithName(shb.getQName());</span> +<span class="nc" id="L1120"> OMElement e = header.getFirstChildWithName(shb.getQName());</span> -<span class="nc bnc" id="L1104" title="All 2 branches missed."> if (!found.contains(e)) {</span> +<span class="nc bnc" id="L1122" title="All 2 branches missed."> if (!found.contains(e)) {</span> // found new -<span class="nc" id="L1106"> found.add(e);</span> +<span class="nc" id="L1124"> found.add(e);</span> -<span class="nc bnc" id="L1108" title="All 2 branches missed."> if (sign) {</span> -<span class="nc" id="L1109"> result.add(createEncryptionPart(e.getLocalName(), null,</span> +<span class="nc bnc" id="L1126" title="All 2 branches missed."> if (sign) {</span> +<span class="nc" id="L1127"> result.add(createEncryptionPart(e.getLocalName(), null,</span> part.getNamespace(), "Content")); } else { -<span class="nc" id="L1113"> OMAttribute wsuIdAttribute = e.getAttribute(new QName(WSConstants.WSU_NS, "Id"));</span> +<span class="nc" id="L1131"> OMAttribute wsuIdAttribute = e.getAttribute(new QName(WSConstants.WSU_NS, "Id"));</span> -<span class="nc" id="L1115"> String wsuId = null;</span> -<span class="nc bnc" id="L1116" title="All 2 branches missed."> if (wsuIdAttribute != null) {</span> -<span class="nc" id="L1117"> wsuId = wsuIdAttribute.getAttributeValue();</span> +<span class="nc" id="L1133"> String wsuId = null;</span> +<span class="nc bnc" id="L1134" title="All 2 branches missed."> if (wsuIdAttribute != null) {</span> +<span class="nc" id="L1135"> wsuId = wsuIdAttribute.getAttributeValue();</span> } -<span class="nc" id="L1120"> result.add(createEncryptionPart(e.getLocalName(),wsuId,</span> +<span class="nc" id="L1138"> result.add(createEncryptionPart(e.getLocalName(),wsuId,</span> part.getNamespace(), "Element")); } } -<span class="nc" id="L1124"> }</span> -<span class="nc" id="L1125"> } else {</span> +<span class="nc" id="L1142"> }</span> +<span class="nc" id="L1143"> } else {</span> // try to find -<span class="fc" id="L1127"> OMElement e = header.getFirstChildWithName(new QName(part.getNamespace(), part.getName()));</span> -<span class="fc bfc" id="L1128" title="All 2 branches covered."> if (e != null) {</span> -<span class="pc bpc" id="L1129" title="1 of 2 branches missed."> if (!found.contains(e)) {</span> +<span class="fc" id="L1145"> OMElement e = header.getFirstChildWithName(new QName(part.getNamespace(), part.getName()));</span> +<span class="fc bfc" id="L1146" title="All 2 branches covered."> if (e != null) {</span> +<span class="pc bpc" id="L1147" title="1 of 2 branches missed."> if (!found.contains(e)) {</span> // found new (reuse wsep) -<span class="fc" id="L1131"> found.add(e);</span> -<span class="fc" id="L1132"> OMAttribute wsuId = e.getAttribute(new QName(WSConstants.WSU_NS, "Id"));</span> +<span class="fc" id="L1149"> found.add(e);</span> +<span class="fc" id="L1150"> OMAttribute wsuId = e.getAttribute(new QName(WSConstants.WSU_NS, "Id"));</span> -<span class="fc bfc" id="L1134" title="All 2 branches covered."> if (wsuId != null) {</span> -<span class="fc" id="L1135"> part.setEncId(wsuId.getAttributeValue());</span> +<span class="fc bfc" id="L1152" title="All 2 branches covered."> if (wsuId != null) {</span> +<span class="fc" id="L1153"> part.setEncId(wsuId.getAttributeValue());</span> } -<span class="fc" id="L1138"> result.add(part);</span> +<span class="fc" id="L1156"> result.add(part);</span> } } } -<span class="fc" id="L1142"> }</span> +<span class="fc" id="L1160"> }</span> // ?? Search for 'Elements' here // decide what exactly is going to be used - only the default namespaces, or the list of all declared namespaces in the message ! -<span class="fc" id="L1147"> Set namespaces = findAllPrefixNamespaces(envelope, decNamespaces);</span> +<span class="fc" id="L1165"> Set namespaces = findAllPrefixNamespaces(envelope, decNamespaces);</span> -<span class="fc bfc" id="L1149" title="All 2 branches covered."> for (String expression : elements) {</span> +<span class="fc bfc" id="L1167" title="All 2 branches covered."> for (String expression : elements) {</span> try { -<span class="fc" id="L1151"> XPath xp = new AXIOMXPath(expression);</span> +<span class="fc" id="L1169"> XPath xp = new AXIOMXPath(expression);</span> -<span class="fc bfc" id="L1153" title="All 2 branches covered."> for (Object objectNamespace : namespaces) {</span> -<span class="fc" id="L1154"> OMNamespace tmpNs = (OMNamespace) objectNamespace;</span> -<span class="fc" id="L1155"> xp.addNamespace(tmpNs.getPrefix(), tmpNs.getNamespaceURI());</span> -<span class="fc" id="L1156"> }</span> +<span class="fc bfc" id="L1171" title="All 2 branches covered."> for (Object objectNamespace : namespaces) {</span> +<span class="fc" id="L1172"> OMNamespace tmpNs = (OMNamespace) objectNamespace;</span> +<span class="fc" id="L1173"> xp.addNamespace(tmpNs.getPrefix(), tmpNs.getNamespaceURI());</span> +<span class="fc" id="L1174"> }</span> -<span class="fc" id="L1158"> List selectedNodes = xp.selectNodes(envelope);</span> +<span class="fc" id="L1176"> List selectedNodes = xp.selectNodes(envelope);</span> -<span class="fc bfc" id="L1160" title="All 2 branches covered."> for (Object selectedNode : selectedNodes) {</span> -<span class="fc" id="L1161"> OMElement e = (OMElement) selectedNode;</span> -<span class="fc" id="L1162"> String localName = e.getLocalName();</span> -<span class="pc bpc" id="L1163" title="1 of 2 branches missed."> String namespace = e.getNamespace() != null ? e.getNamespace().getNamespaceURI() : null;</span> +<span class="fc bfc" id="L1178" title="All 2 branches covered."> for (Object selectedNode : selectedNodes) {</span> +<span class="fc" id="L1179"> OMElement e = (OMElement) selectedNode;</span> +<span class="fc" id="L1180"> String localName = e.getLocalName();</span> +<span class="pc bpc" id="L1181" title="1 of 2 branches missed."> String namespace = e.getNamespace() != null ? e.getNamespace().getNamespaceURI() : null;</span> -<span class="fc bfc" id="L1165" title="All 2 branches covered."> if (sign) {</span> +<span class="fc bfc" id="L1183" title="All 2 branches covered."> if (sign) {</span> -<span class="fc" id="L1167"> result.add(createEncryptionPart(localName, null, namespace, "Content", expression));</span> +<span class="fc" id="L1185"> result.add(createEncryptionPart(localName, null, namespace, "Content", expression));</span> } else { -<span class="fc" id="L1171"> OMAttribute wsuIdAttribute = e.getAttribute(new QName(WSConstants.WSU_NS, "Id"));</span> +<span class="fc" id="L1189"> OMAttribute wsuIdAttribute = e.getAttribute(new QName(WSConstants.WSU_NS, "Id"));</span> -<span class="fc" id="L1173"> String wsuId = null;</span> -<span class="fc bfc" id="L1174" title="All 2 branches covered."> if (wsuIdAttribute != null) {</span> -<span class="fc" id="L1175"> wsuId = wsuIdAttribute.getAttributeValue();</span> +<span class="fc" id="L1191"> String wsuId = null;</span> +<span class="fc bfc" id="L1192" title="All 2 branches covered."> if (wsuIdAttribute != null) {</span> +<span class="fc" id="L1193"> wsuId = wsuIdAttribute.getAttributeValue();</span> } -<span class="fc" id="L1178"> result.add(createEncryptionPart(localName, wsuId, namespace, "Element", expression));</span> +<span class="fc" id="L1196"> result.add(createEncryptionPart(localName, wsuId, namespace, "Element", expression));</span> } -<span class="fc" id="L1180"> }</span> +<span class="fc" id="L1198"> }</span> -<span class="nc" id="L1182"> } catch (JaxenException e) {</span> +<span class="nc" id="L1200"> } catch (JaxenException e) {</span> // This has to be changed to propagate an instance of a RampartException up -<span class="nc" id="L1184"> throw new RuntimeException(e);</span> -<span class="fc" id="L1185"> }</span> -<span class="fc" id="L1186"> }</span> +<span class="nc" id="L1202"> throw new RuntimeException(e);</span> +<span class="fc" id="L1203"> }</span> +<span class="fc" id="L1204"> }</span> -<span class="fc" id="L1188"> return result;</span> +<span class="fc" id="L1206"> return result;</span> } /** @@ -1199,29 +1217,29 @@ import java.util.concurrent.ConcurrentHa // The XPath expression must be evaluated against the SOAP header // http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/ws-securitypolicy-1.2-spec-os.html#_Toc161826519 -<span class="fc" id="L1202"> SOAPHeader header = envelope.getHeader();</span> -<span class="fc" id="L1203"> Set namespaces = findAllPrefixNamespaces(header, decNamespaces);</span> +<span class="fc" id="L1220"> SOAPHeader header = envelope.getHeader();</span> +<span class="fc" id="L1221"> Set namespaces = findAllPrefixNamespaces(header, decNamespaces);</span> try { -<span class="fc" id="L1206"> XPath xp = new AXIOMXPath(expression);</span> +<span class="fc" id="L1224"> XPath xp = new AXIOMXPath(expression);</span> -<span class="fc bfc" id="L1208" title="All 2 branches covered."> for (Object namespace : namespaces) {</span> -<span class="fc" id="L1209"> OMNamespace tmpNs = (OMNamespace) namespace;</span> -<span class="fc" id="L1210"> xp.addNamespace(tmpNs.getPrefix(), tmpNs.getNamespaceURI());</span> -<span class="fc" id="L1211"> }</span> +<span class="fc bfc" id="L1226" title="All 2 branches covered."> for (Object namespace : namespaces) {</span> +<span class="fc" id="L1227"> OMNamespace tmpNs = (OMNamespace) namespace;</span> +<span class="fc" id="L1228"> xp.addNamespace(tmpNs.getPrefix(), tmpNs.getNamespaceURI());</span> +<span class="fc" id="L1229"> }</span> -<span class="fc" id="L1213"> List selectedNodes = xp.selectNodes(header);</span> +<span class="fc" id="L1231"> List selectedNodes = xp.selectNodes(header);</span> -<span class="fc bfc" id="L1215" title="All 2 branches covered."> if (selectedNodes.size() == 0) {</span> -<span class="fc" id="L1216"> return false;</span> +<span class="fc bfc" id="L1233" title="All 2 branches covered."> if (selectedNodes.size() == 0) {</span> +<span class="fc" id="L1234"> return false;</span> } -<span class="nc" id="L1219"> } catch (JaxenException e) {</span> +<span class="nc" id="L1237"> } catch (JaxenException e) {</span> // This has to be changed to propagate an instance of a RampartException up -<span class="nc" id="L1221"> throw new RuntimeException(e);</span> -<span class="fc" id="L1222"> }</span> +<span class="nc" id="L1239"> throw new RuntimeException(e);</span> +<span class="fc" id="L1240"> }</span> -<span class="fc" id="L1224"> return true;</span> +<span class="fc" id="L1242"> return true;</span> } @@ -1231,23 +1249,23 @@ import java.util.concurrent.ConcurrentHa /* * Assume AES as default, so initialize it */ -<span class="nc" id="L1234"> keyGen = KeyGenerator.getInstance("AES");</span> -<span class="nc bnc" id="L1235" title="All 2 branches missed."> if (symEncrAlgo.equalsIgnoreCase(WSConstants.TRIPLE_DES)) {</span> -<span class="nc" id="L1236"> keyGen = KeyGenerator.getInstance("DESede");</span> -<span class="nc bnc" id="L1237" title="All 2 branches missed."> } else if (symEncrAlgo.equalsIgnoreCase(WSConstants.AES_128)) {</span> -<span class="nc" id="L1238"> keyGen.init(128);</span> -<span class="nc bnc" id="L1239" title="All 2 branches missed."> } else if (symEncrAlgo.equalsIgnoreCase(WSConstants.AES_192)) {</span> -<span class="nc" id="L1240"> keyGen.init(192);</span> -<span class="nc bnc" id="L1241" title="All 2 branches missed."> } else if (symEncrAlgo.equalsIgnoreCase(WSConstants.AES_256)) {</span> -<span class="nc" id="L1242"> keyGen.init(256);</span> +<span class="nc" id="L1252"> keyGen = KeyGenerator.getInstance("AES");</span> +<span class="nc bnc" id="L1253" title="All 2 branches missed."> if (symEncrAlgo.equalsIgnoreCase(WSConstants.TRIPLE_DES)) {</span> +<span class="nc" id="L1254"> keyGen = KeyGenerator.getInstance("DESede");</span> +<span class="nc bnc" id="L1255" title="All 2 branches missed."> } else if (symEncrAlgo.equalsIgnoreCase(WSConstants.AES_128)) {</span> +<span class="nc" id="L1256"> keyGen.init(128);</span> +<span class="nc bnc" id="L1257" title="All 2 branches missed."> } else if (symEncrAlgo.equalsIgnoreCase(WSConstants.AES_192)) {</span> +<span class="nc" id="L1258"> keyGen.init(192);</span> +<span class="nc bnc" id="L1259" title="All 2 branches missed."> } else if (symEncrAlgo.equalsIgnoreCase(WSConstants.AES_256)) {</span> +<span class="nc" id="L1260"> keyGen.init(256);</span> } else { -<span class="nc" id="L1244"> return null;</span> +<span class="nc" id="L1262"> return null;</span> } -<span class="nc" id="L1246"> } catch (NoSuchAlgorithmException e) {</span> -<span class="nc" id="L1247"> throw new WSSecurityException(</span> +<span class="nc" id="L1264"> } catch (NoSuchAlgorithmException e) {</span> +<span class="nc" id="L1265"> throw new WSSecurityException(</span> WSSecurityException.UNSUPPORTED_ALGORITHM, null, null, e); -<span class="nc" id="L1249"> }</span> -<span class="nc" id="L1250"> return keyGen;</span> +<span class="nc" id="L1267"> }</span> +<span class="nc" id="L1268"> return keyGen;</span> } /** @@ -1256,7 +1274,7 @@ import java.util.concurrent.ConcurrentHa * @return Id to hold the context identifier in the message context */ public static String getContextIdentifierKey(MessageContext msgContext) { -<span class="fc" id="L1259"> return msgContext.getAxisService().getName();</span> +<span class="fc" id="L1277"> return msgContext.getAxisService().getName();</span> } @@ -1266,66 +1284,66 @@ import java.util.concurrent.ConcurrentHa */ public static Hashtable getContextMap(MessageContext msgContext) { //Fist check whether its there -<span class="fc" id="L1269"> Object map = msgContext.getConfigurationContext().getProperty(</span> +<span class="fc" id="L1287"> Object map = msgContext.getConfigurationContext().getProperty(</span> ConversationConstants.KEY_CONTEXT_MAP); -<span class="fc bfc" id="L1272" title="All 2 branches covered."> if(map == null) {</span> +<span class="fc bfc" id="L1290" title="All 2 branches covered."> if(map == null) {</span> //If not create a new one -<span class="fc" id="L1274"> map = new Hashtable();</span> +<span class="fc" id="L1292"> map = new Hashtable();</span> //Set the map globally -<span class="fc" id="L1276"> msgContext.getConfigurationContext().setProperty(</span> +<span class="fc" id="L1294"> msgContext.getConfigurationContext().setProperty(</span> ConversationConstants.KEY_CONTEXT_MAP, map); } -<span class="fc" id="L1280"> return (Hashtable)map;</span> +<span class="fc" id="L1298"> return (Hashtable)map;</span> } public static boolean isTokenValid(RampartMessageData rmd, String id) throws RampartException { try { -<span class="fc" id="L1285"> org.apache.rahas.Token token = rmd.getTokenStorage().getToken(id);</span> -<span class="pc bpc" id="L1286" title="1 of 4 branches missed."> return token!= null && token.getState() == org.apache.rahas.Token.ISSUED;</span> -<span class="nc" id="L1287"> } catch (TrustException e) {</span> -<span class="nc" id="L1288"> throw new RampartException("errorExtractingToken");</span> +<span class="fc" id="L1303"> org.apache.rahas.Token token = rmd.getTokenStorage().getToken(id);</span> +<span class="pc bpc" id="L1304" title="1 of 4 branches missed."> return token!= null && token.getState() == org.apache.rahas.Token.ISSUED;</span> +<span class="nc" id="L1305"> } catch (TrustException e) {</span> +<span class="nc" id="L1306"> throw new RampartException("errorExtractingToken");</span> } } public static void setEncryptionUser(RampartMessageData rmd, WSSecEncryptedKey encrKeyBuilder) throws RampartException { -<span class="fc" id="L1294"> RampartPolicyData rpd = rmd.getPolicyData();</span> -<span class="fc" id="L1295"> String encrUser = rpd.getRampartConfig().getEncryptionUser();</span> -<span class="fc" id="L1296"> setEncryptionUser(rmd, encrKeyBuilder, encrUser);</span> -<span class="fc" id="L1297"> }</span> +<span class="fc" id="L1312"> RampartPolicyData rpd = rmd.getPolicyData();</span> +<span class="fc" id="L1313"> String encrUser = rpd.getRampartConfig().getEncryptionUser();</span> +<span class="fc" id="L1314"> setEncryptionUser(rmd, encrKeyBuilder, encrUser);</span> +<span class="fc" id="L1315"> }</span> public static void setEncryptionUser(RampartMessageData rmd, WSSecEncryptedKey encrKeyBuilder, String encrUser) throws RampartException { -<span class="fc" id="L1301"> RampartPolicyData rpd = rmd.getPolicyData();</span> +<span class="fc" id="L1319"> RampartPolicyData rpd = rmd.getPolicyData();</span> -<span class="pc bpc" id="L1303" title="1 of 2 branches missed."> if (encrUser == null) {</span> -<span class="nc" id="L1304"> encrUser = rpd.getRampartConfig().getEncryptionUser();</span> +<span class="pc bpc" id="L1321" title="1 of 2 branches missed."> if (encrUser == null) {</span> +<span class="nc" id="L1322"> encrUser = rpd.getRampartConfig().getEncryptionUser();</span> } -<span class="pc bpc" id="L1307" title="2 of 4 branches missed."> if (encrUser == null || "".equals(encrUser)) {</span> -<span class="nc" id="L1308"> throw new RampartException("missingEncryptionUser");</span> +<span class="pc bpc" id="L1325" title="2 of 4 branches missed."> if (encrUser == null || "".equals(encrUser)) {</span> +<span class="nc" id="L1326"> throw new RampartException("missingEncryptionUser");</span> } -<span class="pc bpc" id="L1310" title="1 of 2 branches missed."> if(encrUser.equals(WSHandlerConstants.USE_REQ_SIG_CERT)) {</span> -<span class="nc" id="L1311"> List<WSHandlerResult> resultsObj</span> +<span class="fc bfc" id="L1328" title="All 2 branches covered."> if(encrUser.equals(WSHandlerConstants.USE_REQ_SIG_CERT)) {</span> +<span class="fc" id="L1329"> List<WSHandlerResult> resultsObj</span> = (List<WSHandlerResult>)rmd.getMsgContext().getProperty(WSHandlerConstants.RECV_RESULTS); -<span class="nc bnc" id="L1313" title="All 2 branches missed."> if(resultsObj != null) {</span> -<span class="nc" id="L1314"> encrKeyBuilder.setUseThisCert(getReqSigCert(resultsObj));</span> +<span class="pc bpc" id="L1331" title="1 of 2 branches missed."> if(resultsObj != null) {</span> +<span class="fc" id="L1332"> encrKeyBuilder.setUseThisCert(getReqSigCert(resultsObj));</span> //TODO This is a hack, this should not come under USE_REQ_SIG_CERT -<span class="nc bnc" id="L1317" title="All 2 branches missed."> if(encrKeyBuilder.isCertSet()) {</span> -<span class="nc" id="L1318"> encrKeyBuilder.setUserInfo(getUsername(resultsObj));</span> +<span class="pc bpc" id="L1335" title="1 of 2 branches missed."> if(encrKeyBuilder.isCertSet()) {</span> +<span class="fc" id="L1336"> encrKeyBuilder.setUserInfo(getUsername(resultsObj));</span> } } else { -<span class="nc" id="L1323"> throw new RampartException("noSecurityResults");</span> +<span class="nc" id="L1341"> throw new RampartException("noSecurityResults");</span> } -<span class="nc" id="L1325"> } else {</span> -<span class="fc" id="L1326"> encrKeyBuilder.setUserInfo(encrUser);</span> +<span class="fc" id="L1343"> } else {</span> +<span class="fc" id="L1344"> encrKeyBuilder.setUserInfo(encrUser);</span> } -<span class="fc" id="L1328"> }</span> +<span class="fc" id="L1346"> }</span> /** * Sets the keyIdentifierType of <code>WSSecSignature</code> or <code>WSSecEncryptedKey</code> @@ -1339,72 +1357,72 @@ import java.util.concurrent.ConcurrentHa // Use a reference rather than the binary security token if: the policy never allows the token to be // included; or this is the recipient and the token should only be included in requests; or this is // the initiator and the token should only be included in responses. -<span class="pc bpc" id="L1342" title="3 of 10 branches missed."> final boolean useReference = token.getInclusion() == SPConstants.INCLUDE_TOKEN_NEVER</span> +<span class="pc bpc" id="L1360" title="3 of 10 branches missed."> final boolean useReference = token.getInclusion() == SPConstants.INCLUDE_TOKEN_NEVER</span> || !rmd.isInitiator() && token.getInclusion() == SPConstants.INCLUDE_TOEKN_ALWAYS_TO_RECIPIENT || rmd.isInitiator() && token.getInclusion() == SPConstants.INCLUDE_TOEKN_ALWAYS_TO_INITIATOR; -<span class="fc bfc" id="L1345" title="All 2 branches covered."> if (useReference) {</span> +<span class="fc bfc" id="L1363" title="All 2 branches covered."> if (useReference) {</span> -<span class="fc" id="L1347"> boolean tokenTypeSet = false;</span> +<span class="fc" id="L1365"> boolean tokenTypeSet = false;</span> -<span class="pc bpc" id="L1349" title="1 of 2 branches missed."> if(token instanceof X509Token) {</span> -<span class="fc" id="L1350"> X509Token x509Token = (X509Token)token;</span> +<span class="pc bpc" id="L1367" title="1 of 2 branches missed."> if(token instanceof X509Token) {</span> +<span class="fc" id="L1368"> X509Token x509Token = (X509Token)token;</span> -<span class="pc bpc" id="L1352" title="1 of 2 branches missed."> if(x509Token.isRequireIssuerSerialReference()) {</span> -<span class="nc" id="L1353"> secBase.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);</span> -<span class="nc" id="L1354"> tokenTypeSet = true;</span> -<span class="fc bfc" id="L1355" title="All 2 branches covered."> } else if (x509Token.isRequireKeyIdentifierReference()) {</span> -<span class="fc" id="L1356"> secBase.setKeyIdentifierType(WSConstants.SKI_KEY_IDENTIFIER);</span> -<span class="fc" id="L1357"> tokenTypeSet = true;</span> -<span class="fc bfc" id="L1358" title="All 2 branches covered."> } else if (x509Token.isRequireThumbprintReference()) {</span> -<span class="fc" id="L1359"> secBase.setKeyIdentifierType(WSConstants.THUMBPRINT_IDENTIFIER);</span> -<span class="fc" id="L1360"> tokenTypeSet = true;</span> +<span class="pc bpc" id="L1370" title="1 of 2 branches missed."> if(x509Token.isRequireIssuerSerialReference()) {</span> +<span class="nc" id="L1371"> secBase.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);</span> +<span class="nc" id="L1372"> tokenTypeSet = true;</span> +<span class="fc bfc" id="L1373" title="All 2 branches covered."> } else if (x509Token.isRequireKeyIdentifierReference()) {</span> +<span class="fc" id="L1374"> secBase.setKeyIdentifierType(WSConstants.SKI_KEY_IDENTIFIER);</span> +<span class="fc" id="L1375"> tokenTypeSet = true;</span> +<span class="fc bfc" id="L1376" title="All 2 branches covered."> } else if (x509Token.isRequireThumbprintReference()) {</span> +<span class="fc" id="L1377"> secBase.setKeyIdentifierType(WSConstants.THUMBPRINT_IDENTIFIER);</span> +<span class="fc" id="L1378"> tokenTypeSet = true;</span> } } -<span class="fc bfc" id="L1364" title="All 2 branches covered."> if (!tokenTypeSet) {</span> -<span class="fc" id="L1365"> final RampartPolicyData rpd = rmd.getPolicyData();</span> -<span class="fc" id="L1366"> Wss10 wss = rpd.getWss11();</span> -<span class="pc bpc" id="L1367" title="1 of 2 branches missed."> if (wss == null) {</span> -<span class="fc" id="L1368"> wss = rpd.getWss10();</span> +<span class="fc bfc" id="L1382" title="All 2 branches covered."> if (!tokenTypeSet) {</span> +<span class="fc" id="L1383"> final RampartPolicyData rpd = rmd.getPolicyData();</span> +<span class="fc" id="L1384"> Wss10 wss = rpd.getWss11();</span> +<span class="pc bpc" id="L1385" title="1 of 2 branches missed."> if (wss == null) {</span> +<span class="fc" id="L1386"> wss = rpd.getWss10();</span> } -<span class="fc bfc" id="L1371" title="All 2 branches covered."> if (wss.isMustSupportRefKeyIdentifier()) {</span> -<span class="fc" id="L1372"> secBase.setKeyIdentifierType(WSConstants.SKI_KEY_IDENTIFIER);</span> -<span class="pc bpc" id="L1373" title="1 of 2 branches missed."> } else if (wss.isMustSupportRefIssuerSerial()) {</span> -<span class="nc" id="L1374"> secBase.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);</span> -<span class="pc bpc" id="L1375" title="3 of 4 branches missed."> } else if (wss instanceof Wss11</span> +<span class="fc bfc" id="L1389" title="All 2 branches covered."> if (wss.isMustSupportRefKeyIdentifier()) {</span> +<span class="fc" id="L1390"> secBase.setKeyIdentifierType(WSConstants.SKI_KEY_IDENTIFIER);</span> +<span class="pc bpc" id="L1391" title="1 of 2 branches missed."> } else if (wss.isMustSupportRefIssuerSerial()) {</span> +<span class="nc" id="L1392"> secBase.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);</span> +<span class="pc bpc" id="L1393" title="3 of 4 branches missed."> } else if (wss instanceof Wss11</span> && ((Wss11) wss).isMustSupportRefThumbprint()) { -<span class="nc" id="L1377"> secBase.setKeyIdentifierType(WSConstants.THUMBPRINT_IDENTIFIER);</span> +<span class="nc" id="L1395"> secBase.setKeyIdentifierType(WSConstants.THUMBPRINT_IDENTIFIER);</span> } } -<span class="fc" id="L1381"> } else {</span> -<span class="fc" id="L1382"> secBase.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);</span> +<span class="fc" id="L1399"> } else {</span> +<span class="fc" id="L1400"> secBase.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);</span> } -<span class="fc" id="L1384"> }</span> +<span class="fc" id="L1402"> }</span> private static X509Certificate getReqSigCert(List<WSHandlerResult> results) { /* * Scan the results for a matching actor. Use results only if the * receiving Actor and the sending Actor match. */ -<span class="nc bnc" id="L1391" title="All 2 branches missed."> for (WSHandlerResult result : results) {</span> +<span class="pc bpc" id="L1409" title="1 of 2 branches missed."> for (WSHandlerResult result : results) {</span> -<span class="nc" id="L1393"> List<WSSecurityEngineResult> wsSecEngineResults = result.getResults();</span> +<span class="fc" id="L1411"> List<WSSecurityEngineResult> wsSecEngineResults = result.getResults();</span> /* * Scan the results for the first Signature action. Use the * certificate of this Signature to set the certificate for the * encryption action :-). */ -<span class="nc bnc" id="L1399" title="All 2 branches missed."> for (WSSecurityEngineResult wsSecEngineResult : wsSecEngineResults) {</span> -<span class="nc" id="L1400"> Integer actInt = (Integer) wsSecEngineResult.get(WSSecurityEngineResult.TAG_ACTION);</span> -<span class="nc bnc" id="L1401" title="All 2 branches missed."> if (actInt == WSConstants.SIGN) {</span> -<span class="nc" id="L1402"> return (X509Certificate) wsSecEngineResult.get(WSSecurityEngineResult.TAG_X509_CERTIFICATE);</span> +<span class="pc bpc" id="L1417" title="1 of 2 branches missed."> for (WSSecurityEngineResult wsSecEngineResult : wsSecEngineResults) {</span> +<span class="fc" id="L1418"> Integer actInt = (Integer) wsSecEngineResult.get(WSSecurityEngineResult.TAG_ACTION);</span> +<span class="pc bpc" id="L1419" title="1 of 2 branches missed."> if (actInt == WSConstants.SIGN) {</span> +<span class="fc" id="L1420"> return (X509Certificate) wsSecEngineResult.get(WSSecurityEngineResult.TAG_X509_CERTIFICATE);</span> } -<span class="nc" id="L1404"> }</span> -<span class="nc" id="L1405"> }</span> +<span class="nc" id="L1422"> }</span> +<span class="nc" id="L1423"> }</span> -<span class="nc" id="L1407"> return null;</span> +<span class="nc" id="L1425"> return null;</span> } /** @@ -1419,75 +1437,75 @@ import java.util.concurrent.ConcurrentHa * Scan the results for a matching actor. Use results only if the * receiving Actor and the sending Actor match. */ -<span class="nc bnc" id="L1422" title="All 2 branches missed."> for (WSHandlerResult result : results) {</span> +<span class="fc bfc" id="L1440" title="All 2 branches covered."> for (WSHandlerResult result : results) {</span> -<span class="nc" id="L1424"> List<WSSecurityEngineResult> wsSecEngineResults = result.getResults();</span> +<span class="fc" id="L1442"> List<WSSecurityEngineResult> wsSecEngineResults = result.getResults();</span> /* * Scan the results for a username token. Use the username * of this token to set the alias for the encryption user */ -<span class="nc bnc" id="L1429" title="All 2 branches missed."> for (WSSecurityEngineResult wsSecEngineResult : wsSecEngineResults) {</span> -<span class="nc" id="L1430"> Integer actInt = (Integer) wsSecEngineResult.get(WSSecurityEngineResult.TAG_ACTION);</span> -<span class="nc bnc" id="L1431" title="All 2 branches missed."> if (actInt == WSConstants.UT) {</span> -<span class="nc" id="L1432"> WSUsernameTokenPrincipal principal = (WSUsernameTokenPrincipal) wsSecEngineResult.</span> +<span class="fc bfc" id="L1447" title="All 2 branches covered."> for (WSSecurityEngineResult wsSecEngineResult : wsSecEngineResults) {</span> +<span class="fc" id="L1448"> Integer actInt = (Integer) wsSecEngineResult.get(WSSecurityEngineResult.TAG_ACTION);</span> +<span class="pc bpc" id="L1449" title="1 of 2 branches missed."> if (actInt == WSConstants.UT) {</span> +<span class="nc" id="L1450"> WSUsernameTokenPrincipal principal = (WSUsernameTokenPrincipal) wsSecEngineResult.</span> get(WSSecurityEngineResult.TAG_PRINCIPAL); -<span class="nc" id="L1434"> return principal.getName();</span> +<span class="nc" id="L1452"> return principal.getName();</span> } -<span class="nc" id="L1436"> }</span> -<span class="nc" id="L1437"> }</span> +<span class="fc" id="L1454"> }</span> +<span class="fc" id="L1455"> }</span> -<span class="nc" id="L1439"> return null;</span> +<span class="fc" id="L1457"> return null;</span> } public static String getRequestEncryptedKeyId(List<WSHandlerResult> results) { -<span class="pc bpc" id="L1444" title="1 of 2 branches missed."> for (WSHandlerResult result : results) {</span> +<span class="pc bpc" id="L1462" title="1 of 2 branches missed."> for (WSHandlerResult result : results) {</span> -<span class="fc" id="L1446"> List<WSSecurityEngineResult> wsSecEngineResults = result.getResults();</span> +<span class="fc" id="L1464"> List<WSSecurityEngineResult> wsSecEngineResults = result.getResults();</span> /* * Scan the results for the first Signature action. Use the * certificate of this Signature to set the certificate for the * encryption action :-). */ -<span class="pc bpc" id="L1452" title="1 of 2 branches missed."> for (WSSecurityEngineResult wsSecEngineResult : wsSecEngineResults) {</span> -<span class="fc" id="L1453"> Integer actInt = (Integer) wsSecEngineResult.get(WSSecurityEngineResult.TAG_ACTION);</span> -<span class="fc" id="L1454"> String encrKeyId = (String) wsSecEngineResult.get(WSSecurityEngineResult.TAG_ID);</span> -<span class="pc bpc" id="L1455" title="1 of 4 branches missed."> if (actInt == WSConstants.ENCR &&</span> +<span class="pc bpc" id="L1470" title="1 of 2 branches missed."> for (WSSecurityEngineResult wsSecEngineResult : wsSecEngineResults) {</span> +<span class="fc" id="L1471"> Integer actInt = (Integer) wsSecEngineResult.get(WSSecurityEngineResult.TAG_ACTION);</span> +<span class="fc" id="L1472"> String encrKeyId = (String) wsSecEngineResult.get(WSSecurityEngineResult.TAG_ID);</span> +<span class="pc bpc" id="L1473" title="1 of 4 branches missed."> if (actInt == WSConstants.ENCR &&</span> encrKeyId != null) { -<span class="fc bfc" id="L1457" title="All 2 branches covered."> if (encrKeyId.length() > 0) {</span> -<span class="fc" id="L1458"> return encrKeyId;</span> +<span class="fc bfc" id="L1475" title="All 2 branches covered."> if (encrKeyId.length() > 0) {</span> +<span class="fc" id="L1476"> return encrKeyId;</span> } -<span class="pc bpc" id="L1460" title="1 of 2 branches missed."> else if (log.isDebugEnabled()) {</span> -<span class="nc" id="L1461"> log.debug("Found encryption security processing result with empty id, skipping it: " + wsSecEngineResult);</span> +<span class="pc bpc" id="L1478" title="1 of 2 branches missed."> else if (log.isDebugEnabled()) {</span> +<span class="nc" id="L1479"> log.debug("Found encryption security processing result with empty id, skipping it: " + wsSecEngineResult);</span> } } -<span class="fc" id="L1464"> }</span> -<span class="nc" id="L1465"> }</span> +<span class="fc" id="L1482"> }</span> +<span class="nc" id="L1483"> }</span> -<span class="nc" id="L1467"> return null;</span> +<span class="nc" id="L1485"> return null;</span> } public static byte[] getRequestEncryptedKeyValue(List<WSHandlerResult> results) { -<span class="pc bpc" id="L1472" title="1 of 2 branches missed."> for (WSHandlerResult result : results) {</span> +<span class="pc bpc" id="L1490" title="1 of 2 branches missed."> for (WSHandlerResult result : results) {</span> -<span class="fc" id="L1474"> List<WSSecurityEngineResult> wsSecEngineResults = result.getResults();</span> +<span class="fc" id="L1492"> List<WSSecurityEngineResult> wsSecEngineResults = result.getResults();</span> /* * Scan the results for the first Signature action. Use the * certificate of this Signature to set the certificate for the * encryption action :-). */ -<span class="pc bpc" id="L1480" title="1 of 2 branches missed."> for (WSSecurityEngineResult wsSecEngineResult : wsSecEngineResults) {</span> -<span class="fc" id="L1481"> Integer actInt = (Integer) wsSecEngineResult.get(WSSecurityEngineResult.TAG_ACTION);</span> -<span class="fc" id="L1482"> byte[] decryptedKey = (byte[]) wsSecEngineResult.get(WSSecurityEngineResult.TAG_SECRET);</span> -<span class="fc bfc" id="L1483" title="All 4 branches covered."> if (actInt == WSConstants.ENCR &&</span> +<span class="pc bpc" id="L1498" title="1 of 2 branches missed."> for (WSSecurityEngineResult wsSecEngineResult : wsSecEngineResults) {</span> +<span class="fc" id="L1499"> Integer actInt = (Integer) wsSecEngineResult.get(WSSecurityEngineResult.TAG_ACTION);</span> +<span class="fc" id="L1500"> byte[] decryptedKey = (byte[]) wsSecEngineResult.get(WSSecurityEngineResult.TAG_SECRET);</span> +<span class="fc bfc" id="L1501" title="All 4 branches covered."> if (actInt == WSConstants.ENCR &&</span> decryptedKey != null) { -<span class="fc" id="L1485"> return decryptedKey;</span> +<span class="fc" id="L1503"> return decryptedKey;</span> } -<span class="fc" id="L1487"> }</span> -<span class="nc" id="L1488"> }</span> +<span class="fc" id="L1505"> }</span> +<span class="nc" id="L1506"> }</span> -<span class="nc" id="L1490"> return null;</span> +<span class="nc" id="L1508"> return null;</span> } /** @@ -1501,49 +1519,49 @@ import java.util.concurrent.ConcurrentHa * @return */ public static Element insertSiblingAfterOrPrepend(RampartMessageData rmd, Element child, Element elem) { -<span class="fc" id="L1504"> Element retElem = null;</span> -<span class="fc bfc" id="L1505" title="All 2 branches covered."> if (child != null) { // child is not null so insert sibling after</span> -<span class="fc" id="L1506"> retElem = RampartUtil.insertSiblingAfter(rmd, child, elem);</span> +<span class="fc" id="L1522"> Element retElem = null;</span> +<span class="fc bfc" id="L1523" title="All 2 branches covered."> if (child != null) { // child is not null so insert sibling after</span> +<span class="fc" id="L1524"> retElem = RampartUtil.insertSiblingAfter(rmd, child, elem);</span> } else { //Prepend -<span class="fc" id="L1508"> retElem = prependSecHeader(rmd, elem);</span> +<span class="fc" id="L1526"> retElem = prependSecHeader(rmd, elem);</span> } -<span class="fc" id="L1511"> return retElem;</span> +<span class="fc" id="L1529"> return retElem;</span> } public static Element insertSiblingBeforeOrPrepend(RampartMessageData rmd, Element child, Element elem) { -<span class="fc" id="L1515"> Element retElem = null;</span> -<span class="fc bfc" id="L1516" title="All 4 branches covered."> if (child != null && child.getPreviousSibling() != null) {</span> -<span class="fc" id="L1517"> retElem = RampartUtil.insertSiblingBefore(rmd, child, elem);</span> +<span class="fc" id="L1533"> Element retElem = null;</span> +<span class="fc bfc" id="L1534" title="All 4 branches covered."> if (child != null && child.getPreviousSibling() != null) {</span> +<span class="fc" id="L1535"> retElem = RampartUtil.insertSiblingBefore(rmd, child, elem);</span> } else { //Prepend -<span class="fc" id="L1519"> retElem = prependSecHeader(rmd, elem);</span> +<span class="fc" id="L1537"> retElem = prependSecHeader(rmd, elem);</span> } -<span class="fc" id="L1522"> return retElem;</span> +<span class="fc" id="L1540"> return retElem;</span> } private static Element prependSecHeader(RampartMessageData rmd, Element elem) { -<span class="fc" id="L1526"> Element retElem = null;</span> +<span class="fc" id="L1544"> Element retElem = null;</span> -<span class="fc" id="L1528"> Element secHeaderElem = rmd.getSecHeader().getSecurityHeader();</span> -<span class="fc" id="L1529"> Node node = secHeaderElem.getOwnerDocument().importNode(</span> +<span class="fc" id="L1546"> Element secHeaderElem = rmd.getSecHeader().getSecurityHeader();</span> +<span class="fc" id="L1547"> Node node = secHeaderElem.getOwnerDocument().importNode(</span> elem, true); -<span class="fc" id="L1531"> Element firstElem = (Element) secHeaderElem.getFirstChild();</span> +<span class="fc" id="L1549"> Element firstElem = (Element) secHeaderElem.getFirstChild();</span> -<span class="fc bfc" id="L1533" title="All 2 branches covered."> if (firstElem == null) {</span> -<span class="fc" id="L1534"> retElem = (Element) secHeaderElem.appendChild(node);</span> +<span class="fc bfc" id="L1551" title="All 2 branches covered."> if (firstElem == null) {</span> +<span class="fc" id="L1552"> retElem = (Element) secHeaderElem.appendChild(node);</span> } else { -<span class="pc bpc" id="L1536" title="1 of 2 branches missed."> if (firstElem.getOwnerDocument().equals(elem.getOwnerDocument())) {</span> -<span class="fc" id="L1537"> ((OMElement) firstElem).insertSiblingBefore((OMElement) elem);</span> -<span class="fc" id="L1538"> retElem = elem;</span> +<span class="pc bpc" id="L1554" title="1 of 2 branches missed."> if (firstElem.getOwnerDocument().equals(elem.getOwnerDocument())) {</span> +<span class="fc" id="L1555"> ((OMElement) firstElem).insertSiblingBefore((OMElement) elem);</span> +<span class="fc" id="L1556"> retElem = elem;</span> } else { -<span class="nc" id="L1540"> Element newSib = (Element) firstElem.getOwnerDocument().importNode(elem, true);</span> -<span class="nc" id="L1541"> ((OMElement) firstElem).insertSiblingBefore((OMElement) newSib);</span> -<span class="nc" id="L1542"> retElem = newSib;</span> +<span class="nc" id="L1558"> Element newSib = (Element) firstElem.getOwnerDocument().importNode(elem, true);</span> +<span class="nc" id="L1559"> ((OMElement) firstElem).insertSiblingBefore((OMElement) newSib);</span> +<span class="nc" id="L1560"> retElem = newSib;</span> } } -<span class="fc" id="L1546"> return retElem;</span> +<span class="fc" id="L1564"> return retElem;</span> } /** @@ -1555,71 +1573,71 @@ import java.util.concurrent.ConcurrentHa boolean inflow ) { // Checking for time stamp -<span class="fc bfc" id="L1558" title="All 2 branches covered."> if ( rpd.isIncludeTimestamp() ) {</span> -<span class="fc" id="L1559"> return true;</span> +<span class="fc bfc" id="L1576" title="All 2 branches covered."> if ( rpd.isIncludeTimestamp() ) {</span> +<span class="fc" id="L1577"> return true;</span> } // Checking for signed parts and elements -<span class="pc bpc" id="L1563" title="2 of 6 branches missed."> if (rpd.isSignBody() || rpd.getSignedParts().size() != 0 || </span> +<span class="pc bpc" id="L1581" title="2 of 6 branches missed."> if (rpd.isSignBody() || rpd.getSignedParts().size() != 0 || </span> rpd.getSignedElements().size() != 0) { -<span class="fc" id="L1565"> return true;</span> +<span class="fc" id="L1583"> return true;</span> } // Checking for encrypted parts and elements -<span class="pc bpc" id="L1569" title="2 of 6 branches missed."> if (rpd.isEncryptBody() || rpd.getEncryptedParts().size() != 0 || </span> +<span class="pc bpc" id="L1587" title="1 of 6 branches missed."> if (rpd.isEncryptBody() || rpd.getEncryptedParts().size() != 0 || </span> rpd.getEncryptedElements().size() != 0 ) { -<span class="fc" id="L1571"> return true;</span> +<span class="fc" id="L1589"> return true;</span> } // Checking for supporting tokens SupportingToken supportingTokens; -<span class="nc bnc" id="L1577" title="All 8 branches missed."> if (!initiator && inflow || initiator && !inflow ) {</span> +<span class="pc bpc" id="L1595" title="3 of 8 branches missed."> if (!initiator && inflow || initiator && !inflow ) {</span> -<span class="nc" id="L1579"> List<SupportingToken> supportingToks = rpd.getSupportingTokensList();</span> -<span class="nc bnc" id="L1580" title="All 2 branches missed."> for (SupportingToken supportingTok : supportingToks) {</span> -<span class="nc bnc" id="L1581" title="All 4 branches missed."> if (supportingTok != null && supportingTok.getTokens().size() != 0) {</span> -<span class="nc" id="L1582"> return true;</span> +<span class="fc" id="L1597"> List<SupportingToken> supportingToks = rpd.getSupportingTokensList();</span> +<span class="pc bpc" id="L1598" title="1 of 2 branches missed."> for (SupportingToken supportingTok : supportingToks) {</span> +<span class="nc bnc" id="L1599" title="All 4 branches missed."> if (supportingTok != null && supportingTok.getTokens().size() != 0) {</span> +<span class="nc" id="L1600"> return true;</span> } -<span class="nc" id="L1584"> }</span> +<span class="nc" id="L1602"> }</span> -<span class="nc" id="L1586"> supportingTokens = rpd.getSignedSupportingTokens();</span> -<span class="nc bnc" id="L1587" title="All 4 branches missed."> if (supportingTokens != null && supportingTokens.getTokens().size() != 0) {</span> -<span class="nc" id="L1588"> return true;</span> +<span class="fc" id="L1604"> supportingTokens = rpd.getSignedSupportingTokens();</span> +<span class="pc bpc" id="L1605" title="2 of 4 branches missed."> if (supportingTokens != null && supportingTokens.getTokens().size() != 0) {</span> +<span class="fc" id="L1606"> return true;</span> } -<span class="nc" id="L1591"> supportingTokens = rpd.getEndorsingSupportingTokens();</span> -<span class="nc bnc" id="L1592" title="All 4 branches missed."> if (supportingTokens != null && supportingTokens.getTokens().size() != 0) {</span> -<span class="nc" id="L1593"> return true;</span> +<span class="nc" id="L1609"> supportingTokens = rpd.getEndorsingSupportingTokens();</span> +<span class="nc bnc" id="L1610" title="All 4 branches missed."> if (supportingTokens != null && supportingTokens.getTokens().size() != 0) {</span> +<span class="nc" id="L1611"> return true;</span> } -<span class="nc" id="L1596"> supportingTokens = rpd.getSignedEndorsingSupportingTokens();</span> -<span class="nc bnc" id="L1597" title="All 4 branches missed."> if (supportingTokens != null && supportingTokens.getTokens().size() != 0) {</span> -<span class="nc" id="L1598"> return true;</span> +<span class="nc" id="L1614"> supportingTokens = rpd.getSignedEndorsingSupportingTokens();</span> +<span class="nc bnc" id="L1615" title="All 4 branches missed."> if (supportingTokens != null && supportingTokens.getTokens().size() != 0) {</span> +<span class="nc" id="L1616"> return true;</span> } -<span class="nc" id="L1601"> supportingTokens = rpd.getEncryptedSupportingTokens();</span> -<span class="nc bnc" id="L1602" title="All 4 branches missed."> if (supportingTokens != null && supportingTokens.getTokens().size() != 0) {</span> -<span class="nc" id="L1603"> return true;</span> +<span class="nc" id="L1619"> supportingTokens = rpd.getEncryptedSupportingTokens();</span> +<span class="nc bnc" id="L1620" title="All 4 branches missed."> if (supportingTokens != null && supportingTokens.getTokens().size() != 0) {</span> +<span class="nc" id="L1621"> return true;</span> } -<span class="nc" id="L1606"> supportingTokens = rpd.getSignedEncryptedSupportingTokens();</span> -<span class="nc bnc" id="L1607" title="All 4 branches missed."> if (supportingTokens != null && supportingTokens.getTokens().size() != 0) {</span> -<span class="nc" id="L1608"> return true;</span> +<span class="nc" id="L1624"> supportingTokens = rpd.getSignedEncryptedSupportingTokens();</span> +<span class="nc bnc" id="L1625" title="All 4 branches missed."> if (supportingTokens != null && supportingTokens.getTokens().size() != 0) {</span> +<span class="nc" id="L1626"> return true;</span> } -<span class="nc" id="L1611"> supportingTokens = rpd.getEndorsingEncryptedSupportingTokens();</span> -<span class="nc bnc" id="L1612" title="All 4 branches missed."> if (supportingTokens != null && supportingTokens.getTokens().size() != 0) {</span> -<span class="nc" id="L1613"> return true;</span> +<span class="nc" id="L1629"> supportingTokens = rpd.getEndorsingEncryptedSupportingTokens();</span> +<span class="nc bnc" id="L1630" title="All 4 branches missed."> if (supportingTokens != null && supportingTokens.getTokens().size() != 0) {</span> +<span class="nc" id="L1631"> return true;</span> } -<span class="nc" id="L1616"> supportingTokens = rpd.getSignedEndorsingEncryptedSupportingTokens();</span> -<span class="nc bnc" id="L1617" title="All 4 branches missed."> if (supportingTokens != null && supportingTokens.getTokens().size() != 0) {</span> -<span class="nc" id="L1618"> return true;</span> +<span class="nc" id="L1634"> supportingTokens = rpd.getSignedEndorsingEncryptedSupportingTokens();</span>
[... 464 lines stripped ...]
