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=1040461&r1=1040460&r2=1040461&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 Nov 30 11:10:26 2010 @@ -322,127 +322,139 @@ <a name="312" href="#312">312</a> id = id.substring(1); <a name="313" href="#313">313</a> } <a name="314" href="#314">314</a> <a href="../../../../../org/apache/ws/security/processor/Processor.html">Processor</a> p = wsDocInfo.getProcessor(id); -<a name="315" href="#315">315</a> <strong class="jxr_keyword">if</strong> (!(p instanceof EncryptedKeyProcessor -<a name="316" href="#316">316</a> || p instanceof <a href="../../../../../org/apache/ws/security/processor/DerivedKeyTokenProcessor.html">DerivedKeyTokenProcessor</a> -<a name="317" href="#317">317</a> || p instanceof <a href="../../../../../org/apache/ws/security/processor/SAMLTokenProcessor.html">SAMLTokenProcessor</a>) -<a name="318" href="#318">318</a> ) { -<a name="319" href="#319">319</a> <em class="jxr_comment">// Try custom token</em> -<a name="320" href="#320">320</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="321" href="#321">321</a> <strong class="jxr_keyword">try</strong> { -<a name="322" href="#322">322</a> Callback[] callbacks = <strong class="jxr_keyword">new</strong> Callback[]{pwcb}; -<a name="323" href="#323">323</a> cb.handle(callbacks); -<a name="324" href="#324">324</a> } <strong class="jxr_keyword">catch</strong> (Exception e) { -<a name="325" href="#325">325</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="326" href="#326">326</a> WSSecurityException.FAILURE, -<a name="327" href="#327">327</a> <span class="jxr_string">"noPassword"</span>, -<a name="328" href="#328">328</a> <strong class="jxr_keyword">new</strong> Object[] {id}, -<a name="329" href="#329">329</a> e -<a name="330" href="#330">330</a> ); -<a name="331" href="#331">331</a> } -<a name="332" href="#332">332</a> decryptedData = pwcb.getKey(); -<a name="333" href="#333">333</a> -<a name="334" href="#334">334</a> <strong class="jxr_keyword">if</strong> (decryptedData == <strong class="jxr_keyword">null</strong>) { +<a name="315" href="#315">315</a> <strong class="jxr_keyword">if</strong> (p instanceof EncryptedKeyProcessor) { +<a name="316" href="#316">316</a> <a href="../../../../../org/apache/ws/security/processor/EncryptedKeyProcessor.html">EncryptedKeyProcessor</a> ekp = (EncryptedKeyProcessor) p; +<a name="317" href="#317">317</a> decryptedData = ekp.getDecryptedBytes(); +<a name="318" href="#318">318</a> } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (p instanceof DerivedKeyTokenProcessor) { +<a name="319" href="#319">319</a> <a href="../../../../../org/apache/ws/security/processor/DerivedKeyTokenProcessor.html">DerivedKeyTokenProcessor</a> dkp = (DerivedKeyTokenProcessor) p; +<a name="320" href="#320">320</a> decryptedData = dkp.getKeyBytes(WSSecurityUtil.getKeyLength(algorithm)); +<a name="321" href="#321">321</a> } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (p instanceof SAMLTokenProcessor) { +<a name="322" href="#322">322</a> <a href="../../../../../org/apache/ws/security/processor/SAMLTokenProcessor.html">SAMLTokenProcessor</a> samlp = (SAMLTokenProcessor) p; +<a name="323" href="#323">323</a> <a href="../../../../../org/apache/ws/security/saml/SAMLKeyInfo.html">SAMLKeyInfo</a> keyInfo = +<a name="324" href="#324">324</a> SAMLUtil.getSAMLKeyInfo(samlp.getSamlTokenElement(), crypto, cb); +<a name="325" href="#325">325</a> <em class="jxr_comment">// TODO Handle malformed SAML tokens where they don't have the </em> +<a name="326" href="#326">326</a> <em class="jxr_comment">// secret in them</em> +<a name="327" href="#327">327</a> decryptedData = keyInfo.getSecret(); +<a name="328" href="#328">328</a> } <strong class="jxr_keyword">else</strong> { +<a name="329" href="#329">329</a> <em class="jxr_comment">// Try custom token</em> +<a name="330" href="#330">330</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="331" href="#331">331</a> <strong class="jxr_keyword">try</strong> { +<a name="332" href="#332">332</a> Callback[] callbacks = <strong class="jxr_keyword">new</strong> Callback[]{pwcb}; +<a name="333" href="#333">333</a> cb.handle(callbacks); +<a name="334" href="#334">334</a> } <strong class="jxr_keyword">catch</strong> (Exception e) { <a name="335" href="#335">335</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="336" href="#336">336</a> WSSecurityException.FAILED_CHECK, <span class="jxr_string">"unsupportedKeyId"</span> -<a name="337" href="#337">337</a> ); -<a name="338" href="#338">338</a> } -<a name="339" href="#339">339</a> } -<a name="340" href="#340">340</a> <strong class="jxr_keyword">if</strong> (p instanceof EncryptedKeyProcessor) { -<a name="341" href="#341">341</a> <a href="../../../../../org/apache/ws/security/processor/EncryptedKeyProcessor.html">EncryptedKeyProcessor</a> ekp = (EncryptedKeyProcessor) p; -<a name="342" href="#342">342</a> decryptedData = ekp.getDecryptedBytes(); -<a name="343" href="#343">343</a> } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (p instanceof DerivedKeyTokenProcessor) { -<a name="344" href="#344">344</a> <a href="../../../../../org/apache/ws/security/processor/DerivedKeyTokenProcessor.html">DerivedKeyTokenProcessor</a> dkp = (DerivedKeyTokenProcessor) p; -<a name="345" href="#345">345</a> decryptedData = dkp.getKeyBytes(WSSecurityUtil.getKeyLength(algorithm)); -<a name="346" href="#346">346</a> } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (p instanceof SAMLTokenProcessor) { -<a name="347" href="#347">347</a> <a href="../../../../../org/apache/ws/security/processor/SAMLTokenProcessor.html">SAMLTokenProcessor</a> samlp = (SAMLTokenProcessor) p; -<a name="348" href="#348">348</a> <a href="../../../../../org/apache/ws/security/saml/SAMLKeyInfo.html">SAMLKeyInfo</a> keyInfo = -<a name="349" href="#349">349</a> SAMLUtil.getSAMLKeyInfo(samlp.getSamlTokenElement(), crypto, cb); -<a name="350" href="#350">350</a> <em class="jxr_comment">// TODO Handle malformed SAML tokens where they don't have the </em> -<a name="351" href="#351">351</a> <em class="jxr_comment">// secret in them</em> -<a name="352" href="#352">352</a> decryptedData = keyInfo.getSecret(); -<a name="353" href="#353">353</a> } -<a name="354" href="#354">354</a> } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (secRef.containsKeyIdentifier()){ -<a name="355" href="#355">355</a> String sha = secRef.getKeyIdentifierValue(); -<a name="356" href="#356">356</a> <a href="../../../../../org/apache/ws/security/WSPasswordCallback.html">WSPasswordCallback</a> pwcb = -<a name="357" href="#357">357</a> <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSPasswordCallback.html">WSPasswordCallback</a>( -<a name="358" href="#358">358</a> secRef.getKeyIdentifierValue(), -<a name="359" href="#359">359</a> <strong class="jxr_keyword">null</strong>, -<a name="360" href="#360">360</a> secRef.getKeyIdentifierValueType(), -<a name="361" href="#361">361</a> WSPasswordCallback.ENCRYPTED_KEY_TOKEN -<a name="362" href="#362">362</a> ); -<a name="363" href="#363">363</a> -<a name="364" href="#364">364</a> <strong class="jxr_keyword">try</strong> { -<a name="365" href="#365">365</a> Callback[] callbacks = <strong class="jxr_keyword">new</strong> Callback[]{pwcb}; -<a name="366" href="#366">366</a> cb.handle(callbacks); -<a name="367" href="#367">367</a> } <strong class="jxr_keyword">catch</strong> (Exception e) { -<a name="368" href="#368">368</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="369" href="#369">369</a> WSSecurityException.FAILURE, -<a name="370" href="#370">370</a> <span class="jxr_string">"noPassword"</span>, -<a name="371" href="#371">371</a> <strong class="jxr_keyword">new</strong> Object[] {sha}, -<a name="372" href="#372">372</a> e -<a name="373" href="#373">373</a> ); -<a name="374" href="#374">374</a> } -<a name="375" href="#375">375</a> decryptedData = pwcb.getKey(); -<a name="376" href="#376">376</a> } <strong class="jxr_keyword">else</strong> { -<a name="377" href="#377">377</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="378" href="#378">378</a> } -<a name="379" href="#379">379</a> <strong class="jxr_keyword">return</strong> WSSecurityUtil.prepareSecretKey(algorithm, decryptedData); -<a name="380" href="#380">380</a> } -<a name="381" href="#381">381</a> -<a name="382" href="#382">382</a> <strong class="jxr_keyword">public</strong> String getId() { -<a name="383" href="#383">383</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>; -<a name="384" href="#384">384</a> } -<a name="385" href="#385">385</a> -<a name="386" href="#386">386</a> -<a name="387" href="#387">387</a> <em class="jxr_javadoccomment">/**</em> -<a name="388" href="#388">388</a> <em class="jxr_javadoccomment"> * @param decryptedNode the decrypted node</em> -<a name="389" href="#389">389</a> <em class="jxr_javadoccomment"> * @return a fully built xpath </em> -<a name="390" href="#390">390</a> <em class="jxr_javadoccomment"> * (eg. &quot;/soapenv:Envelope/soapenv:Body/ns:decryptedElement&quot;)</em> -<a name="391" href="#391">391</a> <em class="jxr_javadoccomment"> * if the decryptedNode is an Element or an Attr node and is not detached</em> -<a name="392" href="#392">392</a> <em class="jxr_javadoccomment"> * from the document. <code>null</code> otherwise</em> -<a name="393" href="#393">393</a> <em class="jxr_javadoccomment"> */</em> -<a name="394" href="#394">394</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> String getXPath(Node decryptedNode) { -<a name="395" href="#395">395</a> <strong class="jxr_keyword">if</strong> (decryptedNode == <strong class="jxr_keyword">null</strong>) { -<a name="396" href="#396">396</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>; -<a name="397" href="#397">397</a> } -<a name="398" href="#398">398</a> -<a name="399" href="#399">399</a> String result = <span class="jxr_string">""</span>; -<a name="400" href="#400">400</a> <strong class="jxr_keyword">if</strong> (Node.ELEMENT_NODE == decryptedNode.getNodeType()) { -<a name="401" href="#401">401</a> result = decryptedNode.getNodeName(); -<a name="402" href="#402">402</a> result = prependFullPath(result, decryptedNode.getParentNode()); -<a name="403" href="#403">403</a> } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (Node.ATTRIBUTE_NODE == decryptedNode.getNodeType()) { -<a name="404" href="#404">404</a> result = <span class="jxr_string">"@"</span> + decryptedNode.getNodeName(); -<a name="405" href="#405">405</a> result = prependFullPath(result, ((Attr)decryptedNode).getOwnerElement()); -<a name="406" href="#406">406</a> } <strong class="jxr_keyword">else</strong> { -<a name="407" href="#407">407</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>; -<a name="408" href="#408">408</a> } -<a name="409" href="#409">409</a> -<a name="410" href="#410">410</a> <strong class="jxr_keyword">return</strong> result; -<a name="411" href="#411">411</a> } -<a name="412" href="#412">412</a> -<a name="413" href="#413">413</a> -<a name="414" href="#414">414</a> <em class="jxr_javadoccomment">/**</em> -<a name="415" href="#415">415</a> <em class="jxr_javadoccomment"> * Recursively build an absolute xpath (starting with the root &quot;/&quot;)</em> -<a name="416" href="#416">416</a> <em class="jxr_javadoccomment"> * </em> -<a name="417" href="#417">417</a> <em class="jxr_javadoccomment"> * @param xpath the xpath expression built so far</em> -<a name="418" href="#418">418</a> <em class="jxr_javadoccomment"> * @param node the current node whose name is to be prepended</em> -<a name="419" href="#419">419</a> <em class="jxr_javadoccomment"> * @return a fully built xpath</em> -<a name="420" href="#420">420</a> <em class="jxr_javadoccomment"> */</em> -<a name="421" href="#421">421</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> String prependFullPath(String xpath, Node node) { -<a name="422" href="#422">422</a> <strong class="jxr_keyword">if</strong> (node == <strong class="jxr_keyword">null</strong>) { -<a name="423" href="#423">423</a> <em class="jxr_comment">// probably a detached node... not really useful</em> -<a name="424" href="#424">424</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>; -<a name="425" href="#425">425</a> } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (Node.ELEMENT_NODE == node.getNodeType()) { -<a name="426" href="#426">426</a> xpath = node.getNodeName() + <span class="jxr_string">"/"</span> + xpath; -<a name="427" href="#427">427</a> <strong class="jxr_keyword">return</strong> prependFullPath(xpath, node.getParentNode()); -<a name="428" href="#428">428</a> } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (Node.DOCUMENT_NODE == node.getNodeType()) { -<a name="429" href="#429">429</a> <strong class="jxr_keyword">return</strong> <span class="jxr_string">"/"</span> + xpath; -<a name="430" href="#430">430</a> } <strong class="jxr_keyword">else</strong> { -<a name="431" href="#431">431</a> <strong class="jxr_keyword">return</strong> prependFullPath(xpath, node.getParentNode()); -<a name="432" href="#432">432</a> } -<a name="433" href="#433">433</a> } -<a name="434" href="#434">434</a> -<a name="435" href="#435">435</a> } +<a name="336" href="#336">336</a> WSSecurityException.FAILURE, +<a name="337" href="#337">337</a> <span class="jxr_string">"noPassword"</span>, +<a name="338" href="#338">338</a> <strong class="jxr_keyword">new</strong> Object[] {id}, +<a name="339" href="#339">339</a> e +<a name="340" href="#340">340</a> ); +<a name="341" href="#341">341</a> } +<a name="342" href="#342">342</a> decryptedData = pwcb.getKey(); +<a name="343" href="#343">343</a> +<a name="344" href="#344">344</a> <strong class="jxr_keyword">if</strong> (decryptedData == <strong class="jxr_keyword">null</strong>) { +<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.FAILED_CHECK, <span class="jxr_string">"unsupportedKeyId"</span> +<a name="347" href="#347">347</a> ); +<a name="348" href="#348">348</a> } +<a name="349" href="#349">349</a> } +<a name="350" href="#350">350</a> } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (secRef.containsKeyIdentifier()) { +<a name="351" href="#351">351</a> <strong class="jxr_keyword">if</strong> (WSConstants.WSS_SAML_KI_VALUE_TYPE.equals(secRef.getKeyIdentifierValueType())) { +<a name="352" href="#352">352</a> Element token = +<a name="353" href="#353">353</a> secRef.getKeyIdentifierTokenElement(secRefToken.getOwnerDocument(), wsDocInfo, cb); +<a name="354" href="#354">354</a> +<a name="355" href="#355">355</a> <strong class="jxr_keyword">if</strong> (crypto == <strong class="jxr_keyword">null</strong>) { +<a name="356" href="#356">356</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="357" href="#357">357</a> WSSecurityException.FAILURE, <span class="jxr_string">"noSigCryptoFile"</span> +<a name="358" href="#358">358</a> ); +<a name="359" href="#359">359</a> } +<a name="360" href="#360">360</a> <a href="../../../../../org/apache/ws/security/saml/SAMLKeyInfo.html">SAMLKeyInfo</a> keyInfo = SAMLUtil.getSAMLKeyInfo(token, crypto, cb); +<a name="361" href="#361">361</a> <em class="jxr_comment">// TODO Handle malformed SAML tokens where they don't have the </em> +<a name="362" href="#362">362</a> <em class="jxr_comment">// secret in them</em> +<a name="363" href="#363">363</a> decryptedData = keyInfo.getSecret(); +<a name="364" href="#364">364</a> } <strong class="jxr_keyword">else</strong> { +<a name="365" href="#365">365</a> String sha = secRef.getKeyIdentifierValue(); +<a name="366" href="#366">366</a> +<a name="367" href="#367">367</a> <a href="../../../../../org/apache/ws/security/WSPasswordCallback.html">WSPasswordCallback</a> pwcb = +<a name="368" href="#368">368</a> <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSPasswordCallback.html">WSPasswordCallback</a>( +<a name="369" href="#369">369</a> secRef.getKeyIdentifierValue(), +<a name="370" href="#370">370</a> <strong class="jxr_keyword">null</strong>, +<a name="371" href="#371">371</a> secRef.getKeyIdentifierValueType(), +<a name="372" href="#372">372</a> WSPasswordCallback.ENCRYPTED_KEY_TOKEN +<a name="373" href="#373">373</a> ); +<a name="374" href="#374">374</a> +<a name="375" href="#375">375</a> <strong class="jxr_keyword">try</strong> { +<a name="376" href="#376">376</a> Callback[] callbacks = <strong class="jxr_keyword">new</strong> Callback[]{pwcb}; +<a name="377" href="#377">377</a> cb.handle(callbacks); +<a name="378" href="#378">378</a> } <strong class="jxr_keyword">catch</strong> (Exception e) { +<a name="379" href="#379">379</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="380" href="#380">380</a> WSSecurityException.FAILURE, +<a name="381" href="#381">381</a> <span class="jxr_string">"noPassword"</span>, +<a name="382" href="#382">382</a> <strong class="jxr_keyword">new</strong> Object[] {sha}, +<a name="383" href="#383">383</a> e +<a name="384" href="#384">384</a> ); +<a name="385" href="#385">385</a> } +<a name="386" href="#386">386</a> decryptedData = pwcb.getKey(); +<a name="387" href="#387">387</a> } +<a name="388" href="#388">388</a> } <strong class="jxr_keyword">else</strong> { +<a name="389" href="#389">389</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="390" href="#390">390</a> } +<a name="391" href="#391">391</a> <strong class="jxr_keyword">return</strong> WSSecurityUtil.prepareSecretKey(algorithm, decryptedData); +<a name="392" href="#392">392</a> } +<a name="393" href="#393">393</a> +<a name="394" href="#394">394</a> <strong class="jxr_keyword">public</strong> String getId() { +<a name="395" href="#395">395</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>; +<a name="396" href="#396">396</a> } +<a name="397" href="#397">397</a> +<a name="398" href="#398">398</a> +<a name="399" href="#399">399</a> <em class="jxr_javadoccomment">/**</em> +<a name="400" href="#400">400</a> <em class="jxr_javadoccomment"> * @param decryptedNode the decrypted node</em> +<a name="401" href="#401">401</a> <em class="jxr_javadoccomment"> * @return a fully built xpath </em> +<a name="402" href="#402">402</a> <em class="jxr_javadoccomment"> * (eg. &quot;/soapenv:Envelope/soapenv:Body/ns:decryptedElement&quot;)</em> +<a name="403" href="#403">403</a> <em class="jxr_javadoccomment"> * if the decryptedNode is an Element or an Attr node and is not detached</em> +<a name="404" href="#404">404</a> <em class="jxr_javadoccomment"> * from the document. <code>null</code> otherwise</em> +<a name="405" href="#405">405</a> <em class="jxr_javadoccomment"> */</em> +<a name="406" href="#406">406</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">static</strong> String getXPath(Node decryptedNode) { +<a name="407" href="#407">407</a> <strong class="jxr_keyword">if</strong> (decryptedNode == <strong class="jxr_keyword">null</strong>) { +<a name="408" href="#408">408</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>; +<a name="409" href="#409">409</a> } +<a name="410" href="#410">410</a> +<a name="411" href="#411">411</a> String result = <span class="jxr_string">""</span>; +<a name="412" href="#412">412</a> <strong class="jxr_keyword">if</strong> (Node.ELEMENT_NODE == decryptedNode.getNodeType()) { +<a name="413" href="#413">413</a> result = decryptedNode.getNodeName(); +<a name="414" href="#414">414</a> result = prependFullPath(result, decryptedNode.getParentNode()); +<a name="415" href="#415">415</a> } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (Node.ATTRIBUTE_NODE == decryptedNode.getNodeType()) { +<a name="416" href="#416">416</a> result = <span class="jxr_string">"@"</span> + decryptedNode.getNodeName(); +<a name="417" href="#417">417</a> result = prependFullPath(result, ((Attr)decryptedNode).getOwnerElement()); +<a name="418" href="#418">418</a> } <strong class="jxr_keyword">else</strong> { +<a name="419" href="#419">419</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>; +<a name="420" href="#420">420</a> } +<a name="421" href="#421">421</a> +<a name="422" href="#422">422</a> <strong class="jxr_keyword">return</strong> result; +<a name="423" href="#423">423</a> } +<a name="424" href="#424">424</a> +<a name="425" href="#425">425</a> +<a name="426" href="#426">426</a> <em class="jxr_javadoccomment">/**</em> +<a name="427" href="#427">427</a> <em class="jxr_javadoccomment"> * Recursively build an absolute xpath (starting with the root &quot;/&quot;)</em> +<a name="428" href="#428">428</a> <em class="jxr_javadoccomment"> * </em> +<a name="429" href="#429">429</a> <em class="jxr_javadoccomment"> * @param xpath the xpath expression built so far</em> +<a name="430" href="#430">430</a> <em class="jxr_javadoccomment"> * @param node the current node whose name is to be prepended</em> +<a name="431" href="#431">431</a> <em class="jxr_javadoccomment"> * @return a fully built xpath</em> +<a name="432" href="#432">432</a> <em class="jxr_javadoccomment"> */</em> +<a name="433" href="#433">433</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">static</strong> String prependFullPath(String xpath, Node node) { +<a name="434" href="#434">434</a> <strong class="jxr_keyword">if</strong> (node == <strong class="jxr_keyword">null</strong>) { +<a name="435" href="#435">435</a> <em class="jxr_comment">// probably a detached node... not really useful</em> +<a name="436" href="#436">436</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>; +<a name="437" href="#437">437</a> } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (Node.ELEMENT_NODE == node.getNodeType()) { +<a name="438" href="#438">438</a> xpath = node.getNodeName() + <span class="jxr_string">"/"</span> + xpath; +<a name="439" href="#439">439</a> <strong class="jxr_keyword">return</strong> prependFullPath(xpath, node.getParentNode()); +<a name="440" href="#440">440</a> } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (Node.DOCUMENT_NODE == node.getNodeType()) { +<a name="441" href="#441">441</a> <strong class="jxr_keyword">return</strong> <span class="jxr_string">"/"</span> + xpath; +<a name="442" href="#442">442</a> } <strong class="jxr_keyword">else</strong> { +<a name="443" href="#443">443</a> <strong class="jxr_keyword">return</strong> prependFullPath(xpath, node.getParentNode()); +<a name="444" href="#444">444</a> } +<a name="445" href="#445">445</a> } +<a name="446" href="#446">446</a> +<a name="447" href="#447">447</a> } </pre> <hr/><div id="footer">This page was automatically generated by <a href="http://maven.apache.org/">Maven</a></div></body> </html>
