You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wss4j-dev@ws.apache.org by co...@apache.org on 2009/07/28 15:24:03 UTC

svn commit: r798514 [40/44] - in /webservices/wss4j/site: ./ apidocs/ apidocs/org/apache/ws/axis/security/ apidocs/org/apache/ws/axis/security/class-use/ apidocs/org/apache/ws/axis/security/handler/ apidocs/org/apache/ws/axis/security/handler/class-use...

Modified: webservices/wss4j/site/xref/org/apache/ws/security/processor/ReferenceListProcessor.html
URL: http://svn.apache.org/viewvc/webservices/wss4j/site/xref/org/apache/ws/security/processor/ReferenceListProcessor.html?rev=798514&r1=798513&r2=798514&view=diff
==============================================================================
--- webservices/wss4j/site/xref/org/apache/ws/security/processor/ReferenceListProcessor.html (original)
+++ webservices/wss4j/site/xref/org/apache/ws/security/processor/ReferenceListProcessor.html Tue Jul 28 13:23:48 2009
@@ -33,424 +33,413 @@
 <a name="23" href="#23">23</a>  <strong class="jxr_keyword">import</strong> javax.crypto.SecretKey;
 <a name="24" href="#24">24</a>  <strong class="jxr_keyword">import</strong> javax.security.auth.callback.Callback;
 <a name="25" href="#25">25</a>  <strong class="jxr_keyword">import</strong> javax.security.auth.callback.CallbackHandler;
-<a name="26" href="#26">26</a>  <strong class="jxr_keyword">import</strong> javax.xml.namespace.QName;
-<a name="27" href="#27">27</a>  
-<a name="28" href="#28">28</a>  <strong class="jxr_keyword">import</strong> org.apache.commons.logging.Log;
-<a name="29" href="#29">29</a>  <strong class="jxr_keyword">import</strong> org.apache.commons.logging.LogFactory;
-<a name="30" href="#30">30</a>  <strong class="jxr_keyword">import</strong> org.apache.ws.security.WSConstants;
-<a name="31" href="#31">31</a>  <strong class="jxr_keyword">import</strong> org.apache.ws.security.WSDataRef;
-<a name="32" href="#32">32</a>  <strong class="jxr_keyword">import</strong> org.apache.ws.security.WSDocInfo;
-<a name="33" href="#33">33</a>  <strong class="jxr_keyword">import</strong> org.apache.ws.security.WSPasswordCallback;
-<a name="34" href="#34">34</a>  <strong class="jxr_keyword">import</strong> org.apache.ws.security.WSSConfig;
-<a name="35" href="#35">35</a>  <strong class="jxr_keyword">import</strong> org.apache.ws.security.WSSecurityEngineResult;
-<a name="36" href="#36">36</a>  <strong class="jxr_keyword">import</strong> org.apache.ws.security.WSSecurityException;
-<a name="37" href="#37">37</a>  <strong class="jxr_keyword">import</strong> org.apache.ws.security.components.crypto.Crypto;
-<a name="38" href="#38">38</a>  <strong class="jxr_keyword">import</strong> org.apache.ws.security.message.token.Reference;
-<a name="39" href="#39">39</a>  <strong class="jxr_keyword">import</strong> org.apache.ws.security.message.token.SecurityTokenReference;
-<a name="40" href="#40">40</a>  <strong class="jxr_keyword">import</strong> org.apache.ws.security.saml.SAMLKeyInfo;
-<a name="41" href="#41">41</a>  <strong class="jxr_keyword">import</strong> org.apache.ws.security.saml.SAMLUtil;
-<a name="42" href="#42">42</a>  <strong class="jxr_keyword">import</strong> org.apache.ws.security.util.WSSecurityUtil;
-<a name="43" href="#43">43</a>  <strong class="jxr_keyword">import</strong> org.apache.xml.security.encryption.XMLCipher;
-<a name="44" href="#44">44</a>  <strong class="jxr_keyword">import</strong> org.apache.xml.security.encryption.XMLEncryptionException;
-<a name="45" href="#45">45</a>  <strong class="jxr_keyword">import</strong> org.apache.xml.security.utils.Constants;
-<a name="46" href="#46">46</a>  <strong class="jxr_keyword">import</strong> org.w3c.dom.Document;
-<a name="47" href="#47">47</a>  <strong class="jxr_keyword">import</strong> org.w3c.dom.Element;
-<a name="48" href="#48">48</a>  <strong class="jxr_keyword">import</strong> org.w3c.dom.Node;
-<a name="49" href="#49">49</a>  <strong class="jxr_keyword">import</strong> org.w3c.dom.NodeList;
-<a name="50" href="#50">50</a>  
-<a name="51" href="#51">51</a>  <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../org/apache/ws/security/processor/ReferenceListProcessor.html">ReferenceListProcessor</a> implements <a href="../../../../../org/apache/ws/security/processor/Processor.html">Processor</a> {
-<a name="52" href="#52">52</a>      <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> Log log = 
-<a name="53" href="#53">53</a>          LogFactory.getLog(ReferenceListProcessor.<strong class="jxr_keyword">class</strong>.getName());
-<a name="54" href="#54">54</a>  
-<a name="55" href="#55">55</a>      <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">boolean</strong> debug = false;
-<a name="56" href="#56">56</a>      <a href="../../../../../org/apache/ws/security/WSDocInfo.html">WSDocInfo</a> wsDocInfo = <strong class="jxr_keyword">null</strong>;
-<a name="57" href="#57">57</a>  
-<a name="58" href="#58">58</a>      <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> handleToken(
-<a name="59" href="#59">59</a>          Element elem, 
-<a name="60" href="#60">60</a>          <a href="../../../../../org/apache/ws/security/components/crypto/Crypto.html">Crypto</a> crypto, 
-<a name="61" href="#61">61</a>          <a href="../../../../../org/apache/ws/security/components/crypto/Crypto.html">Crypto</a> decCrypto,
-<a name="62" href="#62">62</a>          CallbackHandler cb, 
-<a name="63" href="#63">63</a>          <a href="../../../../../org/apache/ws/security/WSDocInfo.html">WSDocInfo</a> wdi, 
-<a name="64" href="#64">64</a>          Vector returnResults,
-<a name="65" href="#65">65</a>          <a href="../../../../../org/apache/ws/security/WSSConfig.html">WSSConfig</a> wsc
-<a name="66" href="#66">66</a>      ) <strong class="jxr_keyword">throws</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a> {
-<a name="67" href="#67">67</a>  
-<a name="68" href="#68">68</a>          debug = log.isDebugEnabled();
-<a name="69" href="#69">69</a>          <strong class="jxr_keyword">if</strong> (debug) {
-<a name="70" href="#70">70</a>              log.debug(<span class="jxr_string">"Found reference list element"</span>);
-<a name="71" href="#71">71</a>          }
-<a name="72" href="#72">72</a>          <strong class="jxr_keyword">if</strong> (cb == <strong class="jxr_keyword">null</strong>) {
-<a name="73" href="#73">73</a>              <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a>(WSSecurityException.FAILURE, <span class="jxr_string">"noCallback"</span>);
-<a name="74" href="#74">74</a>          }
-<a name="75" href="#75">75</a>          wsDocInfo = wdi;
-<a name="76" href="#76">76</a>          ArrayList uris = handleReferenceList(elem, cb, crypto);
-<a name="77" href="#77">77</a>          returnResults.add(
-<a name="78" href="#78">78</a>              0,
-<a name="79" href="#79">79</a>              <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSSecurityEngineResult.html">WSSecurityEngineResult</a>(WSConstants.ENCR, uris)
-<a name="80" href="#80">80</a>          );
-<a name="81" href="#81">81</a>      }
-<a name="82" href="#82">82</a>  
-<a name="83" href="#83">83</a>      <em class="jxr_javadoccomment">/**</em>
-<a name="84" href="#84">84</a>  <em class="jxr_javadoccomment">     * Dereferences and decodes encrypted data elements.</em>
-<a name="85" href="#85">85</a>  <em class="jxr_javadoccomment">     * </em>
-<a name="86" href="#86">86</a>  <em class="jxr_javadoccomment">     * @param elem contains the &lt;code&gt;ReferenceList&lt;/code&gt; to the encrypted</em>
-<a name="87" href="#87">87</a>  <em class="jxr_javadoccomment">     *             data elements</em>
-<a name="88" href="#88">88</a>  <em class="jxr_javadoccomment">     * @param cb the callback handler to get the key for a key name stored if</em>
-<a name="89" href="#89">89</a>  <em class="jxr_javadoccomment">     *           &lt;code&gt;KeyInfo&lt;/code&gt; inside the encrypted data elements</em>
-<a name="90" href="#90">90</a>  <em class="jxr_javadoccomment">     */</em>
-<a name="91" href="#91">91</a>      <strong class="jxr_keyword">private</strong> ArrayList handleReferenceList(
-<a name="92" href="#92">92</a>          Element elem, 
-<a name="93" href="#93">93</a>          CallbackHandler cb,
-<a name="94" href="#94">94</a>          <a href="../../../../../org/apache/ws/security/components/crypto/Crypto.html">Crypto</a> crypto
-<a name="95" href="#95">95</a>      ) <strong class="jxr_keyword">throws</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a> {
-<a name="96" href="#96">96</a>          Document doc = elem.getOwnerDocument();
-<a name="97" href="#97">97</a>  
-<a name="98" href="#98">98</a>          Node tmpE = <strong class="jxr_keyword">null</strong>;
-<a name="99" href="#99">99</a>          ArrayList dataRefUris = <strong class="jxr_keyword">new</strong> ArrayList();
-<a name="100" href="#100">100</a>         <strong class="jxr_keyword">for</strong> (tmpE = elem.getFirstChild(); 
-<a name="101" href="#101">101</a>             tmpE != <strong class="jxr_keyword">null</strong>; 
-<a name="102" href="#102">102</a>             tmpE = tmpE.getNextSibling()
-<a name="103" href="#103">103</a>         ) {
-<a name="104" href="#104">104</a>             <strong class="jxr_keyword">if</strong> (tmpE.getNodeType() != Node.ELEMENT_NODE) {
-<a name="105" href="#105">105</a>                 <strong class="jxr_keyword">continue</strong>;
-<a name="106" href="#106">106</a>             }
-<a name="107" href="#107">107</a>             <strong class="jxr_keyword">if</strong> (!tmpE.getNamespaceURI().equals(WSConstants.ENC_NS)) {
-<a name="108" href="#108">108</a>                 <strong class="jxr_keyword">continue</strong>;
-<a name="109" href="#109">109</a>             }
-<a name="110" href="#110">110</a>             <strong class="jxr_keyword">if</strong> (tmpE.getLocalName().equals(<span class="jxr_string">"DataReference"</span>)) {
-<a name="111" href="#111">111</a>                 String dataRefURI = ((Element) tmpE).getAttribute(<span class="jxr_string">"URI"</span>);
-<a name="112" href="#112">112</a>                 <a href="../../../../../org/apache/ws/security/WSDataRef.html">WSDataRef</a> dataRef = <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSDataRef.html">WSDataRef</a>(dataRefURI.substring(1));
-<a name="113" href="#113">113</a>                 decryptDataRefEmbedded(doc, dataRefURI, dataRef, cb, crypto);
-<a name="114" href="#114">114</a>                 dataRefUris.add(dataRef);
-<a name="115" href="#115">115</a>             }
-<a name="116" href="#116">116</a>         }
-<a name="117" href="#117">117</a>         
-<a name="118" href="#118">118</a>         <strong class="jxr_keyword">return</strong> dataRefUris;
-<a name="119" href="#119">119</a>     }
-<a name="120" href="#120">120</a> 
-<a name="121" href="#121">121</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> decryptDataRefEmbedded(
-<a name="122" href="#122">122</a>         Document doc, 
-<a name="123" href="#123">123</a>         String dataRefURI, 
-<a name="124" href="#124">124</a>         <a href="../../../../../org/apache/ws/security/WSDataRef.html">WSDataRef</a> dataRef,
-<a name="125" href="#125">125</a>         CallbackHandler cb, 
-<a name="126" href="#126">126</a>         <a href="../../../../../org/apache/ws/security/components/crypto/Crypto.html">Crypto</a> crypto
-<a name="127" href="#127">127</a>     ) <strong class="jxr_keyword">throws</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a> {
-<a name="128" href="#128">128</a> 
-<a name="129" href="#129">129</a>         <strong class="jxr_keyword">if</strong> (log.isDebugEnabled()) {
-<a name="130" href="#130">130</a>             log.debug(<span class="jxr_string">"Found data reference: "</span> + dataRefURI);
-<a name="131" href="#131">131</a>         }
-<a name="132" href="#132">132</a>         <em class="jxr_comment">//</em>
-<a name="133" href="#133">133</a>         <em class="jxr_comment">// Look up the encrypted data. First try wsu:Id="someURI". If no such Id</em>
-<a name="134" href="#134">134</a>         <em class="jxr_comment">// then try the generic lookup to find Id="someURI"</em>
+<a name="26" href="#26">26</a>  
+<a name="27" href="#27">27</a>  <strong class="jxr_keyword">import</strong> org.apache.commons.logging.Log;
+<a name="28" href="#28">28</a>  <strong class="jxr_keyword">import</strong> org.apache.commons.logging.LogFactory;
+<a name="29" href="#29">29</a>  <strong class="jxr_keyword">import</strong> org.apache.ws.security.WSConstants;
+<a name="30" href="#30">30</a>  <strong class="jxr_keyword">import</strong> org.apache.ws.security.WSDataRef;
+<a name="31" href="#31">31</a>  <strong class="jxr_keyword">import</strong> org.apache.ws.security.WSDocInfo;
+<a name="32" href="#32">32</a>  <strong class="jxr_keyword">import</strong> org.apache.ws.security.WSPasswordCallback;
+<a name="33" href="#33">33</a>  <strong class="jxr_keyword">import</strong> org.apache.ws.security.WSSConfig;
+<a name="34" href="#34">34</a>  <strong class="jxr_keyword">import</strong> org.apache.ws.security.WSSecurityEngineResult;
+<a name="35" href="#35">35</a>  <strong class="jxr_keyword">import</strong> org.apache.ws.security.WSSecurityException;
+<a name="36" href="#36">36</a>  <strong class="jxr_keyword">import</strong> org.apache.ws.security.components.crypto.Crypto;
+<a name="37" href="#37">37</a>  <strong class="jxr_keyword">import</strong> org.apache.ws.security.message.token.Reference;
+<a name="38" href="#38">38</a>  <strong class="jxr_keyword">import</strong> org.apache.ws.security.message.token.SecurityTokenReference;
+<a name="39" href="#39">39</a>  <strong class="jxr_keyword">import</strong> org.apache.ws.security.saml.SAMLKeyInfo;
+<a name="40" href="#40">40</a>  <strong class="jxr_keyword">import</strong> org.apache.ws.security.saml.SAMLUtil;
+<a name="41" href="#41">41</a>  <strong class="jxr_keyword">import</strong> org.apache.ws.security.util.WSSecurityUtil;
+<a name="42" href="#42">42</a>  <strong class="jxr_keyword">import</strong> org.apache.xml.security.encryption.XMLCipher;
+<a name="43" href="#43">43</a>  <strong class="jxr_keyword">import</strong> org.apache.xml.security.encryption.XMLEncryptionException;
+<a name="44" href="#44">44</a>  <strong class="jxr_keyword">import</strong> org.w3c.dom.Attr;
+<a name="45" href="#45">45</a>  <strong class="jxr_keyword">import</strong> org.w3c.dom.Document;
+<a name="46" href="#46">46</a>  <strong class="jxr_keyword">import</strong> org.w3c.dom.Element;
+<a name="47" href="#47">47</a>  <strong class="jxr_keyword">import</strong> org.w3c.dom.Node;
+<a name="48" href="#48">48</a>  
+<a name="49" href="#49">49</a>  <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">class</strong> <a href="../../../../../org/apache/ws/security/processor/ReferenceListProcessor.html">ReferenceListProcessor</a> implements <a href="../../../../../org/apache/ws/security/processor/Processor.html">Processor</a> {
+<a name="50" href="#50">50</a>      <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> Log log = 
+<a name="51" href="#51">51</a>          LogFactory.getLog(ReferenceListProcessor.<strong class="jxr_keyword">class</strong>.getName());
+<a name="52" href="#52">52</a>  
+<a name="53" href="#53">53</a>      <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">boolean</strong> debug = false;
+<a name="54" href="#54">54</a>      <a href="../../../../../org/apache/ws/security/WSDocInfo.html">WSDocInfo</a> wsDocInfo = <strong class="jxr_keyword">null</strong>;
+<a name="55" href="#55">55</a>  
+<a name="56" href="#56">56</a>      <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> handleToken(
+<a name="57" href="#57">57</a>          Element elem, 
+<a name="58" href="#58">58</a>          <a href="../../../../../org/apache/ws/security/components/crypto/Crypto.html">Crypto</a> crypto, 
+<a name="59" href="#59">59</a>          <a href="../../../../../org/apache/ws/security/components/crypto/Crypto.html">Crypto</a> decCrypto,
+<a name="60" href="#60">60</a>          CallbackHandler cb, 
+<a name="61" href="#61">61</a>          <a href="../../../../../org/apache/ws/security/WSDocInfo.html">WSDocInfo</a> wdi, 
+<a name="62" href="#62">62</a>          Vector returnResults,
+<a name="63" href="#63">63</a>          <a href="../../../../../org/apache/ws/security/WSSConfig.html">WSSConfig</a> wsc
+<a name="64" href="#64">64</a>      ) <strong class="jxr_keyword">throws</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a> {
+<a name="65" href="#65">65</a>  
+<a name="66" href="#66">66</a>          debug = log.isDebugEnabled();
+<a name="67" href="#67">67</a>          <strong class="jxr_keyword">if</strong> (debug) {
+<a name="68" href="#68">68</a>              log.debug(<span class="jxr_string">"Found reference list element"</span>);
+<a name="69" href="#69">69</a>          }
+<a name="70" href="#70">70</a>          <strong class="jxr_keyword">if</strong> (cb == <strong class="jxr_keyword">null</strong>) {
+<a name="71" href="#71">71</a>              <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a>(WSSecurityException.FAILURE, <span class="jxr_string">"noCallback"</span>);
+<a name="72" href="#72">72</a>          }
+<a name="73" href="#73">73</a>          wsDocInfo = wdi;
+<a name="74" href="#74">74</a>          ArrayList uris = handleReferenceList(elem, cb, decCrypto);
+<a name="75" href="#75">75</a>          returnResults.add(
+<a name="76" href="#76">76</a>              0,
+<a name="77" href="#77">77</a>              <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSSecurityEngineResult.html">WSSecurityEngineResult</a>(WSConstants.ENCR, uris)
+<a name="78" href="#78">78</a>          );
+<a name="79" href="#79">79</a>      }
+<a name="80" href="#80">80</a>  
+<a name="81" href="#81">81</a>      <em class="jxr_javadoccomment">/**</em>
+<a name="82" href="#82">82</a>  <em class="jxr_javadoccomment">     * Dereferences and decodes encrypted data elements.</em>
+<a name="83" href="#83">83</a>  <em class="jxr_javadoccomment">     * </em>
+<a name="84" href="#84">84</a>  <em class="jxr_javadoccomment">     * @param elem contains the &lt;code&gt;ReferenceList&lt;/code&gt; to the encrypted</em>
+<a name="85" href="#85">85</a>  <em class="jxr_javadoccomment">     *             data elements</em>
+<a name="86" href="#86">86</a>  <em class="jxr_javadoccomment">     * @param cb the callback handler to get the key for a key name stored if</em>
+<a name="87" href="#87">87</a>  <em class="jxr_javadoccomment">     *           &lt;code&gt;KeyInfo&lt;/code&gt; inside the encrypted data elements</em>
+<a name="88" href="#88">88</a>  <em class="jxr_javadoccomment">     */</em>
+<a name="89" href="#89">89</a>      <strong class="jxr_keyword">private</strong> ArrayList handleReferenceList(
+<a name="90" href="#90">90</a>          Element elem, 
+<a name="91" href="#91">91</a>          CallbackHandler cb,
+<a name="92" href="#92">92</a>          <a href="../../../../../org/apache/ws/security/components/crypto/Crypto.html">Crypto</a> crypto
+<a name="93" href="#93">93</a>      ) <strong class="jxr_keyword">throws</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a> {
+<a name="94" href="#94">94</a>          Node tmpE = <strong class="jxr_keyword">null</strong>;
+<a name="95" href="#95">95</a>          ArrayList dataRefUris = <strong class="jxr_keyword">new</strong> ArrayList();
+<a name="96" href="#96">96</a>          <strong class="jxr_keyword">for</strong> (tmpE = elem.getFirstChild(); 
+<a name="97" href="#97">97</a>              tmpE != <strong class="jxr_keyword">null</strong>; 
+<a name="98" href="#98">98</a>              tmpE = tmpE.getNextSibling()
+<a name="99" href="#99">99</a>          ) {
+<a name="100" href="#100">100</a>             <strong class="jxr_keyword">if</strong> (tmpE.getNodeType() != Node.ELEMENT_NODE) {
+<a name="101" href="#101">101</a>                 <strong class="jxr_keyword">continue</strong>;
+<a name="102" href="#102">102</a>             }
+<a name="103" href="#103">103</a>             <strong class="jxr_keyword">if</strong> (!tmpE.getNamespaceURI().equals(WSConstants.ENC_NS)) {
+<a name="104" href="#104">104</a>                 <strong class="jxr_keyword">continue</strong>;
+<a name="105" href="#105">105</a>             }
+<a name="106" href="#106">106</a>             <strong class="jxr_keyword">if</strong> (tmpE.getLocalName().equals(<span class="jxr_string">"DataReference"</span>)) {
+<a name="107" href="#107">107</a>                 String dataRefURI = ((Element) tmpE).getAttribute(<span class="jxr_string">"URI"</span>);
+<a name="108" href="#108">108</a>                 <strong class="jxr_keyword">if</strong> (dataRefURI.charAt(0) == '#') {
+<a name="109" href="#109">109</a>                     dataRefURI = dataRefURI.substring(1);
+<a name="110" href="#110">110</a>                 }
+<a name="111" href="#111">111</a>                 <a href="../../../../../org/apache/ws/security/WSDataRef.html">WSDataRef</a> dataRef = 
+<a name="112" href="#112">112</a>                     decryptDataRefEmbedded(elem.getOwnerDocument(), dataRefURI, cb, crypto);
+<a name="113" href="#113">113</a>                 dataRefUris.add(dataRef);
+<a name="114" href="#114">114</a>             }
+<a name="115" href="#115">115</a>         }
+<a name="116" href="#116">116</a>         
+<a name="117" href="#117">117</a>         <strong class="jxr_keyword">return</strong> dataRefUris;
+<a name="118" href="#118">118</a>     }
+<a name="119" href="#119">119</a> 
+<a name="120" href="#120">120</a>     
+<a name="121" href="#121">121</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="122" href="#122">122</a> <em class="jxr_javadoccomment">     * Decrypt an (embedded) EncryptedData element referenced by dataRefURI.</em>
+<a name="123" href="#123">123</a> <em class="jxr_javadoccomment">     */</em>
+<a name="124" href="#124">124</a>     <strong class="jxr_keyword">private</strong> <a href="../../../../../org/apache/ws/security/WSDataRef.html">WSDataRef</a> decryptDataRefEmbedded(
+<a name="125" href="#125">125</a>         Document doc, 
+<a name="126" href="#126">126</a>         String dataRefURI, 
+<a name="127" href="#127">127</a>         CallbackHandler cb, 
+<a name="128" href="#128">128</a>         <a href="../../../../../org/apache/ws/security/components/crypto/Crypto.html">Crypto</a> crypto
+<a name="129" href="#129">129</a>     ) <strong class="jxr_keyword">throws</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a> {
+<a name="130" href="#130">130</a>         <strong class="jxr_keyword">if</strong> (log.isDebugEnabled()) {
+<a name="131" href="#131">131</a>             log.debug(<span class="jxr_string">"Found data reference: "</span> + dataRefURI);
+<a name="132" href="#132">132</a>         }
+<a name="133" href="#133">133</a>         <em class="jxr_comment">//</em>
+<a name="134" href="#134">134</a>         <em class="jxr_comment">// Find the encrypted data element referenced by dataRefURI</em>
 <a name="135" href="#135">135</a>         <em class="jxr_comment">//</em>
-<a name="136" href="#136">136</a>         Element encBodyData = <strong class="jxr_keyword">null</strong>;
-<a name="137" href="#137">137</a>         <strong class="jxr_keyword">if</strong> ((encBodyData = WSSecurityUtil.getElementByWsuId(doc, dataRefURI)) == <strong class="jxr_keyword">null</strong>) {            
-<a name="138" href="#138">138</a>             encBodyData = WSSecurityUtil.getElementByGenId(doc, dataRefURI);
-<a name="139" href="#139">139</a>         }
-<a name="140" href="#140">140</a>         <strong class="jxr_keyword">if</strong> (encBodyData == <strong class="jxr_keyword">null</strong>) {
-<a name="141" href="#141">141</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a>(
-<a name="142" href="#142">142</a>                 WSSecurityException.INVALID_SECURITY, <span class="jxr_string">"dataRef"</span>, <strong class="jxr_keyword">new</strong> Object[] {dataRefURI}
-<a name="143" href="#143">143</a>             );
-<a name="144" href="#144">144</a>         }
-<a name="145" href="#145">145</a> 
-<a name="146" href="#146">146</a>         <strong class="jxr_keyword">boolean</strong> content = X509Util.isContent(encBodyData);
-<a name="147" href="#147">147</a> 
-<a name="148" href="#148">148</a>         <em class="jxr_comment">// Now figure out the encryption algorithm</em>
-<a name="149" href="#149">149</a>         String symEncAlgo = X509Util.getEncAlgo(encBodyData);
-<a name="150" href="#150">150</a> 
-<a name="151" href="#151">151</a>         Element tmpE = 
-<a name="152" href="#152">152</a>             (Element)WSSecurityUtil.findElement(
-<a name="153" href="#153">153</a>                 (Node) encBodyData, <span class="jxr_string">"KeyInfo"</span>, WSConstants.SIG_NS
-<a name="154" href="#154">154</a>             );
-<a name="155" href="#155">155</a>         <strong class="jxr_keyword">if</strong> (tmpE == <strong class="jxr_keyword">null</strong>) {
-<a name="156" href="#156">156</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a>(WSSecurityException.INVALID_SECURITY, <span class="jxr_string">"noKeyinfo"</span>);
-<a name="157" href="#157">157</a>         }
-<a name="158" href="#158">158</a> 
-<a name="159" href="#159">159</a>         <em class="jxr_comment">//</em>
-<a name="160" href="#160">160</a>         <em class="jxr_comment">// Try to get a security reference token, if none found try to get a</em>
-<a name="161" href="#161">161</a>         <em class="jxr_comment">// shared key using a KeyName.</em>
-<a name="162" href="#162">162</a>         <em class="jxr_comment">//</em>
-<a name="163" href="#163">163</a>         Element secRefToken = 
-<a name="164" href="#164">164</a>             (Element) WSSecurityUtil.getDirectChild(
-<a name="165" href="#165">165</a>                 tmpE, <span class="jxr_string">"SecurityTokenReference"</span>, WSConstants.WSSE_NS
-<a name="166" href="#166">166</a>             );
-<a name="167" href="#167">167</a> 
-<a name="168" href="#168">168</a>         SecretKey symmetricKey = <strong class="jxr_keyword">null</strong>;
-<a name="169" href="#169">169</a>         <strong class="jxr_keyword">if</strong> (secRefToken == <strong class="jxr_keyword">null</strong>) {
-<a name="170" href="#170">170</a>             symmetricKey = X509Util.getSharedKey(tmpE, symEncAlgo, cb);
-<a name="171" href="#171">171</a>         } <strong class="jxr_keyword">else</strong> {
-<a name="172" href="#172">172</a>             symmetricKey = getKeyFromSecurityTokenReference(secRefToken, symEncAlgo, crypto, cb);
-<a name="173" href="#173">173</a>         }
-<a name="174" href="#174">174</a> 
-<a name="175" href="#175">175</a>         <em class="jxr_comment">// initialize Cipher ....</em>
-<a name="176" href="#176">176</a>         XMLCipher xmlCipher = <strong class="jxr_keyword">null</strong>;
-<a name="177" href="#177">177</a>         <strong class="jxr_keyword">try</strong> {
-<a name="178" href="#178">178</a>             xmlCipher = XMLCipher.getInstance(symEncAlgo);
-<a name="179" href="#179">179</a>             xmlCipher.init(XMLCipher.DECRYPT_MODE, symmetricKey);
-<a name="180" href="#180">180</a>         } <strong class="jxr_keyword">catch</strong> (XMLEncryptionException e1) {
-<a name="181" href="#181">181</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a>(
-<a name="182" href="#182">182</a>                 WSSecurityException.UNSUPPORTED_ALGORITHM, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">null</strong>, e1
-<a name="183" href="#183">183</a>             );
-<a name="184" href="#184">184</a>         }
-<a name="185" href="#185">185</a> 
-<a name="186" href="#186">186</a>         <strong class="jxr_keyword">if</strong> (content) {
-<a name="187" href="#187">187</a>             encBodyData = (Element) encBodyData.getParentNode();
-<a name="188" href="#188">188</a>             dataRef.setName(<strong class="jxr_keyword">new</strong> QName(encBodyData.getNamespaceURI(), encBodyData.getLocalName()));
+<a name="136" href="#136">136</a>         Element encryptedDataElement = findEncryptedDataElement(doc, dataRefURI);
+<a name="137" href="#137">137</a>         <em class="jxr_comment">//</em>
+<a name="138" href="#138">138</a>         <em class="jxr_comment">// Prepare the SecretKey object to decrypt EncryptedData</em>
+<a name="139" href="#139">139</a>         <em class="jxr_comment">//</em>
+<a name="140" href="#140">140</a>         String symEncAlgo = X509Util.getEncAlgo(encryptedDataElement);
+<a name="141" href="#141">141</a>         Element keyInfoElement = 
+<a name="142" href="#142">142</a>             (Element)WSSecurityUtil.getDirectChildElement(
+<a name="143" href="#143">143</a>                 encryptedDataElement, <span class="jxr_string">"KeyInfo"</span>, WSConstants.SIG_NS
+<a name="144" href="#144">144</a>             );
+<a name="145" href="#145">145</a>         <strong class="jxr_keyword">if</strong> (keyInfoElement == <strong class="jxr_keyword">null</strong>) {
+<a name="146" href="#146">146</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a>(WSSecurityException.INVALID_SECURITY, <span class="jxr_string">"noKeyinfo"</span>);
+<a name="147" href="#147">147</a>         }
+<a name="148" href="#148">148</a>         <em class="jxr_comment">//</em>
+<a name="149" href="#149">149</a>         <em class="jxr_comment">// Try to get a security reference token, if none found try to get a</em>
+<a name="150" href="#150">150</a>         <em class="jxr_comment">// shared key using a KeyName.</em>
+<a name="151" href="#151">151</a>         <em class="jxr_comment">//</em>
+<a name="152" href="#152">152</a>         Element secRefToken = 
+<a name="153" href="#153">153</a>             WSSecurityUtil.getDirectChildElement(
+<a name="154" href="#154">154</a>                 keyInfoElement, <span class="jxr_string">"SecurityTokenReference"</span>, WSConstants.WSSE_NS
+<a name="155" href="#155">155</a>             );
+<a name="156" href="#156">156</a>         SecretKey symmetricKey = <strong class="jxr_keyword">null</strong>;
+<a name="157" href="#157">157</a>         <strong class="jxr_keyword">if</strong> (secRefToken == <strong class="jxr_keyword">null</strong>) {
+<a name="158" href="#158">158</a>             symmetricKey = X509Util.getSharedKey(keyInfoElement, symEncAlgo, cb);
+<a name="159" href="#159">159</a>         } <strong class="jxr_keyword">else</strong> {
+<a name="160" href="#160">160</a>             symmetricKey = 
+<a name="161" href="#161">161</a>                 getKeyFromSecurityTokenReference(secRefToken, symEncAlgo, crypto, cb);
+<a name="162" href="#162">162</a>         }
+<a name="163" href="#163">163</a> 
+<a name="164" href="#164">164</a>         <strong class="jxr_keyword">return</strong> 
+<a name="165" href="#165">165</a>             decryptEncryptedData(
+<a name="166" href="#166">166</a>                 doc, dataRefURI, encryptedDataElement, symmetricKey, symEncAlgo
+<a name="167" href="#167">167</a>             );
+<a name="168" href="#168">168</a>     }
+<a name="169" href="#169">169</a> 
+<a name="170" href="#170">170</a>     
+<a name="171" href="#171">171</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="172" href="#172">172</a> <em class="jxr_javadoccomment">     * Look up the encrypted data. First try wsu:Id="someURI". If no such Id then try the </em>
+<a name="173" href="#173">173</a> <em class="jxr_javadoccomment">     * generic lookup to find Id="someURI"</em>
+<a name="174" href="#174">174</a> <em class="jxr_javadoccomment">     * </em>
+<a name="175" href="#175">175</a> <em class="jxr_javadoccomment">     * @param doc The document in which to find EncryptedData</em>
+<a name="176" href="#176">176</a> <em class="jxr_javadoccomment">     * @param dataRefURI The URI of EncryptedData</em>
+<a name="177" href="#177">177</a> <em class="jxr_javadoccomment">     * @return The EncryptedData element</em>
+<a name="178" href="#178">178</a> <em class="jxr_javadoccomment">     * @throws WSSecurityException if the EncryptedData element referenced by dataRefURI is </em>
+<a name="179" href="#179">179</a> <em class="jxr_javadoccomment">     * not found</em>
+<a name="180" href="#180">180</a> <em class="jxr_javadoccomment">     */</em>
+<a name="181" href="#181">181</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> Element
+<a name="182" href="#182">182</a>     findEncryptedDataElement(
+<a name="183" href="#183">183</a>         Document doc,
+<a name="184" href="#184">184</a>         String dataRefURI
+<a name="185" href="#185">185</a>     ) <strong class="jxr_keyword">throws</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a> {
+<a name="186" href="#186">186</a>         Element encryptedDataElement = WSSecurityUtil.getElementByWsuId(doc, dataRefURI);
+<a name="187" href="#187">187</a>         <strong class="jxr_keyword">if</strong> (encryptedDataElement == <strong class="jxr_keyword">null</strong>) {   
+<a name="188" href="#188">188</a>             encryptedDataElement = WSSecurityUtil.getElementByGenId(doc, dataRefURI);
 <a name="189" href="#189">189</a>         }
-<a name="190" href="#190">190</a>             
-<a name="191" href="#191">191</a>         <strong class="jxr_keyword">try</strong> {
-<a name="192" href="#192">192</a>             Node parentEncBody =encBodyData.getParentNode();
-<a name="193" href="#193">193</a>             <strong class="jxr_keyword">final</strong> java.util.List before_peers = listChildren(parentEncBody);
-<a name="194" href="#194">194</a>             
-<a name="195" href="#195">195</a>             xmlCipher.doFinal(doc, encBodyData, content);
-<a name="196" href="#196">196</a>             
-<a name="197" href="#197">197</a>             <strong class="jxr_keyword">if</strong> (parentEncBody.getLocalName().equals(WSConstants.ENCRYPTED_HEADER)
-<a name="198" href="#198">198</a>                 &amp;&amp; parentEncBody.getNamespaceURI().equals(WSConstants.WSSE11_NS)) {
-<a name="199" href="#199">199</a>                 Node decryptedHeader = parentEncBody.getFirstChild();
-<a name="200" href="#200">200</a>                 Element decryptedHeaderClone = (Element)decryptedHeader.cloneNode(<strong class="jxr_keyword">true</strong>);
-<a name="201" href="#201">201</a>                 String sigId = decryptedHeaderClone.getAttributeNS(WSConstants.WSU_NS, <span class="jxr_string">"Id"</span>);
-<a name="202" href="#202">202</a>                 
-<a name="203" href="#203">203</a>                 <strong class="jxr_keyword">if</strong> (sigId == <strong class="jxr_keyword">null</strong> || sigId.equals(<span class="jxr_string">""</span>)) {
-<a name="204" href="#204">204</a>                     String id = ((Element)parentEncBody).getAttributeNS(WSConstants.WSU_NS, <span class="jxr_string">"Id"</span>);                              
-<a name="205" href="#205">205</a>                     String wsuPrefix = 
-<a name="206" href="#206">206</a>                         WSSecurityUtil.setNamespace(
-<a name="207" href="#207">207</a>                             decryptedHeaderClone, WSConstants.WSU_NS, WSConstants.WSU_PREFIX
-<a name="208" href="#208">208</a>                         );
-<a name="209" href="#209">209</a>                     decryptedHeaderClone.setAttributeNS(WSConstants.WSU_NS, wsuPrefix + <span class="jxr_string">":Id"</span>, id);
-<a name="210" href="#210">210</a>                     dataRef.setWsuId(id.substring(1));
-<a name="211" href="#211">211</a>                 } <strong class="jxr_keyword">else</strong> {
-<a name="212" href="#212">212</a>                     dataRef.setWsuId(sigId);
-<a name="213" href="#213">213</a>                 }
-<a name="214" href="#214">214</a>                     
-<a name="215" href="#215">215</a>                 parentEncBody.getParentNode().appendChild(decryptedHeaderClone);
-<a name="216" href="#216">216</a>                 parentEncBody.getParentNode().removeChild(parentEncBody);
-<a name="217" href="#217">217</a>             } 
-<a name="218" href="#218">218</a>             
-<a name="219" href="#219">219</a>             <strong class="jxr_keyword">final</strong> java.util.List after_peers = listChildren(parentEncBody);
-<a name="220" href="#220">220</a>             <strong class="jxr_keyword">final</strong> java.util.List <strong class="jxr_keyword">new</strong>_nodes = newNodes(before_peers, after_peers);
-<a name="221" href="#221">221</a>             <strong class="jxr_keyword">for</strong> (
-<a name="222" href="#222">222</a>                 <strong class="jxr_keyword">final</strong> java.util.Iterator pos = <strong class="jxr_keyword">new</strong>_nodes.iterator();
-<a name="223" href="#223">223</a>                 pos.hasNext();
-<a name="224" href="#224">224</a>             ) {
-<a name="225" href="#225">225</a>                 Node node = (Node) pos.next();
-<a name="226" href="#226">226</a>                 <strong class="jxr_keyword">if</strong> (node instanceof Element) {
-<a name="227" href="#227">227</a>                     <strong class="jxr_keyword">if</strong>(!Constants.SignatureSpecNS.equals(node.getNamespaceURI()) 
-<a name="228" href="#228">228</a>                         &amp;&amp; node.getAttributes().getNamedItemNS(WSConstants.WSU_NS, <span class="jxr_string">"Id"</span>) == <strong class="jxr_keyword">null</strong>) {
-<a name="229" href="#229">229</a>                         String wsuPrefix = 
-<a name="230" href="#230">230</a>                             WSSecurityUtil.setNamespace(
-<a name="231" href="#231">231</a>                                 (Element)node, WSConstants.WSU_NS, WSConstants.WSU_PREFIX
-<a name="232" href="#232">232</a>                             );
-<a name="233" href="#233">233</a>                         ((Element)node).setAttributeNS(
-<a name="234" href="#234">234</a>                             WSConstants.WSU_NS, wsuPrefix + <span class="jxr_string">":Id"</span>, dataRefURI
-<a name="235" href="#235">235</a>                         );
-<a name="236" href="#236">236</a>                         dataRef.setWsuId(dataRefURI.substring(1));                              
-<a name="237" href="#237">237</a>                     }
-<a name="238" href="#238">238</a>                     dataRef.setName(<strong class="jxr_keyword">new</strong> QName(node.getNamespaceURI(),node.getLocalName()));
-<a name="239" href="#239">239</a>                 }
-<a name="240" href="#240">240</a>             }
-<a name="241" href="#241">241</a> 
-<a name="242" href="#242">242</a>         } <strong class="jxr_keyword">catch</strong> (Exception e) {
-<a name="243" href="#243">243</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a>(
-<a name="244" href="#244">244</a>                 WSSecurityException.FAILED_CHECK, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">null</strong>, e
-<a name="245" href="#245">245</a>             );
-<a name="246" href="#246">246</a>         }
-<a name="247" href="#247">247</a>     }
-<a name="248" href="#248">248</a> 
-<a name="249" href="#249">249</a>     <strong class="jxr_keyword">public</strong> String getId() {
-<a name="250" href="#250">250</a>         <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
-<a name="251" href="#251">251</a>     }
-<a name="252" href="#252">252</a> 
-<a name="253" href="#253">253</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="254" href="#254">254</a> <em class="jxr_javadoccomment">     * Retrieves a secret key (session key) from a already parsed EncryptedKey</em>
-<a name="255" href="#255">255</a> <em class="jxr_javadoccomment">     * element</em>
-<a name="256" href="#256">256</a> <em class="jxr_javadoccomment">     * </em>
-<a name="257" href="#257">257</a> <em class="jxr_javadoccomment">     * This method takes a security token reference (STR) element and checks if</em>
-<a name="258" href="#258">258</a> <em class="jxr_javadoccomment">     * it contains a Reference element. Then it gets the vale of the URI</em>
-<a name="259" href="#259">259</a> <em class="jxr_javadoccomment">     * attribute of the Reference and uses the retrieved value to lookup an</em>
-<a name="260" href="#260">260</a> <em class="jxr_javadoccomment">     * EncrypteKey element to get the decrypted session key bytes. Using the</em>
-<a name="261" href="#261">261</a> <em class="jxr_javadoccomment">     * algorithm parameter these bytes are converted into a secret key.</em>
-<a name="262" href="#262">262</a> <em class="jxr_javadoccomment">     * </em>
-<a name="263" href="#263">263</a> <em class="jxr_javadoccomment">     * This method requires that the EncyrptedKey element is already available,</em>
-<a name="264" href="#264">264</a> <em class="jxr_javadoccomment">     * thus requires a strict layout of the security header. This method</em>
-<a name="265" href="#265">265</a> <em class="jxr_javadoccomment">     * supports EncryptedKey elements within the same message.</em>
-<a name="266" href="#266">266</a> <em class="jxr_javadoccomment">     * </em>
-<a name="267" href="#267">267</a> <em class="jxr_javadoccomment">     * @param secRefToken The element containing the STR</em>
-<a name="268" href="#268">268</a> <em class="jxr_javadoccomment">     * @param algorithm A string that identifies the symmetric decryption algorithm</em>
-<a name="269" href="#269">269</a> <em class="jxr_javadoccomment">     * @param crypto Crypto instance to obtain key</em>
-<a name="270" href="#270">270</a> <em class="jxr_javadoccomment">     * @param cb CAllback handler to obtain the key passwords</em>
-<a name="271" href="#271">271</a> <em class="jxr_javadoccomment">     * @return The secret key for the specified algorithm</em>
-<a name="272" href="#272">272</a> <em class="jxr_javadoccomment">     * @throws WSSecurityException</em>
-<a name="273" href="#273">273</a> <em class="jxr_javadoccomment">     */</em>
-<a name="274" href="#274">274</a>     <strong class="jxr_keyword">private</strong> SecretKey getKeyFromSecurityTokenReference(
-<a name="275" href="#275">275</a>         Element secRefToken, 
-<a name="276" href="#276">276</a>         String algorithm,
-<a name="277" href="#277">277</a>         <a href="../../../../../org/apache/ws/security/components/crypto/Crypto.html">Crypto</a> crypto, 
-<a name="278" href="#278">278</a>         CallbackHandler cb
-<a name="279" href="#279">279</a>     ) <strong class="jxr_keyword">throws</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a> {
-<a name="280" href="#280">280</a> 
-<a name="281" href="#281">281</a>         <a href="../../../../../org/apache/ws/security/message/token/SecurityTokenReference.html">SecurityTokenReference</a> secRef = <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/message/token/SecurityTokenReference.html">SecurityTokenReference</a>(secRefToken);
-<a name="282" href="#282">282</a>         byte[] decryptedData = <strong class="jxr_keyword">null</strong>;
-<a name="283" href="#283">283</a> 
-<a name="284" href="#284">284</a>         <strong class="jxr_keyword">if</strong> (secRef.containsReference()) {
-<a name="285" href="#285">285</a>             <a href="../../../../../org/apache/ws/security/message/token/Reference.html">Reference</a> reference = secRef.getReference();
-<a name="286" href="#286">286</a>             String uri = reference.getURI();
-<a name="287" href="#287">287</a>             String id = uri;
-<a name="288" href="#288">288</a>             <strong class="jxr_keyword">if</strong> (id.charAt(0) == '#') {
-<a name="289" href="#289">289</a>                 id = id.substring(1);
-<a name="290" href="#290">290</a>             }
-<a name="291" href="#291">291</a>             <a href="../../../../../org/apache/ws/security/processor/Processor.html">Processor</a> p = wsDocInfo.getProcessor(id);
-<a name="292" href="#292">292</a>             <strong class="jxr_keyword">if</strong> (!(p instanceof EncryptedKeyProcessor
-<a name="293" href="#293">293</a>                 || p instanceof <a href="../../../../../org/apache/ws/security/processor/DerivedKeyTokenProcessor.html">DerivedKeyTokenProcessor</a> 
-<a name="294" href="#294">294</a>                 || p instanceof <a href="../../../../../org/apache/ws/security/processor/SAMLTokenProcessor.html">SAMLTokenProcessor</a>)
-<a name="295" href="#295">295</a>             ) {
-<a name="296" href="#296">296</a>                 <em class="jxr_comment">// Try custom token</em>
-<a name="297" href="#297">297</a>                 <a href="../../../../../org/apache/ws/security/WSPasswordCallback.html">WSPasswordCallback</a> pwcb = <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSPasswordCallback.html">WSPasswordCallback</a>(id, WSPasswordCallback.CUSTOM_TOKEN);
-<a name="298" href="#298">298</a>                 <strong class="jxr_keyword">try</strong> {
-<a name="299" href="#299">299</a>                     Callback[] callbacks = <strong class="jxr_keyword">new</strong> Callback[]{pwcb};
-<a name="300" href="#300">300</a>                     cb.handle(callbacks);
-<a name="301" href="#301">301</a>                 } <strong class="jxr_keyword">catch</strong> (Exception e) {
-<a name="302" href="#302">302</a>                     <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a>(
-<a name="303" href="#303">303</a>                         WSSecurityException.FAILURE,
-<a name="304" href="#304">304</a>                         <span class="jxr_string">"noPassword"</span>, 
-<a name="305" href="#305">305</a>                         <strong class="jxr_keyword">new</strong> Object[] {id}, 
-<a name="306" href="#306">306</a>                         e
-<a name="307" href="#307">307</a>                     );
-<a name="308" href="#308">308</a>                 }
-<a name="309" href="#309">309</a>                 decryptedData = pwcb.getKey();
-<a name="310" href="#310">310</a>                 
-<a name="311" href="#311">311</a>                 <strong class="jxr_keyword">if</strong> (decryptedData == <strong class="jxr_keyword">null</strong>) {
-<a name="312" href="#312">312</a>                     <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a>(
-<a name="313" href="#313">313</a>                         WSSecurityException.FAILED_CHECK, <span class="jxr_string">"unsupportedKeyId"</span>
-<a name="314" href="#314">314</a>                     );
-<a name="315" href="#315">315</a>                 }
-<a name="316" href="#316">316</a>             }
-<a name="317" href="#317">317</a>             <strong class="jxr_keyword">if</strong> (p instanceof EncryptedKeyProcessor) {
-<a name="318" href="#318">318</a>                 <a href="../../../../../org/apache/ws/security/processor/EncryptedKeyProcessor.html">EncryptedKeyProcessor</a> ekp = (EncryptedKeyProcessor) p;
-<a name="319" href="#319">319</a>                 decryptedData = ekp.getDecryptedBytes();
-<a name="320" href="#320">320</a>             } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (p instanceof DerivedKeyTokenProcessor) {
-<a name="321" href="#321">321</a>                 <a href="../../../../../org/apache/ws/security/processor/DerivedKeyTokenProcessor.html">DerivedKeyTokenProcessor</a> dkp = (DerivedKeyTokenProcessor) p;
-<a name="322" href="#322">322</a>                 decryptedData = dkp.getKeyBytes(WSSecurityUtil.getKeyLength(algorithm));
-<a name="323" href="#323">323</a>             } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (p instanceof SAMLTokenProcessor) {
-<a name="324" href="#324">324</a>                 <a href="../../../../../org/apache/ws/security/processor/SAMLTokenProcessor.html">SAMLTokenProcessor</a> samlp = (SAMLTokenProcessor) p;
-<a name="325" href="#325">325</a>                 <a href="../../../../../org/apache/ws/security/saml/SAMLKeyInfo.html">SAMLKeyInfo</a> keyInfo = 
-<a name="326" href="#326">326</a>                     SAMLUtil.getSAMLKeyInfo(samlp.getSamlTokenElement(), crypto, cb);
-<a name="327" href="#327">327</a>                 <em class="jxr_comment">// TODO Handle malformed SAML tokens where they don't have the </em>
-<a name="328" href="#328">328</a>                 <em class="jxr_comment">// secret in them</em>
-<a name="329" href="#329">329</a>                 decryptedData = keyInfo.getSecret();
-<a name="330" href="#330">330</a>             }
-<a name="331" href="#331">331</a>         } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (secRef.containsKeyIdentifier()){
-<a name="332" href="#332">332</a>             String sha = secRef.getKeyIdentifierValue();
-<a name="333" href="#333">333</a>             <a href="../../../../../org/apache/ws/security/WSPasswordCallback.html">WSPasswordCallback</a> pwcb = 
-<a name="334" href="#334">334</a>                 <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSPasswordCallback.html">WSPasswordCallback</a>(
-<a name="335" href="#335">335</a>                     secRef.getKeyIdentifierValue(),
-<a name="336" href="#336">336</a>                     <strong class="jxr_keyword">null</strong>,
-<a name="337" href="#337">337</a>                     secRef.getKeyIdentifierValueType(),
-<a name="338" href="#338">338</a>                     WSPasswordCallback.ENCRYPTED_KEY_TOKEN
-<a name="339" href="#339">339</a>                 );
-<a name="340" href="#340">340</a>             
-<a name="341" href="#341">341</a>             <strong class="jxr_keyword">try</strong> {
-<a name="342" href="#342">342</a>                 Callback[] callbacks = <strong class="jxr_keyword">new</strong> Callback[]{pwcb};
-<a name="343" href="#343">343</a>                 cb.handle(callbacks);
-<a name="344" href="#344">344</a>             } <strong class="jxr_keyword">catch</strong> (Exception e) {
-<a name="345" href="#345">345</a>                 <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a>(
-<a name="346" href="#346">346</a>                     WSSecurityException.FAILURE,
-<a name="347" href="#347">347</a>                     <span class="jxr_string">"noPassword"</span>, 
-<a name="348" href="#348">348</a>                     <strong class="jxr_keyword">new</strong> Object[] {sha}, 
-<a name="349" href="#349">349</a>                     e
-<a name="350" href="#350">350</a>                 );
-<a name="351" href="#351">351</a>             }
-<a name="352" href="#352">352</a>             decryptedData = pwcb.getKey();
-<a name="353" href="#353">353</a>         } <strong class="jxr_keyword">else</strong> {
-<a name="354" href="#354">354</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a>(WSSecurityException.FAILED_CHECK, <span class="jxr_string">"noReference"</span>);
-<a name="355" href="#355">355</a>         }
-<a name="356" href="#356">356</a>         <strong class="jxr_keyword">return</strong> WSSecurityUtil.prepareSecretKey(algorithm, decryptedData);
-<a name="357" href="#357">357</a>     }
-<a name="358" href="#358">358</a>     
-<a name="359" href="#359">359</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="360" href="#360">360</a> <em class="jxr_javadoccomment">     * @return      a list of Nodes, representing the </em>
-<a name="361" href="#361">361</a> <em class="jxr_javadoccomment">     */</em>
-<a name="362" href="#362">362</a>     <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> java.util.List
-<a name="363" href="#363">363</a>     listChildren(
-<a name="364" href="#364">364</a>         <strong class="jxr_keyword">final</strong> Node parent
-<a name="365" href="#365">365</a>     ) {
-<a name="366" href="#366">366</a>         <strong class="jxr_keyword">if</strong> (parent == <strong class="jxr_keyword">null</strong>) {
-<a name="367" href="#367">367</a>             <strong class="jxr_keyword">return</strong> java.util.Collections.EMPTY_LIST;
-<a name="368" href="#368">368</a>         }
-<a name="369" href="#369">369</a>         <strong class="jxr_keyword">final</strong> java.util.List ret = <strong class="jxr_keyword">new</strong> java.util.ArrayList();
-<a name="370" href="#370">370</a>         <strong class="jxr_keyword">if</strong> (parent.hasChildNodes()) {
-<a name="371" href="#371">371</a>             <strong class="jxr_keyword">final</strong> NodeList children = parent.getChildNodes();
-<a name="372" href="#372">372</a>             <strong class="jxr_keyword">if</strong> (children != <strong class="jxr_keyword">null</strong>) {
-<a name="373" href="#373">373</a>                 <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = 0, n = children.getLength();  i &lt; n;  ++i) {
-<a name="374" href="#374">374</a>                     ret.add(children.item(i));
-<a name="375" href="#375">375</a>                 }
-<a name="376" href="#376">376</a>             }
-<a name="377" href="#377">377</a>         }
-<a name="378" href="#378">378</a>         <strong class="jxr_keyword">return</strong> ret;
-<a name="379" href="#379">379</a>     }
-<a name="380" href="#380">380</a> 
-<a name="381" href="#381">381</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="382" href="#382">382</a> <em class="jxr_javadoccomment">     * @return a list of Nodes in b that are not in a</em>
-<a name="383" href="#383">383</a> <em class="jxr_javadoccomment">     */</em>
-<a name="384" href="#384">384</a>     <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> java.util.List
-<a name="385" href="#385">385</a>     newNodes(
-<a name="386" href="#386">386</a>         java.util.List a,
-<a name="387" href="#387">387</a>         java.util.List b
-<a name="388" href="#388">388</a>     ) {
-<a name="389" href="#389">389</a>         <strong class="jxr_keyword">if</strong> (a.size() == 0) {
-<a name="390" href="#390">390</a>             <strong class="jxr_keyword">return</strong> b;
-<a name="391" href="#391">391</a>         }
-<a name="392" href="#392">392</a>         <strong class="jxr_keyword">if</strong> (b.size() == 0) {
-<a name="393" href="#393">393</a>             <strong class="jxr_keyword">return</strong> java.util.Collections.EMPTY_LIST;
+<a name="190" href="#190">190</a>         <strong class="jxr_keyword">if</strong> (encryptedDataElement == <strong class="jxr_keyword">null</strong>) {
+<a name="191" href="#191">191</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a>(
+<a name="192" href="#192">192</a>                 WSSecurityException.INVALID_SECURITY, <span class="jxr_string">"dataRef"</span>, <strong class="jxr_keyword">new</strong> Object[] {dataRefURI}
+<a name="193" href="#193">193</a>             );
+<a name="194" href="#194">194</a>         }
+<a name="195" href="#195">195</a>         <strong class="jxr_keyword">return</strong> encryptedDataElement;
+<a name="196" href="#196">196</a>     }
+<a name="197" href="#197">197</a> 
+<a name="198" href="#198">198</a>     
+<a name="199" href="#199">199</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="200" href="#200">200</a> <em class="jxr_javadoccomment">     * Decrypt the EncryptedData argument using a SecretKey.</em>
+<a name="201" href="#201">201</a> <em class="jxr_javadoccomment">     * @param doc The (document) owner of EncryptedData</em>
+<a name="202" href="#202">202</a> <em class="jxr_javadoccomment">     * @param dataRefURI The URI of EncryptedData</em>
+<a name="203" href="#203">203</a> <em class="jxr_javadoccomment">     * @param encData The EncryptedData element</em>
+<a name="204" href="#204">204</a> <em class="jxr_javadoccomment">     * @param symmetricKey The SecretKey with which to decrypt EncryptedData</em>
+<a name="205" href="#205">205</a> <em class="jxr_javadoccomment">     * @param symEncAlgo The symmetric encryption algorithm to use</em>
+<a name="206" href="#206">206</a> <em class="jxr_javadoccomment">     * @throws WSSecurityException</em>
+<a name="207" href="#207">207</a> <em class="jxr_javadoccomment">     */</em>
+<a name="208" href="#208">208</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> <a href="../../../../../org/apache/ws/security/WSDataRef.html">WSDataRef</a>
+<a name="209" href="#209">209</a>     decryptEncryptedData(
+<a name="210" href="#210">210</a>         Document doc,
+<a name="211" href="#211">211</a>         String dataRefURI,
+<a name="212" href="#212">212</a>         Element encData,
+<a name="213" href="#213">213</a>         SecretKey symmetricKey,
+<a name="214" href="#214">214</a>         String symEncAlgo
+<a name="215" href="#215">215</a>     ) <strong class="jxr_keyword">throws</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a> {
+<a name="216" href="#216">216</a>         XMLCipher xmlCipher = <strong class="jxr_keyword">null</strong>;
+<a name="217" href="#217">217</a>         <strong class="jxr_keyword">try</strong> {
+<a name="218" href="#218">218</a>             xmlCipher = XMLCipher.getInstance(symEncAlgo);
+<a name="219" href="#219">219</a>             xmlCipher.init(XMLCipher.DECRYPT_MODE, symmetricKey);
+<a name="220" href="#220">220</a>         } <strong class="jxr_keyword">catch</strong> (XMLEncryptionException ex) {
+<a name="221" href="#221">221</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a>(
+<a name="222" href="#222">222</a>                 WSSecurityException.UNSUPPORTED_ALGORITHM, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">null</strong>, ex
+<a name="223" href="#223">223</a>             );
+<a name="224" href="#224">224</a>         }
+<a name="225" href="#225">225</a> 
+<a name="226" href="#226">226</a>         <a href="../../../../../org/apache/ws/security/WSDataRef.html">WSDataRef</a> dataRef = <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSDataRef.html">WSDataRef</a>(dataRefURI);
+<a name="227" href="#227">227</a>         dataRef.setWsuId(dataRefURI);
+<a name="228" href="#228">228</a>         <strong class="jxr_keyword">boolean</strong> content = X509Util.isContent(encData);
+<a name="229" href="#229">229</a>         dataRef.setContent(content);
+<a name="230" href="#230">230</a>         
+<a name="231" href="#231">231</a>         Node parent = encData.getParentNode();
+<a name="232" href="#232">232</a>         Node previousSibling = encData.getPreviousSibling();
+<a name="233" href="#233">233</a>         <strong class="jxr_keyword">if</strong> (content) {
+<a name="234" href="#234">234</a>             encData = (Element) encData.getParentNode();
+<a name="235" href="#235">235</a>             parent = encData.getParentNode();
+<a name="236" href="#236">236</a>         }
+<a name="237" href="#237">237</a>         
+<a name="238" href="#238">238</a>         <strong class="jxr_keyword">try</strong> {
+<a name="239" href="#239">239</a>             xmlCipher.doFinal(doc, encData, content);
+<a name="240" href="#240">240</a>         } <strong class="jxr_keyword">catch</strong> (Exception ex) {
+<a name="241" href="#241">241</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a>(WSSecurityException.FAILED_CHECK, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">null</strong>, ex);
+<a name="242" href="#242">242</a>         }
+<a name="243" href="#243">243</a>         
+<a name="244" href="#244">244</a>         <strong class="jxr_keyword">if</strong> (parent.getLocalName().equals(WSConstants.ENCRYPTED_HEADER)
+<a name="245" href="#245">245</a>             &amp;&amp; parent.getNamespaceURI().equals(WSConstants.WSSE11_NS)) {
+<a name="246" href="#246">246</a>                 
+<a name="247" href="#247">247</a>             Node decryptedHeader = parent.getFirstChild();
+<a name="248" href="#248">248</a>             Element decryptedHeaderClone = (Element)decryptedHeader.cloneNode(<strong class="jxr_keyword">true</strong>);            
+<a name="249" href="#249">249</a>             parent.getParentNode().appendChild(decryptedHeaderClone);
+<a name="250" href="#250">250</a>             parent.getParentNode().removeChild(parent);
+<a name="251" href="#251">251</a>             dataRef.setProtectedElement(decryptedHeaderClone);
+<a name="252" href="#252">252</a>             dataRef.setXpath(getXPath(decryptedHeader));
+<a name="253" href="#253">253</a>         } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (content) {
+<a name="254" href="#254">254</a>             dataRef.setProtectedElement(encData);
+<a name="255" href="#255">255</a>             dataRef.setXpath(getXPath(encData));
+<a name="256" href="#256">256</a>         } <strong class="jxr_keyword">else</strong> {
+<a name="257" href="#257">257</a>             Node decryptedNode;
+<a name="258" href="#258">258</a>             <strong class="jxr_keyword">if</strong> (previousSibling == <strong class="jxr_keyword">null</strong>) {
+<a name="259" href="#259">259</a>                 decryptedNode = parent.getFirstChild();
+<a name="260" href="#260">260</a>             } <strong class="jxr_keyword">else</strong> {
+<a name="261" href="#261">261</a>                 decryptedNode = previousSibling.getNextSibling();
+<a name="262" href="#262">262</a>             }
+<a name="263" href="#263">263</a>             <strong class="jxr_keyword">if</strong> (decryptedNode != <strong class="jxr_keyword">null</strong> &amp;&amp; Node.ELEMENT_NODE == decryptedNode.getNodeType()) {
+<a name="264" href="#264">264</a>                 dataRef.setProtectedElement((Element)decryptedNode);
+<a name="265" href="#265">265</a>             }
+<a name="266" href="#266">266</a>             dataRef.setXpath(getXPath(decryptedNode));
+<a name="267" href="#267">267</a>         }
+<a name="268" href="#268">268</a>         
+<a name="269" href="#269">269</a>         <strong class="jxr_keyword">return</strong> dataRef;
+<a name="270" href="#270">270</a>     }
+<a name="271" href="#271">271</a>     
+<a name="272" href="#272">272</a> 
+<a name="273" href="#273">273</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="274" href="#274">274</a> <em class="jxr_javadoccomment">     * Retrieves a secret key (session key) from a already parsed EncryptedKey</em>
+<a name="275" href="#275">275</a> <em class="jxr_javadoccomment">     * element</em>
+<a name="276" href="#276">276</a> <em class="jxr_javadoccomment">     * </em>
+<a name="277" href="#277">277</a> <em class="jxr_javadoccomment">     * This method takes a security token reference (STR) element and checks if</em>
+<a name="278" href="#278">278</a> <em class="jxr_javadoccomment">     * it contains a Reference element. Then it gets the vale of the URI</em>
+<a name="279" href="#279">279</a> <em class="jxr_javadoccomment">     * attribute of the Reference and uses the retrieved value to lookup an</em>
+<a name="280" href="#280">280</a> <em class="jxr_javadoccomment">     * EncrypteKey element to get the decrypted session key bytes. Using the</em>
+<a name="281" href="#281">281</a> <em class="jxr_javadoccomment">     * algorithm parameter these bytes are converted into a secret key.</em>
+<a name="282" href="#282">282</a> <em class="jxr_javadoccomment">     * </em>
+<a name="283" href="#283">283</a> <em class="jxr_javadoccomment">     * This method requires that the EncyrptedKey element is already available,</em>
+<a name="284" href="#284">284</a> <em class="jxr_javadoccomment">     * thus requires a strict layout of the security header. This method</em>
+<a name="285" href="#285">285</a> <em class="jxr_javadoccomment">     * supports EncryptedKey elements within the same message.</em>
+<a name="286" href="#286">286</a> <em class="jxr_javadoccomment">     * </em>
+<a name="287" href="#287">287</a> <em class="jxr_javadoccomment">     * @param secRefToken The element containing the STR</em>
+<a name="288" href="#288">288</a> <em class="jxr_javadoccomment">     * @param algorithm A string that identifies the symmetric decryption algorithm</em>
+<a name="289" href="#289">289</a> <em class="jxr_javadoccomment">     * @param crypto Crypto instance to obtain key</em>
+<a name="290" href="#290">290</a> <em class="jxr_javadoccomment">     * @param cb CAllback handler to obtain the key passwords</em>
+<a name="291" href="#291">291</a> <em class="jxr_javadoccomment">     * @return The secret key for the specified algorithm</em>
+<a name="292" href="#292">292</a> <em class="jxr_javadoccomment">     * @throws WSSecurityException</em>
+<a name="293" href="#293">293</a> <em class="jxr_javadoccomment">     */</em>
+<a name="294" href="#294">294</a>     <strong class="jxr_keyword">private</strong> SecretKey getKeyFromSecurityTokenReference(
+<a name="295" href="#295">295</a>         Element secRefToken, 
+<a name="296" href="#296">296</a>         String algorithm,
+<a name="297" href="#297">297</a>         <a href="../../../../../org/apache/ws/security/components/crypto/Crypto.html">Crypto</a> crypto, 
+<a name="298" href="#298">298</a>         CallbackHandler cb
+<a name="299" href="#299">299</a>     ) <strong class="jxr_keyword">throws</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a> {
+<a name="300" href="#300">300</a> 
+<a name="301" href="#301">301</a>         <a href="../../../../../org/apache/ws/security/message/token/SecurityTokenReference.html">SecurityTokenReference</a> secRef = <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/message/token/SecurityTokenReference.html">SecurityTokenReference</a>(secRefToken);
+<a name="302" href="#302">302</a>         byte[] decryptedData = <strong class="jxr_keyword">null</strong>;
+<a name="303" href="#303">303</a> 
+<a name="304" href="#304">304</a>         <strong class="jxr_keyword">if</strong> (secRef.containsReference()) {
+<a name="305" href="#305">305</a>             <a href="../../../../../org/apache/ws/security/message/token/Reference.html">Reference</a> reference = secRef.getReference();
+<a name="306" href="#306">306</a>             String uri = reference.getURI();
+<a name="307" href="#307">307</a>             String id = uri;
+<a name="308" href="#308">308</a>             <strong class="jxr_keyword">if</strong> (id.charAt(0) == '#') {
+<a name="309" href="#309">309</a>                 id = id.substring(1);
+<a name="310" href="#310">310</a>             }
+<a name="311" href="#311">311</a>             <a href="../../../../../org/apache/ws/security/processor/Processor.html">Processor</a> p = wsDocInfo.getProcessor(id);
+<a name="312" href="#312">312</a>             <strong class="jxr_keyword">if</strong> (!(p instanceof EncryptedKeyProcessor
+<a name="313" href="#313">313</a>                 || p instanceof <a href="../../../../../org/apache/ws/security/processor/DerivedKeyTokenProcessor.html">DerivedKeyTokenProcessor</a> 
+<a name="314" href="#314">314</a>                 || p instanceof <a href="../../../../../org/apache/ws/security/processor/SAMLTokenProcessor.html">SAMLTokenProcessor</a>)
+<a name="315" href="#315">315</a>             ) {
+<a name="316" href="#316">316</a>                 <em class="jxr_comment">// Try custom token</em>
+<a name="317" href="#317">317</a>                 <a href="../../../../../org/apache/ws/security/WSPasswordCallback.html">WSPasswordCallback</a> pwcb = <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSPasswordCallback.html">WSPasswordCallback</a>(id, WSPasswordCallback.CUSTOM_TOKEN);
+<a name="318" href="#318">318</a>                 <strong class="jxr_keyword">try</strong> {
+<a name="319" href="#319">319</a>                     Callback[] callbacks = <strong class="jxr_keyword">new</strong> Callback[]{pwcb};
+<a name="320" href="#320">320</a>                     cb.handle(callbacks);
+<a name="321" href="#321">321</a>                 } <strong class="jxr_keyword">catch</strong> (Exception e) {
+<a name="322" href="#322">322</a>                     <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a>(
+<a name="323" href="#323">323</a>                         WSSecurityException.FAILURE,
+<a name="324" href="#324">324</a>                         <span class="jxr_string">"noPassword"</span>, 
+<a name="325" href="#325">325</a>                         <strong class="jxr_keyword">new</strong> Object[] {id}, 
+<a name="326" href="#326">326</a>                         e
+<a name="327" href="#327">327</a>                     );
+<a name="328" href="#328">328</a>                 }
+<a name="329" href="#329">329</a>                 decryptedData = pwcb.getKey();
+<a name="330" href="#330">330</a>                 
+<a name="331" href="#331">331</a>                 <strong class="jxr_keyword">if</strong> (decryptedData == <strong class="jxr_keyword">null</strong>) {
+<a name="332" href="#332">332</a>                     <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a>(
+<a name="333" href="#333">333</a>                         WSSecurityException.FAILED_CHECK, <span class="jxr_string">"unsupportedKeyId"</span>
+<a name="334" href="#334">334</a>                     );
+<a name="335" href="#335">335</a>                 }
+<a name="336" href="#336">336</a>             }
+<a name="337" href="#337">337</a>             <strong class="jxr_keyword">if</strong> (p instanceof EncryptedKeyProcessor) {
+<a name="338" href="#338">338</a>                 <a href="../../../../../org/apache/ws/security/processor/EncryptedKeyProcessor.html">EncryptedKeyProcessor</a> ekp = (EncryptedKeyProcessor) p;
+<a name="339" href="#339">339</a>                 decryptedData = ekp.getDecryptedBytes();
+<a name="340" href="#340">340</a>             } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (p instanceof DerivedKeyTokenProcessor) {
+<a name="341" href="#341">341</a>                 <a href="../../../../../org/apache/ws/security/processor/DerivedKeyTokenProcessor.html">DerivedKeyTokenProcessor</a> dkp = (DerivedKeyTokenProcessor) p;
+<a name="342" href="#342">342</a>                 decryptedData = dkp.getKeyBytes(WSSecurityUtil.getKeyLength(algorithm));
+<a name="343" href="#343">343</a>             } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (p instanceof SAMLTokenProcessor) {
+<a name="344" href="#344">344</a>                 <a href="../../../../../org/apache/ws/security/processor/SAMLTokenProcessor.html">SAMLTokenProcessor</a> samlp = (SAMLTokenProcessor) p;
+<a name="345" href="#345">345</a>                 <a href="../../../../../org/apache/ws/security/saml/SAMLKeyInfo.html">SAMLKeyInfo</a> keyInfo = 
+<a name="346" href="#346">346</a>                     SAMLUtil.getSAMLKeyInfo(samlp.getSamlTokenElement(), crypto, cb);
+<a name="347" href="#347">347</a>                 <em class="jxr_comment">// TODO Handle malformed SAML tokens where they don't have the </em>
+<a name="348" href="#348">348</a>                 <em class="jxr_comment">// secret in them</em>
+<a name="349" href="#349">349</a>                 decryptedData = keyInfo.getSecret();
+<a name="350" href="#350">350</a>             }
+<a name="351" href="#351">351</a>         } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (secRef.containsKeyIdentifier()){
+<a name="352" href="#352">352</a>             String sha = secRef.getKeyIdentifierValue();
+<a name="353" href="#353">353</a>             <a href="../../../../../org/apache/ws/security/WSPasswordCallback.html">WSPasswordCallback</a> pwcb = 
+<a name="354" href="#354">354</a>                 <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSPasswordCallback.html">WSPasswordCallback</a>(
+<a name="355" href="#355">355</a>                     secRef.getKeyIdentifierValue(),
+<a name="356" href="#356">356</a>                     <strong class="jxr_keyword">null</strong>,
+<a name="357" href="#357">357</a>                     secRef.getKeyIdentifierValueType(),
+<a name="358" href="#358">358</a>                     WSPasswordCallback.ENCRYPTED_KEY_TOKEN
+<a name="359" href="#359">359</a>                 );
+<a name="360" href="#360">360</a>             
+<a name="361" href="#361">361</a>             <strong class="jxr_keyword">try</strong> {
+<a name="362" href="#362">362</a>                 Callback[] callbacks = <strong class="jxr_keyword">new</strong> Callback[]{pwcb};
+<a name="363" href="#363">363</a>                 cb.handle(callbacks);
+<a name="364" href="#364">364</a>             } <strong class="jxr_keyword">catch</strong> (Exception e) {
+<a name="365" href="#365">365</a>                 <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a>(
+<a name="366" href="#366">366</a>                     WSSecurityException.FAILURE,
+<a name="367" href="#367">367</a>                     <span class="jxr_string">"noPassword"</span>, 
+<a name="368" href="#368">368</a>                     <strong class="jxr_keyword">new</strong> Object[] {sha}, 
+<a name="369" href="#369">369</a>                     e
+<a name="370" href="#370">370</a>                 );
+<a name="371" href="#371">371</a>             }
+<a name="372" href="#372">372</a>             decryptedData = pwcb.getKey();
+<a name="373" href="#373">373</a>         } <strong class="jxr_keyword">else</strong> {
+<a name="374" href="#374">374</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a>(WSSecurityException.FAILED_CHECK, <span class="jxr_string">"noReference"</span>);
+<a name="375" href="#375">375</a>         }
+<a name="376" href="#376">376</a>         <strong class="jxr_keyword">return</strong> WSSecurityUtil.prepareSecretKey(algorithm, decryptedData);
+<a name="377" href="#377">377</a>     }
+<a name="378" href="#378">378</a>     
+<a name="379" href="#379">379</a>     <strong class="jxr_keyword">public</strong> String getId() {
+<a name="380" href="#380">380</a>         <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
+<a name="381" href="#381">381</a>     }
+<a name="382" href="#382">382</a>     
+<a name="383" href="#383">383</a>     
+<a name="384" href="#384">384</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="385" href="#385">385</a> <em class="jxr_javadoccomment">     * @param decryptedNode the decrypted node</em>
+<a name="386" href="#386">386</a> <em class="jxr_javadoccomment">     * @return a fully built xpath </em>
+<a name="387" href="#387">387</a> <em class="jxr_javadoccomment">     *        (eg. &amp;quot;/soapenv:Envelope/soapenv:Body/ns:decryptedElement&amp;quot;)</em>
+<a name="388" href="#388">388</a> <em class="jxr_javadoccomment">     *        if the decryptedNode is an Element or an Attr node and is not detached</em>
+<a name="389" href="#389">389</a> <em class="jxr_javadoccomment">     *        from the document. &lt;code&gt;null&lt;/code&gt; otherwise</em>
+<a name="390" href="#390">390</a> <em class="jxr_javadoccomment">     */</em>
+<a name="391" href="#391">391</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> String getXPath(Node decryptedNode) {
+<a name="392" href="#392">392</a>         <strong class="jxr_keyword">if</strong> (decryptedNode == <strong class="jxr_keyword">null</strong>) {
+<a name="393" href="#393">393</a>             <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
 <a name="394" href="#394">394</a>         }
-<a name="395" href="#395">395</a>         
-<a name="396" href="#396">396</a>         a = <strong class="jxr_keyword">new</strong> ArrayList(a);
-<a name="397" href="#397">397</a>         <em class="jxr_comment">//try a fast node compare at same position first.....</em>
-<a name="398" href="#398">398</a>         <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> x = 0; x &lt; b.size(); x++) {
-<a name="399" href="#399">399</a>             <strong class="jxr_keyword">final</strong> Node bnode = (Node)b.get(x);
-<a name="400" href="#400">400</a>             <strong class="jxr_keyword">final</strong> Node anode = (Node)a.get(x);
-<a name="401" href="#401">401</a>             <strong class="jxr_keyword">if</strong> (bnode == anode
-<a name="402" href="#402">402</a>                 || bnode.getLocalName().equals(anode.getLocalName())
-<a name="403" href="#403">403</a>                 &amp;&amp; bnode.getNamespaceURI().equals(anode.getNamespaceURI())) {
-<a name="404" href="#404">404</a>                 b.remove(x);
-<a name="405" href="#405">405</a>                 a.remove(x);
-<a name="406" href="#406">406</a>             }
-<a name="407" href="#407">407</a>         }
-<a name="408" href="#408">408</a>         <em class="jxr_comment">//what's left is stuff that didn't exactly position match, do slower searches</em>
-<a name="409" href="#409">409</a>         <strong class="jxr_keyword">final</strong> java.util.List ret = <strong class="jxr_keyword">new</strong> java.util.ArrayList();
-<a name="410" href="#410">410</a>         <strong class="jxr_keyword">for</strong> (
-<a name="411" href="#411">411</a>             <strong class="jxr_keyword">final</strong> java.util.Iterator bpos = b.iterator();
-<a name="412" href="#412">412</a>             bpos.hasNext();
-<a name="413" href="#413">413</a>         ) {
-<a name="414" href="#414">414</a>             <strong class="jxr_keyword">final</strong> Node bnode = (Node) bpos.next();
-<a name="415" href="#415">415</a>             <strong class="jxr_keyword">final</strong> java.lang.String bns = bnode.getNamespaceURI();
-<a name="416" href="#416">416</a>             <strong class="jxr_keyword">final</strong> java.lang.String bln = bnode.getLocalName();
-<a name="417" href="#417">417</a>             <strong class="jxr_keyword">boolean</strong> found = false;
-<a name="418" href="#418">418</a>             <strong class="jxr_keyword">for</strong> (
-<a name="419" href="#419">419</a>                 <strong class="jxr_keyword">final</strong> java.util.Iterator apos = a.iterator();
-<a name="420" href="#420">420</a>                 apos.hasNext() &amp;&amp; !found;
-<a name="421" href="#421">421</a>             ) {
-<a name="422" href="#422">422</a>                 <strong class="jxr_keyword">final</strong> Node anode = (Node) apos.next();
-<a name="423" href="#423">423</a>                 <strong class="jxr_keyword">final</strong> java.lang.String ans = anode.getNamespaceURI();
-<a name="424" href="#424">424</a>                 <strong class="jxr_keyword">final</strong> java.lang.String aln = anode.getLocalName();
-<a name="425" href="#425">425</a>                 <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">boolean</strong> nsmatch =
-<a name="426" href="#426">426</a>                     ans == <strong class="jxr_keyword">null</strong>
-<a name="427" href="#427">427</a>                     ? ((bns == <strong class="jxr_keyword">null</strong>) ? <strong class="jxr_keyword">true</strong> : false)
-<a name="428" href="#428">428</a>                             : ((bns == <strong class="jxr_keyword">null</strong>) ? false : ans.equals(bns));
-<a name="429" href="#429">429</a>                 <strong class="jxr_keyword">final</strong> <strong class="jxr_keyword">boolean</strong> lnmatch =
-<a name="430" href="#430">430</a>                     aln == <strong class="jxr_keyword">null</strong>
-<a name="431" href="#431">431</a>                     ? ((bln == <strong class="jxr_keyword">null</strong>) ? <strong class="jxr_keyword">true</strong> : false)
-<a name="432" href="#432">432</a>                             : ((bln == <strong class="jxr_keyword">null</strong>) ? false : aln.equals(bln));
-<a name="433" href="#433">433</a>                 <strong class="jxr_keyword">if</strong> (nsmatch &amp;&amp; lnmatch) {
-<a name="434" href="#434">434</a>                     found = <strong class="jxr_keyword">true</strong>;
-<a name="435" href="#435">435</a>                 }
-<a name="436" href="#436">436</a>             }
-<a name="437" href="#437">437</a>             <strong class="jxr_keyword">if</strong> (!found) {
-<a name="438" href="#438">438</a>                 ret.add(bnode);
-<a name="439" href="#439">439</a>             }
-<a name="440" href="#440">440</a>         }
-<a name="441" href="#441">441</a>         <strong class="jxr_keyword">return</strong> ret;
-<a name="442" href="#442">442</a>     }
-<a name="443" href="#443">443</a> }
+<a name="395" href="#395">395</a> 
+<a name="396" href="#396">396</a>         String result = <span class="jxr_string">""</span>;
+<a name="397" href="#397">397</a>         <strong class="jxr_keyword">if</strong> (Node.ELEMENT_NODE == decryptedNode.getNodeType()) {
+<a name="398" href="#398">398</a>             result = decryptedNode.getNodeName();
+<a name="399" href="#399">399</a>             result = prependFullPath(result, decryptedNode.getParentNode());
+<a name="400" href="#400">400</a>         } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (Node.ATTRIBUTE_NODE == decryptedNode.getNodeType()) {
+<a name="401" href="#401">401</a>             result = <span class="jxr_string">"@"</span> + decryptedNode.getNodeName();
+<a name="402" href="#402">402</a>             result = prependFullPath(result, ((Attr)decryptedNode).getOwnerElement());
+<a name="403" href="#403">403</a>         } <strong class="jxr_keyword">else</strong> {
+<a name="404" href="#404">404</a>             <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
+<a name="405" href="#405">405</a>         }
+<a name="406" href="#406">406</a> 
+<a name="407" href="#407">407</a>         <strong class="jxr_keyword">return</strong> result;
+<a name="408" href="#408">408</a>     }
+<a name="409" href="#409">409</a> 
+<a name="410" href="#410">410</a> 
+<a name="411" href="#411">411</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="412" href="#412">412</a> <em class="jxr_javadoccomment">     * Recursively build an absolute xpath (starting with the root &amp;quot;/&amp;quot;)</em>
+<a name="413" href="#413">413</a> <em class="jxr_javadoccomment">     * </em>
+<a name="414" href="#414">414</a> <em class="jxr_javadoccomment">     * @param xpath the xpath expression built so far</em>
+<a name="415" href="#415">415</a> <em class="jxr_javadoccomment">     * @param node the current node whose name is to be prepended</em>
+<a name="416" href="#416">416</a> <em class="jxr_javadoccomment">     * @return a fully built xpath</em>
+<a name="417" href="#417">417</a> <em class="jxr_javadoccomment">     */</em>
+<a name="418" href="#418">418</a>     <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> String prependFullPath(String xpath, Node node) {
+<a name="419" href="#419">419</a>         <strong class="jxr_keyword">if</strong> (node == <strong class="jxr_keyword">null</strong>) {
+<a name="420" href="#420">420</a>             <em class="jxr_comment">// probably a detached node... not really useful</em>
+<a name="421" href="#421">421</a>             <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
+<a name="422" href="#422">422</a>         } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (Node.ELEMENT_NODE == node.getNodeType()) {
+<a name="423" href="#423">423</a>             xpath = node.getNodeName() + <span class="jxr_string">"/"</span> + xpath;
+<a name="424" href="#424">424</a>             <strong class="jxr_keyword">return</strong> prependFullPath(xpath, node.getParentNode());
+<a name="425" href="#425">425</a>         } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (Node.DOCUMENT_NODE == node.getNodeType()) {
+<a name="426" href="#426">426</a>             <strong class="jxr_keyword">return</strong> <span class="jxr_string">"/"</span> + xpath;
+<a name="427" href="#427">427</a>         } <strong class="jxr_keyword">else</strong> {
+<a name="428" href="#428">428</a>             <strong class="jxr_keyword">return</strong> prependFullPath(xpath, node.getParentNode());
+<a name="429" href="#429">429</a>         }
+<a name="430" href="#430">430</a>     }
+<a name="431" href="#431">431</a> 
+<a name="432" href="#432">432</a> }
 </pre>
 <hr/><div id="footer">This page was automatically generated by <a href="http://maven.apache.org/">Maven</a></div></body>
 </html>



---------------------------------------------------------------------
To unsubscribe, e-mail: wss4j-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: wss4j-dev-help@ws.apache.org