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 2013/11/18 12:34:10 UTC

svn commit: r1542988 [20/25] - in /webservices/website/wss4j: ./ 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/cache/ apidocs/org/apache/w...

Modified: webservices/website/wss4j/xref/org/apache/ws/security/message/WSSecSignature.html
URL: http://svn.apache.org/viewvc/webservices/website/wss4j/xref/org/apache/ws/security/message/WSSecSignature.html?rev=1542988&r1=1542987&r2=1542988&view=diff
==============================================================================
--- webservices/website/wss4j/xref/org/apache/ws/security/message/WSSecSignature.html (original)
+++ webservices/website/wss4j/xref/org/apache/ws/security/message/WSSecSignature.html Mon Nov 18 11:33:41 2013
@@ -219,619 +219,621 @@
 <a name="209" href="#209">209</a>                     bstToken = <strong class="jxr_keyword">new</strong> X509Security(document);
 <a name="210" href="#210">210</a>                     ((X509Security) bstToken).setX509Certificate(certs[0]);
 <a name="211" href="#211">211</a>                 }
-<a name="212" href="#212">212</a>                 ref.setValueType(bstToken.getValueType());
-<a name="213" href="#213">213</a>                 secRef.setReference(ref);
-<a name="214" href="#214">214</a>                 bstToken.setID(certUri);
-<a name="215" href="#215">215</a>                 wsDocInfo.addTokenElement(bstToken.getElement(), false);
-<a name="216" href="#216">216</a>                 <strong class="jxr_keyword">break</strong>;
-<a name="217" href="#217">217</a>     
-<a name="218" href="#218">218</a>             <strong class="jxr_keyword">case</strong> WSConstants.ISSUER_SERIAL:
-<a name="219" href="#219">219</a>                 String issuer = certs[0].getIssuerX500Principal().getName();
-<a name="220" href="#220">220</a>                 java.math.BigInteger serialNumber = certs[0].getSerialNumber();
-<a name="221" href="#221">221</a>                 DOMX509IssuerSerial domIssuerSerial = 
-<a name="222" href="#222">222</a>                     <strong class="jxr_keyword">new</strong> DOMX509IssuerSerial(doc, issuer, serialNumber);
-<a name="223" href="#223">223</a>                 DOMX509Data domX509Data = <strong class="jxr_keyword">new</strong> DOMX509Data(doc, domIssuerSerial);
-<a name="224" href="#224">224</a>                 secRef.setX509Data(domX509Data);
-<a name="225" href="#225">225</a>                 <strong class="jxr_keyword">break</strong>;
-<a name="226" href="#226">226</a>     
-<a name="227" href="#227">227</a>             <strong class="jxr_keyword">case</strong> WSConstants.X509_KEY_IDENTIFIER:
-<a name="228" href="#228">228</a>                 secRef.setKeyIdentifier(certs[0]);
-<a name="229" href="#229">229</a>                 <strong class="jxr_keyword">break</strong>;
-<a name="230" href="#230">230</a>     
-<a name="231" href="#231">231</a>             <strong class="jxr_keyword">case</strong> WSConstants.SKI_KEY_IDENTIFIER:
-<a name="232" href="#232">232</a>                 secRef.setKeyIdentifierSKI(certs[0], crypto);
-<a name="233" href="#233">233</a>                 <strong class="jxr_keyword">break</strong>;
-<a name="234" href="#234">234</a>     
-<a name="235" href="#235">235</a>             <strong class="jxr_keyword">case</strong> WSConstants.THUMBPRINT_IDENTIFIER:
-<a name="236" href="#236">236</a>                 secRef.setKeyIdentifierThumb(certs[0]);
-<a name="237" href="#237">237</a>                 <strong class="jxr_keyword">break</strong>;
-<a name="238" href="#238">238</a>                 
-<a name="239" href="#239">239</a>             <strong class="jxr_keyword">case</strong> WSConstants.ENCRYPTED_KEY_SHA1_IDENTIFIER:
-<a name="240" href="#240">240</a>                 <strong class="jxr_keyword">if</strong> (encrKeySha1value != <strong class="jxr_keyword">null</strong>) {
-<a name="241" href="#241">241</a>                     secRef.setKeyIdentifierEncKeySHA1(encrKeySha1value);
-<a name="242" href="#242">242</a>                 } <strong class="jxr_keyword">else</strong> {
-<a name="243" href="#243">243</a>                     byte[] digestBytes = WSSecurityUtil.generateDigest(secretKey);
-<a name="244" href="#244">244</a>                     secRef.setKeyIdentifierEncKeySHA1(Base64.encode(digestBytes));
-<a name="245" href="#245">245</a>                 }
-<a name="246" href="#246">246</a>                 secRef.addTokenType(WSConstants.WSS_ENC_KEY_VALUE_TYPE);
-<a name="247" href="#247">247</a>                 <strong class="jxr_keyword">break</strong>;
-<a name="248" href="#248">248</a>     
-<a name="249" href="#249">249</a>             <strong class="jxr_keyword">case</strong> WSConstants.CUSTOM_SYMM_SIGNING :
-<a name="250" href="#250">250</a>                 <a href="../../../../../org/apache/ws/security/message/token/Reference.html">Reference</a> refCust = <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/message/token/Reference.html">Reference</a>(document);
-<a name="251" href="#251">251</a>                 <strong class="jxr_keyword">if</strong> (WSConstants.WSS_SAML_KI_VALUE_TYPE.equals(customTokenValueType)) {
-<a name="252" href="#252">252</a>                     secRef.addTokenType(WSConstants.WSS_SAML_TOKEN_TYPE);
-<a name="253" href="#253">253</a>                     refCust.setValueType(customTokenValueType);
-<a name="254" href="#254">254</a>                 } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (WSConstants.WSS_SAML2_KI_VALUE_TYPE.equals(customTokenValueType)) {
-<a name="255" href="#255">255</a>                     secRef.addTokenType(WSConstants.WSS_SAML2_TOKEN_TYPE);
-<a name="256" href="#256">256</a>                 } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (WSConstants.WSS_ENC_KEY_VALUE_TYPE.equals(customTokenValueType)) {
-<a name="257" href="#257">257</a>                     secRef.addTokenType(WSConstants.WSS_ENC_KEY_VALUE_TYPE);
-<a name="258" href="#258">258</a>                     refCust.setValueType(customTokenValueType);
-<a name="259" href="#259">259</a>                 } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (KerberosSecurity.isKerberosToken(customTokenValueType)) {
-<a name="260" href="#260">260</a>                     secRef.addTokenType(customTokenValueType);
-<a name="261" href="#261">261</a>                     refCust.setValueType(customTokenValueType);
-<a name="262" href="#262">262</a>                 } <strong class="jxr_keyword">else</strong> {
-<a name="263" href="#263">263</a>                     refCust.setValueType(customTokenValueType);
-<a name="264" href="#264">264</a>                 }
-<a name="265" href="#265">265</a>                 refCust.setURI(<span class="jxr_string">"#"</span> + customTokenId);
-<a name="266" href="#266">266</a>                 secRef.setReference(refCust);
-<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_SYMM_SIGNING_DIRECT :
-<a name="270" href="#270">270</a>                 <a href="../../../../../org/apache/ws/security/message/token/Reference.html">Reference</a> refCustd = <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/message/token/Reference.html">Reference</a>(document);
-<a name="271" href="#271">271</a>                 <strong class="jxr_keyword">if</strong> (WSConstants.WSS_SAML_KI_VALUE_TYPE.equals(customTokenValueType)) {
-<a name="272" href="#272">272</a>                     secRef.addTokenType(WSConstants.WSS_SAML_TOKEN_TYPE);
-<a name="273" href="#273">273</a>                     refCustd.setValueType(customTokenValueType);
-<a name="274" href="#274">274</a>                 } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (WSConstants.WSS_SAML2_KI_VALUE_TYPE.equals(customTokenValueType)) {
-<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.addTokenType(WSConstants.WSS_ENC_KEY_VALUE_TYPE);
-<a name="278" href="#278">278</a>                     refCustd.setValueType(customTokenValueType);
-<a name="279" href="#279">279</a>                 } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (KerberosSecurity.isKerberosToken(customTokenValueType)) {
-<a name="280" href="#280">280</a>                     secRef.addTokenType(customTokenValueType);
-<a name="281" href="#281">281</a>                     refCustd.setValueType(customTokenValueType);
-<a name="282" href="#282">282</a>                 } <strong class="jxr_keyword">else</strong> {
-<a name="283" href="#283">283</a>                     refCustd.setValueType(customTokenValueType);
-<a name="284" href="#284">284</a>                 }
-<a name="285" href="#285">285</a>                 refCustd.setURI(customTokenId);
-<a name="286" href="#286">286</a>                 secRef.setReference(refCustd);
-<a name="287" href="#287">287</a>                 <strong class="jxr_keyword">break</strong>;
-<a name="288" href="#288">288</a>                 
-<a name="289" href="#289">289</a>             <strong class="jxr_keyword">case</strong> WSConstants.CUSTOM_KEY_IDENTIFIER:
-<a name="290" href="#290">290</a>                 <strong class="jxr_keyword">if</strong> (WSConstants.WSS_SAML_KI_VALUE_TYPE.equals(customTokenValueType)) {
-<a name="291" href="#291">291</a>                     secRef.setKeyIdentifier(customTokenValueType, customTokenId);
-<a name="292" href="#292">292</a>                     secRef.addTokenType(WSConstants.WSS_SAML_TOKEN_TYPE);
-<a name="293" href="#293">293</a>                 } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (WSConstants.WSS_SAML2_KI_VALUE_TYPE.equals(customTokenValueType)) {
-<a name="294" href="#294">294</a>                     secRef.setKeyIdentifier(customTokenValueType, customTokenId);
-<a name="295" href="#295">295</a>                     secRef.addTokenType(WSConstants.WSS_SAML2_TOKEN_TYPE);
-<a name="296" href="#296">296</a>                 } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (WSConstants.WSS_ENC_KEY_VALUE_TYPE.equals(customTokenValueType)) {
-<a name="297" href="#297">297</a>                     secRef.setKeyIdentifier(customTokenValueType, customTokenId, <strong class="jxr_keyword">true</strong>);
-<a name="298" href="#298">298</a>                     secRef.addTokenType(WSConstants.WSS_ENC_KEY_VALUE_TYPE);
-<a name="299" href="#299">299</a>                 } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (SecurityTokenReference.ENC_KEY_SHA1_URI.equals(customTokenValueType)) {
-<a name="300" href="#300">300</a>                     secRef.setKeyIdentifier(customTokenValueType, customTokenId, <strong class="jxr_keyword">true</strong>);
-<a name="301" href="#301">301</a>                     secRef.addTokenType(WSConstants.WSS_ENC_KEY_VALUE_TYPE);
-<a name="302" href="#302">302</a>                 } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (WSConstants.WSS_KRB_KI_VALUE_TYPE.equals(customTokenValueType)) {
-<a name="303" href="#303">303</a>                     secRef.setKeyIdentifier(customTokenValueType, customTokenId, <strong class="jxr_keyword">true</strong>);
-<a name="304" href="#304">304</a>                     secRef.addTokenType(WSConstants.WSS_GSS_KRB_V5_AP_REQ);
-<a name="305" href="#305">305</a>                 } 
-<a name="306" href="#306">306</a>                 <strong class="jxr_keyword">break</strong>;
-<a name="307" href="#307">307</a>                 
-<a name="308" href="#308">308</a>             <strong class="jxr_keyword">case</strong> WSConstants.KEY_VALUE:
-<a name="309" href="#309">309</a>                 java.security.PublicKey publicKey = certs[0].getPublicKey();
-<a name="310" href="#310">310</a>                 
-<a name="311" href="#311">311</a>                 <strong class="jxr_keyword">try</strong> {
-<a name="312" href="#312">312</a>                     KeyValue keyValue = keyInfoFactory.newKeyValue(publicKey);
-<a name="313" href="#313">313</a>                     keyInfo = 
-<a name="314" href="#314">314</a>                         keyInfoFactory.newKeyInfo(
-<a name="315" href="#315">315</a>                             java.util.Collections.singletonList(keyValue), keyInfoUri
-<a name="316" href="#316">316</a>                         );
-<a name="317" href="#317">317</a>                 } <strong class="jxr_keyword">catch</strong> (java.security.KeyException ex) {
-<a name="318" href="#318">318</a>                     log.error(<span class="jxr_string">""</span>, ex);
-<a name="319" href="#319">319</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="320" href="#320">320</a>                         WSSecurityException.FAILED_SIGNATURE, <span class="jxr_string">"noXMLSig"</span>, <strong class="jxr_keyword">null</strong>, ex
-<a name="321" href="#321">321</a>                     );
-<a name="322" href="#322">322</a>                 }
-<a name="323" href="#323">323</a>                 <strong class="jxr_keyword">break</strong>;
-<a name="324" href="#324">324</a>             <strong class="jxr_keyword">default</strong>:
-<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>(WSSecurityException.FAILURE, <span class="jxr_string">"unsupportedKeyId"</span>);
-<a name="326" href="#326">326</a>             }
-<a name="327" href="#327">327</a>         }
-<a name="328" href="#328">328</a>         
-<a name="329" href="#329">329</a>         <strong class="jxr_keyword">if</strong> (keyIdentifierType != WSConstants.KEY_VALUE) {
-<a name="330" href="#330">330</a>             XMLStructure structure = <strong class="jxr_keyword">new</strong> DOMStructure(secRef.getElement());
-<a name="331" href="#331">331</a>             wsDocInfo.addTokenElement(secRef.getElement(), false);
-<a name="332" href="#332">332</a>             keyInfo = 
-<a name="333" href="#333">333</a>                 keyInfoFactory.newKeyInfo(
-<a name="334" href="#334">334</a>                     java.util.Collections.singletonList(structure), keyInfoUri
-<a name="335" href="#335">335</a>                 );
-<a name="336" href="#336">336</a>         }
-<a name="337" href="#337">337</a>     }
-<a name="338" href="#338">338</a>     
+<a name="212" href="#212">212</a>                 bstAddedToSecurityHeader = false;
+<a name="213" href="#213">213</a>                 ref.setValueType(bstToken.getValueType());
+<a name="214" href="#214">214</a>                 secRef.setReference(ref);
+<a name="215" href="#215">215</a>                 bstToken.setID(certUri);
+<a name="216" href="#216">216</a>                 wsDocInfo.addTokenElement(bstToken.getElement(), false);
+<a name="217" href="#217">217</a>                 <strong class="jxr_keyword">break</strong>;
+<a name="218" href="#218">218</a>     
+<a name="219" href="#219">219</a>             <strong class="jxr_keyword">case</strong> WSConstants.ISSUER_SERIAL:
+<a name="220" href="#220">220</a>                 String issuer = certs[0].getIssuerX500Principal().getName();
+<a name="221" href="#221">221</a>                 java.math.BigInteger serialNumber = certs[0].getSerialNumber();
+<a name="222" href="#222">222</a>                 DOMX509IssuerSerial domIssuerSerial = 
+<a name="223" href="#223">223</a>                     <strong class="jxr_keyword">new</strong> DOMX509IssuerSerial(doc, issuer, serialNumber);
+<a name="224" href="#224">224</a>                 DOMX509Data domX509Data = <strong class="jxr_keyword">new</strong> DOMX509Data(doc, domIssuerSerial);
+<a name="225" href="#225">225</a>                 secRef.setX509Data(domX509Data);
+<a name="226" href="#226">226</a>                 <strong class="jxr_keyword">break</strong>;
+<a name="227" href="#227">227</a>     
+<a name="228" href="#228">228</a>             <strong class="jxr_keyword">case</strong> WSConstants.X509_KEY_IDENTIFIER:
+<a name="229" href="#229">229</a>                 secRef.setKeyIdentifier(certs[0]);
+<a name="230" href="#230">230</a>                 <strong class="jxr_keyword">break</strong>;
+<a name="231" href="#231">231</a>     
+<a name="232" href="#232">232</a>             <strong class="jxr_keyword">case</strong> WSConstants.SKI_KEY_IDENTIFIER:
+<a name="233" href="#233">233</a>                 secRef.setKeyIdentifierSKI(certs[0], crypto);
+<a name="234" href="#234">234</a>                 <strong class="jxr_keyword">break</strong>;
+<a name="235" href="#235">235</a>     
+<a name="236" href="#236">236</a>             <strong class="jxr_keyword">case</strong> WSConstants.THUMBPRINT_IDENTIFIER:
+<a name="237" href="#237">237</a>                 secRef.setKeyIdentifierThumb(certs[0]);
+<a name="238" href="#238">238</a>                 <strong class="jxr_keyword">break</strong>;
+<a name="239" href="#239">239</a>                 
+<a name="240" href="#240">240</a>             <strong class="jxr_keyword">case</strong> WSConstants.ENCRYPTED_KEY_SHA1_IDENTIFIER:
+<a name="241" href="#241">241</a>                 <strong class="jxr_keyword">if</strong> (encrKeySha1value != <strong class="jxr_keyword">null</strong>) {
+<a name="242" href="#242">242</a>                     secRef.setKeyIdentifierEncKeySHA1(encrKeySha1value);
+<a name="243" href="#243">243</a>                 } <strong class="jxr_keyword">else</strong> {
+<a name="244" href="#244">244</a>                     byte[] digestBytes = WSSecurityUtil.generateDigest(secretKey);
+<a name="245" href="#245">245</a>                     secRef.setKeyIdentifierEncKeySHA1(Base64.encode(digestBytes));
+<a name="246" href="#246">246</a>                 }
+<a name="247" href="#247">247</a>                 secRef.addTokenType(WSConstants.WSS_ENC_KEY_VALUE_TYPE);
+<a name="248" href="#248">248</a>                 <strong class="jxr_keyword">break</strong>;
+<a name="249" href="#249">249</a>     
+<a name="250" href="#250">250</a>             <strong class="jxr_keyword">case</strong> WSConstants.CUSTOM_SYMM_SIGNING :
+<a name="251" href="#251">251</a>                 <a href="../../../../../org/apache/ws/security/message/token/Reference.html">Reference</a> refCust = <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/message/token/Reference.html">Reference</a>(document);
+<a name="252" href="#252">252</a>                 <strong class="jxr_keyword">if</strong> (WSConstants.WSS_SAML_KI_VALUE_TYPE.equals(customTokenValueType)) {
+<a name="253" href="#253">253</a>                     secRef.addTokenType(WSConstants.WSS_SAML_TOKEN_TYPE);
+<a name="254" href="#254">254</a>                     refCust.setValueType(customTokenValueType);
+<a name="255" href="#255">255</a>                 } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (WSConstants.WSS_SAML2_KI_VALUE_TYPE.equals(customTokenValueType)) {
+<a name="256" href="#256">256</a>                     secRef.addTokenType(WSConstants.WSS_SAML2_TOKEN_TYPE);
+<a name="257" href="#257">257</a>                 } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (WSConstants.WSS_ENC_KEY_VALUE_TYPE.equals(customTokenValueType)) {
+<a name="258" href="#258">258</a>                     secRef.addTokenType(WSConstants.WSS_ENC_KEY_VALUE_TYPE);
+<a name="259" href="#259">259</a>                     refCust.setValueType(customTokenValueType);
+<a name="260" href="#260">260</a>                 } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (KerberosSecurity.isKerberosToken(customTokenValueType)) {
+<a name="261" href="#261">261</a>                     secRef.addTokenType(customTokenValueType);
+<a name="262" href="#262">262</a>                     refCust.setValueType(customTokenValueType);
+<a name="263" href="#263">263</a>                 } <strong class="jxr_keyword">else</strong> {
+<a name="264" href="#264">264</a>                     refCust.setValueType(customTokenValueType);
+<a name="265" href="#265">265</a>                 }
+<a name="266" href="#266">266</a>                 refCust.setURI(<span class="jxr_string">"#"</span> + customTokenId);
+<a name="267" href="#267">267</a>                 secRef.setReference(refCust);
+<a name="268" href="#268">268</a>                 <strong class="jxr_keyword">break</strong>;
+<a name="269" href="#269">269</a>     
+<a name="270" href="#270">270</a>             <strong class="jxr_keyword">case</strong> WSConstants.CUSTOM_SYMM_SIGNING_DIRECT :
+<a name="271" href="#271">271</a>                 <a href="../../../../../org/apache/ws/security/message/token/Reference.html">Reference</a> refCustd = <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/message/token/Reference.html">Reference</a>(document);
+<a name="272" href="#272">272</a>                 <strong class="jxr_keyword">if</strong> (WSConstants.WSS_SAML_KI_VALUE_TYPE.equals(customTokenValueType)) {
+<a name="273" href="#273">273</a>                     secRef.addTokenType(WSConstants.WSS_SAML_TOKEN_TYPE);
+<a name="274" href="#274">274</a>                     refCustd.setValueType(customTokenValueType);
+<a name="275" href="#275">275</a>                 } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (WSConstants.WSS_SAML2_KI_VALUE_TYPE.equals(customTokenValueType)) {
+<a name="276" href="#276">276</a>                     secRef.addTokenType(WSConstants.WSS_SAML2_TOKEN_TYPE);
+<a name="277" href="#277">277</a>                 } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (WSConstants.WSS_ENC_KEY_VALUE_TYPE.equals(customTokenValueType)) {
+<a name="278" href="#278">278</a>                     secRef.addTokenType(WSConstants.WSS_ENC_KEY_VALUE_TYPE);
+<a name="279" href="#279">279</a>                     refCustd.setValueType(customTokenValueType);
+<a name="280" href="#280">280</a>                 } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (KerberosSecurity.isKerberosToken(customTokenValueType)) {
+<a name="281" href="#281">281</a>                     secRef.addTokenType(customTokenValueType);
+<a name="282" href="#282">282</a>                     refCustd.setValueType(customTokenValueType);
+<a name="283" href="#283">283</a>                 } <strong class="jxr_keyword">else</strong> {
+<a name="284" href="#284">284</a>                     refCustd.setValueType(customTokenValueType);
+<a name="285" href="#285">285</a>                 }
+<a name="286" href="#286">286</a>                 refCustd.setURI(customTokenId);
+<a name="287" href="#287">287</a>                 secRef.setReference(refCustd);
+<a name="288" href="#288">288</a>                 <strong class="jxr_keyword">break</strong>;
+<a name="289" href="#289">289</a>                 
+<a name="290" href="#290">290</a>             <strong class="jxr_keyword">case</strong> WSConstants.CUSTOM_KEY_IDENTIFIER:
+<a name="291" href="#291">291</a>                 <strong class="jxr_keyword">if</strong> (WSConstants.WSS_SAML_KI_VALUE_TYPE.equals(customTokenValueType)) {
+<a name="292" href="#292">292</a>                     secRef.setKeyIdentifier(customTokenValueType, customTokenId);
+<a name="293" href="#293">293</a>                     secRef.addTokenType(WSConstants.WSS_SAML_TOKEN_TYPE);
+<a name="294" href="#294">294</a>                 } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (WSConstants.WSS_SAML2_KI_VALUE_TYPE.equals(customTokenValueType)) {
+<a name="295" href="#295">295</a>                     secRef.setKeyIdentifier(customTokenValueType, customTokenId);
+<a name="296" href="#296">296</a>                     secRef.addTokenType(WSConstants.WSS_SAML2_TOKEN_TYPE);
+<a name="297" href="#297">297</a>                 } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (WSConstants.WSS_ENC_KEY_VALUE_TYPE.equals(customTokenValueType)) {
+<a name="298" href="#298">298</a>                     secRef.setKeyIdentifier(customTokenValueType, customTokenId, <strong class="jxr_keyword">true</strong>);
+<a name="299" href="#299">299</a>                     secRef.addTokenType(WSConstants.WSS_ENC_KEY_VALUE_TYPE);
+<a name="300" href="#300">300</a>                 } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (SecurityTokenReference.ENC_KEY_SHA1_URI.equals(customTokenValueType)) {
+<a name="301" href="#301">301</a>                     secRef.setKeyIdentifier(customTokenValueType, customTokenId, <strong class="jxr_keyword">true</strong>);
+<a name="302" href="#302">302</a>                     secRef.addTokenType(WSConstants.WSS_ENC_KEY_VALUE_TYPE);
+<a name="303" href="#303">303</a>                 } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (WSConstants.WSS_KRB_KI_VALUE_TYPE.equals(customTokenValueType)) {
+<a name="304" href="#304">304</a>                     secRef.setKeyIdentifier(customTokenValueType, customTokenId, <strong class="jxr_keyword">true</strong>);
+<a name="305" href="#305">305</a>                     secRef.addTokenType(WSConstants.WSS_GSS_KRB_V5_AP_REQ);
+<a name="306" href="#306">306</a>                 } 
+<a name="307" href="#307">307</a>                 <strong class="jxr_keyword">break</strong>;
+<a name="308" href="#308">308</a>                 
+<a name="309" href="#309">309</a>             <strong class="jxr_keyword">case</strong> WSConstants.KEY_VALUE:
+<a name="310" href="#310">310</a>                 java.security.PublicKey publicKey = certs[0].getPublicKey();
+<a name="311" href="#311">311</a>                 
+<a name="312" href="#312">312</a>                 <strong class="jxr_keyword">try</strong> {
+<a name="313" href="#313">313</a>                     KeyValue keyValue = keyInfoFactory.newKeyValue(publicKey);
+<a name="314" href="#314">314</a>                     keyInfo = 
+<a name="315" href="#315">315</a>                         keyInfoFactory.newKeyInfo(
+<a name="316" href="#316">316</a>                             java.util.Collections.singletonList(keyValue), keyInfoUri
+<a name="317" href="#317">317</a>                         );
+<a name="318" href="#318">318</a>                 } <strong class="jxr_keyword">catch</strong> (java.security.KeyException ex) {
+<a name="319" href="#319">319</a>                     log.error(<span class="jxr_string">""</span>, ex);
+<a name="320" href="#320">320</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="321" href="#321">321</a>                         WSSecurityException.FAILED_SIGNATURE, <span class="jxr_string">"noXMLSig"</span>, <strong class="jxr_keyword">null</strong>, ex
+<a name="322" href="#322">322</a>                     );
+<a name="323" href="#323">323</a>                 }
+<a name="324" href="#324">324</a>                 <strong class="jxr_keyword">break</strong>;
+<a name="325" href="#325">325</a>             <strong class="jxr_keyword">default</strong>:
+<a name="326" href="#326">326</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="327" href="#327">327</a>             }
+<a name="328" href="#328">328</a>         }
+<a name="329" href="#329">329</a>         
+<a name="330" href="#330">330</a>         <strong class="jxr_keyword">if</strong> (keyIdentifierType != WSConstants.KEY_VALUE) {
+<a name="331" href="#331">331</a>             XMLStructure structure = <strong class="jxr_keyword">new</strong> DOMStructure(secRef.getElement());
+<a name="332" href="#332">332</a>             wsDocInfo.addTokenElement(secRef.getElement(), false);
+<a name="333" href="#333">333</a>             keyInfo = 
+<a name="334" href="#334">334</a>                 keyInfoFactory.newKeyInfo(
+<a name="335" href="#335">335</a>                     java.util.Collections.singletonList(structure), keyInfoUri
+<a name="336" href="#336">336</a>                 );
+<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>     <em class="jxr_javadoccomment">/**</em>
-<a name="341" href="#341">341</a> <em class="jxr_javadoccomment">     * Builds a signed soap envelope.</em>
-<a name="342" href="#342">342</a> <em class="jxr_javadoccomment">     * </em>
-<a name="343" href="#343">343</a> <em class="jxr_javadoccomment">     * This is a convenience method and for backward compatibility. The method</em>
-<a name="344" href="#344">344</a> <em class="jxr_javadoccomment">     * creates a Signature and puts it into the Security header. It does so by</em>
-<a name="345" href="#345">345</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="346" href="#346">346</a> <em class="jxr_javadoccomment">     * This method is compatible with the build method of the previous version</em>
-<a name="347" href="#347">347</a> <em class="jxr_javadoccomment">     * with the exception of the additional WSSecHeader parameter.</em>
-<a name="348" href="#348">348</a> <em class="jxr_javadoccomment">     * </em>
-<a name="349" href="#349">349</a> <em class="jxr_javadoccomment">     * @param doc The unsigned SOAP envelope as &lt;code&gt;Document&lt;/code&gt;</em>
-<a name="350" href="#350">350</a> <em class="jxr_javadoccomment">     * @param cr An instance of the Crypto API to handle keystore and certificates</em>
-<a name="351" href="#351">351</a> <em class="jxr_javadoccomment">     * @param secHeader the security header element to hold the encrypted key element.</em>
-<a name="352" href="#352">352</a> <em class="jxr_javadoccomment">     * @return A signed SOAP envelope as &lt;code&gt;Document&lt;/code&gt;</em>
-<a name="353" href="#353">353</a> <em class="jxr_javadoccomment">     * @throws WSSecurityException</em>
-<a name="354" href="#354">354</a> <em class="jxr_javadoccomment">     */</em>
-<a name="355" href="#355">355</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="356" href="#356">356</a>         <strong class="jxr_keyword">throws</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a> {
-<a name="357" href="#357">357</a>         doDebug = log.isDebugEnabled();
-<a name="358" href="#358">358</a> 
-<a name="359" href="#359">359</a>         <strong class="jxr_keyword">if</strong> (doDebug) {
-<a name="360" href="#360">360</a>             log.debug(<span class="jxr_string">"Beginning signing..."</span>);
-<a name="361" href="#361">361</a>         }
-<a name="362" href="#362">362</a> 
-<a name="363" href="#363">363</a>         prepare(doc, cr, secHeader);
-<a name="364" href="#364">364</a>         <strong class="jxr_keyword">if</strong> (parts == <strong class="jxr_keyword">null</strong>) {
-<a name="365" href="#365">365</a>             parts = <strong class="jxr_keyword">new</strong> ArrayList&lt;WSEncryptionPart&gt;(1);
-<a name="366" href="#366">366</a>             String soapNamespace = WSSecurityUtil.getSOAPNamespace(doc.getDocumentElement());
-<a name="367" href="#367">367</a>             <a href="../../../../../org/apache/ws/security/WSEncryptionPart.html">WSEncryptionPart</a> encP = 
-<a name="368" href="#368">368</a>                 <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSEncryptionPart.html">WSEncryptionPart</a>(
-<a name="369" href="#369">369</a>                     WSConstants.ELEM_BODY, 
-<a name="370" href="#370">370</a>                     soapNamespace, 
-<a name="371" href="#371">371</a>                     <span class="jxr_string">"Content"</span>
-<a name="372" href="#372">372</a>                 );
-<a name="373" href="#373">373</a>             parts.add(encP);
-<a name="374" href="#374">374</a>         } <strong class="jxr_keyword">else</strong> {
-<a name="375" href="#375">375</a>             <strong class="jxr_keyword">for</strong> (WSEncryptionPart part : parts) {
-<a name="376" href="#376">376</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="377" href="#377">377</a>                     part.setId(strUri);
-<a name="378" href="#378">378</a>                 }
-<a name="379" href="#379">379</a>             }
-<a name="380" href="#380">380</a>         }
-<a name="381" href="#381">381</a> 
-<a name="382" href="#382">382</a>         List&lt;javax.xml.crypto.dsig.Reference&gt; referenceList = 
-<a name="383" href="#383">383</a>             addReferencesToSign(parts, secHeader);
-<a name="384" href="#384">384</a> 
-<a name="385" href="#385">385</a>         computeSignature(referenceList);
-<a name="386" href="#386">386</a>         
-<a name="387" href="#387">387</a>         <em class="jxr_comment">//</em>
-<a name="388" href="#388">388</a>         <em class="jxr_comment">// if we have a BST prepend it in front of the Signature according to</em>
-<a name="389" href="#389">389</a>         <em class="jxr_comment">// strict layout rules.</em>
-<a name="390" href="#390">390</a>         <em class="jxr_comment">//</em>
-<a name="391" href="#391">391</a>         <strong class="jxr_keyword">if</strong> (bstToken != <strong class="jxr_keyword">null</strong>) {
-<a name="392" href="#392">392</a>             prependBSTElementToHeader(secHeader);
-<a name="393" href="#393">393</a>         }
-<a name="394" href="#394">394</a> 
-<a name="395" href="#395">395</a>         <strong class="jxr_keyword">return</strong> doc;
-<a name="396" href="#396">396</a>     }
-<a name="397" href="#397">397</a>     
+<a name="340" href="#340">340</a>     
+<a name="341" href="#341">341</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="342" href="#342">342</a> <em class="jxr_javadoccomment">     * Builds a signed soap envelope.</em>
+<a name="343" href="#343">343</a> <em class="jxr_javadoccomment">     * </em>
+<a name="344" href="#344">344</a> <em class="jxr_javadoccomment">     * This is a convenience method and for backward compatibility. The method</em>
+<a name="345" href="#345">345</a> <em class="jxr_javadoccomment">     * creates a Signature and puts it into the Security header. It does so by</em>
+<a name="346" href="#346">346</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="347" href="#347">347</a> <em class="jxr_javadoccomment">     * This method is compatible with the build method of the previous version</em>
+<a name="348" href="#348">348</a> <em class="jxr_javadoccomment">     * with the exception of the additional WSSecHeader parameter.</em>
+<a name="349" href="#349">349</a> <em class="jxr_javadoccomment">     * </em>
+<a name="350" href="#350">350</a> <em class="jxr_javadoccomment">     * @param doc The unsigned SOAP envelope as &lt;code&gt;Document&lt;/code&gt;</em>
+<a name="351" href="#351">351</a> <em class="jxr_javadoccomment">     * @param cr An instance of the Crypto API to handle keystore and certificates</em>
+<a name="352" href="#352">352</a> <em class="jxr_javadoccomment">     * @param secHeader the security header element to hold the encrypted key element.</em>
+<a name="353" href="#353">353</a> <em class="jxr_javadoccomment">     * @return A signed SOAP envelope as &lt;code&gt;Document&lt;/code&gt;</em>
+<a name="354" href="#354">354</a> <em class="jxr_javadoccomment">     * @throws WSSecurityException</em>
+<a name="355" href="#355">355</a> <em class="jxr_javadoccomment">     */</em>
+<a name="356" href="#356">356</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="357" href="#357">357</a>         <strong class="jxr_keyword">throws</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a> {
+<a name="358" href="#358">358</a>         doDebug = log.isDebugEnabled();
+<a name="359" href="#359">359</a> 
+<a name="360" href="#360">360</a>         <strong class="jxr_keyword">if</strong> (doDebug) {
+<a name="361" href="#361">361</a>             log.debug(<span class="jxr_string">"Beginning signing..."</span>);
+<a name="362" href="#362">362</a>         }
+<a name="363" href="#363">363</a> 
+<a name="364" href="#364">364</a>         prepare(doc, cr, secHeader);
+<a name="365" href="#365">365</a>         <strong class="jxr_keyword">if</strong> (parts == <strong class="jxr_keyword">null</strong>) {
+<a name="366" href="#366">366</a>             parts = <strong class="jxr_keyword">new</strong> ArrayList&lt;WSEncryptionPart&gt;(1);
+<a name="367" href="#367">367</a>             String soapNamespace = WSSecurityUtil.getSOAPNamespace(doc.getDocumentElement());
+<a name="368" href="#368">368</a>             <a href="../../../../../org/apache/ws/security/WSEncryptionPart.html">WSEncryptionPart</a> encP = 
+<a name="369" href="#369">369</a>                 <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSEncryptionPart.html">WSEncryptionPart</a>(
+<a name="370" href="#370">370</a>                     WSConstants.ELEM_BODY, 
+<a name="371" href="#371">371</a>                     soapNamespace, 
+<a name="372" href="#372">372</a>                     <span class="jxr_string">"Content"</span>
+<a name="373" href="#373">373</a>                 );
+<a name="374" href="#374">374</a>             parts.add(encP);
+<a name="375" href="#375">375</a>         } <strong class="jxr_keyword">else</strong> {
+<a name="376" href="#376">376</a>             <strong class="jxr_keyword">for</strong> (WSEncryptionPart part : parts) {
+<a name="377" href="#377">377</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="378" href="#378">378</a>                     part.setId(strUri);
+<a name="379" href="#379">379</a>                 }
+<a name="380" href="#380">380</a>             }
+<a name="381" href="#381">381</a>         }
+<a name="382" href="#382">382</a> 
+<a name="383" href="#383">383</a>         List&lt;javax.xml.crypto.dsig.Reference&gt; referenceList = 
+<a name="384" href="#384">384</a>             addReferencesToSign(parts, secHeader);
+<a name="385" href="#385">385</a> 
+<a name="386" href="#386">386</a>         computeSignature(referenceList);
+<a name="387" href="#387">387</a>         
+<a name="388" href="#388">388</a>         <em class="jxr_comment">//</em>
+<a name="389" href="#389">389</a>         <em class="jxr_comment">// if we have a BST prepend it in front of the Signature according to</em>
+<a name="390" href="#390">390</a>         <em class="jxr_comment">// strict layout rules.</em>
+<a name="391" href="#391">391</a>         <em class="jxr_comment">//</em>
+<a name="392" href="#392">392</a>         <strong class="jxr_keyword">if</strong> (bstToken != <strong class="jxr_keyword">null</strong>) {
+<a name="393" href="#393">393</a>             prependBSTElementToHeader(secHeader);
+<a name="394" href="#394">394</a>         }
+<a name="395" href="#395">395</a> 
+<a name="396" href="#396">396</a>         <strong class="jxr_keyword">return</strong> doc;
+<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">     * This method adds references to the Signature.</em>
-<a name="401" href="#401">401</a> <em class="jxr_javadoccomment">     * </em>
-<a name="402" href="#402">402</a> <em class="jxr_javadoccomment">     * @param references The list of references to sign</em>
-<a name="403" href="#403">403</a> <em class="jxr_javadoccomment">     * @param secHeader The Security Header</em>
-<a name="404" href="#404">404</a> <em class="jxr_javadoccomment">     * @throws WSSecurityException</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> List&lt;javax.xml.crypto.dsig.Reference&gt; addReferencesToSign(
-<a name="407" href="#407">407</a>         List&lt;WSEncryptionPart&gt; references, 
-<a name="408" href="#408">408</a>         <a href="../../../../../org/apache/ws/security/message/WSSecHeader.html">WSSecHeader</a> secHeader
-<a name="409" href="#409">409</a>     ) <strong class="jxr_keyword">throws</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a> {
-<a name="410" href="#410">410</a>         <strong class="jxr_keyword">return</strong> 
-<a name="411" href="#411">411</a>             addReferencesToSign(
-<a name="412" href="#412">412</a>                 document, 
-<a name="413" href="#413">413</a>                 references,
-<a name="414" href="#414">414</a>                 wsDocInfo,
-<a name="415" href="#415">415</a>                 signatureFactory, 
-<a name="416" href="#416">416</a>                 secHeader, 
-<a name="417" href="#417">417</a>                 getWsConfig(), 
-<a name="418" href="#418">418</a>                 digestAlgo
-<a name="419" href="#419">419</a>             );
-<a name="420" href="#420">420</a>     }
-<a name="421" href="#421">421</a> 
-<a name="422" href="#422">422</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="423" href="#423">423</a> <em class="jxr_javadoccomment">     * Returns the SignatureElement.</em>
-<a name="424" href="#424">424</a> <em class="jxr_javadoccomment">     * The method can be called any time after &lt;code&gt;prepare()&lt;/code&gt;.</em>
-<a name="425" href="#425">425</a> <em class="jxr_javadoccomment">     * @return The DOM Element of the signature.</em>
-<a name="426" href="#426">426</a> <em class="jxr_javadoccomment">     */</em>
-<a name="427" href="#427">427</a>     <strong class="jxr_keyword">public</strong> Element getSignatureElement() {
-<a name="428" href="#428">428</a>         <strong class="jxr_keyword">return</strong>
-<a name="429" href="#429">429</a>             WSSecurityUtil.getDirectChildElement(
-<a name="430" href="#430">430</a>                 securityHeader,
-<a name="431" href="#431">431</a>                 WSConstants.SIG_LN,
-<a name="432" href="#432">432</a>                 WSConstants.SIG_NS
-<a name="433" href="#433">433</a>             );
-<a name="434" href="#434">434</a>     }
-<a name="435" href="#435">435</a>     
-<a name="436" href="#436">436</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="437" href="#437">437</a> <em class="jxr_javadoccomment">     * Prepend the BinarySecurityToken to the elements already in the Security</em>
-<a name="438" href="#438">438</a> <em class="jxr_javadoccomment">     * header.</em>
-<a name="439" href="#439">439</a> <em class="jxr_javadoccomment">     * </em>
-<a name="440" href="#440">440</a> <em class="jxr_javadoccomment">     * The method can be called any time after &lt;code&gt;prepare()&lt;/code&gt;.</em>
-<a name="441" href="#441">441</a> <em class="jxr_javadoccomment">     * This allows to insert the BST element at any position in the Security</em>
-<a name="442" href="#442">442</a> <em class="jxr_javadoccomment">     * header.</em>
-<a name="443" href="#443">443</a> <em class="jxr_javadoccomment">     * </em>
-<a name="444" href="#444">444</a> <em class="jxr_javadoccomment">     * @param secHeader The security header</em>
-<a name="445" href="#445">445</a> <em class="jxr_javadoccomment">     */</em>
-<a name="446" href="#446">446</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="447" href="#447">447</a>         <strong class="jxr_keyword">if</strong> (bstToken != <strong class="jxr_keyword">null</strong> &amp;&amp; !bstAddedToSecurityHeader) {
-<a name="448" href="#448">448</a>             WSSecurityUtil.prependChildElement(secHeader.getSecurityHeader(), bstToken.getElement());
-<a name="449" href="#449">449</a>             bstAddedToSecurityHeader = <strong class="jxr_keyword">true</strong>;
-<a name="450" href="#450">450</a>         }
-<a name="451" href="#451">451</a>     }
-<a name="452" href="#452">452</a> 
-<a name="453" href="#453">453</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="454" href="#454">454</a> <em class="jxr_javadoccomment">     * Append the BinarySecurityToken to the security header. </em>
-<a name="455" href="#455">455</a> <em class="jxr_javadoccomment">     * @param secHeader The security header</em>
-<a name="456" href="#456">456</a> <em class="jxr_javadoccomment">     */</em>
-<a name="457" href="#457">457</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="458" href="#458">458</a>         <strong class="jxr_keyword">if</strong> (bstToken != <strong class="jxr_keyword">null</strong> &amp;&amp; !bstAddedToSecurityHeader) {
-<a name="459" href="#459">459</a>             Element secHeaderElement = secHeader.getSecurityHeader();
-<a name="460" href="#460">460</a>             secHeaderElement.appendChild(bstToken.getElement());
-<a name="461" href="#461">461</a>             bstAddedToSecurityHeader = <strong class="jxr_keyword">true</strong>;
-<a name="462" href="#462">462</a>         }
-<a name="463" href="#463">463</a>     }
-<a name="464" href="#464">464</a>     
-<a name="465" href="#465">465</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="466" href="#466">466</a> <em class="jxr_javadoccomment">     * Compute the Signature over the references. The signature element will be </em>
-<a name="467" href="#467">467</a> <em class="jxr_javadoccomment">     * prepended to the security header.</em>
-<a name="468" href="#468">468</a> <em class="jxr_javadoccomment">     * </em>
-<a name="469" href="#469">469</a> <em class="jxr_javadoccomment">     * This method can be called any time after the references were set. See</em>
-<a name="470" href="#470">470</a> <em class="jxr_javadoccomment">     * &lt;code&gt;addReferencesToSign()&lt;/code&gt;.</em>
-<a name="471" href="#471">471</a> <em class="jxr_javadoccomment">     * </em>
-<a name="472" href="#472">472</a> <em class="jxr_javadoccomment">     * @param referenceList The list of references to sign</em>
+<a name="399" href="#399">399</a>     
+<a name="400" href="#400">400</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="401" href="#401">401</a> <em class="jxr_javadoccomment">     * This method adds references to the Signature.</em>
+<a name="402" href="#402">402</a> <em class="jxr_javadoccomment">     * </em>
+<a name="403" href="#403">403</a> <em class="jxr_javadoccomment">     * @param references The list of references to sign</em>
+<a name="404" href="#404">404</a> <em class="jxr_javadoccomment">     * @param secHeader The Security Header</em>
+<a name="405" href="#405">405</a> <em class="jxr_javadoccomment">     * @throws WSSecurityException</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> List&lt;javax.xml.crypto.dsig.Reference&gt; addReferencesToSign(
+<a name="408" href="#408">408</a>         List&lt;WSEncryptionPart&gt; references, 
+<a name="409" href="#409">409</a>         <a href="../../../../../org/apache/ws/security/message/WSSecHeader.html">WSSecHeader</a> secHeader
+<a name="410" href="#410">410</a>     ) <strong class="jxr_keyword">throws</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a> {
+<a name="411" href="#411">411</a>         <strong class="jxr_keyword">return</strong> 
+<a name="412" href="#412">412</a>             addReferencesToSign(
+<a name="413" href="#413">413</a>                 document, 
+<a name="414" href="#414">414</a>                 references,
+<a name="415" href="#415">415</a>                 wsDocInfo,
+<a name="416" href="#416">416</a>                 signatureFactory, 
+<a name="417" href="#417">417</a>                 secHeader, 
+<a name="418" href="#418">418</a>                 getWsConfig(), 
+<a name="419" href="#419">419</a>                 digestAlgo
+<a name="420" href="#420">420</a>             );
+<a name="421" href="#421">421</a>     }
+<a name="422" href="#422">422</a> 
+<a name="423" href="#423">423</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="424" href="#424">424</a> <em class="jxr_javadoccomment">     * Returns the SignatureElement.</em>
+<a name="425" href="#425">425</a> <em class="jxr_javadoccomment">     * The method can be called any time after &lt;code&gt;prepare()&lt;/code&gt;.</em>
+<a name="426" href="#426">426</a> <em class="jxr_javadoccomment">     * @return The DOM Element of the signature.</em>
+<a name="427" href="#427">427</a> <em class="jxr_javadoccomment">     */</em>
+<a name="428" href="#428">428</a>     <strong class="jxr_keyword">public</strong> Element getSignatureElement() {
+<a name="429" href="#429">429</a>         <strong class="jxr_keyword">return</strong>
+<a name="430" href="#430">430</a>             WSSecurityUtil.getDirectChildElement(
+<a name="431" href="#431">431</a>                 securityHeader,
+<a name="432" href="#432">432</a>                 WSConstants.SIG_LN,
+<a name="433" href="#433">433</a>                 WSConstants.SIG_NS
+<a name="434" href="#434">434</a>             );
+<a name="435" href="#435">435</a>     }
+<a name="436" href="#436">436</a>     
+<a name="437" href="#437">437</a>     
+<a name="438" href="#438">438</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="439" href="#439">439</a> <em class="jxr_javadoccomment">     * Prepend the BinarySecurityToken to the elements already in the Security</em>
+<a name="440" href="#440">440</a> <em class="jxr_javadoccomment">     * header.</em>
+<a name="441" href="#441">441</a> <em class="jxr_javadoccomment">     * </em>
+<a name="442" href="#442">442</a> <em class="jxr_javadoccomment">     * The method can be called any time after &lt;code&gt;prepare()&lt;/code&gt;.</em>
+<a name="443" href="#443">443</a> <em class="jxr_javadoccomment">     * This allows to insert the BST element at any position in the Security</em>
+<a name="444" href="#444">444</a> <em class="jxr_javadoccomment">     * header.</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 secHeader The security header</em>
+<a name="447" href="#447">447</a> <em class="jxr_javadoccomment">     */</em>
+<a name="448" href="#448">448</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="449" href="#449">449</a>         <strong class="jxr_keyword">if</strong> (bstToken != <strong class="jxr_keyword">null</strong> &amp;&amp; !bstAddedToSecurityHeader) {
+<a name="450" href="#450">450</a>             WSSecurityUtil.prependChildElement(secHeader.getSecurityHeader(), bstToken.getElement());
+<a name="451" href="#451">451</a>             bstAddedToSecurityHeader = <strong class="jxr_keyword">true</strong>;
+<a name="452" href="#452">452</a>         }
+<a name="453" href="#453">453</a>     }
+<a name="454" href="#454">454</a> 
+<a name="455" href="#455">455</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="456" href="#456">456</a> <em class="jxr_javadoccomment">     * Append the BinarySecurityToken to the security header. </em>
+<a name="457" href="#457">457</a> <em class="jxr_javadoccomment">     * @param secHeader The security header</em>
+<a name="458" href="#458">458</a> <em class="jxr_javadoccomment">     */</em>
+<a name="459" href="#459">459</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="460" href="#460">460</a>         <strong class="jxr_keyword">if</strong> (bstToken != <strong class="jxr_keyword">null</strong> &amp;&amp; !bstAddedToSecurityHeader) {
+<a name="461" href="#461">461</a>             Element secHeaderElement = secHeader.getSecurityHeader();
+<a name="462" href="#462">462</a>             secHeaderElement.appendChild(bstToken.getElement());
+<a name="463" href="#463">463</a>             bstAddedToSecurityHeader = <strong class="jxr_keyword">true</strong>;
+<a name="464" href="#464">464</a>         }
+<a name="465" href="#465">465</a>     }
+<a name="466" href="#466">466</a>     
+<a name="467" href="#467">467</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="468" href="#468">468</a> <em class="jxr_javadoccomment">     * Compute the Signature over the references. The signature element will be </em>
+<a name="469" href="#469">469</a> <em class="jxr_javadoccomment">     * prepended to the security header.</em>
+<a name="470" href="#470">470</a> <em class="jxr_javadoccomment">     * </em>
+<a name="471" href="#471">471</a> <em class="jxr_javadoccomment">     * This method can be called any time after the references were set. See</em>
+<a name="472" href="#472">472</a> <em class="jxr_javadoccomment">     * &lt;code&gt;addReferencesToSign()&lt;/code&gt;.</em>
 <a name="473" href="#473">473</a> <em class="jxr_javadoccomment">     * </em>
-<a name="474" href="#474">474</a> <em class="jxr_javadoccomment">     * @throws WSSecurityException</em>
-<a name="475" href="#475">475</a> <em class="jxr_javadoccomment">     */</em>
-<a name="476" href="#476">476</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> computeSignature(
-<a name="477" href="#477">477</a>         List&lt;javax.xml.crypto.dsig.Reference&gt; referenceList 
-<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>         computeSignature(referenceList, <strong class="jxr_keyword">true</strong>, <strong class="jxr_keyword">null</strong>);
-<a name="480" href="#480">480</a>     }
-<a name="481" href="#481">481</a>     
-<a name="482" href="#482">482</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="483" href="#483">483</a> <em class="jxr_javadoccomment">     * Compute the Signature over the references.</em>
-<a name="484" href="#484">484</a> <em class="jxr_javadoccomment">     * </em>
-<a name="485" href="#485">485</a> <em class="jxr_javadoccomment">     * This method can be called any time after the references were set. See</em>
-<a name="486" href="#486">486</a> <em class="jxr_javadoccomment">     * &lt;code&gt;addReferencesToSign()&lt;/code&gt;.</em>
-<a name="487" href="#487">487</a> <em class="jxr_javadoccomment">     * </em>
-<a name="488" href="#488">488</a> <em class="jxr_javadoccomment">     * @param referenceList The list of references to sign</em>
-<a name="489" href="#489">489</a> <em class="jxr_javadoccomment">     * @param prepend Whether to prepend the signature element to the security header</em>
-<a name="490" href="#490">490</a> <em class="jxr_javadoccomment">     * @param siblingElement If prepending, then prepend before this sibling Element</em>
-<a name="491" href="#491">491</a> <em class="jxr_javadoccomment">     * </em>
-<a name="492" href="#492">492</a> <em class="jxr_javadoccomment">     * @throws WSSecurityException</em>
-<a name="493" href="#493">493</a> <em class="jxr_javadoccomment">     */</em>
-<a name="494" href="#494">494</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> computeSignature(
-<a name="495" href="#495">495</a>         List&lt;javax.xml.crypto.dsig.Reference&gt; referenceList, 
-<a name="496" href="#496">496</a>         <strong class="jxr_keyword">boolean</strong> prepend,
-<a name="497" href="#497">497</a>         Element siblingElement
-<a name="498" href="#498">498</a>     ) <strong class="jxr_keyword">throws</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a> {
-<a name="499" href="#499">499</a>         <strong class="jxr_keyword">try</strong> {
-<a name="500" href="#500">500</a>             java.security.Key key;
-<a name="501" href="#501">501</a>             <strong class="jxr_keyword">if</strong> (secretKey == <strong class="jxr_keyword">null</strong>) {
-<a name="502" href="#502">502</a>                 key = crypto.getPrivateKey(user, password);
-<a name="503" href="#503">503</a>             } <strong class="jxr_keyword">else</strong> {
-<a name="504" href="#504">504</a>                 key = WSSecurityUtil.prepareSecretKey(sigAlgo, secretKey);
-<a name="505" href="#505">505</a>             }
-<a name="506" href="#506">506</a>             SignatureMethod signatureMethod = 
-<a name="507" href="#507">507</a>                 signatureFactory.newSignatureMethod(sigAlgo, <strong class="jxr_keyword">null</strong>);
-<a name="508" href="#508">508</a>             SignedInfo signedInfo = 
-<a name="509" href="#509">509</a>                 signatureFactory.newSignedInfo(c14nMethod, signatureMethod, referenceList);
-<a name="510" href="#510">510</a>             
-<a name="511" href="#511">511</a>             sig = signatureFactory.newXMLSignature(
-<a name="512" href="#512">512</a>                     signedInfo, 
-<a name="513" href="#513">513</a>                     keyInfo,
-<a name="514" href="#514">514</a>                     <strong class="jxr_keyword">null</strong>,
-<a name="515" href="#515">515</a>                     getWsConfig().getIdAllocator().createId(<span class="jxr_string">"SIG-"</span>, <strong class="jxr_keyword">null</strong>),
-<a name="516" href="#516">516</a>                     <strong class="jxr_keyword">null</strong>);
-<a name="517" href="#517">517</a>             
-<a name="518" href="#518">518</a>             <em class="jxr_comment">//</em>
-<a name="519" href="#519">519</a>             <em class="jxr_comment">// Figure out where to insert the signature element</em>
+<a name="474" href="#474">474</a> <em class="jxr_javadoccomment">     * @param referenceList The list of references to sign</em>
+<a name="475" href="#475">475</a> <em class="jxr_javadoccomment">     * </em>
+<a name="476" href="#476">476</a> <em class="jxr_javadoccomment">     * @throws WSSecurityException</em>
+<a name="477" href="#477">477</a> <em class="jxr_javadoccomment">     */</em>
+<a name="478" href="#478">478</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> computeSignature(
+<a name="479" href="#479">479</a>         List&lt;javax.xml.crypto.dsig.Reference&gt; referenceList 
+<a name="480" href="#480">480</a>     ) <strong class="jxr_keyword">throws</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a> {
+<a name="481" href="#481">481</a>         computeSignature(referenceList, <strong class="jxr_keyword">true</strong>, <strong class="jxr_keyword">null</strong>);
+<a name="482" href="#482">482</a>     }
+<a name="483" href="#483">483</a>     
+<a name="484" href="#484">484</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="485" href="#485">485</a> <em class="jxr_javadoccomment">     * Compute the Signature over the references.</em>
+<a name="486" href="#486">486</a> <em class="jxr_javadoccomment">     * </em>
+<a name="487" href="#487">487</a> <em class="jxr_javadoccomment">     * This method can be called any time after the references were set. See</em>
+<a name="488" href="#488">488</a> <em class="jxr_javadoccomment">     * &lt;code&gt;addReferencesToSign()&lt;/code&gt;.</em>
+<a name="489" href="#489">489</a> <em class="jxr_javadoccomment">     * </em>
+<a name="490" href="#490">490</a> <em class="jxr_javadoccomment">     * @param referenceList The list of references to sign</em>
+<a name="491" href="#491">491</a> <em class="jxr_javadoccomment">     * @param prepend Whether to prepend the signature element to the security header</em>
+<a name="492" href="#492">492</a> <em class="jxr_javadoccomment">     * @param siblingElement If prepending, then prepend before this sibling Element</em>
+<a name="493" href="#493">493</a> <em class="jxr_javadoccomment">     * </em>
+<a name="494" href="#494">494</a> <em class="jxr_javadoccomment">     * @throws WSSecurityException</em>
+<a name="495" href="#495">495</a> <em class="jxr_javadoccomment">     */</em>
+<a name="496" href="#496">496</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> computeSignature(
+<a name="497" href="#497">497</a>         List&lt;javax.xml.crypto.dsig.Reference&gt; referenceList, 
+<a name="498" href="#498">498</a>         <strong class="jxr_keyword">boolean</strong> prepend,
+<a name="499" href="#499">499</a>         Element siblingElement
+<a name="500" href="#500">500</a>     ) <strong class="jxr_keyword">throws</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a> {
+<a name="501" href="#501">501</a>         <strong class="jxr_keyword">try</strong> {
+<a name="502" href="#502">502</a>             java.security.Key key;
+<a name="503" href="#503">503</a>             <strong class="jxr_keyword">if</strong> (secretKey == <strong class="jxr_keyword">null</strong>) {
+<a name="504" href="#504">504</a>                 key = crypto.getPrivateKey(user, password);
+<a name="505" href="#505">505</a>             } <strong class="jxr_keyword">else</strong> {
+<a name="506" href="#506">506</a>                 key = WSSecurityUtil.prepareSecretKey(sigAlgo, secretKey);
+<a name="507" href="#507">507</a>             }
+<a name="508" href="#508">508</a>             SignatureMethod signatureMethod = 
+<a name="509" href="#509">509</a>                 signatureFactory.newSignatureMethod(sigAlgo, <strong class="jxr_keyword">null</strong>);
+<a name="510" href="#510">510</a>             SignedInfo signedInfo = 
+<a name="511" href="#511">511</a>                 signatureFactory.newSignedInfo(c14nMethod, signatureMethod, referenceList);
+<a name="512" href="#512">512</a>             
+<a name="513" href="#513">513</a>             sig = signatureFactory.newXMLSignature(
+<a name="514" href="#514">514</a>                     signedInfo, 
+<a name="515" href="#515">515</a>                     keyInfo,
+<a name="516" href="#516">516</a>                     <strong class="jxr_keyword">null</strong>,
+<a name="517" href="#517">517</a>                     getWsConfig().getIdAllocator().createId(<span class="jxr_string">"SIG-"</span>, <strong class="jxr_keyword">null</strong>),
+<a name="518" href="#518">518</a>                     <strong class="jxr_keyword">null</strong>);
+<a name="519" href="#519">519</a>             
 <a name="520" href="#520">520</a>             <em class="jxr_comment">//</em>
-<a name="521" href="#521">521</a>             XMLSignContext signContext = <strong class="jxr_keyword">null</strong>;
-<a name="522" href="#522">522</a>             <strong class="jxr_keyword">if</strong> (prepend) {
-<a name="523" href="#523">523</a>                 <strong class="jxr_keyword">if</strong> (siblingElement == <strong class="jxr_keyword">null</strong>) {
-<a name="524" href="#524">524</a>                     Node child = securityHeader.getFirstChild();
-<a name="525" href="#525">525</a>                     <strong class="jxr_keyword">while</strong> (child != <strong class="jxr_keyword">null</strong> &amp;&amp; child.getNodeType() != Node.ELEMENT_NODE) {
-<a name="526" href="#526">526</a>                         child = child.getNextSibling();
-<a name="527" href="#527">527</a>                     } 
-<a name="528" href="#528">528</a>                     siblingElement = (Element)child;
-<a name="529" href="#529">529</a>                 }
-<a name="530" href="#530">530</a>                 <strong class="jxr_keyword">if</strong> (siblingElement == <strong class="jxr_keyword">null</strong>) {
-<a name="531" href="#531">531</a>                     signContext = <strong class="jxr_keyword">new</strong> DOMSignContext(key, securityHeader);
-<a name="532" href="#532">532</a>                 } <strong class="jxr_keyword">else</strong> {
-<a name="533" href="#533">533</a>                     signContext = <strong class="jxr_keyword">new</strong> DOMSignContext(key, securityHeader, siblingElement);
-<a name="534" href="#534">534</a>                 }
-<a name="535" href="#535">535</a>             } <strong class="jxr_keyword">else</strong> {
-<a name="536" href="#536">536</a>                 signContext = <strong class="jxr_keyword">new</strong> DOMSignContext(key, securityHeader);
-<a name="537" href="#537">537</a>             }
-<a name="538" href="#538">538</a>             
-<a name="539" href="#539">539</a>             signContext.putNamespacePrefix(WSConstants.SIG_NS, WSConstants.SIG_PREFIX);
-<a name="540" href="#540">540</a>             <strong class="jxr_keyword">if</strong> (WSConstants.C14N_EXCL_OMIT_COMMENTS.equals(canonAlgo)) {
-<a name="541" href="#541">541</a>                 signContext.putNamespacePrefix(
-<a name="542" href="#542">542</a>                     WSConstants.C14N_EXCL_OMIT_COMMENTS, 
-<a name="543" href="#543">543</a>                     WSConstants.C14N_EXCL_OMIT_COMMENTS_PREFIX
-<a name="544" href="#544">544</a>                 );
-<a name="545" href="#545">545</a>             }
-<a name="546" href="#546">546</a>             signContext.setProperty(STRTransform.TRANSFORM_WS_DOC_INFO, wsDocInfo);
-<a name="547" href="#547">547</a>             wsDocInfo.setCallbackLookup(callbackLookup);
-<a name="548" href="#548">548</a>             
-<a name="549" href="#549">549</a>             <em class="jxr_comment">// Add the elements to sign to the Signature Context</em>
-<a name="550" href="#550">550</a>             wsDocInfo.setTokensOnContext((DOMSignContext)signContext);
-<a name="551" href="#551">551</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="552" href="#552">552</a>                 WSSecurityUtil.storeElementInContext((DOMSignContext)signContext, secRef.getElement());
-<a name="553" href="#553">553</a>             }
-<a name="554" href="#554">554</a>             sig.sign(signContext);
-<a name="555" href="#555">555</a>             
-<a name="556" href="#556">556</a>             signatureValue = sig.getSignatureValue().getValue();
-<a name="557" href="#557">557</a>         } <strong class="jxr_keyword">catch</strong> (Exception ex) {
-<a name="558" href="#558">558</a>             log.error(ex);
-<a name="559" href="#559">559</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="560" href="#560">560</a>                 WSSecurityException.FAILED_SIGNATURE, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">null</strong>, ex
-<a name="561" href="#561">561</a>             );
-<a name="562" href="#562">562</a>         }
-<a name="563" href="#563">563</a>     }
-<a name="564" href="#564">564</a>     
-<a name="565" href="#565">565</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="566" href="#566">566</a> <em class="jxr_javadoccomment">     * Set the single cert flag.</em>
-<a name="567" href="#567">567</a> <em class="jxr_javadoccomment">     * </em>
-<a name="568" href="#568">568</a> <em class="jxr_javadoccomment">     * @param useSingleCert</em>
-<a name="569" href="#569">569</a> <em class="jxr_javadoccomment">     */</em>
-<a name="570" href="#570">570</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> setUseSingleCertificate(<strong class="jxr_keyword">boolean</strong> useSingleCert) {
-<a name="571" href="#571">571</a>         <strong class="jxr_keyword">this</strong>.useSingleCert = useSingleCert;
-<a name="572" href="#572">572</a>     }
-<a name="573" href="#573">573</a> 
-<a name="574" href="#574">574</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="575" href="#575">575</a> <em class="jxr_javadoccomment">     * Get the single cert flag.</em>
-<a name="576" href="#576">576</a> <em class="jxr_javadoccomment">     * </em>
-<a name="577" href="#577">577</a> <em class="jxr_javadoccomment">     * @return A boolean if single certificate is set.</em>
-<a name="578" href="#578">578</a> <em class="jxr_javadoccomment">     */</em>
-<a name="579" href="#579">579</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">boolean</strong> isUseSingleCertificate() {
-<a name="580" href="#580">580</a>         <strong class="jxr_keyword">return</strong> useSingleCert;
-<a name="581" href="#581">581</a>     }
-<a name="582" href="#582">582</a> 
-<a name="583" href="#583">583</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="584" href="#584">584</a> <em class="jxr_javadoccomment">     * Set the name (uri) of the signature encryption algorithm to use.</em>
-<a name="585" href="#585">585</a> <em class="jxr_javadoccomment">     * </em>
-<a name="586" href="#586">586</a> <em class="jxr_javadoccomment">     * If the algorithm is not set then an automatic detection of the signature</em>
-<a name="587" href="#587">587</a> <em class="jxr_javadoccomment">     * algorithm to use is performed during the &lt;code&gt;prepare()&lt;/code&gt;</em>
-<a name="588" href="#588">588</a> <em class="jxr_javadoccomment">     * method. Refer to WSConstants which algorithms are supported.</em>
-<a name="589" href="#589">589</a> <em class="jxr_javadoccomment">     * </em>
-<a name="590" href="#590">590</a> <em class="jxr_javadoccomment">     * @param algo the name of the signature algorithm</em>
-<a name="591" href="#591">591</a> <em class="jxr_javadoccomment">     * @see WSConstants#RSA</em>
-<a name="592" href="#592">592</a> <em class="jxr_javadoccomment">     * @see WSConstants#DSA</em>
-<a name="593" href="#593">593</a> <em class="jxr_javadoccomment">     */</em>
-<a name="594" href="#594">594</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> setSignatureAlgorithm(String algo) {
-<a name="595" href="#595">595</a>         sigAlgo = algo;
-<a name="596" href="#596">596</a>     }
-<a name="597" href="#597">597</a> 
-<a name="598" href="#598">598</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="599" href="#599">599</a> <em class="jxr_javadoccomment">     * Get the name (uri) of the signature algorithm that is being used.</em>
-<a name="600" href="#600">600</a> <em class="jxr_javadoccomment">     * </em>
-<a name="601" href="#601">601</a> <em class="jxr_javadoccomment">     * Call this method after &lt;code&gt;prepare&lt;/code&gt; to get the information</em>
-<a name="602" href="#602">602</a> <em class="jxr_javadoccomment">     * which signature algorithm was automatically detected if no signature</em>
-<a name="603" href="#603">603</a> <em class="jxr_javadoccomment">     * algorithm was preset.</em>
-<a name="604" href="#604">604</a> <em class="jxr_javadoccomment">     * </em>
-<a name="605" href="#605">605</a> <em class="jxr_javadoccomment">     * @return the identifier URI of the signature algorithm</em>
-<a name="606" href="#606">606</a> <em class="jxr_javadoccomment">     */</em>
-<a name="607" href="#607">607</a>     <strong class="jxr_keyword">public</strong> String getSignatureAlgorithm() {
-<a name="608" href="#608">608</a>         <strong class="jxr_keyword">return</strong> sigAlgo;
-<a name="609" href="#609">609</a>     }
-<a name="610" href="#610">610</a> 
-<a name="611" href="#611">611</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="612" href="#612">612</a> <em class="jxr_javadoccomment">     * Set the canonicalization method to use.</em>
-<a name="613" href="#613">613</a> <em class="jxr_javadoccomment">     * </em>
-<a name="614" href="#614">614</a> <em class="jxr_javadoccomment">     * If the canonicalization method is not set then the recommended Exclusive</em>
-<a name="615" href="#615">615</a> <em class="jxr_javadoccomment">     * XML Canonicalization is used by default. Refer to WSConstants which</em>
-<a name="616" href="#616">616</a> <em class="jxr_javadoccomment">     * algorithms are supported.</em>
-<a name="617" href="#617">617</a> <em class="jxr_javadoccomment">     * </em>
-<a name="618" href="#618">618</a> <em class="jxr_javadoccomment">     * @param algo Is the name of the signature algorithm</em>
-<a name="619" href="#619">619</a> <em class="jxr_javadoccomment">     * @see WSConstants#C14N_OMIT_COMMENTS</em>
-<a name="620" href="#620">620</a> <em class="jxr_javadoccomment">     * @see WSConstants#C14N_WITH_COMMENTS</em>
-<a name="621" href="#621">621</a> <em class="jxr_javadoccomment">     * @see WSConstants#C14N_EXCL_OMIT_COMMENTS</em>
-<a name="622" href="#622">622</a> <em class="jxr_javadoccomment">     * @see WSConstants#C14N_EXCL_WITH_COMMENTS</em>
-<a name="623" href="#623">623</a> <em class="jxr_javadoccomment">     */</em>
-<a name="624" href="#624">624</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> setSigCanonicalization(String algo) {
-<a name="625" href="#625">625</a>         canonAlgo = algo;
-<a name="626" href="#626">626</a>     }
-<a name="627" href="#627">627</a> 
-<a name="628" href="#628">628</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="629" href="#629">629</a> <em class="jxr_javadoccomment">     * Get the canonicalization method.</em>
-<a name="630" href="#630">630</a> <em class="jxr_javadoccomment">     * </em>
-<a name="631" href="#631">631</a> <em class="jxr_javadoccomment">     * If the canonicalization method was not set then Exclusive XML</em>
-<a name="632" href="#632">632</a> <em class="jxr_javadoccomment">     * Canonicalization is used by default.</em>
-<a name="633" href="#633">633</a> <em class="jxr_javadoccomment">     * </em>
-<a name="634" href="#634">634</a> <em class="jxr_javadoccomment">     * @return The string describing the canonicalization algorithm.</em>
-<a name="635" href="#635">635</a> <em class="jxr_javadoccomment">     */</em>
-<a name="636" href="#636">636</a>     <strong class="jxr_keyword">public</strong> String getSigCanonicalization() {
-<a name="637" href="#637">637</a>         <strong class="jxr_keyword">return</strong> canonAlgo;
-<a name="638" href="#638">638</a>     }
-<a name="639" href="#639">639</a> 
-<a name="640" href="#640">640</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="641" href="#641">641</a> <em class="jxr_javadoccomment">     * @return the digest algorithm to use</em>
-<a name="642" href="#642">642</a> <em class="jxr_javadoccomment">     */</em>
-<a name="643" href="#643">643</a>     <strong class="jxr_keyword">public</strong> String getDigestAlgo() {
-<a name="644" href="#644">644</a>         <strong class="jxr_keyword">return</strong> digestAlgo;
-<a name="645" href="#645">645</a>     }
-<a name="646" href="#646">646</a> 
-<a name="647" href="#647">647</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="648" href="#648">648</a> <em class="jxr_javadoccomment">     * Set the string that defines which digest algorithm to use. </em>
-<a name="649" href="#649">649</a> <em class="jxr_javadoccomment">     * The default is Constants.ALGO_ID_DIGEST_SHA1.</em>
-<a name="650" href="#650">650</a> <em class="jxr_javadoccomment">     * </em>
-<a name="651" href="#651">651</a> <em class="jxr_javadoccomment">     * @param digestAlgo the digestAlgo to set</em>
-<a name="652" href="#652">652</a> <em class="jxr_javadoccomment">     */</em>
-<a name="653" href="#653">653</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> setDigestAlgo(String digestAlgo) {
-<a name="654" href="#654">654</a>         <strong class="jxr_keyword">this</strong>.digestAlgo = digestAlgo;
-<a name="655" href="#655">655</a>     }
-<a name="656" href="#656">656</a>     
-<a name="657" href="#657">657</a>     
-<a name="658" href="#658">658</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="659" href="#659">659</a> <em class="jxr_javadoccomment">     * Returns the computed Signature value.</em>
-<a name="660" href="#660">660</a> <em class="jxr_javadoccomment">     * </em>
-<a name="661" href="#661">661</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="662" href="#662">662</a> <em class="jxr_javadoccomment">     * methods were called.</em>
-<a name="663" href="#663">663</a> <em class="jxr_javadoccomment">     * </em>
-<a name="664" href="#664">664</a> <em class="jxr_javadoccomment">     * @return Returns the signatureValue.</em>
-<a name="665" href="#665">665</a> <em class="jxr_javadoccomment">     */</em>
-<a name="666" href="#666">666</a>     <strong class="jxr_keyword">public</strong> byte[] getSignatureValue() {
-<a name="667" href="#667">667</a>         <strong class="jxr_keyword">return</strong> signatureValue;
-<a name="668" href="#668">668</a>     }
-<a name="669" href="#669">669</a> 
-<a name="670" href="#670">670</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="671" href="#671">671</a> <em class="jxr_javadoccomment">     * Get the id generated during &lt;code&gt;prepare()&lt;/code&gt;.</em>
-<a name="672" href="#672">672</a> <em class="jxr_javadoccomment">     * </em>
-<a name="673" href="#673">673</a> <em class="jxr_javadoccomment">     * Returns the the value of wsu:Id attribute of the Signature element.</em>
+<a name="521" href="#521">521</a>             <em class="jxr_comment">// Figure out where to insert the signature element</em>
+<a name="522" href="#522">522</a>             <em class="jxr_comment">//</em>
+<a name="523" href="#523">523</a>             XMLSignContext signContext = <strong class="jxr_keyword">null</strong>;
+<a name="524" href="#524">524</a>             <strong class="jxr_keyword">if</strong> (prepend) {
+<a name="525" href="#525">525</a>                 <strong class="jxr_keyword">if</strong> (siblingElement == <strong class="jxr_keyword">null</strong>) {
+<a name="526" href="#526">526</a>                     Node child = securityHeader.getFirstChild();
+<a name="527" href="#527">527</a>                     <strong class="jxr_keyword">while</strong> (child != <strong class="jxr_keyword">null</strong> &amp;&amp; child.getNodeType() != Node.ELEMENT_NODE) {
+<a name="528" href="#528">528</a>                         child = child.getNextSibling();
+<a name="529" href="#529">529</a>                     } 
+<a name="530" href="#530">530</a>                     siblingElement = (Element)child;
+<a name="531" href="#531">531</a>                 }
+<a name="532" href="#532">532</a>                 <strong class="jxr_keyword">if</strong> (siblingElement == <strong class="jxr_keyword">null</strong>) {
+<a name="533" href="#533">533</a>                     signContext = <strong class="jxr_keyword">new</strong> DOMSignContext(key, securityHeader);
+<a name="534" href="#534">534</a>                 } <strong class="jxr_keyword">else</strong> {
+<a name="535" href="#535">535</a>                     signContext = <strong class="jxr_keyword">new</strong> DOMSignContext(key, securityHeader, siblingElement);
+<a name="536" href="#536">536</a>                 }
+<a name="537" href="#537">537</a>             } <strong class="jxr_keyword">else</strong> {
+<a name="538" href="#538">538</a>                 signContext = <strong class="jxr_keyword">new</strong> DOMSignContext(key, securityHeader);
+<a name="539" href="#539">539</a>             }
+<a name="540" href="#540">540</a>             
+<a name="541" href="#541">541</a>             signContext.putNamespacePrefix(WSConstants.SIG_NS, WSConstants.SIG_PREFIX);
+<a name="542" href="#542">542</a>             <strong class="jxr_keyword">if</strong> (WSConstants.C14N_EXCL_OMIT_COMMENTS.equals(canonAlgo)) {
+<a name="543" href="#543">543</a>                 signContext.putNamespacePrefix(
+<a name="544" href="#544">544</a>                     WSConstants.C14N_EXCL_OMIT_COMMENTS, 
+<a name="545" href="#545">545</a>                     WSConstants.C14N_EXCL_OMIT_COMMENTS_PREFIX
+<a name="546" href="#546">546</a>                 );
+<a name="547" href="#547">547</a>             }
+<a name="548" href="#548">548</a>             signContext.setProperty(STRTransform.TRANSFORM_WS_DOC_INFO, wsDocInfo);
+<a name="549" href="#549">549</a>             wsDocInfo.setCallbackLookup(callbackLookup);
+<a name="550" href="#550">550</a>             
+<a name="551" href="#551">551</a>             <em class="jxr_comment">// Add the elements to sign to the Signature Context</em>
+<a name="552" href="#552">552</a>             wsDocInfo.setTokensOnContext((DOMSignContext)signContext);
+<a name="553" href="#553">553</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="554" href="#554">554</a>                 WSSecurityUtil.storeElementInContext((DOMSignContext)signContext, secRef.getElement());
+<a name="555" href="#555">555</a>             }
+<a name="556" href="#556">556</a>             sig.sign(signContext);
+<a name="557" href="#557">557</a>             
+<a name="558" href="#558">558</a>             signatureValue = sig.getSignatureValue().getValue();
+<a name="559" href="#559">559</a>         } <strong class="jxr_keyword">catch</strong> (Exception ex) {
+<a name="560" href="#560">560</a>             log.error(ex);
+<a name="561" href="#561">561</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="562" href="#562">562</a>                 WSSecurityException.FAILED_SIGNATURE, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">null</strong>, ex
+<a name="563" href="#563">563</a>             );
+<a name="564" href="#564">564</a>         }
+<a name="565" href="#565">565</a>     }
+<a name="566" href="#566">566</a>     
+<a name="567" href="#567">567</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="568" href="#568">568</a> <em class="jxr_javadoccomment">     * Set the single cert flag.</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 useSingleCert</em>
+<a name="571" href="#571">571</a> <em class="jxr_javadoccomment">     */</em>
+<a name="572" href="#572">572</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> setUseSingleCertificate(<strong class="jxr_keyword">boolean</strong> useSingleCert) {
+<a name="573" href="#573">573</a>         <strong class="jxr_keyword">this</strong>.useSingleCert = useSingleCert;
+<a name="574" href="#574">574</a>     }
+<a name="575" href="#575">575</a> 
+<a name="576" href="#576">576</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="577" href="#577">577</a> <em class="jxr_javadoccomment">     * Get the single cert flag.</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 A boolean if single certificate is set.</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> <strong class="jxr_keyword">boolean</strong> isUseSingleCertificate() {
+<a name="582" href="#582">582</a>         <strong class="jxr_keyword">return</strong> useSingleCert;
+<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 name (uri) of the signature encryption algorithm 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 algorithm is not set then an automatic detection of the signature</em>
+<a name="589" href="#589">589</a> <em class="jxr_javadoccomment">     * algorithm to use is performed during the &lt;code&gt;prepare()&lt;/code&gt;</em>
+<a name="590" href="#590">590</a> <em class="jxr_javadoccomment">     * method. Refer to WSConstants which 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 the name of the signature algorithm</em>
+<a name="593" href="#593">593</a> <em class="jxr_javadoccomment">     * @see WSConstants#RSA</em>
+<a name="594" href="#594">594</a> <em class="jxr_javadoccomment">     * @see WSConstants#DSA</em>
+<a name="595" href="#595">595</a> <em class="jxr_javadoccomment">     */</em>
+<a name="596" href="#596">596</a>     <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> setSignatureAlgorithm(String algo) {
+<a name="597" href="#597">597</a>         sigAlgo = algo;
+<a name="598" href="#598">598</a>     }
+<a name="599" href="#599">599</a> 
+<a name="600" href="#600">600</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="601" href="#601">601</a> <em class="jxr_javadoccomment">     * Get the name (uri) of the signature algorithm that is being used.</em>
+<a name="602" href="#602">602</a> <em class="jxr_javadoccomment">     * </em>
+<a name="603" href="#603">603</a> <em class="jxr_javadoccomment">     * Call this method after &lt;code&gt;prepare&lt;/code&gt; to get the information</em>
+<a name="604" href="#604">604</a> <em class="jxr_javadoccomment">     * which signature algorithm was automatically detected if no signature</em>
+<a name="605" href="#605">605</a> <em class="jxr_javadoccomment">     * algorithm was preset.</em>
+<a name="606" href="#606">606</a> <em class="jxr_javadoccomment">     * </em>
+<a name="607" href="#607">607</a> <em class="jxr_javadoccomment">     * @return the identifier URI of the signature algorithm</em>
+<a name="608" href="#608">608</a> <em class="jxr_javadoccomment">     */</em>
+<a name="609" href="#609">609</a>     <strong class="jxr_keyword">public</strong> String getSignatureAlgorithm() {
+<a name="610" href="#610">610</a>         <strong class="jxr_keyword">return</strong> sigAlgo;
+<a name="611" href="#611">611</a>     }
+<a name="612" href="#612">612</a> 
+<a name="613" href="#613">613</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="614" href="#614">614</a> <em class="jxr_javadoccomment">     * Set the canonicalization method to use.</em>
+<a name="615" href="#615">615</a> <em class="jxr_javadoccomment">     * </em>
+<a name="616" href="#616">616</a> <em class="jxr_javadoccomment">     * If the canonicalization method is not set then the recommended Exclusive</em>
+<a name="617" href="#617">617</a> <em class="jxr_javadoccomment">     * XML Canonicalization is used by default. Refer to WSConstants which</em>
+<a name="618" href="#618">618</a> <em class="jxr_javadoccomment">     * algorithms are supported.</em>
+<a name="619" href="#619">619</a> <em class="jxr_javadoccomment">     * </em>
+<a name="620" href="#620">620</a> <em class="jxr_javadoccomment">     * @param algo Is the name of the signature algorithm</em>
+<a name="621" href="#621">621</a> <em class="jxr_javadoccomment">     * @see WSConstants#C14N_OMIT_COMMENTS</em>
+<a name="622" href="#622">622</a> <em class="jxr_javadoccomment">     * @see WSConstants#C14N_WITH_COMMENTS</em>

[... 358 lines stripped ...]