You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by co...@apache.org on 2011/10/03 17:16:11 UTC

svn commit: r1178426 [28/40] - in /webservices/wss4j/site: ./ apidocs/ apidocs/org/apache/ws/security/ apidocs/org/apache/ws/security/action/ apidocs/org/apache/ws/security/action/class-use/ apidocs/org/apache/ws/security/class-use/ apidocs/org/apache/...

Modified: webservices/wss4j/site/xref/org/apache/ws/security/message/WSSecSignature.html
URL: http://svn.apache.org/viewvc/webservices/wss4j/site/xref/org/apache/ws/security/message/WSSecSignature.html?rev=1178426&r1=1178425&r2=1178426&view=diff
==============================================================================
--- webservices/wss4j/site/xref/org/apache/ws/security/message/WSSecSignature.html (original)
+++ webservices/wss4j/site/xref/org/apache/ws/security/message/WSSecSignature.html Mon Oct  3 15:15:52 2011
@@ -277,532 +277,538 @@
 <a name="267" href="#267">267</a>                 <strong class="jxr_keyword">break</strong>;
 <a name="268" href="#268">268</a>                 
 <a name="269" href="#269">269</a>             <strong class="jxr_keyword">case</strong> WSConstants.CUSTOM_KEY_IDENTIFIER:
-<a name="270" href="#270">270</a>                 secRef.setKeyIdentifier(customTokenValueType, customTokenId);
-<a name="271" href="#271">271</a>                 <strong class="jxr_keyword">if</strong> (WSConstants.WSS_SAML_KI_VALUE_TYPE.equals(customTokenValueType)) {
+<a name="270" href="#270">270</a>                 <strong class="jxr_keyword">if</strong> (WSConstants.WSS_SAML_KI_VALUE_TYPE.equals(customTokenValueType)) {
+<a name="271" href="#271">271</a>                     secRef.setKeyIdentifier(customTokenValueType, customTokenId);
 <a name="272" href="#272">272</a>                     secRef.addTokenType(WSConstants.WSS_SAML_TOKEN_TYPE);
 <a name="273" href="#273">273</a>                 } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (WSConstants.WSS_SAML2_KI_VALUE_TYPE.equals(customTokenValueType)) {
-<a name="274" href="#274">274</a>                     secRef.addTokenType(WSConstants.WSS_SAML2_TOKEN_TYPE);
-<a name="275" href="#275">275</a>                 } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (WSConstants.WSS_ENC_KEY_VALUE_TYPE.equals(customTokenValueType)) {
-<a name="276" href="#276">276</a>                     secRef.addTokenType(WSConstants.WSS_ENC_KEY_VALUE_TYPE);
-<a name="277" href="#277">277</a>                 } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (SecurityTokenReference.ENC_KEY_SHA1_URI.equals(customTokenValueType)) {
+<a name="274" href="#274">274</a>                     secRef.setKeyIdentifier(customTokenValueType, customTokenId);
+<a name="275" href="#275">275</a>                     secRef.addTokenType(WSConstants.WSS_SAML2_TOKEN_TYPE);
+<a name="276" href="#276">276</a>                 } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (WSConstants.WSS_ENC_KEY_VALUE_TYPE.equals(customTokenValueType)) {
+<a name="277" href="#277">277</a>                     secRef.setKeyIdentifier(customTokenValueType, customTokenId, <strong class="jxr_keyword">true</strong>);
 <a name="278" href="#278">278</a>                     secRef.addTokenType(WSConstants.WSS_ENC_KEY_VALUE_TYPE);
-<a name="279" href="#279">279</a>                 }
-<a name="280" href="#280">280</a>                 <strong class="jxr_keyword">break</strong>;
-<a name="281" href="#281">281</a>                 
-<a name="282" href="#282">282</a>             <strong class="jxr_keyword">case</strong> WSConstants.KEY_VALUE:
-<a name="283" href="#283">283</a>                 java.security.PublicKey publicKey = certs[0].getPublicKey();
-<a name="284" href="#284">284</a>                 
-<a name="285" href="#285">285</a>                 <strong class="jxr_keyword">try</strong> {
-<a name="286" href="#286">286</a>                     KeyValue keyValue = keyInfoFactory.newKeyValue(publicKey);
-<a name="287" href="#287">287</a>                     keyInfo = 
-<a name="288" href="#288">288</a>                         keyInfoFactory.newKeyInfo(
-<a name="289" href="#289">289</a>                             java.util.Collections.singletonList(keyValue), keyInfoUri
-<a name="290" href="#290">290</a>                         );
-<a name="291" href="#291">291</a>                 } <strong class="jxr_keyword">catch</strong> (java.security.KeyException ex) {
-<a name="292" href="#292">292</a>                     log.error(<span class="jxr_string">""</span>, ex);
-<a name="293" href="#293">293</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="294" href="#294">294</a>                         WSSecurityException.FAILED_SIGNATURE, <span class="jxr_string">"noXMLSig"</span>, <strong class="jxr_keyword">null</strong>, ex
-<a name="295" href="#295">295</a>                     );
-<a name="296" href="#296">296</a>                 }
-<a name="297" href="#297">297</a>                 <strong class="jxr_keyword">break</strong>;
-<a name="298" href="#298">298</a>             <strong class="jxr_keyword">default</strong>:
-<a name="299" href="#299">299</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">"unsupportedKeyId"</span>);
-<a name="300" href="#300">300</a>             }
-<a name="301" href="#301">301</a>         }
-<a name="302" href="#302">302</a>         
-<a name="303" href="#303">303</a>         <strong class="jxr_keyword">if</strong> (keyIdentifierType != WSConstants.KEY_VALUE) {
-<a name="304" href="#304">304</a>             XMLStructure structure = <strong class="jxr_keyword">new</strong> DOMStructure(secRef.getElement());
-<a name="305" href="#305">305</a>             wsDocInfo.addTokenElement(secRef.getElement(), false);
-<a name="306" href="#306">306</a>             keyInfo = 
-<a name="307" href="#307">307</a>                 keyInfoFactory.newKeyInfo(
-<a name="308" href="#308">308</a>                     java.util.Collections.singletonList(structure), keyInfoUri
-<a name="309" href="#309">309</a>                 );
-<a name="310" href="#310">310</a>         }
-<a name="311" href="#311">311</a>     }
-<a name="312" href="#312">312</a>     
-<a name="313" href="#313">313</a>     
-<a name="314" href="#314">314</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="315" href="#315">315</a> <em class="jxr_javadoccomment">     * Builds a signed soap envelope.</em>
-<a name="316" href="#316">316</a> <em class="jxr_javadoccomment">     * </em>
-<a name="317" href="#317">317</a> <em class="jxr_javadoccomment">     * This is a convenience method and for backward compatibility. The method</em>
-<a name="318" href="#318">318</a> <em class="jxr_javadoccomment">     * creates a Signature and puts it into the Security header. It does so by</em>
-<a name="319" href="#319">319</a> <em class="jxr_javadoccomment">     * calling the single functions in order to perform a &lt;i&gt;one shot signature&lt;/i&gt;.</em>
-<a name="320" href="#320">320</a> <em class="jxr_javadoccomment">     * This method is compatible with the build method of the previous version</em>
-<a name="321" href="#321">321</a> <em class="jxr_javadoccomment">     * with the exception of the additional WSSecHeader parameter.</em>
+<a name="279" href="#279">279</a>                 } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (SecurityTokenReference.ENC_KEY_SHA1_URI.equals(customTokenValueType)) {
+<a name="280" href="#280">280</a>                     secRef.setKeyIdentifier(customTokenValueType, customTokenId, <strong class="jxr_keyword">true</strong>);
+<a name="281" href="#281">281</a>                     secRef.addTokenType(WSConstants.WSS_ENC_KEY_VALUE_TYPE);
+<a name="282" href="#282">282</a>                 } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (WSConstants.WSS_KRB_KI_VALUE_TYPE.equals(customTokenValueType)) {
+<a name="283" href="#283">283</a>                     secRef.setKeyIdentifier(customTokenValueType, customTokenId, <strong class="jxr_keyword">true</strong>);
+<a name="284" href="#284">284</a>                     secRef.addTokenType(WSConstants.WSS_GSS_KRB_V5_AP_REQ);
+<a name="285" href="#285">285</a>                 } 
+<a name="286" href="#286">286</a>                 <strong class="jxr_keyword">break</strong>;
+<a name="287" href="#287">287</a>                 
+<a name="288" href="#288">288</a>             <strong class="jxr_keyword">case</strong> WSConstants.KEY_VALUE:
+<a name="289" href="#289">289</a>                 java.security.PublicKey publicKey = certs[0].getPublicKey();
+<a name="290" href="#290">290</a>                 
+<a name="291" href="#291">291</a>                 <strong class="jxr_keyword">try</strong> {
+<a name="292" href="#292">292</a>                     KeyValue keyValue = keyInfoFactory.newKeyValue(publicKey);
+<a name="293" href="#293">293</a>                     keyInfo = 
+<a name="294" href="#294">294</a>                         keyInfoFactory.newKeyInfo(
+<a name="295" href="#295">295</a>                             java.util.Collections.singletonList(keyValue), keyInfoUri
+<a name="296" href="#296">296</a>                         );
+<a name="297" href="#297">297</a>                 } <strong class="jxr_keyword">catch</strong> (java.security.KeyException ex) {
+<a name="298" href="#298">298</a>                     log.error(<span class="jxr_string">""</span>, ex);
+<a name="299" href="#299">299</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="300" href="#300">300</a>                         WSSecurityException.FAILED_SIGNATURE, <span class="jxr_string">"noXMLSig"</span>, <strong class="jxr_keyword">null</strong>, ex
+<a name="301" href="#301">301</a>                     );
+<a name="302" href="#302">302</a>                 }
+<a name="303" href="#303">303</a>                 <strong class="jxr_keyword">break</strong>;
+<a name="304" href="#304">304</a>             <strong class="jxr_keyword">default</strong>:
+<a name="305" href="#305">305</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">"unsupportedKeyId"</span>);
+<a name="306" href="#306">306</a>             }
+<a name="307" href="#307">307</a>         }
+<a name="308" href="#308">308</a>         
+<a name="309" href="#309">309</a>         <strong class="jxr_keyword">if</strong> (keyIdentifierType != WSConstants.KEY_VALUE) {
+<a name="310" href="#310">310</a>             XMLStructure structure = <strong class="jxr_keyword">new</strong> DOMStructure(secRef.getElement());
+<a name="311" href="#311">311</a>             wsDocInfo.addTokenElement(secRef.getElement(), false);
+<a name="312" href="#312">312</a>             keyInfo = 
+<a name="313" href="#313">313</a>                 keyInfoFactory.newKeyInfo(
+<a name="314" href="#314">314</a>                     java.util.Collections.singletonList(structure), keyInfoUri
+<a name="315" href="#315">315</a>                 );
+<a name="316" href="#316">316</a>         }
+<a name="317" href="#317">317</a>     }
+<a name="318" href="#318">318</a>     
+<a name="319" href="#319">319</a>     
+<a name="320" href="#320">320</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="321" href="#321">321</a> <em class="jxr_javadoccomment">     * Builds a signed soap envelope.</em>
 <a name="322" href="#322">322</a> <em class="jxr_javadoccomment">     * </em>
-<a name="323" href="#323">323</a> <em class="jxr_javadoccomment">     * @param doc The unsigned SOAP envelope as &lt;code&gt;Document&lt;/code&gt;</em>
-<a name="324" href="#324">324</a> <em class="jxr_javadoccomment">     * @param cr An instance of the Crypto API to handle keystore and certificates</em>
-<a name="325" href="#325">325</a> <em class="jxr_javadoccomment">     * @param secHeader the security header element to hold the encrypted key element.</em>
-<a name="326" href="#326">326</a> <em class="jxr_javadoccomment">     * @return A signed SOAP envelope as &lt;code&gt;Document&lt;/code&gt;</em>
-<a name="327" href="#327">327</a> <em class="jxr_javadoccomment">     * @throws WSSecurityException</em>
-<a name="328" href="#328">328</a> <em class="jxr_javadoccomment">     */</em>
-<a name="329" href="#329">329</a>     <strong class="jxr_keyword">public</strong> Document build(Document doc, <a href="../../../../../org/apache/ws/security/components/crypto/Crypto.html">Crypto</a> cr, <a href="../../../../../org/apache/ws/security/message/WSSecHeader.html">WSSecHeader</a> secHeader)
-<a name="330" href="#330">330</a>         <strong class="jxr_keyword">throws</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a> {
-<a name="331" href="#331">331</a>         doDebug = log.isDebugEnabled();
-<a name="332" href="#332">332</a> 
-<a name="333" href="#333">333</a>         <strong class="jxr_keyword">if</strong> (doDebug) {
-<a name="334" href="#334">334</a>             log.debug(<span class="jxr_string">"Beginning signing..."</span>);
-<a name="335" href="#335">335</a>         }
-<a name="336" href="#336">336</a> 
-<a name="337" href="#337">337</a>         prepare(doc, cr, secHeader);
-<a name="338" href="#338">338</a>         <strong class="jxr_keyword">if</strong> (parts == <strong class="jxr_keyword">null</strong>) {
-<a name="339" href="#339">339</a>             parts = <strong class="jxr_keyword">new</strong> ArrayList&lt;WSEncryptionPart&gt;(1);
-<a name="340" href="#340">340</a>             String soapNamespace = WSSecurityUtil.getSOAPNamespace(doc.getDocumentElement());
-<a name="341" href="#341">341</a>             <a href="../../../../../org/apache/ws/security/WSEncryptionPart.html">WSEncryptionPart</a> encP = 
-<a name="342" href="#342">342</a>                 <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSEncryptionPart.html">WSEncryptionPart</a>(
-<a name="343" href="#343">343</a>                     WSConstants.ELEM_BODY, 
-<a name="344" href="#344">344</a>                     soapNamespace, 
-<a name="345" href="#345">345</a>                     <span class="jxr_string">"Content"</span>
-<a name="346" href="#346">346</a>                 );
-<a name="347" href="#347">347</a>             parts.add(encP);
-<a name="348" href="#348">348</a>         } <strong class="jxr_keyword">else</strong> {
-<a name="349" href="#349">349</a>             <strong class="jxr_keyword">for</strong> (WSEncryptionPart part : parts) {
-<a name="350" href="#350">350</a>                 <strong class="jxr_keyword">if</strong> (<span class="jxr_string">"STRTransform"</span>.equals(part.getName()) &amp;&amp; part.getId() == <strong class="jxr_keyword">null</strong>) {
-<a name="351" href="#351">351</a>                     part.setId(strUri);
-<a name="352" href="#352">352</a>                 }
-<a name="353" href="#353">353</a>             }
-<a name="354" href="#354">354</a>         }
-<a name="355" href="#355">355</a> 
-<a name="356" href="#356">356</a>         List&lt;javax.xml.crypto.dsig.Reference&gt; referenceList = 
-<a name="357" href="#357">357</a>             addReferencesToSign(parts, secHeader);
-<a name="358" href="#358">358</a> 
-<a name="359" href="#359">359</a>         computeSignature(referenceList);
-<a name="360" href="#360">360</a>         
-<a name="361" href="#361">361</a>         <em class="jxr_comment">//</em>
-<a name="362" href="#362">362</a>         <em class="jxr_comment">// if we have a BST prepend it in front of the Signature according to</em>
-<a name="363" href="#363">363</a>         <em class="jxr_comment">// strict layout rules.</em>
-<a name="364" href="#364">364</a>         <em class="jxr_comment">//</em>
-<a name="365" href="#365">365</a>         <strong class="jxr_keyword">if</strong> (bstToken != <strong class="jxr_keyword">null</strong>) {
-<a name="366" href="#366">366</a>             prependBSTElementToHeader(secHeader);
-<a name="367" href="#367">367</a>         }
-<a name="368" href="#368">368</a> 
-<a name="369" href="#369">369</a>         <strong class="jxr_keyword">return</strong> doc;
-<a name="370" href="#370">370</a>     }
-<a name="371" href="#371">371</a>     
-<a name="372" href="#372">372</a>     
-<a name="373" href="#373">373</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="374" href="#374">374</a> <em class="jxr_javadoccomment">     * This method adds references to the Signature.</em>
-<a name="375" href="#375">375</a> <em class="jxr_javadoccomment">     * </em>
-<a name="376" href="#376">376</a> <em class="jxr_javadoccomment">     * @param references The list of references to sign</em>
-<a name="377" href="#377">377</a> <em class="jxr_javadoccomment">     * @param secHeader The Security Header</em>
-<a name="378" href="#378">378</a> <em class="jxr_javadoccomment">     * @throws WSSecurityException</em>
-<a name="379" href="#379">379</a> <em class="jxr_javadoccomment">     */</em>
-<a name="380" href="#380">380</a>     <strong class="jxr_keyword">public</strong> List&lt;javax.xml.crypto.dsig.Reference&gt; addReferencesToSign(
-<a name="381" href="#381">381</a>         List&lt;WSEncryptionPart&gt; references, 
-<a name="382" href="#382">382</a>         <a href="../../../../../org/apache/ws/security/message/WSSecHeader.html">WSSecHeader</a> secHeader
-<a name="383" href="#383">383</a>     ) <strong class="jxr_keyword">throws</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a> {
-<a name="384" href="#384">384</a>         <strong class="jxr_keyword">return</strong> 
-<a name="385" href="#385">385</a>             addReferencesToSign(
-<a name="386" href="#386">386</a>                 document, 
-<a name="387" href="#387">387</a>                 references,
-<a name="388" href="#388">388</a>                 wsDocInfo,
-<a name="389" href="#389">389</a>                 signatureFactory, 
-<a name="390" href="#390">390</a>                 secHeader, 
-<a name="391" href="#391">391</a>                 getWsConfig(), 
-<a name="392" href="#392">392</a>                 digestAlgo
-<a name="393" href="#393">393</a>             );
-<a name="394" href="#394">394</a>     }
-<a name="395" href="#395">395</a> 
-<a name="396" href="#396">396</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="397" href="#397">397</a> <em class="jxr_javadoccomment">     * Returns the SignatureElement.</em>
-<a name="398" href="#398">398</a> <em class="jxr_javadoccomment">     * The method can be called any time after &lt;code&gt;prepare()&lt;/code&gt;.</em>
-<a name="399" href="#399">399</a> <em class="jxr_javadoccomment">     * @return The DOM Element of the signature.</em>
-<a name="400" href="#400">400</a> <em class="jxr_javadoccomment">     */</em>
-<a name="401" href="#401">401</a>     <strong class="jxr_keyword">public</strong> Element getSignatureElement() {
-<a name="402" href="#402">402</a>         <strong class="jxr_keyword">return</strong>
-<a name="403" href="#403">403</a>             WSSecurityUtil.getDirectChildElement(
-<a name="404" href="#404">404</a>                 securityHeader,
-<a name="405" href="#405">405</a>                 WSConstants.SIG_LN,
-<a name="406" href="#406">406</a>                 WSConstants.SIG_NS
-<a name="407" href="#407">407</a>             );
-<a name="408" href="#408">408</a>     }
-<a name="409" href="#409">409</a>     
-<a name="410" href="#410">410</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="411" href="#411">411</a> <em class="jxr_javadoccomment">     * Prepend the BinarySecurityToken to the elements already in the Security</em>
-<a name="412" href="#412">412</a> <em class="jxr_javadoccomment">     * header.</em>
-<a name="413" href="#413">413</a> <em class="jxr_javadoccomment">     * </em>
-<a name="414" href="#414">414</a> <em class="jxr_javadoccomment">     * The method can be called any time after &lt;code&gt;prepare()&lt;/code&gt;.</em>
-<a name="415" href="#415">415</a> <em class="jxr_javadoccomment">     * This allows to insert the BST element at any position in the Security</em>
-<a name="416" href="#416">416</a> <em class="jxr_javadoccomment">     * header.</em>
-<a name="417" href="#417">417</a> <em class="jxr_javadoccomment">     * </em>
-<a name="418" href="#418">418</a> <em class="jxr_javadoccomment">     * @param secHeader The security header</em>
-<a name="419" href="#419">419</a> <em class="jxr_javadoccomment">     */</em>
-<a name="420" href="#420">420</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> prependBSTElementToHeader(<a href="../../../../../org/apache/ws/security/message/WSSecHeader.html">WSSecHeader</a> secHeader) {
-<a name="421" href="#421">421</a>         <strong class="jxr_keyword">if</strong> (bstToken != <strong class="jxr_keyword">null</strong>) {
-<a name="422" href="#422">422</a>             WSSecurityUtil.prependChildElement(secHeader.getSecurityHeader(), bstToken.getElement());
-<a name="423" href="#423">423</a>         }
-<a name="424" href="#424">424</a>         bstToken = <strong class="jxr_keyword">null</strong>;
-<a name="425" href="#425">425</a>     }
-<a name="426" href="#426">426</a> 
-<a name="427" href="#427">427</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="428" href="#428">428</a> <em class="jxr_javadoccomment">     * Append the BinarySecurityToken to the security header. </em>
-<a name="429" href="#429">429</a> <em class="jxr_javadoccomment">     * @param secHeader The security header</em>
-<a name="430" href="#430">430</a> <em class="jxr_javadoccomment">     */</em>
-<a name="431" href="#431">431</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> appendBSTElementToHeader(<a href="../../../../../org/apache/ws/security/message/WSSecHeader.html">WSSecHeader</a> secHeader) {
-<a name="432" href="#432">432</a>         <strong class="jxr_keyword">if</strong> (bstToken != <strong class="jxr_keyword">null</strong>) {
-<a name="433" href="#433">433</a>             Element secHeaderElement = secHeader.getSecurityHeader();
-<a name="434" href="#434">434</a>             secHeaderElement.appendChild(bstToken.getElement());
-<a name="435" href="#435">435</a>         }
-<a name="436" href="#436">436</a>         bstToken = <strong class="jxr_keyword">null</strong>;
-<a name="437" href="#437">437</a>     }
-<a name="438" href="#438">438</a>     
-<a name="439" href="#439">439</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="440" href="#440">440</a> <em class="jxr_javadoccomment">     * Compute the Signature over the references. The signature element will be </em>
-<a name="441" href="#441">441</a> <em class="jxr_javadoccomment">     * prepended to the security header.</em>
-<a name="442" href="#442">442</a> <em class="jxr_javadoccomment">     * </em>
-<a name="443" href="#443">443</a> <em class="jxr_javadoccomment">     * This method can be called any time after the references were set. See</em>
-<a name="444" href="#444">444</a> <em class="jxr_javadoccomment">     * &lt;code&gt;addReferencesToSign()&lt;/code&gt;.</em>
-<a name="445" href="#445">445</a> <em class="jxr_javadoccomment">     * </em>
-<a name="446" href="#446">446</a> <em class="jxr_javadoccomment">     * @param referenceList The list of references to sign</em>
-<a name="447" href="#447">447</a> <em class="jxr_javadoccomment">     * </em>
-<a name="448" href="#448">448</a> <em class="jxr_javadoccomment">     * @throws WSSecurityException</em>
-<a name="449" href="#449">449</a> <em class="jxr_javadoccomment">     */</em>
-<a name="450" href="#450">450</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> computeSignature(
-<a name="451" href="#451">451</a>         List&lt;javax.xml.crypto.dsig.Reference&gt; referenceList 
-<a name="452" href="#452">452</a>     ) <strong class="jxr_keyword">throws</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a> {
-<a name="453" href="#453">453</a>         computeSignature(referenceList, <strong class="jxr_keyword">true</strong>, <strong class="jxr_keyword">null</strong>);
-<a name="454" href="#454">454</a>     }
-<a name="455" href="#455">455</a>     
-<a name="456" href="#456">456</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="457" href="#457">457</a> <em class="jxr_javadoccomment">     * Compute the Signature over the references.</em>
-<a name="458" href="#458">458</a> <em class="jxr_javadoccomment">     * </em>
-<a name="459" href="#459">459</a> <em class="jxr_javadoccomment">     * This method can be called any time after the references were set. See</em>
-<a name="460" href="#460">460</a> <em class="jxr_javadoccomment">     * &lt;code&gt;addReferencesToSign()&lt;/code&gt;.</em>
-<a name="461" href="#461">461</a> <em class="jxr_javadoccomment">     * </em>
-<a name="462" href="#462">462</a> <em class="jxr_javadoccomment">     * @param referenceList The list of references to sign</em>
-<a name="463" href="#463">463</a> <em class="jxr_javadoccomment">     * @param prepend Whether to prepend the signature element to the security header</em>
-<a name="464" href="#464">464</a> <em class="jxr_javadoccomment">     * @param siblingElement If prepending, then prepend before this sibling Element</em>
-<a name="465" href="#465">465</a> <em class="jxr_javadoccomment">     * </em>
-<a name="466" href="#466">466</a> <em class="jxr_javadoccomment">     * @throws WSSecurityException</em>
-<a name="467" href="#467">467</a> <em class="jxr_javadoccomment">     */</em>
-<a name="468" href="#468">468</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> computeSignature(
-<a name="469" href="#469">469</a>         List&lt;javax.xml.crypto.dsig.Reference&gt; referenceList, 
-<a name="470" href="#470">470</a>         <strong class="jxr_keyword">boolean</strong> prepend,
-<a name="471" href="#471">471</a>         Element siblingElement
-<a name="472" href="#472">472</a>     ) <strong class="jxr_keyword">throws</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a> {
-<a name="473" href="#473">473</a>         <strong class="jxr_keyword">try</strong> {
-<a name="474" href="#474">474</a>             java.security.Key key;
-<a name="475" href="#475">475</a>             <strong class="jxr_keyword">if</strong> (secretKey == <strong class="jxr_keyword">null</strong>) {
-<a name="476" href="#476">476</a>                 key = crypto.getPrivateKey(user, password);
-<a name="477" href="#477">477</a>             } <strong class="jxr_keyword">else</strong> {
-<a name="478" href="#478">478</a>                 key = WSSecurityUtil.prepareSecretKey(sigAlgo, secretKey);
-<a name="479" href="#479">479</a>             }
-<a name="480" href="#480">480</a>             SignatureMethod signatureMethod = 
-<a name="481" href="#481">481</a>                 signatureFactory.newSignatureMethod(sigAlgo, <strong class="jxr_keyword">null</strong>);
-<a name="482" href="#482">482</a>             SignedInfo signedInfo = 
-<a name="483" href="#483">483</a>                 signatureFactory.newSignedInfo(c14nMethod, signatureMethod, referenceList);
-<a name="484" href="#484">484</a>             
-<a name="485" href="#485">485</a>             sig = signatureFactory.newXMLSignature(
-<a name="486" href="#486">486</a>                     signedInfo, 
-<a name="487" href="#487">487</a>                     keyInfo,
-<a name="488" href="#488">488</a>                     <strong class="jxr_keyword">null</strong>,
-<a name="489" href="#489">489</a>                     getWsConfig().getIdAllocator().createId(<span class="jxr_string">"SIG-"</span>, <strong class="jxr_keyword">null</strong>),
-<a name="490" href="#490">490</a>                     <strong class="jxr_keyword">null</strong>);
-<a name="491" href="#491">491</a>             
-<a name="492" href="#492">492</a>             <em class="jxr_comment">//</em>
-<a name="493" href="#493">493</a>             <em class="jxr_comment">// Figure out where to insert the signature element</em>
-<a name="494" href="#494">494</a>             <em class="jxr_comment">//</em>
-<a name="495" href="#495">495</a>             XMLSignContext signContext = <strong class="jxr_keyword">null</strong>;
-<a name="496" href="#496">496</a>             <strong class="jxr_keyword">if</strong> (prepend) {
-<a name="497" href="#497">497</a>                 <strong class="jxr_keyword">if</strong> (siblingElement == <strong class="jxr_keyword">null</strong>) {
-<a name="498" href="#498">498</a>                     Node child = securityHeader.getFirstChild();
-<a name="499" href="#499">499</a>                     <strong class="jxr_keyword">while</strong> (child != <strong class="jxr_keyword">null</strong> &amp;&amp; child.getNodeType() != Node.ELEMENT_NODE) {
-<a name="500" href="#500">500</a>                         child = child.getNextSibling();
-<a name="501" href="#501">501</a>                     } 
-<a name="502" href="#502">502</a>                     siblingElement = (Element)child;
-<a name="503" href="#503">503</a>                 }
-<a name="504" href="#504">504</a>                 <strong class="jxr_keyword">if</strong> (siblingElement == <strong class="jxr_keyword">null</strong>) {
-<a name="505" href="#505">505</a>                     signContext = <strong class="jxr_keyword">new</strong> DOMSignContext(key, securityHeader);
-<a name="506" href="#506">506</a>                 } <strong class="jxr_keyword">else</strong> {
-<a name="507" href="#507">507</a>                     signContext = <strong class="jxr_keyword">new</strong> DOMSignContext(key, securityHeader, siblingElement);
-<a name="508" href="#508">508</a>                 }
-<a name="509" href="#509">509</a>             } <strong class="jxr_keyword">else</strong> {
-<a name="510" href="#510">510</a>                 signContext = <strong class="jxr_keyword">new</strong> DOMSignContext(key, securityHeader);
-<a name="511" href="#511">511</a>             }
-<a name="512" href="#512">512</a>             
-<a name="513" href="#513">513</a>             signContext.putNamespacePrefix(WSConstants.SIG_NS, WSConstants.SIG_PREFIX);
-<a name="514" href="#514">514</a>             <strong class="jxr_keyword">if</strong> (WSConstants.C14N_EXCL_OMIT_COMMENTS.equals(canonAlgo)) {
-<a name="515" href="#515">515</a>                 signContext.putNamespacePrefix(
-<a name="516" href="#516">516</a>                     WSConstants.C14N_EXCL_OMIT_COMMENTS, 
-<a name="517" href="#517">517</a>                     WSConstants.C14N_EXCL_OMIT_COMMENTS_PREFIX
-<a name="518" href="#518">518</a>                 );
-<a name="519" href="#519">519</a>             }
-<a name="520" href="#520">520</a>             signContext.setProperty(STRTransform.TRANSFORM_WS_DOC_INFO, wsDocInfo);
-<a name="521" href="#521">521</a>             wsDocInfo.setCallbackLookup(callbackLookup);
-<a name="522" href="#522">522</a>             
-<a name="523" href="#523">523</a>             <em class="jxr_comment">// Add the elements to sign to the Signature Context</em>
-<a name="524" href="#524">524</a>             wsDocInfo.setTokensOnContext((DOMSignContext)signContext);
-<a name="525" href="#525">525</a>             <strong class="jxr_keyword">if</strong> (secRef != <strong class="jxr_keyword">null</strong> &amp;&amp; secRef.getElement() != <strong class="jxr_keyword">null</strong>) {
-<a name="526" href="#526">526</a>                 WSSecurityUtil.storeElementInContext((DOMSignContext)signContext, secRef.getElement());
-<a name="527" href="#527">527</a>             }
-<a name="528" href="#528">528</a>             sig.sign(signContext);
-<a name="529" href="#529">529</a>             
-<a name="530" href="#530">530</a>             signatureValue = sig.getSignatureValue().getValue();
-<a name="531" href="#531">531</a>         } <strong class="jxr_keyword">catch</strong> (Exception ex) {
-<a name="532" href="#532">532</a>             log.error(ex);
-<a name="533" href="#533">533</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="534" href="#534">534</a>                 WSSecurityException.FAILED_SIGNATURE, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">null</strong>, ex
-<a name="535" href="#535">535</a>             );
-<a name="536" href="#536">536</a>         }
-<a name="537" href="#537">537</a>     }
-<a name="538" href="#538">538</a>     
-<a name="539" href="#539">539</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="540" href="#540">540</a> <em class="jxr_javadoccomment">     * Set the single cert flag.</em>
-<a name="541" href="#541">541</a> <em class="jxr_javadoccomment">     * </em>
-<a name="542" href="#542">542</a> <em class="jxr_javadoccomment">     * @param useSingleCert</em>
-<a name="543" href="#543">543</a> <em class="jxr_javadoccomment">     */</em>
-<a name="544" href="#544">544</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> setUseSingleCertificate(<strong class="jxr_keyword">boolean</strong> useSingleCert) {
-<a name="545" href="#545">545</a>         <strong class="jxr_keyword">this</strong>.useSingleCert = useSingleCert;
-<a name="546" href="#546">546</a>     }
-<a name="547" href="#547">547</a> 
-<a name="548" href="#548">548</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="549" href="#549">549</a> <em class="jxr_javadoccomment">     * Get the single cert flag.</em>
-<a name="550" href="#550">550</a> <em class="jxr_javadoccomment">     * </em>
-<a name="551" href="#551">551</a> <em class="jxr_javadoccomment">     * @return A boolean if single certificate is set.</em>
-<a name="552" href="#552">552</a> <em class="jxr_javadoccomment">     */</em>
-<a name="553" href="#553">553</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">boolean</strong> isUseSingleCertificate() {
-<a name="554" href="#554">554</a>         <strong class="jxr_keyword">return</strong> useSingleCert;
-<a name="555" href="#555">555</a>     }
-<a name="556" href="#556">556</a> 
-<a name="557" href="#557">557</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="558" href="#558">558</a> <em class="jxr_javadoccomment">     * Set the name (uri) of the signature encryption algorithm to use.</em>
-<a name="559" href="#559">559</a> <em class="jxr_javadoccomment">     * </em>
-<a name="560" href="#560">560</a> <em class="jxr_javadoccomment">     * If the algorithm is not set then an automatic detection of the signature</em>
-<a name="561" href="#561">561</a> <em class="jxr_javadoccomment">     * algorithm to use is performed during the &lt;code&gt;prepare()&lt;/code&gt;</em>
-<a name="562" href="#562">562</a> <em class="jxr_javadoccomment">     * method. Refer to WSConstants which algorithms are supported.</em>
-<a name="563" href="#563">563</a> <em class="jxr_javadoccomment">     * </em>
-<a name="564" href="#564">564</a> <em class="jxr_javadoccomment">     * @param algo the name of the signature algorithm</em>
-<a name="565" href="#565">565</a> <em class="jxr_javadoccomment">     * @see WSConstants#RSA</em>
-<a name="566" href="#566">566</a> <em class="jxr_javadoccomment">     * @see WSConstants#DSA</em>
-<a name="567" href="#567">567</a> <em class="jxr_javadoccomment">     */</em>
-<a name="568" href="#568">568</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> setSignatureAlgorithm(String algo) {
-<a name="569" href="#569">569</a>         sigAlgo = algo;
-<a name="570" href="#570">570</a>     }
-<a name="571" href="#571">571</a> 
-<a name="572" href="#572">572</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="573" href="#573">573</a> <em class="jxr_javadoccomment">     * Get the name (uri) of the signature algorithm that is being used.</em>
-<a name="574" href="#574">574</a> <em class="jxr_javadoccomment">     * </em>
-<a name="575" href="#575">575</a> <em class="jxr_javadoccomment">     * Call this method after &lt;code&gt;prepare&lt;/code&gt; to get the information</em>
-<a name="576" href="#576">576</a> <em class="jxr_javadoccomment">     * which signature algorithm was automatically detected if no signature</em>
-<a name="577" href="#577">577</a> <em class="jxr_javadoccomment">     * algorithm was preset.</em>
-<a name="578" href="#578">578</a> <em class="jxr_javadoccomment">     * </em>
-<a name="579" href="#579">579</a> <em class="jxr_javadoccomment">     * @return the identifier URI of the signature algorithm</em>
-<a name="580" href="#580">580</a> <em class="jxr_javadoccomment">     */</em>
-<a name="581" href="#581">581</a>     <strong class="jxr_keyword">public</strong> String getSignatureAlgorithm() {
-<a name="582" href="#582">582</a>         <strong class="jxr_keyword">return</strong> sigAlgo;
-<a name="583" href="#583">583</a>     }
-<a name="584" href="#584">584</a> 
-<a name="585" href="#585">585</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="586" href="#586">586</a> <em class="jxr_javadoccomment">     * Set the canonicalization method to use.</em>
-<a name="587" href="#587">587</a> <em class="jxr_javadoccomment">     * </em>
-<a name="588" href="#588">588</a> <em class="jxr_javadoccomment">     * If the canonicalization method is not set then the recommended Exclusive</em>
-<a name="589" href="#589">589</a> <em class="jxr_javadoccomment">     * XML Canonicalization is used by default. Refer to WSConstants which</em>
-<a name="590" href="#590">590</a> <em class="jxr_javadoccomment">     * algorithms are supported.</em>
-<a name="591" href="#591">591</a> <em class="jxr_javadoccomment">     * </em>
-<a name="592" href="#592">592</a> <em class="jxr_javadoccomment">     * @param algo Is the name of the signature algorithm</em>
-<a name="593" href="#593">593</a> <em class="jxr_javadoccomment">     * @see WSConstants#C14N_OMIT_COMMENTS</em>
-<a name="594" href="#594">594</a> <em class="jxr_javadoccomment">     * @see WSConstants#C14N_WITH_COMMENTS</em>
-<a name="595" href="#595">595</a> <em class="jxr_javadoccomment">     * @see WSConstants#C14N_EXCL_OMIT_COMMENTS</em>
-<a name="596" href="#596">596</a> <em class="jxr_javadoccomment">     * @see WSConstants#C14N_EXCL_WITH_COMMENTS</em>
-<a name="597" href="#597">597</a> <em class="jxr_javadoccomment">     */</em>
-<a name="598" href="#598">598</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> setSigCanonicalization(String algo) {
-<a name="599" href="#599">599</a>         canonAlgo = algo;
-<a name="600" href="#600">600</a>     }
-<a name="601" href="#601">601</a> 
-<a name="602" href="#602">602</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="603" href="#603">603</a> <em class="jxr_javadoccomment">     * Get the canonicalization method.</em>
-<a name="604" href="#604">604</a> <em class="jxr_javadoccomment">     * </em>
-<a name="605" href="#605">605</a> <em class="jxr_javadoccomment">     * If the canonicalization method was not set then Exclusive XML</em>
-<a name="606" href="#606">606</a> <em class="jxr_javadoccomment">     * Canonicalization is used by default.</em>
-<a name="607" href="#607">607</a> <em class="jxr_javadoccomment">     * </em>
-<a name="608" href="#608">608</a> <em class="jxr_javadoccomment">     * @return The string describing the canonicalization algorithm.</em>
-<a name="609" href="#609">609</a> <em class="jxr_javadoccomment">     */</em>
-<a name="610" href="#610">610</a>     <strong class="jxr_keyword">public</strong> String getSigCanonicalization() {
-<a name="611" href="#611">611</a>         <strong class="jxr_keyword">return</strong> canonAlgo;
-<a name="612" href="#612">612</a>     }
-<a name="613" href="#613">613</a> 
-<a name="614" href="#614">614</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="615" href="#615">615</a> <em class="jxr_javadoccomment">     * @return the digest algorithm to use</em>
-<a name="616" href="#616">616</a> <em class="jxr_javadoccomment">     */</em>
-<a name="617" href="#617">617</a>     <strong class="jxr_keyword">public</strong> String getDigestAlgo() {
-<a name="618" href="#618">618</a>         <strong class="jxr_keyword">return</strong> digestAlgo;
-<a name="619" href="#619">619</a>     }
-<a name="620" href="#620">620</a> 
-<a name="621" href="#621">621</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="622" href="#622">622</a> <em class="jxr_javadoccomment">     * Set the string that defines which digest algorithm to use. </em>
-<a name="623" href="#623">623</a> <em class="jxr_javadoccomment">     * The default is Constants.ALGO_ID_DIGEST_SHA1.</em>
-<a name="624" href="#624">624</a> <em class="jxr_javadoccomment">     * </em>
-<a name="625" href="#625">625</a> <em class="jxr_javadoccomment">     * @param digestAlgo the digestAlgo to set</em>
-<a name="626" href="#626">626</a> <em class="jxr_javadoccomment">     */</em>
-<a name="627" href="#627">627</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> setDigestAlgo(String digestAlgo) {
-<a name="628" href="#628">628</a>         <strong class="jxr_keyword">this</strong>.digestAlgo = digestAlgo;
-<a name="629" href="#629">629</a>     }
-<a name="630" href="#630">630</a>     
-<a name="631" href="#631">631</a>     
-<a name="632" href="#632">632</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="633" href="#633">633</a> <em class="jxr_javadoccomment">     * Returns the computed Signature value.</em>
-<a name="634" href="#634">634</a> <em class="jxr_javadoccomment">     * </em>
-<a name="635" href="#635">635</a> <em class="jxr_javadoccomment">     * Call this method after &lt;code&gt;computeSignature()&lt;/code&gt; or &lt;code&gt;build()&lt;/code&gt;</em>
-<a name="636" href="#636">636</a> <em class="jxr_javadoccomment">     * methods were called.</em>
-<a name="637" href="#637">637</a> <em class="jxr_javadoccomment">     * </em>
-<a name="638" href="#638">638</a> <em class="jxr_javadoccomment">     * @return Returns the signatureValue.</em>
-<a name="639" href="#639">639</a> <em class="jxr_javadoccomment">     */</em>
-<a name="640" href="#640">640</a>     <strong class="jxr_keyword">public</strong> byte[] getSignatureValue() {
-<a name="641" href="#641">641</a>         <strong class="jxr_keyword">return</strong> signatureValue;
-<a name="642" href="#642">642</a>     }
-<a name="643" href="#643">643</a> 
-<a name="644" href="#644">644</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="645" href="#645">645</a> <em class="jxr_javadoccomment">     * Get the id generated during &lt;code&gt;prepare()&lt;/code&gt;.</em>
-<a name="646" href="#646">646</a> <em class="jxr_javadoccomment">     * </em>
-<a name="647" href="#647">647</a> <em class="jxr_javadoccomment">     * Returns the the value of wsu:Id attribute of the Signature element.</em>
-<a name="648" href="#648">648</a> <em class="jxr_javadoccomment">     * </em>
-<a name="649" href="#649">649</a> <em class="jxr_javadoccomment">     * @return Return the wsu:Id of this token or null if &lt;code&gt;prepare()&lt;/code&gt;</em>
-<a name="650" href="#650">650</a> <em class="jxr_javadoccomment">     *         was not called before.</em>
-<a name="651" href="#651">651</a> <em class="jxr_javadoccomment">     */</em>
-<a name="652" href="#652">652</a>     <strong class="jxr_keyword">public</strong> String getId() {
-<a name="653" href="#653">653</a>         <strong class="jxr_keyword">if</strong> (sig == <strong class="jxr_keyword">null</strong>) {
-<a name="654" href="#654">654</a>             <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
-<a name="655" href="#655">655</a>         }
-<a name="656" href="#656">656</a>         <strong class="jxr_keyword">return</strong> sig.getId();
-<a name="657" href="#657">657</a>     }
-<a name="658" href="#658">658</a>     
-<a name="659" href="#659">659</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="660" href="#660">660</a> <em class="jxr_javadoccomment">     * Get the id of the BST generated  during &lt;code&gt;prepare()&lt;/code&gt;.</em>
-<a name="661" href="#661">661</a> <em class="jxr_javadoccomment">     * </em>
-<a name="662" href="#662">662</a> <em class="jxr_javadoccomment">     * @return Returns the the value of wsu:Id attribute of the </em>
-<a name="663" href="#663">663</a> <em class="jxr_javadoccomment">     * BinaruSecurityToken element.</em>
-<a name="664" href="#664">664</a> <em class="jxr_javadoccomment">     */</em>
-<a name="665" href="#665">665</a>     <strong class="jxr_keyword">public</strong> String getBSTTokenId() {
-<a name="666" href="#666">666</a>         <strong class="jxr_keyword">if</strong> (bstToken == <strong class="jxr_keyword">null</strong>) {
-<a name="667" href="#667">667</a>             <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
-<a name="668" href="#668">668</a>         }
-<a name="669" href="#669">669</a>         <strong class="jxr_keyword">return</strong> bstToken.getID();
-<a name="670" href="#670">670</a>     }
-<a name="671" href="#671">671</a>     
-<a name="672" href="#672">672</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="673" href="#673">673</a> <em class="jxr_javadoccomment">     * Set the secret key to use</em>
-<a name="674" href="#674">674</a> <em class="jxr_javadoccomment">     * @param secretKey the secret key to use</em>
-<a name="675" href="#675">675</a> <em class="jxr_javadoccomment">     */</em>
-<a name="676" href="#676">676</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> setSecretKey(byte[] secretKey) {
-<a name="677" href="#677">677</a>         <strong class="jxr_keyword">this</strong>.secretKey = secretKey;
-<a name="678" href="#678">678</a>     }
-<a name="679" href="#679">679</a> 
-<a name="680" href="#680">680</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="681" href="#681">681</a> <em class="jxr_javadoccomment">     * Set the custom token value type to use</em>
-<a name="682" href="#682">682</a> <em class="jxr_javadoccomment">     * @param customTokenValueType the custom token value type to use</em>
-<a name="683" href="#683">683</a> <em class="jxr_javadoccomment">     */</em>
-<a name="684" href="#684">684</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> setCustomTokenValueType(String customTokenValueType) {
-<a name="685" href="#685">685</a>         <strong class="jxr_keyword">this</strong>.customTokenValueType = customTokenValueType;
-<a name="686" href="#686">686</a>     }
-<a name="687" href="#687">687</a> 
-<a name="688" href="#688">688</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="689" href="#689">689</a> <em class="jxr_javadoccomment">     * Set the custom token id</em>
-<a name="690" href="#690">690</a> <em class="jxr_javadoccomment">     * @param customTokenId the custom token id</em>
-<a name="691" href="#691">691</a> <em class="jxr_javadoccomment">     */</em>
-<a name="692" href="#692">692</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> setCustomTokenId(String customTokenId) {
-<a name="693" href="#693">693</a>         <strong class="jxr_keyword">this</strong>.customTokenId = customTokenId;
-<a name="694" href="#694">694</a>     }
-<a name="695" href="#695">695</a> 
-<a name="696" href="#696">696</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="697" href="#697">697</a> <em class="jxr_javadoccomment">     * Set the encrypted key sha1 value</em>
-<a name="698" href="#698">698</a> <em class="jxr_javadoccomment">     * @param encrKeySha1value the encrypted key sha1 value</em>
-<a name="699" href="#699">699</a> <em class="jxr_javadoccomment">     */</em>
-<a name="700" href="#700">700</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> setEncrKeySha1value(String encrKeySha1value) {
-<a name="701" href="#701">701</a>         <strong class="jxr_keyword">this</strong>.encrKeySha1value = encrKeySha1value;
-<a name="702" href="#702">702</a>     }
-<a name="703" href="#703">703</a>     
-<a name="704" href="#704">704</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="705" href="#705">705</a> <em class="jxr_javadoccomment">     * Set the X509 Certificate to use</em>
-<a name="706" href="#706">706</a> <em class="jxr_javadoccomment">     * @param cer the X509 Certificate to use</em>
-<a name="707" href="#707">707</a> <em class="jxr_javadoccomment">     */</em>
-<a name="708" href="#708">708</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> setX509Certificate(X509Certificate cer) {
-<a name="709" href="#709">709</a>         <strong class="jxr_keyword">this</strong>.useThisCert = cer;
-<a name="710" href="#710">710</a>     }
-<a name="711" href="#711">711</a>     
-<a name="712" href="#712">712</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="713" href="#713">713</a> <em class="jxr_javadoccomment">     * Returns the BST Token element.</em>
-<a name="714" href="#714">714</a> <em class="jxr_javadoccomment">     * The method can be called any time after &lt;code&gt;prepare()&lt;/code&gt;.</em>
-<a name="715" href="#715">715</a> <em class="jxr_javadoccomment">     * @return the BST Token element</em>
-<a name="716" href="#716">716</a> <em class="jxr_javadoccomment">     */</em>
-<a name="717" href="#717">717</a>     <strong class="jxr_keyword">public</strong> Element getBinarySecurityTokenElement() {
-<a name="718" href="#718">718</a>         <strong class="jxr_keyword">if</strong> (bstToken != <strong class="jxr_keyword">null</strong>) {
-<a name="719" href="#719">719</a>             <strong class="jxr_keyword">return</strong> bstToken.getElement();
-<a name="720" href="#720">720</a>         }
-<a name="721" href="#721">721</a>         <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
-<a name="722" href="#722">722</a>     }
-<a name="723" href="#723">723</a>     
-<a name="724" href="#724">724</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="725" href="#725">725</a> <em class="jxr_javadoccomment">     * @return the URI associated with the SecurityTokenReference</em>
-<a name="726" href="#726">726</a> <em class="jxr_javadoccomment">     * (must be called after {@link #prepare(Document, Crypto, WSSecHeader)}</em>
-<a name="727" href="#727">727</a> <em class="jxr_javadoccomment">     */</em>
-<a name="728" href="#728">728</a>     <strong class="jxr_keyword">public</strong> String getSecurityTokenReferenceURI() {
-<a name="729" href="#729">729</a>         <strong class="jxr_keyword">return</strong> strUri;
-<a name="730" href="#730">730</a>     }
-<a name="731" href="#731">731</a>     
-<a name="732" href="#732">732</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="733" href="#733">733</a> <em class="jxr_javadoccomment">     * Get the SecurityTokenReference to be used in the KeyInfo element.</em>
-<a name="734" href="#734">734</a> <em class="jxr_javadoccomment">     */</em>
-<a name="735" href="#735">735</a>     <strong class="jxr_keyword">public</strong> <a href="../../../../../org/apache/ws/security/message/token/SecurityTokenReference.html">SecurityTokenReference</a> getSecurityTokenReference() {
-<a name="736" href="#736">736</a>         <strong class="jxr_keyword">return</strong> secRef;
-<a name="737" href="#737">737</a>     }
-<a name="738" href="#738">738</a>     
-<a name="739" href="#739">739</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="740" href="#740">740</a> <em class="jxr_javadoccomment">     * Set the SecurityTokenReference to be used in the KeyInfo element. If this</em>
-<a name="741" href="#741">741</a> <em class="jxr_javadoccomment">     * method is not called, a SecurityTokenRefence will be generated.</em>
-<a name="742" href="#742">742</a> <em class="jxr_javadoccomment">     */</em>
-<a name="743" href="#743">743</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> setSecurityTokenReference(<a href="../../../../../org/apache/ws/security/message/token/SecurityTokenReference.html">SecurityTokenReference</a> secRef) {
-<a name="744" href="#744">744</a>         useCustomSecRef = <strong class="jxr_keyword">true</strong>;
-<a name="745" href="#745">745</a>         <strong class="jxr_keyword">this</strong>.secRef = secRef;
-<a name="746" href="#746">746</a>     }
-<a name="747" href="#747">747</a> 
-<a name="748" href="#748">748</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="749" href="#749">749</a> <em class="jxr_javadoccomment">     * Set up the X509 Certificate(s) for signing.</em>
-<a name="750" href="#750">750</a> <em class="jxr_javadoccomment">     */</em>
-<a name="751" href="#751">751</a>     <strong class="jxr_keyword">private</strong> X509Certificate[] getSigningCerts() <strong class="jxr_keyword">throws</strong> WSSecurityException {
-<a name="752" href="#752">752</a>         X509Certificate[] certs = <strong class="jxr_keyword">null</strong>;
-<a name="753" href="#753">753</a>         <strong class="jxr_keyword">if</strong> (!(keyIdentifierType == WSConstants.CUSTOM_SYMM_SIGNING
-<a name="754" href="#754">754</a>             || keyIdentifierType == WSConstants.CUSTOM_SYMM_SIGNING_DIRECT
-<a name="755" href="#755">755</a>             || keyIdentifierType == WSConstants.ENCRYPTED_KEY_SHA1_IDENTIFIER
-<a name="756" href="#756">756</a>             || keyIdentifierType == WSConstants.CUSTOM_KEY_IDENTIFIER)) {
-<a name="757" href="#757">757</a>             <strong class="jxr_keyword">if</strong> (useThisCert == <strong class="jxr_keyword">null</strong>) {
-<a name="758" href="#758">758</a>                 <a href="../../../../../org/apache/ws/security/components/crypto/CryptoType.html">CryptoType</a> cryptoType = <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/components/crypto/CryptoType.html">CryptoType</a>(CryptoType.TYPE.ALIAS);
-<a name="759" href="#759">759</a>                 cryptoType.setAlias(user);
-<a name="760" href="#760">760</a>                 certs = crypto.getX509Certificates(cryptoType);
-<a name="761" href="#761">761</a>             } <strong class="jxr_keyword">else</strong> {
-<a name="762" href="#762">762</a>                 certs = <strong class="jxr_keyword">new</strong> X509Certificate[] {useThisCert};
-<a name="763" href="#763">763</a>             }
-<a name="764" href="#764">764</a>             <strong class="jxr_keyword">if</strong> (certs == <strong class="jxr_keyword">null</strong> || certs.length &lt;= 0) {
-<a name="765" href="#765">765</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="766" href="#766">766</a>                         WSSecurityException.FAILURE,
-<a name="767" href="#767">767</a>                         <span class="jxr_string">"noUserCertsFound"</span>, 
-<a name="768" href="#768">768</a>                         <strong class="jxr_keyword">new</strong> Object[] { user, <span class="jxr_string">"signature"</span> }
-<a name="769" href="#769">769</a>                 );
-<a name="770" href="#770">770</a>             }
-<a name="771" href="#771">771</a>             certUri = getWsConfig().getIdAllocator().createSecureId(<span class="jxr_string">"X509-"</span>, certs[0]);  
-<a name="772" href="#772">772</a>             <em class="jxr_comment">//</em>
-<a name="773" href="#773">773</a>             <em class="jxr_comment">// If no signature algorithm was set try to detect it according to the</em>
-<a name="774" href="#774">774</a>             <em class="jxr_comment">// data stored in the certificate.</em>
-<a name="775" href="#775">775</a>             <em class="jxr_comment">//</em>
-<a name="776" href="#776">776</a>             <strong class="jxr_keyword">if</strong> (sigAlgo == <strong class="jxr_keyword">null</strong>) {
-<a name="777" href="#777">777</a>                 String pubKeyAlgo = certs[0].getPublicKey().getAlgorithm();
-<a name="778" href="#778">778</a>                 log.debug(<span class="jxr_string">"Automatic signature algorithm detection: "</span> + pubKeyAlgo);
-<a name="779" href="#779">779</a>                 <strong class="jxr_keyword">if</strong> (pubKeyAlgo.equalsIgnoreCase(<span class="jxr_string">"DSA"</span>)) {
-<a name="780" href="#780">780</a>                     sigAlgo = WSConstants.DSA;
-<a name="781" href="#781">781</a>                 } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (pubKeyAlgo.equalsIgnoreCase(<span class="jxr_string">"RSA"</span>)) {
-<a name="782" href="#782">782</a>                     sigAlgo = WSConstants.RSA;
-<a name="783" href="#783">783</a>                 } <strong class="jxr_keyword">else</strong> {
-<a name="784" href="#784">784</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="785" href="#785">785</a>                         WSSecurityException.FAILURE,
-<a name="786" href="#786">786</a>                         <span class="jxr_string">"unknownSignatureAlgorithm"</span>,
-<a name="787" href="#787">787</a>                         <strong class="jxr_keyword">new</strong> Object[] {pubKeyAlgo}
-<a name="788" href="#788">788</a>                     );
-<a name="789" href="#789">789</a>                 }
-<a name="790" href="#790">790</a>             }
-<a name="791" href="#791">791</a>         }
-<a name="792" href="#792">792</a>         <strong class="jxr_keyword">return</strong> certs;
-<a name="793" href="#793">793</a>     }
-<a name="794" href="#794">794</a>     
-<a name="795" href="#795">795</a> }
+<a name="323" href="#323">323</a> <em class="jxr_javadoccomment">     * This is a convenience method and for backward compatibility. The method</em>
+<a name="324" href="#324">324</a> <em class="jxr_javadoccomment">     * creates a Signature and puts it into the Security header. It does so by</em>
+<a name="325" href="#325">325</a> <em class="jxr_javadoccomment">     * calling the single functions in order to perform a &lt;i&gt;one shot signature&lt;/i&gt;.</em>
+<a name="326" href="#326">326</a> <em class="jxr_javadoccomment">     * This method is compatible with the build method of the previous version</em>
+<a name="327" href="#327">327</a> <em class="jxr_javadoccomment">     * with the exception of the additional WSSecHeader parameter.</em>
+<a name="328" href="#328">328</a> <em class="jxr_javadoccomment">     * </em>
+<a name="329" href="#329">329</a> <em class="jxr_javadoccomment">     * @param doc The unsigned SOAP envelope as &lt;code&gt;Document&lt;/code&gt;</em>
+<a name="330" href="#330">330</a> <em class="jxr_javadoccomment">     * @param cr An instance of the Crypto API to handle keystore and certificates</em>
+<a name="331" href="#331">331</a> <em class="jxr_javadoccomment">     * @param secHeader the security header element to hold the encrypted key element.</em>
+<a name="332" href="#332">332</a> <em class="jxr_javadoccomment">     * @return A signed SOAP envelope as &lt;code&gt;Document&lt;/code&gt;</em>
+<a name="333" href="#333">333</a> <em class="jxr_javadoccomment">     * @throws WSSecurityException</em>
+<a name="334" href="#334">334</a> <em class="jxr_javadoccomment">     */</em>
+<a name="335" href="#335">335</a>     <strong class="jxr_keyword">public</strong> Document build(Document doc, <a href="../../../../../org/apache/ws/security/components/crypto/Crypto.html">Crypto</a> cr, <a href="../../../../../org/apache/ws/security/message/WSSecHeader.html">WSSecHeader</a> secHeader)
+<a name="336" href="#336">336</a>         <strong class="jxr_keyword">throws</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a> {
+<a name="337" href="#337">337</a>         doDebug = log.isDebugEnabled();
+<a name="338" href="#338">338</a> 
+<a name="339" href="#339">339</a>         <strong class="jxr_keyword">if</strong> (doDebug) {
+<a name="340" href="#340">340</a>             log.debug(<span class="jxr_string">"Beginning signing..."</span>);
+<a name="341" href="#341">341</a>         }
+<a name="342" href="#342">342</a> 
+<a name="343" href="#343">343</a>         prepare(doc, cr, secHeader);
+<a name="344" href="#344">344</a>         <strong class="jxr_keyword">if</strong> (parts == <strong class="jxr_keyword">null</strong>) {
+<a name="345" href="#345">345</a>             parts = <strong class="jxr_keyword">new</strong> ArrayList&lt;WSEncryptionPart&gt;(1);
+<a name="346" href="#346">346</a>             String soapNamespace = WSSecurityUtil.getSOAPNamespace(doc.getDocumentElement());
+<a name="347" href="#347">347</a>             <a href="../../../../../org/apache/ws/security/WSEncryptionPart.html">WSEncryptionPart</a> encP = 
+<a name="348" href="#348">348</a>                 <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSEncryptionPart.html">WSEncryptionPart</a>(
+<a name="349" href="#349">349</a>                     WSConstants.ELEM_BODY, 
+<a name="350" href="#350">350</a>                     soapNamespace, 
+<a name="351" href="#351">351</a>                     <span class="jxr_string">"Content"</span>
+<a name="352" href="#352">352</a>                 );
+<a name="353" href="#353">353</a>             parts.add(encP);
+<a name="354" href="#354">354</a>         } <strong class="jxr_keyword">else</strong> {
+<a name="355" href="#355">355</a>             <strong class="jxr_keyword">for</strong> (WSEncryptionPart part : parts) {
+<a name="356" href="#356">356</a>                 <strong class="jxr_keyword">if</strong> (<span class="jxr_string">"STRTransform"</span>.equals(part.getName()) &amp;&amp; part.getId() == <strong class="jxr_keyword">null</strong>) {
+<a name="357" href="#357">357</a>                     part.setId(strUri);
+<a name="358" href="#358">358</a>                 }
+<a name="359" href="#359">359</a>             }
+<a name="360" href="#360">360</a>         }
+<a name="361" href="#361">361</a> 
+<a name="362" href="#362">362</a>         List&lt;javax.xml.crypto.dsig.Reference&gt; referenceList = 
+<a name="363" href="#363">363</a>             addReferencesToSign(parts, secHeader);
+<a name="364" href="#364">364</a> 
+<a name="365" href="#365">365</a>         computeSignature(referenceList);
+<a name="366" href="#366">366</a>         
+<a name="367" href="#367">367</a>         <em class="jxr_comment">//</em>
+<a name="368" href="#368">368</a>         <em class="jxr_comment">// if we have a BST prepend it in front of the Signature according to</em>
+<a name="369" href="#369">369</a>         <em class="jxr_comment">// strict layout rules.</em>
+<a name="370" href="#370">370</a>         <em class="jxr_comment">//</em>
+<a name="371" href="#371">371</a>         <strong class="jxr_keyword">if</strong> (bstToken != <strong class="jxr_keyword">null</strong>) {
+<a name="372" href="#372">372</a>             prependBSTElementToHeader(secHeader);
+<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">return</strong> doc;
+<a name="376" href="#376">376</a>     }
+<a name="377" href="#377">377</a>     
+<a name="378" href="#378">378</a>     
+<a name="379" href="#379">379</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="380" href="#380">380</a> <em class="jxr_javadoccomment">     * This method adds references to the Signature.</em>
+<a name="381" href="#381">381</a> <em class="jxr_javadoccomment">     * </em>
+<a name="382" href="#382">382</a> <em class="jxr_javadoccomment">     * @param references The list of references to sign</em>
+<a name="383" href="#383">383</a> <em class="jxr_javadoccomment">     * @param secHeader The Security Header</em>
+<a name="384" href="#384">384</a> <em class="jxr_javadoccomment">     * @throws WSSecurityException</em>
+<a name="385" href="#385">385</a> <em class="jxr_javadoccomment">     */</em>
+<a name="386" href="#386">386</a>     <strong class="jxr_keyword">public</strong> List&lt;javax.xml.crypto.dsig.Reference&gt; addReferencesToSign(
+<a name="387" href="#387">387</a>         List&lt;WSEncryptionPart&gt; references, 
+<a name="388" href="#388">388</a>         <a href="../../../../../org/apache/ws/security/message/WSSecHeader.html">WSSecHeader</a> secHeader
+<a name="389" href="#389">389</a>     ) <strong class="jxr_keyword">throws</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a> {
+<a name="390" href="#390">390</a>         <strong class="jxr_keyword">return</strong> 
+<a name="391" href="#391">391</a>             addReferencesToSign(
+<a name="392" href="#392">392</a>                 document, 
+<a name="393" href="#393">393</a>                 references,
+<a name="394" href="#394">394</a>                 wsDocInfo,
+<a name="395" href="#395">395</a>                 signatureFactory, 
+<a name="396" href="#396">396</a>                 secHeader, 
+<a name="397" href="#397">397</a>                 getWsConfig(), 
+<a name="398" href="#398">398</a>                 digestAlgo
+<a name="399" href="#399">399</a>             );
+<a name="400" href="#400">400</a>     }
+<a name="401" href="#401">401</a> 
+<a name="402" href="#402">402</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="403" href="#403">403</a> <em class="jxr_javadoccomment">     * Returns the SignatureElement.</em>
+<a name="404" href="#404">404</a> <em class="jxr_javadoccomment">     * The method can be called any time after &lt;code&gt;prepare()&lt;/code&gt;.</em>
+<a name="405" href="#405">405</a> <em class="jxr_javadoccomment">     * @return The DOM Element of the signature.</em>
+<a name="406" href="#406">406</a> <em class="jxr_javadoccomment">     */</em>
+<a name="407" href="#407">407</a>     <strong class="jxr_keyword">public</strong> Element getSignatureElement() {
+<a name="408" href="#408">408</a>         <strong class="jxr_keyword">return</strong>
+<a name="409" href="#409">409</a>             WSSecurityUtil.getDirectChildElement(
+<a name="410" href="#410">410</a>                 securityHeader,
+<a name="411" href="#411">411</a>                 WSConstants.SIG_LN,
+<a name="412" href="#412">412</a>                 WSConstants.SIG_NS
+<a name="413" href="#413">413</a>             );
+<a name="414" href="#414">414</a>     }
+<a name="415" href="#415">415</a>     
+<a name="416" href="#416">416</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="417" href="#417">417</a> <em class="jxr_javadoccomment">     * Prepend the BinarySecurityToken to the elements already in the Security</em>
+<a name="418" href="#418">418</a> <em class="jxr_javadoccomment">     * header.</em>
+<a name="419" href="#419">419</a> <em class="jxr_javadoccomment">     * </em>
+<a name="420" href="#420">420</a> <em class="jxr_javadoccomment">     * The method can be called any time after &lt;code&gt;prepare()&lt;/code&gt;.</em>
+<a name="421" href="#421">421</a> <em class="jxr_javadoccomment">     * This allows to insert the BST element at any position in the Security</em>
+<a name="422" href="#422">422</a> <em class="jxr_javadoccomment">     * header.</em>
+<a name="423" href="#423">423</a> <em class="jxr_javadoccomment">     * </em>
+<a name="424" href="#424">424</a> <em class="jxr_javadoccomment">     * @param secHeader The security header</em>
+<a name="425" href="#425">425</a> <em class="jxr_javadoccomment">     */</em>
+<a name="426" href="#426">426</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> prependBSTElementToHeader(<a href="../../../../../org/apache/ws/security/message/WSSecHeader.html">WSSecHeader</a> secHeader) {
+<a name="427" href="#427">427</a>         <strong class="jxr_keyword">if</strong> (bstToken != <strong class="jxr_keyword">null</strong>) {
+<a name="428" href="#428">428</a>             WSSecurityUtil.prependChildElement(secHeader.getSecurityHeader(), bstToken.getElement());
+<a name="429" href="#429">429</a>         }
+<a name="430" href="#430">430</a>         bstToken = <strong class="jxr_keyword">null</strong>;
+<a name="431" href="#431">431</a>     }
+<a name="432" href="#432">432</a> 
+<a name="433" href="#433">433</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="434" href="#434">434</a> <em class="jxr_javadoccomment">     * Append the BinarySecurityToken to the security header. </em>
+<a name="435" href="#435">435</a> <em class="jxr_javadoccomment">     * @param secHeader The security header</em>
+<a name="436" href="#436">436</a> <em class="jxr_javadoccomment">     */</em>
+<a name="437" href="#437">437</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> appendBSTElementToHeader(<a href="../../../../../org/apache/ws/security/message/WSSecHeader.html">WSSecHeader</a> secHeader) {
+<a name="438" href="#438">438</a>         <strong class="jxr_keyword">if</strong> (bstToken != <strong class="jxr_keyword">null</strong>) {
+<a name="439" href="#439">439</a>             Element secHeaderElement = secHeader.getSecurityHeader();
+<a name="440" href="#440">440</a>             secHeaderElement.appendChild(bstToken.getElement());
+<a name="441" href="#441">441</a>         }
+<a name="442" href="#442">442</a>         bstToken = <strong class="jxr_keyword">null</strong>;
+<a name="443" href="#443">443</a>     }
+<a name="444" href="#444">444</a>     
+<a name="445" href="#445">445</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="446" href="#446">446</a> <em class="jxr_javadoccomment">     * Compute the Signature over the references. The signature element will be </em>
+<a name="447" href="#447">447</a> <em class="jxr_javadoccomment">     * prepended to the security header.</em>
+<a name="448" href="#448">448</a> <em class="jxr_javadoccomment">     * </em>
+<a name="449" href="#449">449</a> <em class="jxr_javadoccomment">     * This method can be called any time after the references were set. See</em>
+<a name="450" href="#450">450</a> <em class="jxr_javadoccomment">     * &lt;code&gt;addReferencesToSign()&lt;/code&gt;.</em>
+<a name="451" href="#451">451</a> <em class="jxr_javadoccomment">     * </em>
+<a name="452" href="#452">452</a> <em class="jxr_javadoccomment">     * @param referenceList The list of references to sign</em>
+<a name="453" href="#453">453</a> <em class="jxr_javadoccomment">     * </em>
+<a name="454" href="#454">454</a> <em class="jxr_javadoccomment">     * @throws WSSecurityException</em>
+<a name="455" href="#455">455</a> <em class="jxr_javadoccomment">     */</em>
+<a name="456" href="#456">456</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> computeSignature(
+<a name="457" href="#457">457</a>         List&lt;javax.xml.crypto.dsig.Reference&gt; referenceList 
+<a name="458" href="#458">458</a>     ) <strong class="jxr_keyword">throws</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a> {
+<a name="459" href="#459">459</a>         computeSignature(referenceList, <strong class="jxr_keyword">true</strong>, <strong class="jxr_keyword">null</strong>);
+<a name="460" href="#460">460</a>     }
+<a name="461" href="#461">461</a>     
+<a name="462" href="#462">462</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="463" href="#463">463</a> <em class="jxr_javadoccomment">     * Compute the Signature over the references.</em>
+<a name="464" href="#464">464</a> <em class="jxr_javadoccomment">     * </em>
+<a name="465" href="#465">465</a> <em class="jxr_javadoccomment">     * This method can be called any time after the references were set. See</em>
+<a name="466" href="#466">466</a> <em class="jxr_javadoccomment">     * &lt;code&gt;addReferencesToSign()&lt;/code&gt;.</em>
+<a name="467" href="#467">467</a> <em class="jxr_javadoccomment">     * </em>
+<a name="468" href="#468">468</a> <em class="jxr_javadoccomment">     * @param referenceList The list of references to sign</em>
+<a name="469" href="#469">469</a> <em class="jxr_javadoccomment">     * @param prepend Whether to prepend the signature element to the security header</em>
+<a name="470" href="#470">470</a> <em class="jxr_javadoccomment">     * @param siblingElement If prepending, then prepend before this sibling Element</em>
+<a name="471" href="#471">471</a> <em class="jxr_javadoccomment">     * </em>
+<a name="472" href="#472">472</a> <em class="jxr_javadoccomment">     * @throws WSSecurityException</em>
+<a name="473" href="#473">473</a> <em class="jxr_javadoccomment">     */</em>
+<a name="474" href="#474">474</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> computeSignature(
+<a name="475" href="#475">475</a>         List&lt;javax.xml.crypto.dsig.Reference&gt; referenceList, 
+<a name="476" href="#476">476</a>         <strong class="jxr_keyword">boolean</strong> prepend,
+<a name="477" href="#477">477</a>         Element siblingElement
+<a name="478" href="#478">478</a>     ) <strong class="jxr_keyword">throws</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a> {
+<a name="479" href="#479">479</a>         <strong class="jxr_keyword">try</strong> {
+<a name="480" href="#480">480</a>             java.security.Key key;
+<a name="481" href="#481">481</a>             <strong class="jxr_keyword">if</strong> (secretKey == <strong class="jxr_keyword">null</strong>) {
+<a name="482" href="#482">482</a>                 key = crypto.getPrivateKey(user, password);
+<a name="483" href="#483">483</a>             } <strong class="jxr_keyword">else</strong> {
+<a name="484" href="#484">484</a>                 key = WSSecurityUtil.prepareSecretKey(sigAlgo, secretKey);
+<a name="485" href="#485">485</a>             }
+<a name="486" href="#486">486</a>             SignatureMethod signatureMethod = 
+<a name="487" href="#487">487</a>                 signatureFactory.newSignatureMethod(sigAlgo, <strong class="jxr_keyword">null</strong>);
+<a name="488" href="#488">488</a>             SignedInfo signedInfo = 
+<a name="489" href="#489">489</a>                 signatureFactory.newSignedInfo(c14nMethod, signatureMethod, referenceList);
+<a name="490" href="#490">490</a>             
+<a name="491" href="#491">491</a>             sig = signatureFactory.newXMLSignature(
+<a name="492" href="#492">492</a>                     signedInfo, 
+<a name="493" href="#493">493</a>                     keyInfo,
+<a name="494" href="#494">494</a>                     <strong class="jxr_keyword">null</strong>,
+<a name="495" href="#495">495</a>                     getWsConfig().getIdAllocator().createId(<span class="jxr_string">"SIG-"</span>, <strong class="jxr_keyword">null</strong>),
+<a name="496" href="#496">496</a>                     <strong class="jxr_keyword">null</strong>);
+<a name="497" href="#497">497</a>             
+<a name="498" href="#498">498</a>             <em class="jxr_comment">//</em>
+<a name="499" href="#499">499</a>             <em class="jxr_comment">// Figure out where to insert the signature element</em>
+<a name="500" href="#500">500</a>             <em class="jxr_comment">//</em>
+<a name="501" href="#501">501</a>             XMLSignContext signContext = <strong class="jxr_keyword">null</strong>;
+<a name="502" href="#502">502</a>             <strong class="jxr_keyword">if</strong> (prepend) {
+<a name="503" href="#503">503</a>                 <strong class="jxr_keyword">if</strong> (siblingElement == <strong class="jxr_keyword">null</strong>) {
+<a name="504" href="#504">504</a>                     Node child = securityHeader.getFirstChild();
+<a name="505" href="#505">505</a>                     <strong class="jxr_keyword">while</strong> (child != <strong class="jxr_keyword">null</strong> &amp;&amp; child.getNodeType() != Node.ELEMENT_NODE) {
+<a name="506" href="#506">506</a>                         child = child.getNextSibling();
+<a name="507" href="#507">507</a>                     } 
+<a name="508" href="#508">508</a>                     siblingElement = (Element)child;
+<a name="509" href="#509">509</a>                 }
+<a name="510" href="#510">510</a>                 <strong class="jxr_keyword">if</strong> (siblingElement == <strong class="jxr_keyword">null</strong>) {
+<a name="511" href="#511">511</a>                     signContext = <strong class="jxr_keyword">new</strong> DOMSignContext(key, securityHeader);
+<a name="512" href="#512">512</a>                 } <strong class="jxr_keyword">else</strong> {
+<a name="513" href="#513">513</a>                     signContext = <strong class="jxr_keyword">new</strong> DOMSignContext(key, securityHeader, siblingElement);
+<a name="514" href="#514">514</a>                 }
+<a name="515" href="#515">515</a>             } <strong class="jxr_keyword">else</strong> {
+<a name="516" href="#516">516</a>                 signContext = <strong class="jxr_keyword">new</strong> DOMSignContext(key, securityHeader);
+<a name="517" href="#517">517</a>             }
+<a name="518" href="#518">518</a>             
+<a name="519" href="#519">519</a>             signContext.putNamespacePrefix(WSConstants.SIG_NS, WSConstants.SIG_PREFIX);
+<a name="520" href="#520">520</a>             <strong class="jxr_keyword">if</strong> (WSConstants.C14N_EXCL_OMIT_COMMENTS.equals(canonAlgo)) {
+<a name="521" href="#521">521</a>                 signContext.putNamespacePrefix(
+<a name="522" href="#522">522</a>                     WSConstants.C14N_EXCL_OMIT_COMMENTS, 
+<a name="523" href="#523">523</a>                     WSConstants.C14N_EXCL_OMIT_COMMENTS_PREFIX
+<a name="524" href="#524">524</a>                 );
+<a name="525" href="#525">525</a>             }
+<a name="526" href="#526">526</a>             signContext.setProperty(STRTransform.TRANSFORM_WS_DOC_INFO, wsDocInfo);
+<a name="527" href="#527">527</a>             wsDocInfo.setCallbackLookup(callbackLookup);
+<a name="528" href="#528">528</a>             
+<a name="529" href="#529">529</a>             <em class="jxr_comment">// Add the elements to sign to the Signature Context</em>
+<a name="530" href="#530">530</a>             wsDocInfo.setTokensOnContext((DOMSignContext)signContext);
+<a name="531" href="#531">531</a>             <strong class="jxr_keyword">if</strong> (secRef != <strong class="jxr_keyword">null</strong> &amp;&amp; secRef.getElement() != <strong class="jxr_keyword">null</strong>) {
+<a name="532" href="#532">532</a>                 WSSecurityUtil.storeElementInContext((DOMSignContext)signContext, secRef.getElement());
+<a name="533" href="#533">533</a>             }
+<a name="534" href="#534">534</a>             sig.sign(signContext);
+<a name="535" href="#535">535</a>             
+<a name="536" href="#536">536</a>             signatureValue = sig.getSignatureValue().getValue();
+<a name="537" href="#537">537</a>         } <strong class="jxr_keyword">catch</strong> (Exception ex) {
+<a name="538" href="#538">538</a>             log.error(ex);
+<a name="539" href="#539">539</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="540" href="#540">540</a>                 WSSecurityException.FAILED_SIGNATURE, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">null</strong>, ex
+<a name="541" href="#541">541</a>             );
+<a name="542" href="#542">542</a>         }
+<a name="543" href="#543">543</a>     }
+<a name="544" href="#544">544</a>     
+<a name="545" href="#545">545</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="546" href="#546">546</a> <em class="jxr_javadoccomment">     * Set the single cert flag.</em>
+<a name="547" href="#547">547</a> <em class="jxr_javadoccomment">     * </em>
+<a name="548" href="#548">548</a> <em class="jxr_javadoccomment">     * @param useSingleCert</em>
+<a name="549" href="#549">549</a> <em class="jxr_javadoccomment">     */</em>
+<a name="550" href="#550">550</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> setUseSingleCertificate(<strong class="jxr_keyword">boolean</strong> useSingleCert) {
+<a name="551" href="#551">551</a>         <strong class="jxr_keyword">this</strong>.useSingleCert = useSingleCert;
+<a name="552" href="#552">552</a>     }
+<a name="553" href="#553">553</a> 
+<a name="554" href="#554">554</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="555" href="#555">555</a> <em class="jxr_javadoccomment">     * Get the single cert flag.</em>
+<a name="556" href="#556">556</a> <em class="jxr_javadoccomment">     * </em>
+<a name="557" href="#557">557</a> <em class="jxr_javadoccomment">     * @return A boolean if single certificate is set.</em>
+<a name="558" href="#558">558</a> <em class="jxr_javadoccomment">     */</em>
+<a name="559" href="#559">559</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">boolean</strong> isUseSingleCertificate() {
+<a name="560" href="#560">560</a>         <strong class="jxr_keyword">return</strong> useSingleCert;
+<a name="561" href="#561">561</a>     }
+<a name="562" href="#562">562</a> 
+<a name="563" href="#563">563</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="564" href="#564">564</a> <em class="jxr_javadoccomment">     * Set the name (uri) of the signature encryption algorithm to use.</em>
+<a name="565" href="#565">565</a> <em class="jxr_javadoccomment">     * </em>
+<a name="566" href="#566">566</a> <em class="jxr_javadoccomment">     * If the algorithm is not set then an automatic detection of the signature</em>
+<a name="567" href="#567">567</a> <em class="jxr_javadoccomment">     * algorithm to use is performed during the &lt;code&gt;prepare()&lt;/code&gt;</em>
+<a name="568" href="#568">568</a> <em class="jxr_javadoccomment">     * method. Refer to WSConstants which algorithms are supported.</em>
+<a name="569" href="#569">569</a> <em class="jxr_javadoccomment">     * </em>
+<a name="570" href="#570">570</a> <em class="jxr_javadoccomment">     * @param algo the name of the signature algorithm</em>
+<a name="571" href="#571">571</a> <em class="jxr_javadoccomment">     * @see WSConstants#RSA</em>
+<a name="572" href="#572">572</a> <em class="jxr_javadoccomment">     * @see WSConstants#DSA</em>
+<a name="573" href="#573">573</a> <em class="jxr_javadoccomment">     */</em>
+<a name="574" href="#574">574</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> setSignatureAlgorithm(String algo) {
+<a name="575" href="#575">575</a>         sigAlgo = algo;
+<a name="576" href="#576">576</a>     }
+<a name="577" href="#577">577</a> 
+<a name="578" href="#578">578</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="579" href="#579">579</a> <em class="jxr_javadoccomment">     * Get the name (uri) of the signature algorithm that is being used.</em>
+<a name="580" href="#580">580</a> <em class="jxr_javadoccomment">     * </em>
+<a name="581" href="#581">581</a> <em class="jxr_javadoccomment">     * Call this method after &lt;code&gt;prepare&lt;/code&gt; to get the information</em>
+<a name="582" href="#582">582</a> <em class="jxr_javadoccomment">     * which signature algorithm was automatically detected if no signature</em>
+<a name="583" href="#583">583</a> <em class="jxr_javadoccomment">     * algorithm was preset.</em>
+<a name="584" href="#584">584</a> <em class="jxr_javadoccomment">     * </em>
+<a name="585" href="#585">585</a> <em class="jxr_javadoccomment">     * @return the identifier URI of the signature algorithm</em>
+<a name="586" href="#586">586</a> <em class="jxr_javadoccomment">     */</em>
+<a name="587" href="#587">587</a>     <strong class="jxr_keyword">public</strong> String getSignatureAlgorithm() {
+<a name="588" href="#588">588</a>         <strong class="jxr_keyword">return</strong> sigAlgo;
+<a name="589" href="#589">589</a>     }
+<a name="590" href="#590">590</a> 
+<a name="591" href="#591">591</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="592" href="#592">592</a> <em class="jxr_javadoccomment">     * Set the canonicalization method to use.</em>
+<a name="593" href="#593">593</a> <em class="jxr_javadoccomment">     * </em>
+<a name="594" href="#594">594</a> <em class="jxr_javadoccomment">     * If the canonicalization method is not set then the recommended Exclusive</em>
+<a name="595" href="#595">595</a> <em class="jxr_javadoccomment">     * XML Canonicalization is used by default. Refer to WSConstants which</em>
+<a name="596" href="#596">596</a> <em class="jxr_javadoccomment">     * algorithms are supported.</em>
+<a name="597" href="#597">597</a> <em class="jxr_javadoccomment">     * </em>
+<a name="598" href="#598">598</a> <em class="jxr_javadoccomment">     * @param algo Is the name of the signature algorithm</em>
+<a name="599" href="#599">599</a> <em class="jxr_javadoccomment">     * @see WSConstants#C14N_OMIT_COMMENTS</em>
+<a name="600" href="#600">600</a> <em class="jxr_javadoccomment">     * @see WSConstants#C14N_WITH_COMMENTS</em>
+<a name="601" href="#601">601</a> <em class="jxr_javadoccomment">     * @see WSConstants#C14N_EXCL_OMIT_COMMENTS</em>
+<a name="602" href="#602">602</a> <em class="jxr_javadoccomment">     * @see WSConstants#C14N_EXCL_WITH_COMMENTS</em>
+<a name="603" href="#603">603</a> <em class="jxr_javadoccomment">     */</em>
+<a name="604" href="#604">604</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> setSigCanonicalization(String algo) {
+<a name="605" href="#605">605</a>         canonAlgo = algo;
+<a name="606" href="#606">606</a>     }
+<a name="607" href="#607">607</a> 
+<a name="608" href="#608">608</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="609" href="#609">609</a> <em class="jxr_javadoccomment">     * Get the canonicalization method.</em>
+<a name="610" href="#610">610</a> <em class="jxr_javadoccomment">     * </em>
+<a name="611" href="#611">611</a> <em class="jxr_javadoccomment">     * If the canonicalization method was not set then Exclusive XML</em>
+<a name="612" href="#612">612</a> <em class="jxr_javadoccomment">     * Canonicalization is used by default.</em>
+<a name="613" href="#613">613</a> <em class="jxr_javadoccomment">     * </em>
+<a name="614" href="#614">614</a> <em class="jxr_javadoccomment">     * @return The string describing the canonicalization algorithm.</em>
+<a name="615" href="#615">615</a> <em class="jxr_javadoccomment">     */</em>
+<a name="616" href="#616">616</a>     <strong class="jxr_keyword">public</strong> String getSigCanonicalization() {
+<a name="617" href="#617">617</a>         <strong class="jxr_keyword">return</strong> canonAlgo;
+<a name="618" href="#618">618</a>     }
+<a name="619" href="#619">619</a> 
+<a name="620" href="#620">620</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="621" href="#621">621</a> <em class="jxr_javadoccomment">     * @return the digest algorithm to use</em>
+<a name="622" href="#622">622</a> <em class="jxr_javadoccomment">     */</em>
+<a name="623" href="#623">623</a>     <strong class="jxr_keyword">public</strong> String getDigestAlgo() {
+<a name="624" href="#624">624</a>         <strong class="jxr_keyword">return</strong> digestAlgo;
+<a name="625" href="#625">625</a>     }
+<a name="626" href="#626">626</a> 
+<a name="627" href="#627">627</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="628" href="#628">628</a> <em class="jxr_javadoccomment">     * Set the string that defines which digest algorithm to use. </em>
+<a name="629" href="#629">629</a> <em class="jxr_javadoccomment">     * The default is Constants.ALGO_ID_DIGEST_SHA1.</em>
+<a name="630" href="#630">630</a> <em class="jxr_javadoccomment">     * </em>
+<a name="631" href="#631">631</a> <em class="jxr_javadoccomment">     * @param digestAlgo the digestAlgo to set</em>
+<a name="632" href="#632">632</a> <em class="jxr_javadoccomment">     */</em>
+<a name="633" href="#633">633</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> setDigestAlgo(String digestAlgo) {
+<a name="634" href="#634">634</a>         <strong class="jxr_keyword">this</strong>.digestAlgo = digestAlgo;
+<a name="635" href="#635">635</a>     }
+<a name="636" href="#636">636</a>     
+<a name="637" href="#637">637</a>     
+<a name="638" href="#638">638</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="639" href="#639">639</a> <em class="jxr_javadoccomment">     * Returns the computed Signature value.</em>
+<a name="640" href="#640">640</a> <em class="jxr_javadoccomment">     * </em>

[... 165 lines stripped ...]