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/01/17 16:49:30 UTC
svn commit: r1059959 [15/20] - in /webservices/wss4j/site: ./ apidocs/
apidocs/org/apache/ws/axis/security/
apidocs/org/apache/ws/axis/security/class-use/
apidocs/org/apache/ws/axis/security/handler/
apidocs/org/apache/ws/axis/security/handler/class-us...
Modified: webservices/wss4j/site/xref/org/apache/ws/security/message/token/SecurityTokenReference.html
URL: http://svn.apache.org/viewvc/webservices/wss4j/site/xref/org/apache/ws/security/message/token/SecurityTokenReference.html?rev=1059959&r1=1059958&r2=1059959&view=diff
==============================================================================
--- webservices/wss4j/site/xref/org/apache/ws/security/message/token/SecurityTokenReference.html (original)
+++ webservices/wss4j/site/xref/org/apache/ws/security/message/token/SecurityTokenReference.html Mon Jan 17 15:49:15 2011
@@ -261,485 +261,486 @@
<a name="251" href="#251">251</a> <em class="jxr_comment">// </em>
<a name="252" href="#252">252</a> <em class="jxr_comment">// Try to find a custom token</em>
<a name="253" href="#253">253</a> <em class="jxr_comment">//</em>
-<a name="254" href="#254">254</a> <strong class="jxr_keyword">if</strong> (tokElement == <strong class="jxr_keyword">null</strong> && WSConstants.WSC_SCT.equals(type) && cb != <strong class="jxr_keyword">null</strong>) {
-<a name="255" href="#255">255</a> <em class="jxr_comment">//try to find a custom token</em>
-<a name="256" href="#256">256</a> <a href="../../../../../../org/apache/ws/security/WSPasswordCallback.html">WSPasswordCallback</a> pwcb =
-<a name="257" href="#257">257</a> <strong class="jxr_keyword">new</strong> <a href="../../../../../../org/apache/ws/security/WSPasswordCallback.html">WSPasswordCallback</a>(id, WSPasswordCallback.CUSTOM_TOKEN);
-<a name="258" href="#258">258</a> <strong class="jxr_keyword">try</strong> {
-<a name="259" href="#259">259</a> cb.handle(<strong class="jxr_keyword">new</strong> Callback[]{pwcb});
-<a name="260" href="#260">260</a> Element assertionElem = pwcb.getCustomToken();
-<a name="261" href="#261">261</a> <strong class="jxr_keyword">if</strong> (assertionElem != <strong class="jxr_keyword">null</strong>) {
-<a name="262" href="#262">262</a> tokElement = (Element)doc.importNode(assertionElem, <strong class="jxr_keyword">true</strong>);
-<a name="263" href="#263">263</a> }
-<a name="264" href="#264">264</a> } <strong class="jxr_keyword">catch</strong> (Exception e) {
-<a name="265" href="#265">265</a> log.debug(e.getMessage(), e);
-<a name="266" href="#266">266</a> <em class="jxr_comment">// Consume this failure</em>
-<a name="267" href="#267">267</a> }
-<a name="268" href="#268">268</a> }
-<a name="269" href="#269">269</a>
-<a name="270" href="#270">270</a> <em class="jxr_comment">//</em>
-<a name="271" href="#271">271</a> <em class="jxr_comment">// Finally try to find the element by its Id</em>
-<a name="272" href="#272">272</a> <em class="jxr_comment">//</em>
-<a name="273" href="#273">273</a> <strong class="jxr_keyword">if</strong> (tokElement == <strong class="jxr_keyword">null</strong>) {
-<a name="274" href="#274">274</a> tokElement = WSSecurityUtil.getElementByWsuId(doc, uri);
-<a name="275" href="#275">275</a>
-<a name="276" href="#276">276</a> <em class="jxr_comment">// In some scenarios id is used rather than wsu:Id</em>
-<a name="277" href="#277">277</a> <strong class="jxr_keyword">if</strong> (tokElement == <strong class="jxr_keyword">null</strong>) {
-<a name="278" href="#278">278</a> tokElement = WSSecurityUtil.getElementByGenId(doc, uri);
-<a name="279" href="#279">279</a> }
-<a name="280" href="#280">280</a> }
-<a name="281" href="#281">281</a>
-<a name="282" href="#282">282</a> <strong class="jxr_keyword">return</strong> tokElement;
-<a name="283" href="#283">283</a> }
-<a name="284" href="#284">284</a>
+<a name="254" href="#254">254</a> <strong class="jxr_keyword">if</strong> (tokElement == <strong class="jxr_keyword">null</strong> && cb != <strong class="jxr_keyword">null</strong> && (WSConstants.WSC_SCT.equals(type) ||
+<a name="255" href="#255">255</a> WSConstants.WSS_SAML_KI_VALUE_TYPE.equals(type) || assertionStr.equals(type))) {
+<a name="256" href="#256">256</a> <em class="jxr_comment">//try to find a custom token</em>
+<a name="257" href="#257">257</a> <a href="../../../../../../org/apache/ws/security/WSPasswordCallback.html">WSPasswordCallback</a> pwcb =
+<a name="258" href="#258">258</a> <strong class="jxr_keyword">new</strong> <a href="../../../../../../org/apache/ws/security/WSPasswordCallback.html">WSPasswordCallback</a>(id, WSPasswordCallback.CUSTOM_TOKEN);
+<a name="259" href="#259">259</a> <strong class="jxr_keyword">try</strong> {
+<a name="260" href="#260">260</a> cb.handle(<strong class="jxr_keyword">new</strong> Callback[]{pwcb});
+<a name="261" href="#261">261</a> Element assertionElem = pwcb.getCustomToken();
+<a name="262" href="#262">262</a> <strong class="jxr_keyword">if</strong> (assertionElem != <strong class="jxr_keyword">null</strong>) {
+<a name="263" href="#263">263</a> tokElement = (Element)doc.importNode(assertionElem, <strong class="jxr_keyword">true</strong>);
+<a name="264" href="#264">264</a> }
+<a name="265" href="#265">265</a> } <strong class="jxr_keyword">catch</strong> (Exception e) {
+<a name="266" href="#266">266</a> log.debug(e.getMessage(), e);
+<a name="267" href="#267">267</a> <em class="jxr_comment">// Consume this failure</em>
+<a name="268" href="#268">268</a> }
+<a name="269" href="#269">269</a> }
+<a name="270" href="#270">270</a>
+<a name="271" href="#271">271</a> <em class="jxr_comment">//</em>
+<a name="272" href="#272">272</a> <em class="jxr_comment">// Finally try to find the element by its Id</em>
+<a name="273" href="#273">273</a> <em class="jxr_comment">//</em>
+<a name="274" href="#274">274</a> <strong class="jxr_keyword">if</strong> (tokElement == <strong class="jxr_keyword">null</strong>) {
+<a name="275" href="#275">275</a> tokElement = WSSecurityUtil.getElementByWsuId(doc, uri);
+<a name="276" href="#276">276</a>
+<a name="277" href="#277">277</a> <em class="jxr_comment">// In some scenarios id is used rather than wsu:Id</em>
+<a name="278" href="#278">278</a> <strong class="jxr_keyword">if</strong> (tokElement == <strong class="jxr_keyword">null</strong>) {
+<a name="279" href="#279">279</a> tokElement = WSSecurityUtil.getElementByGenId(doc, uri);
+<a name="280" href="#280">280</a> }
+<a name="281" href="#281">281</a> }
+<a name="282" href="#282">282</a>
+<a name="283" href="#283">283</a> <strong class="jxr_keyword">return</strong> tokElement;
+<a name="284" href="#284">284</a> }
<a name="285" href="#285">285</a>
-<a name="286" href="#286">286</a> <em class="jxr_javadoccomment">/**</em>
-<a name="287" href="#287">287</a> <em class="jxr_javadoccomment"> * Sets the KeyIdentifier Element as a X509 certificate.</em>
-<a name="288" href="#288">288</a> <em class="jxr_javadoccomment"> * Takes a X509 certificate, converts its data into base 64 and inserts</em>
-<a name="289" href="#289">289</a> <em class="jxr_javadoccomment"> * it into a <code>wsse:KeyIdentifier</code> element, which is placed</em>
-<a name="290" href="#290">290</a> <em class="jxr_javadoccomment"> * in the <code>wsse:SecurityTokenReference</code> element.</em>
-<a name="291" href="#291">291</a> <em class="jxr_javadoccomment"> *</em>
-<a name="292" href="#292">292</a> <em class="jxr_javadoccomment"> * @param cert is the X509 certificate to be inserted as key identifier</em>
-<a name="293" href="#293">293</a> <em class="jxr_javadoccomment"> */</em>
-<a name="294" href="#294">294</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> setKeyIdentifier(X509Certificate cert)
-<a name="295" href="#295">295</a> <strong class="jxr_keyword">throws</strong> <a href="../../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a> {
-<a name="296" href="#296">296</a> Document doc = <strong class="jxr_keyword">this</strong>.element.getOwnerDocument();
-<a name="297" href="#297">297</a> byte data[] = <strong class="jxr_keyword">null</strong>;
-<a name="298" href="#298">298</a> <strong class="jxr_keyword">try</strong> {
-<a name="299" href="#299">299</a> data = cert.getEncoded();
-<a name="300" href="#300">300</a> } <strong class="jxr_keyword">catch</strong> (CertificateEncodingException e) {
-<a name="301" href="#301">301</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="302" href="#302">302</a> WSSecurityException.SECURITY_TOKEN_UNAVAILABLE, <span class="jxr_string">"encodeError"</span>, <strong class="jxr_keyword">null</strong>, e
-<a name="303" href="#303">303</a> );
-<a name="304" href="#304">304</a> }
-<a name="305" href="#305">305</a> Text text = doc.createTextNode(Base64.encode(data));
-<a name="306" href="#306">306</a>
-<a name="307" href="#307">307</a> createKeyIdentifier(doc, X509Security.X509_V3_TYPE, text, <strong class="jxr_keyword">true</strong>);
-<a name="308" href="#308">308</a> }
-<a name="309" href="#309">309</a>
-<a name="310" href="#310">310</a> <em class="jxr_javadoccomment">/**</em>
-<a name="311" href="#311">311</a> <em class="jxr_javadoccomment"> * Sets the KeyIdentifier Element as a X509 Subject-Key-Identifier (SKI).</em>
-<a name="312" href="#312">312</a> <em class="jxr_javadoccomment"> * Takes a X509 certificate, gets it SKI data, converts into base 64 and</em>
-<a name="313" href="#313">313</a> <em class="jxr_javadoccomment"> * inserts it into a <code>wsse:KeyIdentifier</code> element, which is placed</em>
-<a name="314" href="#314">314</a> <em class="jxr_javadoccomment"> * in the <code>wsse:SecurityTokenReference</code> element.</em>
-<a name="315" href="#315">315</a> <em class="jxr_javadoccomment"> *</em>
-<a name="316" href="#316">316</a> <em class="jxr_javadoccomment"> * @param cert is the X509 certificate to get the SKI</em>
-<a name="317" href="#317">317</a> <em class="jxr_javadoccomment"> * @param crypto is the Crypto implementation. Used to read SKI info bytes from certificate</em>
-<a name="318" href="#318">318</a> <em class="jxr_javadoccomment"> */</em>
-<a name="319" href="#319">319</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> setKeyIdentifierSKI(X509Certificate cert, <a href="../../../../../../org/apache/ws/security/components/crypto/Crypto.html">Crypto</a> crypto)
-<a name="320" href="#320">320</a> <strong class="jxr_keyword">throws</strong> <a href="../../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a> {
-<a name="321" href="#321">321</a> <em class="jxr_comment">//</em>
-<a name="322" href="#322">322</a> <em class="jxr_comment">// As per the 1.1 specification, SKI can only be used for a V3 certificate</em>
-<a name="323" href="#323">323</a> <em class="jxr_comment">//</em>
-<a name="324" href="#324">324</a> <strong class="jxr_keyword">if</strong> (cert.getVersion() != 3) {
-<a name="325" href="#325">325</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a>(
-<a name="326" href="#326">326</a> WSSecurityException.UNSUPPORTED_SECURITY_TOKEN,
-<a name="327" href="#327">327</a> <span class="jxr_string">"invalidCertForSKI"</span>,
-<a name="328" href="#328">328</a> <strong class="jxr_keyword">new</strong> Object[]{<strong class="jxr_keyword">new</strong> Integer(cert.getVersion())}
-<a name="329" href="#329">329</a> );
-<a name="330" href="#330">330</a> }
-<a name="331" href="#331">331</a>
-<a name="332" href="#332">332</a> Document doc = <strong class="jxr_keyword">this</strong>.element.getOwnerDocument();
-<a name="333" href="#333">333</a> byte data[] = crypto.getSKIBytesFromCert(cert);
-<a name="334" href="#334">334</a>
-<a name="335" href="#335">335</a> org.w3c.dom.Text text = doc.createTextNode(Base64.encode(data));
-<a name="336" href="#336">336</a> createKeyIdentifier(doc, SKI_URI, text, <strong class="jxr_keyword">true</strong>);
-<a name="337" href="#337">337</a> }
-<a name="338" href="#338">338</a>
-<a name="339" href="#339">339</a> <em class="jxr_javadoccomment">/**</em>
-<a name="340" href="#340">340</a> <em class="jxr_javadoccomment"> * Sets the KeyIdentifier Element as a Thumbprint.</em>
-<a name="341" href="#341">341</a> <em class="jxr_javadoccomment"> * </em>
-<a name="342" href="#342">342</a> <em class="jxr_javadoccomment"> * Takes a X509 certificate, computes its thumbprint using SHA-1, converts</em>
-<a name="343" href="#343">343</a> <em class="jxr_javadoccomment"> * into base 64 and inserts it into a <code>wsse:KeyIdentifier</code></em>
-<a name="344" href="#344">344</a> <em class="jxr_javadoccomment"> * element, which is placed in the <code>wsse:SecurityTokenReference</code></em>
-<a name="345" href="#345">345</a> <em class="jxr_javadoccomment"> * element.</em>
-<a name="346" href="#346">346</a> <em class="jxr_javadoccomment"> * </em>
-<a name="347" href="#347">347</a> <em class="jxr_javadoccomment"> * @param cert is the X509 certificate to get the thumbprint</em>
-<a name="348" href="#348">348</a> <em class="jxr_javadoccomment"> */</em>
-<a name="349" href="#349">349</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> setKeyIdentifierThumb(X509Certificate cert) <strong class="jxr_keyword">throws</strong> WSSecurityException {
-<a name="350" href="#350">350</a> Document doc = <strong class="jxr_keyword">this</strong>.element.getOwnerDocument();
-<a name="351" href="#351">351</a> MessageDigest sha = <strong class="jxr_keyword">null</strong>;
-<a name="352" href="#352">352</a> <strong class="jxr_keyword">try</strong> {
-<a name="353" href="#353">353</a> sha = MessageDigest.getInstance(<span class="jxr_string">"SHA-1"</span>);
-<a name="354" href="#354">354</a> } <strong class="jxr_keyword">catch</strong> (NoSuchAlgorithmException e1) {
-<a name="355" href="#355">355</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="356" href="#356">356</a> WSSecurityException.FAILURE, <span class="jxr_string">"noSHA1availabe"</span>, <strong class="jxr_keyword">null</strong>, e1
-<a name="357" href="#357">357</a> );
-<a name="358" href="#358">358</a> }
-<a name="359" href="#359">359</a> sha.reset();
-<a name="360" href="#360">360</a> <strong class="jxr_keyword">try</strong> {
-<a name="361" href="#361">361</a> sha.update(cert.getEncoded());
-<a name="362" href="#362">362</a> } <strong class="jxr_keyword">catch</strong> (CertificateEncodingException e1) {
-<a name="363" href="#363">363</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="364" href="#364">364</a> WSSecurityException.SECURITY_TOKEN_UNAVAILABLE, <span class="jxr_string">"encodeError"</span>, <strong class="jxr_keyword">null</strong>, e1
-<a name="365" href="#365">365</a> );
-<a name="366" href="#366">366</a> }
-<a name="367" href="#367">367</a> byte[] data = sha.digest();
-<a name="368" href="#368">368</a>
-<a name="369" href="#369">369</a> org.w3c.dom.Text text = doc.createTextNode(Base64.encode(data));
-<a name="370" href="#370">370</a> createKeyIdentifier(doc, THUMB_URI, text, <strong class="jxr_keyword">true</strong>);
-<a name="371" href="#371">371</a> }
-<a name="372" href="#372">372</a>
-<a name="373" href="#373">373</a>
-<a name="374" href="#374">374</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> setKeyIdentifierEncKeySHA1(String value) <strong class="jxr_keyword">throws</strong> WSSecurityException {
-<a name="375" href="#375">375</a> Document doc = <strong class="jxr_keyword">this</strong>.element.getOwnerDocument();
-<a name="376" href="#376">376</a> org.w3c.dom.Text text = doc.createTextNode(value);
-<a name="377" href="#377">377</a> createKeyIdentifier(doc, ENC_KEY_SHA1_URI, text, <strong class="jxr_keyword">true</strong>);
-<a name="378" href="#378">378</a> }
-<a name="379" href="#379">379</a>
-<a name="380" href="#380">380</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> setSAMLKeyIdentifier(String keyIdVal) <strong class="jxr_keyword">throws</strong> WSSecurityException {
-<a name="381" href="#381">381</a> Document doc = <strong class="jxr_keyword">this</strong>.element.getOwnerDocument();
-<a name="382" href="#382">382</a> createKeyIdentifier(doc, SAML_ID_URI, doc.createTextNode(keyIdVal), false);
-<a name="383" href="#383">383</a> }
-<a name="384" href="#384">384</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> setKeyIdentifier(String valueType, String keyIdVal) <strong class="jxr_keyword">throws</strong> WSSecurityException {
-<a name="385" href="#385">385</a> Document doc = <strong class="jxr_keyword">this</strong>.element.getOwnerDocument();
-<a name="386" href="#386">386</a> createKeyIdentifier(doc, valueType, doc.createTextNode(keyIdVal), false);
-<a name="387" href="#387">387</a> }
-<a name="388" href="#388">388</a>
-<a name="389" href="#389">389</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> createKeyIdentifier(Document doc, String uri, Node node, <strong class="jxr_keyword">boolean</strong> base64) {
-<a name="390" href="#390">390</a> Element keyId = doc.createElementNS(WSConstants.WSSE_NS, <span class="jxr_string">"wsse:KeyIdentifier"</span>);
-<a name="391" href="#391">391</a> keyId.setAttributeNS(<strong class="jxr_keyword">null</strong>, <span class="jxr_string">"ValueType"</span>, uri);
-<a name="392" href="#392">392</a> <strong class="jxr_keyword">if</strong> (base64) {
-<a name="393" href="#393">393</a> keyId.setAttributeNS(<strong class="jxr_keyword">null</strong>, <span class="jxr_string">"EncodingType"</span>, BinarySecurity.BASE64_ENCODING);
-<a name="394" href="#394">394</a> }
-<a name="395" href="#395">395</a>
-<a name="396" href="#396">396</a> keyId.appendChild(node);
-<a name="397" href="#397">397</a> Element elem = getFirstElement();
-<a name="398" href="#398">398</a> <strong class="jxr_keyword">if</strong> (elem != <strong class="jxr_keyword">null</strong>) {
-<a name="399" href="#399">399</a> <strong class="jxr_keyword">this</strong>.element.replaceChild(keyId, elem);
-<a name="400" href="#400">400</a> } <strong class="jxr_keyword">else</strong> {
-<a name="401" href="#401">401</a> <strong class="jxr_keyword">this</strong>.element.appendChild(keyId);
-<a name="402" href="#402">402</a> }
-<a name="403" href="#403">403</a> }
-<a name="404" href="#404">404</a>
-<a name="405" href="#405">405</a>
-<a name="406" href="#406">406</a> <em class="jxr_javadoccomment">/**</em>
-<a name="407" href="#407">407</a> <em class="jxr_javadoccomment"> * get the first child element.</em>
-<a name="408" href="#408">408</a> <em class="jxr_javadoccomment"> *</em>
-<a name="409" href="#409">409</a> <em class="jxr_javadoccomment"> * @return the first <code>Element</code> child node</em>
-<a name="410" href="#410">410</a> <em class="jxr_javadoccomment"> */</em>
-<a name="411" href="#411">411</a> <strong class="jxr_keyword">public</strong> Element getFirstElement() {
-<a name="412" href="#412">412</a> <strong class="jxr_keyword">for</strong> (Node currentChild = <strong class="jxr_keyword">this</strong>.element.getFirstChild();
-<a name="413" href="#413">413</a> currentChild != <strong class="jxr_keyword">null</strong>;
-<a name="414" href="#414">414</a> currentChild = currentChild.getNextSibling()
-<a name="415" href="#415">415</a> ) {
-<a name="416" href="#416">416</a> <strong class="jxr_keyword">if</strong> (currentChild instanceof Element) {
-<a name="417" href="#417">417</a> <strong class="jxr_keyword">return</strong> (Element) currentChild;
-<a name="418" href="#418">418</a> }
-<a name="419" href="#419">419</a> }
-<a name="420" href="#420">420</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
-<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"> * Gets the KeyIdentifier.</em>
-<a name="425" href="#425">425</a> <em class="jxr_javadoccomment"> *</em>
-<a name="426" href="#426">426</a> <em class="jxr_javadoccomment"> * @return the the X509 certificate or zero if a unknown key identifier</em>
-<a name="427" href="#427">427</a> <em class="jxr_javadoccomment"> * type was detected.</em>
-<a name="428" href="#428">428</a> <em class="jxr_javadoccomment"> */</em>
-<a name="429" href="#429">429</a> <strong class="jxr_keyword">public</strong> X509Certificate[] getKeyIdentifier(<a href="../../../../../../org/apache/ws/security/components/crypto/Crypto.html">Crypto</a> crypto) <strong class="jxr_keyword">throws</strong> WSSecurityException {
-<a name="430" href="#430">430</a> Element elem = getFirstElement();
-<a name="431" href="#431">431</a> String value = elem.getAttribute(<span class="jxr_string">"ValueType"</span>);
-<a name="432" href="#432">432</a> String alias = <strong class="jxr_keyword">null</strong>;
-<a name="433" href="#433">433</a>
-<a name="434" href="#434">434</a> <strong class="jxr_keyword">if</strong> (X509Security.X509_V3_TYPE.equals(value)) {
-<a name="435" href="#435">435</a> X509Security token = <strong class="jxr_keyword">new</strong> X509Security(elem);
-<a name="436" href="#436">436</a> <strong class="jxr_keyword">if</strong> (token != <strong class="jxr_keyword">null</strong>) {
-<a name="437" href="#437">437</a> X509Certificate cert = token.getX509Certificate(crypto);
-<a name="438" href="#438">438</a> X509Certificate[] certs = <strong class="jxr_keyword">new</strong> X509Certificate[1];
-<a name="439" href="#439">439</a> certs[0] = cert;
-<a name="440" href="#440">440</a> <strong class="jxr_keyword">return</strong> certs;
-<a name="441" href="#441">441</a> }
-<a name="442" href="#442">442</a> } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (SKI_URI.equals(value)) {
-<a name="443" href="#443">443</a> alias = getX509SKIAlias(crypto);
-<a name="444" href="#444">444</a> } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (THUMB_URI.equals(value)) {
-<a name="445" href="#445">445</a> Node node = getFirstElement().getFirstChild();
-<a name="446" href="#446">446</a> <strong class="jxr_keyword">if</strong> (node == <strong class="jxr_keyword">null</strong>) {
-<a name="447" href="#447">447</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
-<a name="448" href="#448">448</a> }
-<a name="449" href="#449">449</a> <strong class="jxr_keyword">if</strong> (node.getNodeType() == Node.TEXT_NODE) {
-<a name="450" href="#450">450</a> byte[] thumb = Base64.decode(((Text) node).getData());
-<a name="451" href="#451">451</a> alias = crypto.getAliasForX509CertThumb(thumb);
-<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> <strong class="jxr_keyword">if</strong> (alias != <strong class="jxr_keyword">null</strong>) {
-<a name="456" href="#456">456</a> <strong class="jxr_keyword">return</strong> crypto.getCertificates(alias);
-<a name="457" href="#457">457</a> }
-<a name="458" href="#458">458</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
-<a name="459" href="#459">459</a> }
-<a name="460" href="#460">460</a>
-<a name="461" href="#461">461</a> <strong class="jxr_keyword">public</strong> String getKeyIdentifierValue() {
-<a name="462" href="#462">462</a> <strong class="jxr_keyword">if</strong> (containsKeyIdentifier()) {
-<a name="463" href="#463">463</a> Node node = getFirstElement().getFirstChild();
-<a name="464" href="#464">464</a> <strong class="jxr_keyword">if</strong> (node == <strong class="jxr_keyword">null</strong>) {
-<a name="465" href="#465">465</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
-<a name="466" href="#466">466</a> }
-<a name="467" href="#467">467</a> <strong class="jxr_keyword">if</strong> (node.getNodeType() == Node.TEXT_NODE) {
-<a name="468" href="#468">468</a> <strong class="jxr_keyword">return</strong> ((Text) node).getData();
-<a name="469" href="#469">469</a> }
-<a name="470" href="#470">470</a> }
-<a name="471" href="#471">471</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
-<a name="472" href="#472">472</a> }
-<a name="473" href="#473">473</a>
-<a name="474" href="#474">474</a> <strong class="jxr_keyword">public</strong> String getKeyIdentifierValueType() {
-<a name="475" href="#475">475</a> <strong class="jxr_keyword">if</strong> (containsKeyIdentifier()) {
-<a name="476" href="#476">476</a> Element elem = getFirstElement();
-<a name="477" href="#477">477</a> <strong class="jxr_keyword">return</strong> elem.getAttribute(<span class="jxr_string">"ValueType"</span>);
-<a name="478" href="#478">478</a> }
-<a name="479" href="#479">479</a> <strong class="jxr_keyword">return</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>
-<a name="483" href="#483">483</a> <strong class="jxr_keyword">public</strong> String getX509SKIAlias(<a href="../../../../../../org/apache/ws/security/components/crypto/Crypto.html">Crypto</a> crypto) <strong class="jxr_keyword">throws</strong> WSSecurityException {
-<a name="484" href="#484">484</a> <strong class="jxr_keyword">if</strong> (skiBytes == <strong class="jxr_keyword">null</strong>) {
-<a name="485" href="#485">485</a> skiBytes = getSKIBytes();
-<a name="486" href="#486">486</a> <strong class="jxr_keyword">if</strong> (skiBytes == <strong class="jxr_keyword">null</strong>) {
-<a name="487" href="#487">487</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
-<a name="488" href="#488">488</a> }
-<a name="489" href="#489">489</a> }
-<a name="490" href="#490">490</a> String alias = crypto.getAliasForX509Cert(skiBytes);
-<a name="491" href="#491">491</a> <strong class="jxr_keyword">if</strong> (doDebug) {
-<a name="492" href="#492">492</a> log.info(<span class="jxr_string">"X509 SKI alias: "</span> + alias);
-<a name="493" href="#493">493</a> }
-<a name="494" href="#494">494</a> <strong class="jxr_keyword">return</strong> alias;
-<a name="495" href="#495">495</a> }
-<a name="496" href="#496">496</a>
-<a name="497" href="#497">497</a> <strong class="jxr_keyword">public</strong> byte[] getSKIBytes() {
-<a name="498" href="#498">498</a> <strong class="jxr_keyword">if</strong> (skiBytes != <strong class="jxr_keyword">null</strong>) {
-<a name="499" href="#499">499</a> <strong class="jxr_keyword">return</strong> skiBytes;
-<a name="500" href="#500">500</a> }
-<a name="501" href="#501">501</a> Node node = getFirstElement().getFirstChild();
-<a name="502" href="#502">502</a> <strong class="jxr_keyword">if</strong> (node == <strong class="jxr_keyword">null</strong>) {
-<a name="503" href="#503">503</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
-<a name="504" href="#504">504</a> }
-<a name="505" href="#505">505</a> <strong class="jxr_keyword">if</strong> (node.getNodeType() == Node.TEXT_NODE) {
-<a name="506" href="#506">506</a> <strong class="jxr_keyword">try</strong> {
-<a name="507" href="#507">507</a> skiBytes = Base64.decode(((Text) node).getData());
-<a name="508" href="#508">508</a> } <strong class="jxr_keyword">catch</strong> (WSSecurityException e) {
-<a name="509" href="#509">509</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
-<a name="510" href="#510">510</a> }
-<a name="511" href="#511">511</a> }
-<a name="512" href="#512">512</a> <strong class="jxr_keyword">return</strong> skiBytes;
-<a name="513" href="#513">513</a> }
-<a name="514" href="#514">514</a>
+<a name="286" href="#286">286</a>
+<a name="287" href="#287">287</a> <em class="jxr_javadoccomment">/**</em>
+<a name="288" href="#288">288</a> <em class="jxr_javadoccomment"> * Sets the KeyIdentifier Element as a X509 certificate.</em>
+<a name="289" href="#289">289</a> <em class="jxr_javadoccomment"> * Takes a X509 certificate, converts its data into base 64 and inserts</em>
+<a name="290" href="#290">290</a> <em class="jxr_javadoccomment"> * it into a <code>wsse:KeyIdentifier</code> element, which is placed</em>
+<a name="291" href="#291">291</a> <em class="jxr_javadoccomment"> * in the <code>wsse:SecurityTokenReference</code> element.</em>
+<a name="292" href="#292">292</a> <em class="jxr_javadoccomment"> *</em>
+<a name="293" href="#293">293</a> <em class="jxr_javadoccomment"> * @param cert is the X509 certificate to be inserted as key identifier</em>
+<a name="294" href="#294">294</a> <em class="jxr_javadoccomment"> */</em>
+<a name="295" href="#295">295</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> setKeyIdentifier(X509Certificate cert)
+<a name="296" href="#296">296</a> <strong class="jxr_keyword">throws</strong> <a href="../../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a> {
+<a name="297" href="#297">297</a> Document doc = <strong class="jxr_keyword">this</strong>.element.getOwnerDocument();
+<a name="298" href="#298">298</a> byte data[] = <strong class="jxr_keyword">null</strong>;
+<a name="299" href="#299">299</a> <strong class="jxr_keyword">try</strong> {
+<a name="300" href="#300">300</a> data = cert.getEncoded();
+<a name="301" href="#301">301</a> } <strong class="jxr_keyword">catch</strong> (CertificateEncodingException e) {
+<a name="302" href="#302">302</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a>(
+<a name="303" href="#303">303</a> WSSecurityException.SECURITY_TOKEN_UNAVAILABLE, <span class="jxr_string">"encodeError"</span>, <strong class="jxr_keyword">null</strong>, e
+<a name="304" href="#304">304</a> );
+<a name="305" href="#305">305</a> }
+<a name="306" href="#306">306</a> Text text = doc.createTextNode(Base64.encode(data));
+<a name="307" href="#307">307</a>
+<a name="308" href="#308">308</a> createKeyIdentifier(doc, X509Security.X509_V3_TYPE, text, <strong class="jxr_keyword">true</strong>);
+<a name="309" href="#309">309</a> }
+<a name="310" href="#310">310</a>
+<a name="311" href="#311">311</a> <em class="jxr_javadoccomment">/**</em>
+<a name="312" href="#312">312</a> <em class="jxr_javadoccomment"> * Sets the KeyIdentifier Element as a X509 Subject-Key-Identifier (SKI).</em>
+<a name="313" href="#313">313</a> <em class="jxr_javadoccomment"> * Takes a X509 certificate, gets it SKI data, converts into base 64 and</em>
+<a name="314" href="#314">314</a> <em class="jxr_javadoccomment"> * inserts it into a <code>wsse:KeyIdentifier</code> element, which is placed</em>
+<a name="315" href="#315">315</a> <em class="jxr_javadoccomment"> * in the <code>wsse:SecurityTokenReference</code> element.</em>
+<a name="316" href="#316">316</a> <em class="jxr_javadoccomment"> *</em>
+<a name="317" href="#317">317</a> <em class="jxr_javadoccomment"> * @param cert is the X509 certificate to get the SKI</em>
+<a name="318" href="#318">318</a> <em class="jxr_javadoccomment"> * @param crypto is the Crypto implementation. Used to read SKI info bytes from certificate</em>
+<a name="319" href="#319">319</a> <em class="jxr_javadoccomment"> */</em>
+<a name="320" href="#320">320</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> setKeyIdentifierSKI(X509Certificate cert, <a href="../../../../../../org/apache/ws/security/components/crypto/Crypto.html">Crypto</a> crypto)
+<a name="321" href="#321">321</a> <strong class="jxr_keyword">throws</strong> <a href="../../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a> {
+<a name="322" href="#322">322</a> <em class="jxr_comment">//</em>
+<a name="323" href="#323">323</a> <em class="jxr_comment">// As per the 1.1 specification, SKI can only be used for a V3 certificate</em>
+<a name="324" href="#324">324</a> <em class="jxr_comment">//</em>
+<a name="325" href="#325">325</a> <strong class="jxr_keyword">if</strong> (cert.getVersion() != 3) {
+<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>(
+<a name="327" href="#327">327</a> WSSecurityException.UNSUPPORTED_SECURITY_TOKEN,
+<a name="328" href="#328">328</a> <span class="jxr_string">"invalidCertForSKI"</span>,
+<a name="329" href="#329">329</a> <strong class="jxr_keyword">new</strong> Object[]{<strong class="jxr_keyword">new</strong> Integer(cert.getVersion())}
+<a name="330" href="#330">330</a> );
+<a name="331" href="#331">331</a> }
+<a name="332" href="#332">332</a>
+<a name="333" href="#333">333</a> Document doc = <strong class="jxr_keyword">this</strong>.element.getOwnerDocument();
+<a name="334" href="#334">334</a> byte data[] = crypto.getSKIBytesFromCert(cert);
+<a name="335" href="#335">335</a>
+<a name="336" href="#336">336</a> org.w3c.dom.Text text = doc.createTextNode(Base64.encode(data));
+<a name="337" href="#337">337</a> createKeyIdentifier(doc, SKI_URI, text, <strong class="jxr_keyword">true</strong>);
+<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"> * Sets the KeyIdentifier Element as a Thumbprint.</em>
+<a name="342" href="#342">342</a> <em class="jxr_javadoccomment"> * </em>
+<a name="343" href="#343">343</a> <em class="jxr_javadoccomment"> * Takes a X509 certificate, computes its thumbprint using SHA-1, converts</em>
+<a name="344" href="#344">344</a> <em class="jxr_javadoccomment"> * into base 64 and inserts it into a <code>wsse:KeyIdentifier</code></em>
+<a name="345" href="#345">345</a> <em class="jxr_javadoccomment"> * element, which is placed in the <code>wsse:SecurityTokenReference</code></em>
+<a name="346" href="#346">346</a> <em class="jxr_javadoccomment"> * element.</em>
+<a name="347" href="#347">347</a> <em class="jxr_javadoccomment"> * </em>
+<a name="348" href="#348">348</a> <em class="jxr_javadoccomment"> * @param cert is the X509 certificate to get the thumbprint</em>
+<a name="349" href="#349">349</a> <em class="jxr_javadoccomment"> */</em>
+<a name="350" href="#350">350</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> setKeyIdentifierThumb(X509Certificate cert) <strong class="jxr_keyword">throws</strong> WSSecurityException {
+<a name="351" href="#351">351</a> Document doc = <strong class="jxr_keyword">this</strong>.element.getOwnerDocument();
+<a name="352" href="#352">352</a> MessageDigest sha = <strong class="jxr_keyword">null</strong>;
+<a name="353" href="#353">353</a> <strong class="jxr_keyword">try</strong> {
+<a name="354" href="#354">354</a> sha = MessageDigest.getInstance(<span class="jxr_string">"SHA-1"</span>);
+<a name="355" href="#355">355</a> } <strong class="jxr_keyword">catch</strong> (NoSuchAlgorithmException e1) {
+<a name="356" href="#356">356</a> <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a>(
+<a name="357" href="#357">357</a> WSSecurityException.FAILURE, <span class="jxr_string">"noSHA1availabe"</span>, <strong class="jxr_keyword">null</strong>, e1
+<a name="358" href="#358">358</a> );
+<a name="359" href="#359">359</a> }
+<a name="360" href="#360">360</a> sha.reset();
+<a name="361" href="#361">361</a> <strong class="jxr_keyword">try</strong> {
+<a name="362" href="#362">362</a> sha.update(cert.getEncoded());
+<a name="363" href="#363">363</a> } <strong class="jxr_keyword">catch</strong> (CertificateEncodingException e1) {
+<a name="364" href="#364">364</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="365" href="#365">365</a> WSSecurityException.SECURITY_TOKEN_UNAVAILABLE, <span class="jxr_string">"encodeError"</span>, <strong class="jxr_keyword">null</strong>, e1
+<a name="366" href="#366">366</a> );
+<a name="367" href="#367">367</a> }
+<a name="368" href="#368">368</a> byte[] data = sha.digest();
+<a name="369" href="#369">369</a>
+<a name="370" href="#370">370</a> org.w3c.dom.Text text = doc.createTextNode(Base64.encode(data));
+<a name="371" href="#371">371</a> createKeyIdentifier(doc, THUMB_URI, text, <strong class="jxr_keyword">true</strong>);
+<a name="372" href="#372">372</a> }
+<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">public</strong> <strong class="jxr_keyword">void</strong> setKeyIdentifierEncKeySHA1(String value) <strong class="jxr_keyword">throws</strong> WSSecurityException {
+<a name="376" href="#376">376</a> Document doc = <strong class="jxr_keyword">this</strong>.element.getOwnerDocument();
+<a name="377" href="#377">377</a> org.w3c.dom.Text text = doc.createTextNode(value);
+<a name="378" href="#378">378</a> createKeyIdentifier(doc, ENC_KEY_SHA1_URI, text, <strong class="jxr_keyword">true</strong>);
+<a name="379" href="#379">379</a> }
+<a name="380" href="#380">380</a>
+<a name="381" href="#381">381</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> setSAMLKeyIdentifier(String keyIdVal) <strong class="jxr_keyword">throws</strong> WSSecurityException {
+<a name="382" href="#382">382</a> Document doc = <strong class="jxr_keyword">this</strong>.element.getOwnerDocument();
+<a name="383" href="#383">383</a> createKeyIdentifier(doc, SAML_ID_URI, doc.createTextNode(keyIdVal), false);
+<a name="384" href="#384">384</a> }
+<a name="385" href="#385">385</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> setKeyIdentifier(String valueType, String keyIdVal) <strong class="jxr_keyword">throws</strong> WSSecurityException {
+<a name="386" href="#386">386</a> Document doc = <strong class="jxr_keyword">this</strong>.element.getOwnerDocument();
+<a name="387" href="#387">387</a> createKeyIdentifier(doc, valueType, doc.createTextNode(keyIdVal), false);
+<a name="388" href="#388">388</a> }
+<a name="389" href="#389">389</a>
+<a name="390" href="#390">390</a> <strong class="jxr_keyword">private</strong> <strong class="jxr_keyword">void</strong> createKeyIdentifier(Document doc, String uri, Node node, <strong class="jxr_keyword">boolean</strong> base64) {
+<a name="391" href="#391">391</a> Element keyId = doc.createElementNS(WSConstants.WSSE_NS, <span class="jxr_string">"wsse:KeyIdentifier"</span>);
+<a name="392" href="#392">392</a> keyId.setAttributeNS(<strong class="jxr_keyword">null</strong>, <span class="jxr_string">"ValueType"</span>, uri);
+<a name="393" href="#393">393</a> <strong class="jxr_keyword">if</strong> (base64) {
+<a name="394" href="#394">394</a> keyId.setAttributeNS(<strong class="jxr_keyword">null</strong>, <span class="jxr_string">"EncodingType"</span>, BinarySecurity.BASE64_ENCODING);
+<a name="395" href="#395">395</a> }
+<a name="396" href="#396">396</a>
+<a name="397" href="#397">397</a> keyId.appendChild(node);
+<a name="398" href="#398">398</a> Element elem = getFirstElement();
+<a name="399" href="#399">399</a> <strong class="jxr_keyword">if</strong> (elem != <strong class="jxr_keyword">null</strong>) {
+<a name="400" href="#400">400</a> <strong class="jxr_keyword">this</strong>.element.replaceChild(keyId, elem);
+<a name="401" href="#401">401</a> } <strong class="jxr_keyword">else</strong> {
+<a name="402" href="#402">402</a> <strong class="jxr_keyword">this</strong>.element.appendChild(keyId);
+<a name="403" href="#403">403</a> }
+<a name="404" href="#404">404</a> }
+<a name="405" href="#405">405</a>
+<a name="406" href="#406">406</a>
+<a name="407" href="#407">407</a> <em class="jxr_javadoccomment">/**</em>
+<a name="408" href="#408">408</a> <em class="jxr_javadoccomment"> * get the first child element.</em>
+<a name="409" href="#409">409</a> <em class="jxr_javadoccomment"> *</em>
+<a name="410" href="#410">410</a> <em class="jxr_javadoccomment"> * @return the first <code>Element</code> child node</em>
+<a name="411" href="#411">411</a> <em class="jxr_javadoccomment"> */</em>
+<a name="412" href="#412">412</a> <strong class="jxr_keyword">public</strong> Element getFirstElement() {
+<a name="413" href="#413">413</a> <strong class="jxr_keyword">for</strong> (Node currentChild = <strong class="jxr_keyword">this</strong>.element.getFirstChild();
+<a name="414" href="#414">414</a> currentChild != <strong class="jxr_keyword">null</strong>;
+<a name="415" href="#415">415</a> currentChild = currentChild.getNextSibling()
+<a name="416" href="#416">416</a> ) {
+<a name="417" href="#417">417</a> <strong class="jxr_keyword">if</strong> (currentChild instanceof Element) {
+<a name="418" href="#418">418</a> <strong class="jxr_keyword">return</strong> (Element) currentChild;
+<a name="419" href="#419">419</a> }
+<a name="420" href="#420">420</a> }
+<a name="421" href="#421">421</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
+<a name="422" href="#422">422</a> }
+<a name="423" href="#423">423</a>
+<a name="424" href="#424">424</a> <em class="jxr_javadoccomment">/**</em>
+<a name="425" href="#425">425</a> <em class="jxr_javadoccomment"> * Gets the KeyIdentifier.</em>
+<a name="426" href="#426">426</a> <em class="jxr_javadoccomment"> *</em>
+<a name="427" href="#427">427</a> <em class="jxr_javadoccomment"> * @return the the X509 certificate or zero if a unknown key identifier</em>
+<a name="428" href="#428">428</a> <em class="jxr_javadoccomment"> * type was detected.</em>
+<a name="429" href="#429">429</a> <em class="jxr_javadoccomment"> */</em>
+<a name="430" href="#430">430</a> <strong class="jxr_keyword">public</strong> X509Certificate[] getKeyIdentifier(<a href="../../../../../../org/apache/ws/security/components/crypto/Crypto.html">Crypto</a> crypto) <strong class="jxr_keyword">throws</strong> WSSecurityException {
+<a name="431" href="#431">431</a> Element elem = getFirstElement();
+<a name="432" href="#432">432</a> String value = elem.getAttribute(<span class="jxr_string">"ValueType"</span>);
+<a name="433" href="#433">433</a> String alias = <strong class="jxr_keyword">null</strong>;
+<a name="434" href="#434">434</a>
+<a name="435" href="#435">435</a> <strong class="jxr_keyword">if</strong> (X509Security.X509_V3_TYPE.equals(value)) {
+<a name="436" href="#436">436</a> X509Security token = <strong class="jxr_keyword">new</strong> X509Security(elem);
+<a name="437" href="#437">437</a> <strong class="jxr_keyword">if</strong> (token != <strong class="jxr_keyword">null</strong>) {
+<a name="438" href="#438">438</a> X509Certificate cert = token.getX509Certificate(crypto);
+<a name="439" href="#439">439</a> X509Certificate[] certs = <strong class="jxr_keyword">new</strong> X509Certificate[1];
+<a name="440" href="#440">440</a> certs[0] = cert;
+<a name="441" href="#441">441</a> <strong class="jxr_keyword">return</strong> certs;
+<a name="442" href="#442">442</a> }
+<a name="443" href="#443">443</a> } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (SKI_URI.equals(value)) {
+<a name="444" href="#444">444</a> alias = getX509SKIAlias(crypto);
+<a name="445" href="#445">445</a> } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (THUMB_URI.equals(value)) {
+<a name="446" href="#446">446</a> Node node = getFirstElement().getFirstChild();
+<a name="447" href="#447">447</a> <strong class="jxr_keyword">if</strong> (node == <strong class="jxr_keyword">null</strong>) {
+<a name="448" href="#448">448</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
+<a name="449" href="#449">449</a> }
+<a name="450" href="#450">450</a> <strong class="jxr_keyword">if</strong> (node.getNodeType() == Node.TEXT_NODE) {
+<a name="451" href="#451">451</a> byte[] thumb = Base64.decode(((Text) node).getData());
+<a name="452" href="#452">452</a> alias = crypto.getAliasForX509CertThumb(thumb);
+<a name="453" href="#453">453</a> }
+<a name="454" href="#454">454</a> }
+<a name="455" href="#455">455</a>
+<a name="456" href="#456">456</a> <strong class="jxr_keyword">if</strong> (alias != <strong class="jxr_keyword">null</strong>) {
+<a name="457" href="#457">457</a> <strong class="jxr_keyword">return</strong> crypto.getCertificates(alias);
+<a name="458" href="#458">458</a> }
+<a name="459" href="#459">459</a> <strong class="jxr_keyword">return</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> <strong class="jxr_keyword">public</strong> String getKeyIdentifierValue() {
+<a name="463" href="#463">463</a> <strong class="jxr_keyword">if</strong> (containsKeyIdentifier()) {
+<a name="464" href="#464">464</a> Node node = getFirstElement().getFirstChild();
+<a name="465" href="#465">465</a> <strong class="jxr_keyword">if</strong> (node == <strong class="jxr_keyword">null</strong>) {
+<a name="466" href="#466">466</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
+<a name="467" href="#467">467</a> }
+<a name="468" href="#468">468</a> <strong class="jxr_keyword">if</strong> (node.getNodeType() == Node.TEXT_NODE) {
+<a name="469" href="#469">469</a> <strong class="jxr_keyword">return</strong> ((Text) node).getData();
+<a name="470" href="#470">470</a> }
+<a name="471" href="#471">471</a> }
+<a name="472" href="#472">472</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
+<a name="473" href="#473">473</a> }
+<a name="474" href="#474">474</a>
+<a name="475" href="#475">475</a> <strong class="jxr_keyword">public</strong> String getKeyIdentifierValueType() {
+<a name="476" href="#476">476</a> <strong class="jxr_keyword">if</strong> (containsKeyIdentifier()) {
+<a name="477" href="#477">477</a> Element elem = getFirstElement();
+<a name="478" href="#478">478</a> <strong class="jxr_keyword">return</strong> elem.getAttribute(<span class="jxr_string">"ValueType"</span>);
+<a name="479" href="#479">479</a> }
+<a name="480" href="#480">480</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
+<a name="481" href="#481">481</a> }
+<a name="482" href="#482">482</a>
+<a name="483" href="#483">483</a>
+<a name="484" href="#484">484</a> <strong class="jxr_keyword">public</strong> String getX509SKIAlias(<a href="../../../../../../org/apache/ws/security/components/crypto/Crypto.html">Crypto</a> crypto) <strong class="jxr_keyword">throws</strong> WSSecurityException {
+<a name="485" href="#485">485</a> <strong class="jxr_keyword">if</strong> (skiBytes == <strong class="jxr_keyword">null</strong>) {
+<a name="486" href="#486">486</a> skiBytes = getSKIBytes();
+<a name="487" href="#487">487</a> <strong class="jxr_keyword">if</strong> (skiBytes == <strong class="jxr_keyword">null</strong>) {
+<a name="488" href="#488">488</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
+<a name="489" href="#489">489</a> }
+<a name="490" href="#490">490</a> }
+<a name="491" href="#491">491</a> String alias = crypto.getAliasForX509Cert(skiBytes);
+<a name="492" href="#492">492</a> <strong class="jxr_keyword">if</strong> (doDebug) {
+<a name="493" href="#493">493</a> log.info(<span class="jxr_string">"X509 SKI alias: "</span> + alias);
+<a name="494" href="#494">494</a> }
+<a name="495" href="#495">495</a> <strong class="jxr_keyword">return</strong> alias;
+<a name="496" href="#496">496</a> }
+<a name="497" href="#497">497</a>
+<a name="498" href="#498">498</a> <strong class="jxr_keyword">public</strong> byte[] getSKIBytes() {
+<a name="499" href="#499">499</a> <strong class="jxr_keyword">if</strong> (skiBytes != <strong class="jxr_keyword">null</strong>) {
+<a name="500" href="#500">500</a> <strong class="jxr_keyword">return</strong> skiBytes;
+<a name="501" href="#501">501</a> }
+<a name="502" href="#502">502</a> Node node = getFirstElement().getFirstChild();
+<a name="503" href="#503">503</a> <strong class="jxr_keyword">if</strong> (node == <strong class="jxr_keyword">null</strong>) {
+<a name="504" href="#504">504</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
+<a name="505" href="#505">505</a> }
+<a name="506" href="#506">506</a> <strong class="jxr_keyword">if</strong> (node.getNodeType() == Node.TEXT_NODE) {
+<a name="507" href="#507">507</a> <strong class="jxr_keyword">try</strong> {
+<a name="508" href="#508">508</a> skiBytes = Base64.decode(((Text) node).getData());
+<a name="509" href="#509">509</a> } <strong class="jxr_keyword">catch</strong> (WSSecurityException e) {
+<a name="510" href="#510">510</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
+<a name="511" href="#511">511</a> }
+<a name="512" href="#512">512</a> }
+<a name="513" href="#513">513</a> <strong class="jxr_keyword">return</strong> skiBytes;
+<a name="514" href="#514">514</a> }
<a name="515" href="#515">515</a>
-<a name="516" href="#516">516</a> <em class="jxr_javadoccomment">/**</em>
-<a name="517" href="#517">517</a> <em class="jxr_javadoccomment"> * Sets the X509 IssuerSerial data.</em>
-<a name="518" href="#518">518</a> <em class="jxr_javadoccomment"> *</em>
-<a name="519" href="#519">519</a> <em class="jxr_javadoccomment"> * @param ref the {@link XMLX509IssuerSerial} to put into this</em>
-<a name="520" href="#520">520</a> <em class="jxr_javadoccomment"> * SecurityTokenReference</em>
-<a name="521" href="#521">521</a> <em class="jxr_javadoccomment"> */</em>
-<a name="522" href="#522">522</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> setX509IssuerSerial(X509Data ref) {
-<a name="523" href="#523">523</a> Element elem = getFirstElement();
-<a name="524" href="#524">524</a> <strong class="jxr_keyword">if</strong> (elem != <strong class="jxr_keyword">null</strong>) {
-<a name="525" href="#525">525</a> <strong class="jxr_keyword">this</strong>.element.replaceChild(ref.getElement(), elem);
-<a name="526" href="#526">526</a> } <strong class="jxr_keyword">else</strong> {
-<a name="527" href="#527">527</a> <strong class="jxr_keyword">this</strong>.element.appendChild(ref.getElement());
-<a name="528" href="#528">528</a> }
-<a name="529" href="#529">529</a> }
-<a name="530" href="#530">530</a>
-<a name="531" href="#531">531</a> <em class="jxr_javadoccomment">/**</em>
-<a name="532" href="#532">532</a> <em class="jxr_javadoccomment"> * Gets the certificate identified with X509 issuerSerial data.</em>
-<a name="533" href="#533">533</a> <em class="jxr_javadoccomment"> * This method first tries to get the embedded certificate.</em>
-<a name="534" href="#534">534</a> <em class="jxr_javadoccomment"> * If this fails it checks if the certificate is in the</em>
-<a name="535" href="#535">535</a> <em class="jxr_javadoccomment"> * keystore.</em>
-<a name="536" href="#536">536</a> <em class="jxr_javadoccomment"> *</em>
-<a name="537" href="#537">537</a> <em class="jxr_javadoccomment"> * @return a certificate array or null if nothing found</em>
-<a name="538" href="#538">538</a> <em class="jxr_javadoccomment"> */</em>
-<a name="539" href="#539">539</a> <strong class="jxr_keyword">public</strong> X509Certificate[] getX509IssuerSerial(<a href="../../../../../../org/apache/ws/security/components/crypto/Crypto.html">Crypto</a> crypto) <strong class="jxr_keyword">throws</strong> WSSecurityException {
-<a name="540" href="#540">540</a> String alias = getX509IssuerSerialAlias(crypto);
-<a name="541" href="#541">541</a> <strong class="jxr_keyword">if</strong> (alias != <strong class="jxr_keyword">null</strong>) {
-<a name="542" href="#542">542</a> <strong class="jxr_keyword">return</strong> crypto.getCertificates(alias);
-<a name="543" href="#543">543</a> }
-<a name="544" href="#544">544</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
-<a name="545" href="#545">545</a> }
-<a name="546" href="#546">546</a>
-<a name="547" href="#547">547</a> <em class="jxr_javadoccomment">/**</em>
-<a name="548" href="#548">548</a> <em class="jxr_javadoccomment"> * Gets the alias name of the certificate identified with X509 issuerSerial data.</em>
-<a name="549" href="#549">549</a> <em class="jxr_javadoccomment"> * The keystore identifies the certificate and the key with this alias name.</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 the alias name for the certificate or null if nothing found</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> String getX509IssuerSerialAlias(<a href="../../../../../../org/apache/ws/security/components/crypto/Crypto.html">Crypto</a> crypto) <strong class="jxr_keyword">throws</strong> WSSecurityException {
-<a name="554" href="#554">554</a> <strong class="jxr_keyword">if</strong> (issuerSerial == <strong class="jxr_keyword">null</strong>) {
-<a name="555" href="#555">555</a> issuerSerial = getIssuerSerial();
-<a name="556" href="#556">556</a> <strong class="jxr_keyword">if</strong> (issuerSerial == <strong class="jxr_keyword">null</strong>) {
-<a name="557" href="#557">557</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
-<a name="558" href="#558">558</a> }
-<a name="559" href="#559">559</a> }
-<a name="560" href="#560">560</a>
-<a name="561" href="#561">561</a> String alias =
-<a name="562" href="#562">562</a> crypto.getAliasForX509Cert(issuerSerial.getIssuerName(), issuerSerial.getSerialNumber());
-<a name="563" href="#563">563</a> <strong class="jxr_keyword">if</strong> (doDebug) {
-<a name="564" href="#564">564</a> log.info(<span class="jxr_string">"X509IssuerSerial alias: "</span> + alias);
-<a name="565" href="#565">565</a> }
-<a name="566" href="#566">566</a> <strong class="jxr_keyword">return</strong> alias;
-<a name="567" href="#567">567</a> }
-<a name="568" href="#568">568</a>
-<a name="569" href="#569">569</a> <strong class="jxr_keyword">private</strong> XMLX509IssuerSerial getIssuerSerial() <strong class="jxr_keyword">throws</strong> WSSecurityException {
-<a name="570" href="#570">570</a> <strong class="jxr_keyword">if</strong> (issuerSerial != <strong class="jxr_keyword">null</strong>) {
-<a name="571" href="#571">571</a> <strong class="jxr_keyword">return</strong> issuerSerial;
-<a name="572" href="#572">572</a> }
-<a name="573" href="#573">573</a> Element elem = getFirstElement();
-<a name="574" href="#574">574</a> <strong class="jxr_keyword">if</strong> (elem == <strong class="jxr_keyword">null</strong>) {
-<a name="575" href="#575">575</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
-<a name="576" href="#576">576</a> }
-<a name="577" href="#577">577</a> <strong class="jxr_keyword">try</strong> {
-<a name="578" href="#578">578</a> <strong class="jxr_keyword">if</strong> (Constants._TAG_X509DATA.equals(elem.getLocalName())) {
-<a name="579" href="#579">579</a> elem =
-<a name="580" href="#580">580</a> (Element)WSSecurityUtil.findElement(
-<a name="581" href="#581">581</a> elem, Constants._TAG_X509ISSUERSERIAL, Constants.SignatureSpecNS
-<a name="582" href="#582">582</a> );
-<a name="583" href="#583">583</a> }
-<a name="584" href="#584">584</a> issuerSerial = <strong class="jxr_keyword">new</strong> XMLX509IssuerSerial(elem, <span class="jxr_string">""</span>);
-<a name="585" href="#585">585</a> } <strong class="jxr_keyword">catch</strong> (XMLSecurityException e) {
-<a name="586" href="#586">586</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="587" href="#587">587</a> WSSecurityException.SECURITY_TOKEN_UNAVAILABLE,
-<a name="588" href="#588">588</a> <span class="jxr_string">"noToken"</span>,
-<a name="589" href="#589">589</a> <strong class="jxr_keyword">new</strong> Object[]{<span class="jxr_string">"Issuer/Serial data element missing"</span>},
-<a name="590" href="#590">590</a> e
-<a name="591" href="#591">591</a> );
-<a name="592" href="#592">592</a> }
-<a name="593" href="#593">593</a> <strong class="jxr_keyword">return</strong> issuerSerial;
-<a name="594" href="#594">594</a> }
-<a name="595" href="#595">595</a>
-<a name="596" href="#596">596</a> <em class="jxr_javadoccomment">/**</em>
-<a name="597" href="#597">597</a> <em class="jxr_javadoccomment"> * Method containsReference</em>
-<a name="598" href="#598">598</a> <em class="jxr_javadoccomment"> *</em>
-<a name="599" href="#599">599</a> <em class="jxr_javadoccomment"> * @return true if the <code>SecurtityTokenReference</code> contains</em>
-<a name="600" href="#600">600</a> <em class="jxr_javadoccomment"> * a <code>wsse:Reference</code> element</em>
-<a name="601" href="#601">601</a> <em class="jxr_javadoccomment"> */</em>
-<a name="602" href="#602">602</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">boolean</strong> containsReference() {
-<a name="603" href="#603">603</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">this</strong>.lengthReference() > 0;
-<a name="604" href="#604">604</a> }
-<a name="605" href="#605">605</a>
-<a name="606" href="#606">606</a> <em class="jxr_javadoccomment">/**</em>
-<a name="607" href="#607">607</a> <em class="jxr_javadoccomment"> * Method lengthReference.</em>
-<a name="608" href="#608">608</a> <em class="jxr_javadoccomment"> *</em>
-<a name="609" href="#609">609</a> <em class="jxr_javadoccomment"> * @return number of <code>wsse:Reference</code> elements in</em>
-<a name="610" href="#610">610</a> <em class="jxr_javadoccomment"> * the <code>SecurtityTokenReference</code></em>
-<a name="611" href="#611">611</a> <em class="jxr_javadoccomment"> */</em>
-<a name="612" href="#612">612</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">int</strong> lengthReference() {
-<a name="613" href="#613">613</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">this</strong>.length(WSConstants.WSSE_NS, <span class="jxr_string">"Reference"</span>);
-<a name="614" href="#614">614</a> }
-<a name="615" href="#615">615</a>
-<a name="616" href="#616">616</a> <em class="jxr_javadoccomment">/**</em>
-<a name="617" href="#617">617</a> <em class="jxr_javadoccomment"> * Method containsX509IssuerSerial</em>
-<a name="618" href="#618">618</a> <em class="jxr_javadoccomment"> *</em>
-<a name="619" href="#619">619</a> <em class="jxr_javadoccomment"> * @return true if the <code>SecurtityTokenReference</code> contains</em>
-<a name="620" href="#620">620</a> <em class="jxr_javadoccomment"> * a <code>ds:IssuerSerial</code> element</em>
-<a name="621" href="#621">621</a> <em class="jxr_javadoccomment"> */</em>
-<a name="622" href="#622">622</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">boolean</strong> containsX509IssuerSerial() {
-<a name="623" href="#623">623</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">this</strong>.lengthX509IssuerSerial() > 0;
-<a name="624" href="#624">624</a> }
-<a name="625" href="#625">625</a>
-<a name="626" href="#626">626</a> <em class="jxr_javadoccomment">/**</em>
-<a name="627" href="#627">627</a> <em class="jxr_javadoccomment"> * Method containsX509Data</em>
-<a name="628" href="#628">628</a> <em class="jxr_javadoccomment"> *</em>
-<a name="629" href="#629">629</a> <em class="jxr_javadoccomment"> * @return true if the <code>SecurtityTokenReference</code> contains</em>
-<a name="630" href="#630">630</a> <em class="jxr_javadoccomment"> * a <code>ds:X509Data</code> element</em>
-<a name="631" href="#631">631</a> <em class="jxr_javadoccomment"> */</em>
-<a name="632" href="#632">632</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">boolean</strong> containsX509Data() {
-<a name="633" href="#633">633</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">this</strong>.lengthX509Data() > 0;
-<a name="634" href="#634">634</a> }
-<a name="635" href="#635">635</a>
-<a name="636" href="#636">636</a> <em class="jxr_javadoccomment">/**</em>
-<a name="637" href="#637">637</a> <em class="jxr_javadoccomment"> * Method lengthX509IssuerSerial.</em>
-<a name="638" href="#638">638</a> <em class="jxr_javadoccomment"> *</em>
-<a name="639" href="#639">639</a> <em class="jxr_javadoccomment"> * @return number of <code>ds:IssuerSerial</code> elements in</em>
-<a name="640" href="#640">640</a> <em class="jxr_javadoccomment"> * the <code>SecurtityTokenReference</code></em>
-<a name="641" href="#641">641</a> <em class="jxr_javadoccomment"> */</em>
-<a name="642" href="#642">642</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">int</strong> lengthX509IssuerSerial() {
-<a name="643" href="#643">643</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">this</strong>.length(WSConstants.SIG_NS, Constants._TAG_X509ISSUERSERIAL);
-<a name="644" href="#644">644</a> }
-<a name="645" href="#645">645</a>
-<a name="646" href="#646">646</a> <em class="jxr_javadoccomment">/**</em>
-<a name="647" href="#647">647</a> <em class="jxr_javadoccomment"> * Method lengthX509Data.</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 number of <code>ds:IssuerSerial</code> elements in</em>
-<a name="650" href="#650">650</a> <em class="jxr_javadoccomment"> * the <code>SecurtityTokenReference</code></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> <strong class="jxr_keyword">int</strong> lengthX509Data() {
-<a name="653" href="#653">653</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">this</strong>.length(WSConstants.SIG_NS, Constants._TAG_X509DATA);
-<a name="654" href="#654">654</a> }
-<a name="655" href="#655">655</a>
-<a name="656" href="#656">656</a> <em class="jxr_javadoccomment">/**</em>
-<a name="657" href="#657">657</a> <em class="jxr_javadoccomment"> * Method containsKeyIdentifier.</em>
-<a name="658" href="#658">658</a> <em class="jxr_javadoccomment"> *</em>
-<a name="659" href="#659">659</a> <em class="jxr_javadoccomment"> * @return true if the <code>SecurtityTokenReference</code> contains</em>
-<a name="660" href="#660">660</a> <em class="jxr_javadoccomment"> * a <code>wsse:KeyIdentifier</code> element</em>
-<a name="661" href="#661">661</a> <em class="jxr_javadoccomment"> */</em>
-<a name="662" href="#662">662</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">boolean</strong> containsKeyIdentifier() {
-<a name="663" href="#663">663</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">this</strong>.lengthKeyIdentifier() > 0;
-<a name="664" href="#664">664</a> }
-<a name="665" href="#665">665</a>
-<a name="666" href="#666">666</a> <em class="jxr_javadoccomment">/**</em>
-<a name="667" href="#667">667</a> <em class="jxr_javadoccomment"> * Method lengthKeyIdentifier.</em>
-<a name="668" href="#668">668</a> <em class="jxr_javadoccomment"> *</em>
-<a name="669" href="#669">669</a> <em class="jxr_javadoccomment"> * @return number of <code>wsse:KeyIdentifier</code> elements in</em>
-<a name="670" href="#670">670</a> <em class="jxr_javadoccomment"> * the <code>SecurtityTokenReference</code></em>
-<a name="671" href="#671">671</a> <em class="jxr_javadoccomment"> */</em>
-<a name="672" href="#672">672</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">int</strong> lengthKeyIdentifier() {
-<a name="673" href="#673">673</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">this</strong>.length(WSConstants.WSSE_NS, <span class="jxr_string">"KeyIdentifier"</span>);
-<a name="674" href="#674">674</a> }
-<a name="675" href="#675">675</a>
-<a name="676" href="#676">676</a> <em class="jxr_javadoccomment">/**</em>
-<a name="677" href="#677">677</a> <em class="jxr_javadoccomment"> * Method length.</em>
-<a name="678" href="#678">678</a> <em class="jxr_javadoccomment"> *</em>
-<a name="679" href="#679">679</a> <em class="jxr_javadoccomment"> * @param namespace</em>
-<a name="680" href="#680">680</a> <em class="jxr_javadoccomment"> * @param localname</em>
-<a name="681" href="#681">681</a> <em class="jxr_javadoccomment"> * @return number of elements with matching localname and namespace</em>
-<a name="682" href="#682">682</a> <em class="jxr_javadoccomment"> */</em>
-<a name="683" href="#683">683</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">int</strong> length(String namespace, String localname) {
-<a name="684" href="#684">684</a> NodeList childNodes = <strong class="jxr_keyword">this</strong>.element.getChildNodes();
-<a name="685" href="#685">685</a> <strong class="jxr_keyword">int</strong> result = 0;
-<a name="686" href="#686">686</a> <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = 0; i < childNodes.getLength(); i++) {
-<a name="687" href="#687">687</a> Node n = childNodes.item(i);
-<a name="688" href="#688">688</a> <strong class="jxr_keyword">if</strong> (n.getNodeType() == Node.ELEMENT_NODE) {
-<a name="689" href="#689">689</a> String ns = n.getNamespaceURI();
-<a name="690" href="#690">690</a> String name = n.getLocalName();
-<a name="691" href="#691">691</a> <strong class="jxr_keyword">if</strong> ((((namespace != <strong class="jxr_keyword">null</strong>) && namespace.equals(ns))
-<a name="692" href="#692">692</a> || ((namespace == <strong class="jxr_keyword">null</strong>) && (ns == <strong class="jxr_keyword">null</strong>)))
-<a name="693" href="#693">693</a> && (localname.equals(name))
-<a name="694" href="#694">694</a> ) {
-<a name="695" href="#695">695</a> result++;
-<a name="696" href="#696">696</a> }
-<a name="697" href="#697">697</a> }
-<a name="698" href="#698">698</a> }
-<a name="699" href="#699">699</a> <strong class="jxr_keyword">return</strong> result;
-<a name="700" href="#700">700</a> }
-<a name="701" href="#701">701</a>
-<a name="702" href="#702">702</a> <em class="jxr_javadoccomment">/**</em>
-<a name="703" href="#703">703</a> <em class="jxr_javadoccomment"> * get the dom element.</em>
-<a name="704" href="#704">704</a> <em class="jxr_javadoccomment"> *</em>
-<a name="705" href="#705">705</a> <em class="jxr_javadoccomment"> * @return TODO</em>
-<a name="706" href="#706">706</a> <em class="jxr_javadoccomment"> */</em>
-<a name="707" href="#707">707</a> <strong class="jxr_keyword">public</strong> Element getElement() {
-<a name="708" href="#708">708</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">this</strong>.element;
-<a name="709" href="#709">709</a> }
-<a name="710" href="#710">710</a>
-<a name="711" href="#711">711</a> <em class="jxr_javadoccomment">/**</em>
-<a name="712" href="#712">712</a> <em class="jxr_javadoccomment"> * set the id.</em>
-<a name="713" href="#713">713</a> <em class="jxr_javadoccomment"> *</em>
-<a name="714" href="#714">714</a> <em class="jxr_javadoccomment"> * @param id</em>
-<a name="715" href="#715">715</a> <em class="jxr_javadoccomment"> */</em>
-<a name="716" href="#716">716</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> setID(String id) {
-<a name="717" href="#717">717</a> String prefix =
-<a name="718" href="#718">718</a> WSSecurityUtil.setNamespace(
-<a name="719" href="#719">719</a> <strong class="jxr_keyword">this</strong>.element, WSConstants.WSU_NS, WSConstants.WSU_PREFIX
-<a name="720" href="#720">720</a> );
-<a name="721" href="#721">721</a> <strong class="jxr_keyword">this</strong>.element.setAttributeNS(WSConstants.WSU_NS, prefix + <span class="jxr_string">":Id"</span>, id);
-<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 string representation.</em>
-<a name="726" href="#726">726</a> <em class="jxr_javadoccomment"> *</em>
-<a name="727" href="#727">727</a> <em class="jxr_javadoccomment"> * @return TODO</em>
-<a name="728" href="#728">728</a> <em class="jxr_javadoccomment"> */</em>
-<a name="729" href="#729">729</a> <strong class="jxr_keyword">public</strong> String toString() {
-<a name="730" href="#730">730</a> <strong class="jxr_keyword">return</strong> DOM2Writer.nodeToString((Node) <strong class="jxr_keyword">this</strong>.element);
-<a name="731" href="#731">731</a> }
-<a name="732" href="#732">732</a> }
+<a name="516" href="#516">516</a>
+<a name="517" href="#517">517</a> <em class="jxr_javadoccomment">/**</em>
+<a name="518" href="#518">518</a> <em class="jxr_javadoccomment"> * Sets the X509 IssuerSerial data.</em>
+<a name="519" href="#519">519</a> <em class="jxr_javadoccomment"> *</em>
+<a name="520" href="#520">520</a> <em class="jxr_javadoccomment"> * @param ref the {@link XMLX509IssuerSerial} to put into this</em>
+<a name="521" href="#521">521</a> <em class="jxr_javadoccomment"> * SecurityTokenReference</em>
+<a name="522" href="#522">522</a> <em class="jxr_javadoccomment"> */</em>
+<a name="523" href="#523">523</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">void</strong> setX509IssuerSerial(X509Data ref) {
+<a name="524" href="#524">524</a> Element elem = getFirstElement();
+<a name="525" href="#525">525</a> <strong class="jxr_keyword">if</strong> (elem != <strong class="jxr_keyword">null</strong>) {
+<a name="526" href="#526">526</a> <strong class="jxr_keyword">this</strong>.element.replaceChild(ref.getElement(), elem);
+<a name="527" href="#527">527</a> } <strong class="jxr_keyword">else</strong> {
+<a name="528" href="#528">528</a> <strong class="jxr_keyword">this</strong>.element.appendChild(ref.getElement());
+<a name="529" href="#529">529</a> }
+<a name="530" href="#530">530</a> }
+<a name="531" href="#531">531</a>
+<a name="532" href="#532">532</a> <em class="jxr_javadoccomment">/**</em>
+<a name="533" href="#533">533</a> <em class="jxr_javadoccomment"> * Gets the certificate identified with X509 issuerSerial data.</em>
+<a name="534" href="#534">534</a> <em class="jxr_javadoccomment"> * This method first tries to get the embedded certificate.</em>
+<a name="535" href="#535">535</a> <em class="jxr_javadoccomment"> * If this fails it checks if the certificate is in the</em>
+<a name="536" href="#536">536</a> <em class="jxr_javadoccomment"> * keystore.</em>
+<a name="537" href="#537">537</a> <em class="jxr_javadoccomment"> *</em>
+<a name="538" href="#538">538</a> <em class="jxr_javadoccomment"> * @return a certificate array or null if nothing found</em>
+<a name="539" href="#539">539</a> <em class="jxr_javadoccomment"> */</em>
+<a name="540" href="#540">540</a> <strong class="jxr_keyword">public</strong> X509Certificate[] getX509IssuerSerial(<a href="../../../../../../org/apache/ws/security/components/crypto/Crypto.html">Crypto</a> crypto) <strong class="jxr_keyword">throws</strong> WSSecurityException {
+<a name="541" href="#541">541</a> String alias = getX509IssuerSerialAlias(crypto);
+<a name="542" href="#542">542</a> <strong class="jxr_keyword">if</strong> (alias != <strong class="jxr_keyword">null</strong>) {
+<a name="543" href="#543">543</a> <strong class="jxr_keyword">return</strong> crypto.getCertificates(alias);
+<a name="544" href="#544">544</a> }
+<a name="545" href="#545">545</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
+<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"> * Gets the alias name of the certificate identified with X509 issuerSerial data.</em>
+<a name="550" href="#550">550</a> <em class="jxr_javadoccomment"> * The keystore identifies the certificate and the key with this alias name.</em>
+<a name="551" href="#551">551</a> <em class="jxr_javadoccomment"> *</em>
+<a name="552" href="#552">552</a> <em class="jxr_javadoccomment"> * @return the alias name for the certificate or null if nothing found</em>
+<a name="553" href="#553">553</a> <em class="jxr_javadoccomment"> */</em>
+<a name="554" href="#554">554</a> <strong class="jxr_keyword">public</strong> String getX509IssuerSerialAlias(<a href="../../../../../../org/apache/ws/security/components/crypto/Crypto.html">Crypto</a> crypto) <strong class="jxr_keyword">throws</strong> WSSecurityException {
+<a name="555" href="#555">555</a> <strong class="jxr_keyword">if</strong> (issuerSerial == <strong class="jxr_keyword">null</strong>) {
+<a name="556" href="#556">556</a> issuerSerial = getIssuerSerial();
+<a name="557" href="#557">557</a> <strong class="jxr_keyword">if</strong> (issuerSerial == <strong class="jxr_keyword">null</strong>) {
+<a name="558" href="#558">558</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
+<a name="559" href="#559">559</a> }
+<a name="560" href="#560">560</a> }
+<a name="561" href="#561">561</a>
+<a name="562" href="#562">562</a> String alias =
+<a name="563" href="#563">563</a> crypto.getAliasForX509Cert(issuerSerial.getIssuerName(), issuerSerial.getSerialNumber());
+<a name="564" href="#564">564</a> <strong class="jxr_keyword">if</strong> (doDebug) {
+<a name="565" href="#565">565</a> log.info(<span class="jxr_string">"X509IssuerSerial alias: "</span> + alias);
+<a name="566" href="#566">566</a> }
+<a name="567" href="#567">567</a> <strong class="jxr_keyword">return</strong> alias;
+<a name="568" href="#568">568</a> }
+<a name="569" href="#569">569</a>
+<a name="570" href="#570">570</a> <strong class="jxr_keyword">private</strong> XMLX509IssuerSerial getIssuerSerial() <strong class="jxr_keyword">throws</strong> WSSecurityException {
+<a name="571" href="#571">571</a> <strong class="jxr_keyword">if</strong> (issuerSerial != <strong class="jxr_keyword">null</strong>) {
+<a name="572" href="#572">572</a> <strong class="jxr_keyword">return</strong> issuerSerial;
+<a name="573" href="#573">573</a> }
+<a name="574" href="#574">574</a> Element elem = getFirstElement();
+<a name="575" href="#575">575</a> <strong class="jxr_keyword">if</strong> (elem == <strong class="jxr_keyword">null</strong>) {
+<a name="576" href="#576">576</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
+<a name="577" href="#577">577</a> }
+<a name="578" href="#578">578</a> <strong class="jxr_keyword">try</strong> {
+<a name="579" href="#579">579</a> <strong class="jxr_keyword">if</strong> (Constants._TAG_X509DATA.equals(elem.getLocalName())) {
+<a name="580" href="#580">580</a> elem =
+<a name="581" href="#581">581</a> (Element)WSSecurityUtil.findElement(
+<a name="582" href="#582">582</a> elem, Constants._TAG_X509ISSUERSERIAL, Constants.SignatureSpecNS
+<a name="583" href="#583">583</a> );
+<a name="584" href="#584">584</a> }
+<a name="585" href="#585">585</a> issuerSerial = <strong class="jxr_keyword">new</strong> XMLX509IssuerSerial(elem, <span class="jxr_string">""</span>);
+<a name="586" href="#586">586</a> } <strong class="jxr_keyword">catch</strong> (XMLSecurityException e) {
+<a name="587" href="#587">587</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="588" href="#588">588</a> WSSecurityException.SECURITY_TOKEN_UNAVAILABLE,
+<a name="589" href="#589">589</a> <span class="jxr_string">"noToken"</span>,
+<a name="590" href="#590">590</a> <strong class="jxr_keyword">new</strong> Object[]{<span class="jxr_string">"Issuer/Serial data element missing"</span>},
+<a name="591" href="#591">591</a> e
+<a name="592" href="#592">592</a> );
+<a name="593" href="#593">593</a> }
+<a name="594" href="#594">594</a> <strong class="jxr_keyword">return</strong> issuerSerial;
+<a name="595" href="#595">595</a> }
+<a name="596" href="#596">596</a>
+<a name="597" href="#597">597</a> <em class="jxr_javadoccomment">/**</em>
+<a name="598" href="#598">598</a> <em class="jxr_javadoccomment"> * Method containsReference</em>
+<a name="599" href="#599">599</a> <em class="jxr_javadoccomment"> *</em>
+<a name="600" href="#600">600</a> <em class="jxr_javadoccomment"> * @return true if the <code>SecurtityTokenReference</code> contains</em>
+<a name="601" href="#601">601</a> <em class="jxr_javadoccomment"> * a <code>wsse:Reference</code> element</em>
+<a name="602" href="#602">602</a> <em class="jxr_javadoccomment"> */</em>
+<a name="603" href="#603">603</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">boolean</strong> containsReference() {
+<a name="604" href="#604">604</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">this</strong>.lengthReference() > 0;
+<a name="605" href="#605">605</a> }
+<a name="606" href="#606">606</a>
+<a name="607" href="#607">607</a> <em class="jxr_javadoccomment">/**</em>
+<a name="608" href="#608">608</a> <em class="jxr_javadoccomment"> * Method lengthReference.</em>
+<a name="609" href="#609">609</a> <em class="jxr_javadoccomment"> *</em>
+<a name="610" href="#610">610</a> <em class="jxr_javadoccomment"> * @return number of <code>wsse:Reference</code> elements in</em>
+<a name="611" href="#611">611</a> <em class="jxr_javadoccomment"> * the <code>SecurtityTokenReference</code></em>
+<a name="612" href="#612">612</a> <em class="jxr_javadoccomment"> */</em>
+<a name="613" href="#613">613</a> <strong class="jxr_keyword">public</strong> <strong class="jxr_keyword">int</strong> lengthReference() {
+<a name="614" href="#614">614</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">this</strong>.length(WSConstants.WSSE_NS, <span class="jxr_string">"Reference"</span>);
+<a name="615" href="#615">615</a> }
+<a name="616" href="#616">616</a>
+<a name="617" href="#617">617</a> <em class="jxr_javadoccomment">/**</em>
+<a name="618" href="#618">618</a> <em class="jxr_javadoccomment"> * Method containsX509IssuerSerial</em>
+<a name="619" href="#619">619</a> <em class="jxr_javadoccomment"> *</em>
+<a name="620" href="#620">620</a> <em class="jxr_javadoccomment"> * @return true if the <code>SecurtityTokenReference</code> contains</em>
+<a name="621" href="#621">621</a> <em class="jxr_javadoccomment"> * a <code>ds:IssuerSerial</code> element</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> <strong class="jxr_keyword">boolean</strong> containsX509IssuerSerial() {
+<a name="624" href="#624">624</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">this</strong>.lengthX509IssuerSerial() > 0;
+<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"> * Method containsX509Data</em>
+<a name="629" href="#629">629</a> <em class="jxr_javadoccomment"> *</em>
+<a name="630" href="#630">630</a> <em class="jxr_javadoccomment"> * @return true if the <code>SecurtityTokenReference</code> contains</em>
+<a name="631" href="#631">631</a> <em class="jxr_javadoccomment"> * a <code>ds:X509Data</code> element</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">boolean</strong> containsX509Data() {
+<a name="634" href="#634">634</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">this</strong>.lengthX509Data() > 0;
+<a name="635" href="#635">635</a> }
+<a name="636" href="#636">636</a>
+<a name="637" href="#637">637</a> <em class="jxr_javadoccomment">/**</em>
+<a name="638" href="#638">638</a> <em class="jxr_javadoccomment"> * Method lengthX509IssuerSerial.</em>
+<a name="639" href="#639">639</a> <em class="jxr_javadoccomment"> *</em>
+<a name="640" href="#640">640</a> <em class="jxr_javadoccomment"> * @return number of <code>ds:IssuerSerial</code> elements in</em>
+<a name="641" href="#641">641</a> <em class="jxr_javadoccomment"> * the <code>SecurtityTokenReference</code></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> <strong class="jxr_keyword">int</strong> lengthX509IssuerSerial() {
+<a name="644" href="#644">644</a> <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">this</strong>.length(WSConstants.SIG_NS, Constants._TAG_X509ISSUERSERIAL);
+<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"> * Method lengthX509Data.</em>
+<a name="649" href="#649">649</a> <em class="jxr_javadoccomment"> *</em>
+<a name="650" href="#650">650</a> <em class="jxr_javadoccomment"> * @return number of <code>ds:IssuerSerial</code> elements in</em>
[... 87 lines stripped ...]