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

svn commit: r766696 [30/36] - in /webservices/wss4j/site: ./ apidocs/ apidocs/org/apache/ws/axis/security/ apidocs/org/apache/ws/axis/security/class-use/ apidocs/org/apache/ws/axis/security/handler/ apidocs/org/apache/ws/axis/security/handler/class-use...

Modified: webservices/wss4j/site/xref/org/apache/ws/security/processor/SignatureProcessor.html
URL: http://svn.apache.org/viewvc/webservices/wss4j/site/xref/org/apache/ws/security/processor/SignatureProcessor.html?rev=766696&r1=766695&r2=766696&view=diff
==============================================================================
--- webservices/wss4j/site/xref/org/apache/ws/security/processor/SignatureProcessor.html (original)
+++ webservices/wss4j/site/xref/org/apache/ws/security/processor/SignatureProcessor.html Mon Apr 20 13:56:25 2009
@@ -96,7 +96,7 @@
 <a name="86" href="#86">86</a>          <strong class="jxr_keyword">if</strong> (log.isDebugEnabled()) {
 <a name="87" href="#87">87</a>              log.debug(<span class="jxr_string">"Found signature element"</span>);
 <a name="88" href="#88">88</a>          }
-<a name="89" href="#89">89</a>          WSDocInfoStore.store(wsDocInfo);
+<a name="89" href="#89">89</a>          <strong class="jxr_keyword">boolean</strong> remove = WSDocInfoStore.store(wsDocInfo);
 <a name="90" href="#90">90</a>          X509Certificate[] returnCert = <strong class="jxr_keyword">new</strong> X509Certificate[1];
 <a name="91" href="#91">91</a>          Set returnElements = <strong class="jxr_keyword">new</strong> HashSet();
 <a name="92" href="#92">92</a>          List protectedElements = <strong class="jxr_keyword">new</strong> java.util.ArrayList();
@@ -107,238 +107,238 @@
 <a name="97" href="#97">97</a>              lastPrincipalFound = 
 <a name="98" href="#98">98</a>                  verifyXMLSignature(
 <a name="99" href="#99">99</a>                      elem, crypto, returnCert, returnElements,
-<a name="100" href="#100">100</a>                     protectedElements, signatureValue, cb
-<a name="101" href="#101">101</a>                 );
-<a name="102" href="#102">102</a>         } <strong class="jxr_keyword">catch</strong> (WSSecurityException ex) {
-<a name="103" href="#103">103</a>             <strong class="jxr_keyword">throw</strong> ex;
-<a name="104" href="#104">104</a>         } <strong class="jxr_keyword">finally</strong> {
-<a name="105" href="#105">105</a>             WSDocInfoStore.delete(wsDocInfo);
-<a name="106" href="#106">106</a>         }
-<a name="107" href="#107">107</a>         <strong class="jxr_keyword">if</strong> (lastPrincipalFound instanceof WSUsernameTokenPrincipal) {
-<a name="108" href="#108">108</a>             returnResults.add(
-<a name="109" href="#109">109</a>                 0, 
-<a name="110" href="#110">110</a>                 <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSSecurityEngineResult.html">WSSecurityEngineResult</a>(
-<a name="111" href="#111">111</a>                     WSConstants.UT_SIGN, 
-<a name="112" href="#112">112</a>                     lastPrincipalFound, 
-<a name="113" href="#113">113</a>                     <strong class="jxr_keyword">null</strong>,
-<a name="114" href="#114">114</a>                     returnElements, 
-<a name="115" href="#115">115</a>                     protectedElements, 
-<a name="116" href="#116">116</a>                     signatureValue[0]
-<a name="117" href="#117">117</a>                 )
-<a name="118" href="#118">118</a>             );
-<a name="119" href="#119">119</a>         } <strong class="jxr_keyword">else</strong> {
-<a name="120" href="#120">120</a>             returnResults.add(
-<a name="121" href="#121">121</a>                 0, 
-<a name="122" href="#122">122</a>                 <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSSecurityEngineResult.html">WSSecurityEngineResult</a>(
-<a name="123" href="#123">123</a>                     WSConstants.SIGN, 
-<a name="124" href="#124">124</a>                     lastPrincipalFound,
-<a name="125" href="#125">125</a>                     returnCert[0], 
-<a name="126" href="#126">126</a>                     returnElements, 
-<a name="127" href="#127">127</a>                     protectedElements, 
-<a name="128" href="#128">128</a>                     signatureValue[0]
-<a name="129" href="#129">129</a>                 )
-<a name="130" href="#130">130</a>             );
-<a name="131" href="#131">131</a>         }
-<a name="132" href="#132">132</a>         signatureId = elem.getAttributeNS(<strong class="jxr_keyword">null</strong>, <span class="jxr_string">"Id"</span>);
-<a name="133" href="#133">133</a>     }
-<a name="134" href="#134">134</a> 
-<a name="135" href="#135">135</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="136" href="#136">136</a> <em class="jxr_javadoccomment">     * Verify the WS-Security signature.</em>
-<a name="137" href="#137">137</a> <em class="jxr_javadoccomment">     * </em>
-<a name="138" href="#138">138</a> <em class="jxr_javadoccomment">     * The functions at first checks if then &lt;code&gt;KeyInfo&lt;/code&gt; that is</em>
-<a name="139" href="#139">139</a> <em class="jxr_javadoccomment">     * contained in the signature contains standard X509 data. If yes then</em>
-<a name="140" href="#140">140</a> <em class="jxr_javadoccomment">     * get the certificate data via the standard &lt;code&gt;KeyInfo&lt;/code&gt; methods.</em>
-<a name="141" href="#141">141</a> <em class="jxr_javadoccomment">     * </em>
-<a name="142" href="#142">142</a> <em class="jxr_javadoccomment">     * Otherwise, if the &lt;code&gt;KeyInfo&lt;/code&gt; info does not contain X509 data, check</em>
-<a name="143" href="#143">143</a> <em class="jxr_javadoccomment">     * if we can find a &lt;code&gt;wsse:SecurityTokenReference&lt;/code&gt; element. If yes, the next</em>
-<a name="144" href="#144">144</a> <em class="jxr_javadoccomment">     * step is to check how to get the certificate. Two methods are currently supported</em>
-<a name="145" href="#145">145</a> <em class="jxr_javadoccomment">     * here:</em>
-<a name="146" href="#146">146</a> <em class="jxr_javadoccomment">     * &lt;ul&gt;</em>
-<a name="147" href="#147">147</a> <em class="jxr_javadoccomment">     * &lt;li&gt; A URI reference to a binary security token contained in the &lt;code&gt;wsse:Security</em>
-<a name="148" href="#148">148</a> <em class="jxr_javadoccomment">     * &lt;/code&gt; header.  If the dereferenced token is</em>
-<a name="149" href="#149">149</a> <em class="jxr_javadoccomment">     * of the correct type the contained certificate is extracted.</em>
-<a name="150" href="#150">150</a> <em class="jxr_javadoccomment">     * &lt;/li&gt;</em>
-<a name="151" href="#151">151</a> <em class="jxr_javadoccomment">     * &lt;li&gt; Issuer name an serial number of the certificate. In this case the method</em>
-<a name="152" href="#152">152</a> <em class="jxr_javadoccomment">     * looks up the certificate in the keystore via the &lt;code&gt;crypto&lt;/code&gt; parameter.</em>
+<a name="100" href="#100">100</a>                     protectedElements, signatureValue, cb,
+<a name="101" href="#101">101</a>                     wsDocInfo
+<a name="102" href="#102">102</a>                 );
+<a name="103" href="#103">103</a>         } <strong class="jxr_keyword">catch</strong> (WSSecurityException ex) {
+<a name="104" href="#104">104</a>             <strong class="jxr_keyword">throw</strong> ex;
+<a name="105" href="#105">105</a>         } <strong class="jxr_keyword">finally</strong> {
+<a name="106" href="#106">106</a>             <strong class="jxr_keyword">if</strong> (remove) {
+<a name="107" href="#107">107</a>                 WSDocInfoStore.delete(wsDocInfo);
+<a name="108" href="#108">108</a>             }
+<a name="109" href="#109">109</a>         }
+<a name="110" href="#110">110</a>         <strong class="jxr_keyword">if</strong> (lastPrincipalFound instanceof WSUsernameTokenPrincipal) {
+<a name="111" href="#111">111</a>             returnResults.add(
+<a name="112" href="#112">112</a>                 0, 
+<a name="113" href="#113">113</a>                 <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSSecurityEngineResult.html">WSSecurityEngineResult</a>(
+<a name="114" href="#114">114</a>                     WSConstants.UT_SIGN, 
+<a name="115" href="#115">115</a>                     lastPrincipalFound, 
+<a name="116" href="#116">116</a>                     <strong class="jxr_keyword">null</strong>,
+<a name="117" href="#117">117</a>                     returnElements, 
+<a name="118" href="#118">118</a>                     protectedElements, 
+<a name="119" href="#119">119</a>                     signatureValue[0]
+<a name="120" href="#120">120</a>                 )
+<a name="121" href="#121">121</a>             );
+<a name="122" href="#122">122</a>         } <strong class="jxr_keyword">else</strong> {
+<a name="123" href="#123">123</a>             returnResults.add(
+<a name="124" href="#124">124</a>                 0, 
+<a name="125" href="#125">125</a>                 <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSSecurityEngineResult.html">WSSecurityEngineResult</a>(
+<a name="126" href="#126">126</a>                     WSConstants.SIGN, 
+<a name="127" href="#127">127</a>                     lastPrincipalFound,
+<a name="128" href="#128">128</a>                     returnCert[0], 
+<a name="129" href="#129">129</a>                     returnElements, 
+<a name="130" href="#130">130</a>                     protectedElements, 
+<a name="131" href="#131">131</a>                     signatureValue[0]
+<a name="132" href="#132">132</a>                 )
+<a name="133" href="#133">133</a>             );
+<a name="134" href="#134">134</a>         }
+<a name="135" href="#135">135</a>         signatureId = elem.getAttributeNS(<strong class="jxr_keyword">null</strong>, <span class="jxr_string">"Id"</span>);
+<a name="136" href="#136">136</a>     }
+<a name="137" href="#137">137</a> 
+<a name="138" href="#138">138</a>     <em class="jxr_javadoccomment">/**</em>
+<a name="139" href="#139">139</a> <em class="jxr_javadoccomment">     * Verify the WS-Security signature.</em>
+<a name="140" href="#140">140</a> <em class="jxr_javadoccomment">     * </em>
+<a name="141" href="#141">141</a> <em class="jxr_javadoccomment">     * The functions at first checks if then &lt;code&gt;KeyInfo&lt;/code&gt; that is</em>
+<a name="142" href="#142">142</a> <em class="jxr_javadoccomment">     * contained in the signature contains standard X509 data. If yes then</em>
+<a name="143" href="#143">143</a> <em class="jxr_javadoccomment">     * get the certificate data via the standard &lt;code&gt;KeyInfo&lt;/code&gt; methods.</em>
+<a name="144" href="#144">144</a> <em class="jxr_javadoccomment">     * </em>
+<a name="145" href="#145">145</a> <em class="jxr_javadoccomment">     * Otherwise, if the &lt;code&gt;KeyInfo&lt;/code&gt; info does not contain X509 data, check</em>
+<a name="146" href="#146">146</a> <em class="jxr_javadoccomment">     * if we can find a &lt;code&gt;wsse:SecurityTokenReference&lt;/code&gt; element. If yes, the next</em>
+<a name="147" href="#147">147</a> <em class="jxr_javadoccomment">     * step is to check how to get the certificate. Two methods are currently supported</em>
+<a name="148" href="#148">148</a> <em class="jxr_javadoccomment">     * here:</em>
+<a name="149" href="#149">149</a> <em class="jxr_javadoccomment">     * &lt;ul&gt;</em>
+<a name="150" href="#150">150</a> <em class="jxr_javadoccomment">     * &lt;li&gt; A URI reference to a binary security token contained in the &lt;code&gt;wsse:Security</em>
+<a name="151" href="#151">151</a> <em class="jxr_javadoccomment">     * &lt;/code&gt; header.  If the dereferenced token is</em>
+<a name="152" href="#152">152</a> <em class="jxr_javadoccomment">     * of the correct type the contained certificate is extracted.</em>
 <a name="153" href="#153">153</a> <em class="jxr_javadoccomment">     * &lt;/li&gt;</em>
-<a name="154" href="#154">154</a> <em class="jxr_javadoccomment">     * &lt;/ul&gt;</em>
-<a name="155" href="#155">155</a> <em class="jxr_javadoccomment">     * </em>
-<a name="156" href="#156">156</a> <em class="jxr_javadoccomment">     * The methods checks is the certificate is valid and calls the</em>
-<a name="157" href="#157">157</a> <em class="jxr_javadoccomment">     * {@link org.apache.xml.security.signature.XMLSignature#checkSignatureValue(X509Certificate) </em>
-<a name="158" href="#158">158</a> <em class="jxr_javadoccomment">     * verification} function.</em>
-<a name="159" href="#159">159</a> <em class="jxr_javadoccomment">     *</em>
-<a name="160" href="#160">160</a> <em class="jxr_javadoccomment">     * @param elem        the XMLSignature DOM Element.</em>
-<a name="161" href="#161">161</a> <em class="jxr_javadoccomment">     * @param crypto      the object that implements the access to the keystore and the</em>
-<a name="162" href="#162">162</a> <em class="jxr_javadoccomment">     *                    handling of certificates.</em>
-<a name="163" href="#163">163</a> <em class="jxr_javadoccomment">     * @param returnCert  verifyXMLSignature stores the certificate in the first</em>
-<a name="164" href="#164">164</a> <em class="jxr_javadoccomment">     *                    entry of this array. The caller may then further validate</em>
-<a name="165" href="#165">165</a> <em class="jxr_javadoccomment">     *                    the certificate</em>
-<a name="166" href="#166">166</a> <em class="jxr_javadoccomment">     * @param returnElements verifyXMLSignature adds the wsu:ID attribute values for</em>
-<a name="167" href="#167">167</a> <em class="jxr_javadoccomment">     *               the signed elements to this Set</em>
-<a name="168" href="#168">168</a> <em class="jxr_javadoccomment">     * @param cb CallbackHandler instance to extract key passwords</em>
-<a name="169" href="#169">169</a> <em class="jxr_javadoccomment">     * @return the subject principal of the validated X509 certificate (the</em>
-<a name="170" href="#170">170</a> <em class="jxr_javadoccomment">     *         authenticated subject). The calling function may use this</em>
-<a name="171" href="#171">171</a> <em class="jxr_javadoccomment">     *         principal for further authentication or authorization.</em>
-<a name="172" href="#172">172</a> <em class="jxr_javadoccomment">     * @throws WSSecurityException</em>
-<a name="173" href="#173">173</a> <em class="jxr_javadoccomment">     */</em>
-<a name="174" href="#174">174</a>     <strong class="jxr_keyword">protected</strong> Principal verifyXMLSignature(
-<a name="175" href="#175">175</a>         Element elem,
-<a name="176" href="#176">176</a>         <a href="../../../../../org/apache/ws/security/components/crypto/Crypto.html">Crypto</a> crypto,
-<a name="177" href="#177">177</a>         X509Certificate[] returnCert,
-<a name="178" href="#178">178</a>         Set returnElements,
-<a name="179" href="#179">179</a>         List protectedElements,
-<a name="180" href="#180">180</a>         byte[][] signatureValue,
-<a name="181" href="#181">181</a>         CallbackHandler cb
-<a name="182" href="#182">182</a>     ) <strong class="jxr_keyword">throws</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a> {
-<a name="183" href="#183">183</a>         <strong class="jxr_keyword">if</strong> (log.isDebugEnabled()) {
-<a name="184" href="#184">184</a>             log.debug(<span class="jxr_string">"Verify XML Signature"</span>);
-<a name="185" href="#185">185</a>         }
-<a name="186" href="#186">186</a>         <strong class="jxr_keyword">long</strong> t0 = 0, t1 = 0, t2 = 0;
-<a name="187" href="#187">187</a>         <strong class="jxr_keyword">if</strong> (tlog.isDebugEnabled()) {
-<a name="188" href="#188">188</a>             t0 = System.currentTimeMillis();
+<a name="154" href="#154">154</a> <em class="jxr_javadoccomment">     * &lt;li&gt; Issuer name an serial number of the certificate. In this case the method</em>
+<a name="155" href="#155">155</a> <em class="jxr_javadoccomment">     * looks up the certificate in the keystore via the &lt;code&gt;crypto&lt;/code&gt; parameter.</em>
+<a name="156" href="#156">156</a> <em class="jxr_javadoccomment">     * &lt;/li&gt;</em>
+<a name="157" href="#157">157</a> <em class="jxr_javadoccomment">     * &lt;/ul&gt;</em>
+<a name="158" href="#158">158</a> <em class="jxr_javadoccomment">     * </em>
+<a name="159" href="#159">159</a> <em class="jxr_javadoccomment">     * The methods checks is the certificate is valid and calls the</em>
+<a name="160" href="#160">160</a> <em class="jxr_javadoccomment">     * {@link org.apache.xml.security.signature.XMLSignature#checkSignatureValue(X509Certificate) </em>
+<a name="161" href="#161">161</a> <em class="jxr_javadoccomment">     * verification} function.</em>
+<a name="162" href="#162">162</a> <em class="jxr_javadoccomment">     *</em>
+<a name="163" href="#163">163</a> <em class="jxr_javadoccomment">     * @param elem        the XMLSignature DOM Element.</em>
+<a name="164" href="#164">164</a> <em class="jxr_javadoccomment">     * @param crypto      the object that implements the access to the keystore and the</em>
+<a name="165" href="#165">165</a> <em class="jxr_javadoccomment">     *                    handling of certificates.</em>
+<a name="166" href="#166">166</a> <em class="jxr_javadoccomment">     * @param returnCert  verifyXMLSignature stores the certificate in the first</em>
+<a name="167" href="#167">167</a> <em class="jxr_javadoccomment">     *                    entry of this array. The caller may then further validate</em>
+<a name="168" href="#168">168</a> <em class="jxr_javadoccomment">     *                    the certificate</em>
+<a name="169" href="#169">169</a> <em class="jxr_javadoccomment">     * @param returnElements verifyXMLSignature adds the wsu:ID attribute values for</em>
+<a name="170" href="#170">170</a> <em class="jxr_javadoccomment">     *               the signed elements to this Set</em>
+<a name="171" href="#171">171</a> <em class="jxr_javadoccomment">     * @param cb CallbackHandler instance to extract key passwords</em>
+<a name="172" href="#172">172</a> <em class="jxr_javadoccomment">     * @return the subject principal of the validated X509 certificate (the</em>
+<a name="173" href="#173">173</a> <em class="jxr_javadoccomment">     *         authenticated subject). The calling function may use this</em>
+<a name="174" href="#174">174</a> <em class="jxr_javadoccomment">     *         principal for further authentication or authorization.</em>
+<a name="175" href="#175">175</a> <em class="jxr_javadoccomment">     * @throws WSSecurityException</em>
+<a name="176" href="#176">176</a> <em class="jxr_javadoccomment">     */</em>
+<a name="177" href="#177">177</a>     <strong class="jxr_keyword">protected</strong> Principal verifyXMLSignature(
+<a name="178" href="#178">178</a>         Element elem,
+<a name="179" href="#179">179</a>         <a href="../../../../../org/apache/ws/security/components/crypto/Crypto.html">Crypto</a> crypto,
+<a name="180" href="#180">180</a>         X509Certificate[] returnCert,
+<a name="181" href="#181">181</a>         Set returnElements,
+<a name="182" href="#182">182</a>         List protectedElements,
+<a name="183" href="#183">183</a>         byte[][] signatureValue,
+<a name="184" href="#184">184</a>         CallbackHandler cb,
+<a name="185" href="#185">185</a>         <a href="../../../../../org/apache/ws/security/WSDocInfo.html">WSDocInfo</a> wsDocInfo
+<a name="186" href="#186">186</a>     ) <strong class="jxr_keyword">throws</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a> {
+<a name="187" href="#187">187</a>         <strong class="jxr_keyword">if</strong> (log.isDebugEnabled()) {
+<a name="188" href="#188">188</a>             log.debug(<span class="jxr_string">"Verify XML Signature"</span>);
 <a name="189" href="#189">189</a>         }
-<a name="190" href="#190">190</a> 
-<a name="191" href="#191">191</a>         XMLSignature sig = <strong class="jxr_keyword">null</strong>;
-<a name="192" href="#192">192</a>         <strong class="jxr_keyword">try</strong> {
-<a name="193" href="#193">193</a>             sig = <strong class="jxr_keyword">new</strong> XMLSignature(elem, <strong class="jxr_keyword">null</strong>);
-<a name="194" href="#194">194</a>         } <strong class="jxr_keyword">catch</strong> (XMLSecurityException e2) {
-<a name="195" href="#195">195</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="196" href="#196">196</a>                 WSSecurityException.FAILED_CHECK, <span class="jxr_string">"noXMLSig"</span>, <strong class="jxr_keyword">null</strong>, e2
-<a name="197" href="#197">197</a>             );
-<a name="198" href="#198">198</a>         }
-<a name="199" href="#199">199</a> 
-<a name="200" href="#200">200</a>         sig.addResourceResolver(EnvelopeIdResolver.getInstance());
-<a name="201" href="#201">201</a> 
-<a name="202" href="#202">202</a>         X509Certificate[] certs = <strong class="jxr_keyword">null</strong>;
-<a name="203" href="#203">203</a>         KeyInfo info = sig.getKeyInfo();
-<a name="204" href="#204">204</a>         byte[] secretKey = <strong class="jxr_keyword">null</strong>;
-<a name="205" href="#205">205</a>         <a href="../../../../../org/apache/ws/security/message/token/UsernameToken.html">UsernameToken</a> ut = <strong class="jxr_keyword">null</strong>;
-<a name="206" href="#206">206</a>         <a href="../../../../../org/apache/ws/security/message/token/DerivedKeyToken.html">DerivedKeyToken</a> dkt = <strong class="jxr_keyword">null</strong>;
-<a name="207" href="#207">207</a>         <a href="../../../../../org/apache/ws/security/saml/SAMLKeyInfo.html">SAMLKeyInfo</a> samlKi = <strong class="jxr_keyword">null</strong>;
-<a name="208" href="#208">208</a>         String customTokenId = <strong class="jxr_keyword">null</strong>;
-<a name="209" href="#209">209</a>         java.security.PublicKey publicKey = <strong class="jxr_keyword">null</strong>;
-<a name="210" href="#210">210</a>         
-<a name="211" href="#211">211</a>         <strong class="jxr_keyword">if</strong> (info != <strong class="jxr_keyword">null</strong> &amp;&amp; info.containsKeyValue()) {
-<a name="212" href="#212">212</a>             <strong class="jxr_keyword">try</strong> {
-<a name="213" href="#213">213</a>                 publicKey = info.getPublicKey();
-<a name="214" href="#214">214</a>             } <strong class="jxr_keyword">catch</strong> (Exception ex) {
-<a name="215" href="#215">215</a>                 <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a>(ex.getMessage(), ex);
-<a name="216" href="#216">216</a>             }
-<a name="217" href="#217">217</a>         } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (info != <strong class="jxr_keyword">null</strong>) {
-<a name="218" href="#218">218</a>             Node node = 
-<a name="219" href="#219">219</a>                 WSSecurityUtil.getDirectChild(
-<a name="220" href="#220">220</a>                     info.getElement(),
-<a name="221" href="#221">221</a>                     SecurityTokenReference.SECURITY_TOKEN_REFERENCE,
-<a name="222" href="#222">222</a>                     WSConstants.WSSE_NS
-<a name="223" href="#223">223</a>                 );
-<a name="224" href="#224">224</a>             <strong class="jxr_keyword">if</strong> (node == <strong class="jxr_keyword">null</strong>) {
-<a name="225" href="#225">225</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="226" href="#226">226</a>                     WSSecurityException.INVALID_SECURITY, <span class="jxr_string">"unsupportedKeyInfo"</span>
+<a name="190" href="#190">190</a>         <strong class="jxr_keyword">long</strong> t0 = 0, t1 = 0, t2 = 0;
+<a name="191" href="#191">191</a>         <strong class="jxr_keyword">if</strong> (tlog.isDebugEnabled()) {
+<a name="192" href="#192">192</a>             t0 = System.currentTimeMillis();
+<a name="193" href="#193">193</a>         }
+<a name="194" href="#194">194</a> 
+<a name="195" href="#195">195</a>         XMLSignature sig = <strong class="jxr_keyword">null</strong>;
+<a name="196" href="#196">196</a>         <strong class="jxr_keyword">try</strong> {
+<a name="197" href="#197">197</a>             sig = <strong class="jxr_keyword">new</strong> XMLSignature(elem, <strong class="jxr_keyword">null</strong>);
+<a name="198" href="#198">198</a>         } <strong class="jxr_keyword">catch</strong> (XMLSecurityException e2) {
+<a name="199" href="#199">199</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="200" href="#200">200</a>                 WSSecurityException.FAILED_CHECK, <span class="jxr_string">"noXMLSig"</span>, <strong class="jxr_keyword">null</strong>, e2
+<a name="201" href="#201">201</a>             );
+<a name="202" href="#202">202</a>         }
+<a name="203" href="#203">203</a> 
+<a name="204" href="#204">204</a>         sig.addResourceResolver(EnvelopeIdResolver.getInstance());
+<a name="205" href="#205">205</a> 
+<a name="206" href="#206">206</a>         X509Certificate[] certs = <strong class="jxr_keyword">null</strong>;
+<a name="207" href="#207">207</a>         KeyInfo info = sig.getKeyInfo();
+<a name="208" href="#208">208</a>         byte[] secretKey = <strong class="jxr_keyword">null</strong>;
+<a name="209" href="#209">209</a>         <a href="../../../../../org/apache/ws/security/message/token/UsernameToken.html">UsernameToken</a> ut = <strong class="jxr_keyword">null</strong>;
+<a name="210" href="#210">210</a>         <a href="../../../../../org/apache/ws/security/message/token/DerivedKeyToken.html">DerivedKeyToken</a> dkt = <strong class="jxr_keyword">null</strong>;
+<a name="211" href="#211">211</a>         <a href="../../../../../org/apache/ws/security/saml/SAMLKeyInfo.html">SAMLKeyInfo</a> samlKi = <strong class="jxr_keyword">null</strong>;
+<a name="212" href="#212">212</a>         String customTokenId = <strong class="jxr_keyword">null</strong>;
+<a name="213" href="#213">213</a>         java.security.PublicKey publicKey = <strong class="jxr_keyword">null</strong>;
+<a name="214" href="#214">214</a>         
+<a name="215" href="#215">215</a>         <strong class="jxr_keyword">if</strong> (info != <strong class="jxr_keyword">null</strong> &amp;&amp; info.containsKeyValue()) {
+<a name="216" href="#216">216</a>             <strong class="jxr_keyword">try</strong> {
+<a name="217" href="#217">217</a>                 publicKey = info.getPublicKey();
+<a name="218" href="#218">218</a>             } <strong class="jxr_keyword">catch</strong> (Exception ex) {
+<a name="219" href="#219">219</a>                 <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a>(ex.getMessage(), ex);
+<a name="220" href="#220">220</a>             }
+<a name="221" href="#221">221</a>         } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (info != <strong class="jxr_keyword">null</strong>) {
+<a name="222" href="#222">222</a>             Node node = 
+<a name="223" href="#223">223</a>                 WSSecurityUtil.getDirectChild(
+<a name="224" href="#224">224</a>                     info.getElement(),
+<a name="225" href="#225">225</a>                     SecurityTokenReference.SECURITY_TOKEN_REFERENCE,
+<a name="226" href="#226">226</a>                     WSConstants.WSSE_NS
 <a name="227" href="#227">227</a>                 );
-<a name="228" href="#228">228</a>             }
-<a name="229" href="#229">229</a>             <a href="../../../../../org/apache/ws/security/message/token/SecurityTokenReference.html">SecurityTokenReference</a> secRef = <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/message/token/SecurityTokenReference.html">SecurityTokenReference</a>((Element) node);
-<a name="230" href="#230">230</a>             <strong class="jxr_keyword">int</strong> docHash = elem.getOwnerDocument().hashCode();
-<a name="231" href="#231">231</a>             <em class="jxr_comment">//</em>
-<a name="232" href="#232">232</a>             <em class="jxr_comment">// Here we get some information about the document that is being</em>
-<a name="233" href="#233">233</a>             <em class="jxr_comment">// processed, in particular the crypto implementation, and already</em>
-<a name="234" href="#234">234</a>             <em class="jxr_comment">// detected BST that may be used later during dereferencing.</em>
-<a name="235" href="#235">235</a>             <em class="jxr_comment">//</em>
-<a name="236" href="#236">236</a>             <a href="../../../../../org/apache/ws/security/WSDocInfo.html">WSDocInfo</a> wsDocInfo = WSDocInfoStore.lookup(docHash);
-<a name="237" href="#237">237</a> 
-<a name="238" href="#238">238</a>             <strong class="jxr_keyword">if</strong> (secRef.containsReference()) {
-<a name="239" href="#239">239</a>                 Element token = secRef.getTokenElement(elem.getOwnerDocument(), wsDocInfo, cb);
-<a name="240" href="#240">240</a>                 <em class="jxr_comment">//</em>
-<a name="241" href="#241">241</a>                 <em class="jxr_comment">// at this point check token type: UsernameToken, Binary, SAML</em>
-<a name="242" href="#242">242</a>                 <em class="jxr_comment">// Crypto required only for Binary and SAML</em>
-<a name="243" href="#243">243</a>                 <em class="jxr_comment">//</em>
-<a name="244" href="#244">244</a>                 QName el = <strong class="jxr_keyword">new</strong> QName(token.getNamespaceURI(), token.getLocalName());
-<a name="245" href="#245">245</a>                 <strong class="jxr_keyword">if</strong> (el.equals(WSSecurityEngine.usernameToken)) {
-<a name="246" href="#246">246</a>                     String id = token.getAttributeNS(WSConstants.WSU_NS, <span class="jxr_string">"Id"</span>);
-<a name="247" href="#247">247</a>                     <a href="../../../../../org/apache/ws/security/processor/UsernameTokenProcessor.html">UsernameTokenProcessor</a> utProcessor = 
-<a name="248" href="#248">248</a>                         (<a href="../../../../../org/apache/ws/security/processor/UsernameTokenProcessor.html">UsernameTokenProcessor</a>) wsDocInfo.getProcessor(id);
-<a name="249" href="#249">249</a>                     ut = utProcessor.getUt();
-<a name="250" href="#250">250</a>                     <strong class="jxr_keyword">if</strong> (ut.isDerivedKey()) {
-<a name="251" href="#251">251</a>                         secretKey = ut.getDerivedKey();
-<a name="252" href="#252">252</a>                     } <strong class="jxr_keyword">else</strong> {
-<a name="253" href="#253">253</a>                         secretKey = ut.getSecretKey();
-<a name="254" href="#254">254</a>                     }
-<a name="255" href="#255">255</a>                 } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (el.equals(WSSecurityEngine.DERIVED_KEY_TOKEN_05_02) 
-<a name="256" href="#256">256</a>                     || el.equals(WSSecurityEngine.DERIVED_KEY_TOKEN_05_12)) {
-<a name="257" href="#257">257</a>                     dkt = <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/message/token/DerivedKeyToken.html">DerivedKeyToken</a>(token);
-<a name="258" href="#258">258</a>                     String id = dkt.getID();
-<a name="259" href="#259">259</a>                     <a href="../../../../../org/apache/ws/security/processor/DerivedKeyTokenProcessor.html">DerivedKeyTokenProcessor</a> dktProcessor = 
-<a name="260" href="#260">260</a>                         (<a href="../../../../../org/apache/ws/security/processor/DerivedKeyTokenProcessor.html">DerivedKeyTokenProcessor</a>) wsDocInfo.getProcessor(id);
-<a name="261" href="#261">261</a>                     String signatureMethodURI = sig.getSignedInfo().getSignatureMethodURI();
-<a name="262" href="#262">262</a>                     <strong class="jxr_keyword">int</strong> keyLength = (dkt.getLength() &gt; 0) ? dkt.getLength() : 
-<a name="263" href="#263">263</a>                         WSSecurityUtil.getKeyLength(signatureMethodURI);
-<a name="264" href="#264">264</a>                     
-<a name="265" href="#265">265</a>                     secretKey = dktProcessor.getKeyBytes(keyLength);
-<a name="266" href="#266">266</a>                 } <strong class="jxr_keyword">else</strong> {
-<a name="267" href="#267">267</a>                     <strong class="jxr_keyword">if</strong> (el.equals(WSSecurityEngine.binaryToken)) {
-<a name="268" href="#268">268</a>                         <em class="jxr_comment">// TODO: Use results from BinarySecurityTokenProcessor</em>
-<a name="269" href="#269">269</a>                         certs = getCertificatesTokenReference(token, crypto);
-<a name="270" href="#270">270</a>                     } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (el.equals(WSSecurityEngine.SAML_TOKEN)) {
-<a name="271" href="#271">271</a>                         <strong class="jxr_keyword">if</strong> (crypto == <strong class="jxr_keyword">null</strong>) {
-<a name="272" href="#272">272</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="273" href="#273">273</a>                                 WSSecurityException.FAILURE, <span class="jxr_string">"noSigCryptoFile"</span>
-<a name="274" href="#274">274</a>                             );
-<a name="275" href="#275">275</a>                         }
-<a name="276" href="#276">276</a>                         samlKi = SAMLUtil.getSAMLKeyInfo(token, crypto, cb);
-<a name="277" href="#277">277</a>                         certs = samlKi.getCerts();
-<a name="278" href="#278">278</a>                         secretKey = samlKi.getSecret();
-<a name="279" href="#279">279</a> 
-<a name="280" href="#280">280</a>                     } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (el.equals(WSSecurityEngine.ENCRYPTED_KEY)){
-<a name="281" href="#281">281</a>                         String encryptedKeyID = token.getAttributeNS(<strong class="jxr_keyword">null</strong>,<span class="jxr_string">"Id"</span>);                   
-<a name="282" href="#282">282</a>                         <a href="../../../../../org/apache/ws/security/processor/EncryptedKeyProcessor.html">EncryptedKeyProcessor</a> encryptKeyProcessor = 
-<a name="283" href="#283">283</a>                             (<a href="../../../../../org/apache/ws/security/processor/EncryptedKeyProcessor.html">EncryptedKeyProcessor</a>)wsDocInfo.getProcessor(encryptedKeyID);
-<a name="284" href="#284">284</a>                         
-<a name="285" href="#285">285</a>                         <strong class="jxr_keyword">if</strong> (encryptKeyProcessor == <strong class="jxr_keyword">null</strong> ) {
-<a name="286" href="#286">286</a>                             <strong class="jxr_keyword">if</strong> (crypto == <strong class="jxr_keyword">null</strong>) {
-<a name="287" href="#287">287</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="288" href="#288">288</a>                                     WSSecurityException.FAILURE, <span class="jxr_string">"noSigCryptoFile"</span>
-<a name="289" href="#289">289</a>                                 );
-<a name="290" href="#290">290</a>                             }
-<a name="291" href="#291">291</a>                             encryptKeyProcessor = <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/processor/EncryptedKeyProcessor.html">EncryptedKeyProcessor</a>();
-<a name="292" href="#292">292</a>                             encryptKeyProcessor.handleEncryptedKey((Element)token, cb, crypto);
-<a name="293" href="#293">293</a>                         } 
-<a name="294" href="#294">294</a>                         secretKey = encryptKeyProcessor.getDecryptedBytes();
-<a name="295" href="#295">295</a>                     } <strong class="jxr_keyword">else</strong> {
-<a name="296" href="#296">296</a>                         <em class="jxr_comment">// Try custom token through callback handler</em>
-<a name="297" href="#297">297</a>                         <em class="jxr_comment">// try to find a custom token</em>
-<a name="298" href="#298">298</a>                         String id = secRef.getReference().getURI();
-<a name="299" href="#299">299</a>                         <strong class="jxr_keyword">if</strong> (id.charAt(0) == '#') {
-<a name="300" href="#300">300</a>                             id = id.substring(1);
-<a name="301" href="#301">301</a>                         }
-<a name="302" href="#302">302</a>                         <a href="../../../../../org/apache/ws/security/WSPasswordCallback.html">WSPasswordCallback</a> pwcb = 
-<a name="303" href="#303">303</a>                             <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSPasswordCallback.html">WSPasswordCallback</a>(id, WSPasswordCallback.CUSTOM_TOKEN);
-<a name="304" href="#304">304</a>                         <strong class="jxr_keyword">try</strong> {
-<a name="305" href="#305">305</a>                             Callback[] callbacks = <strong class="jxr_keyword">new</strong> Callback[]{pwcb};
-<a name="306" href="#306">306</a>                             cb.handle(callbacks);
-<a name="307" href="#307">307</a>                         } <strong class="jxr_keyword">catch</strong> (Exception e) {
-<a name="308" href="#308">308</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="309" href="#309">309</a>                                 WSSecurityException.FAILURE,
-<a name="310" href="#310">310</a>                                 <span class="jxr_string">"noPassword"</span>, 
-<a name="311" href="#311">311</a>                                 <strong class="jxr_keyword">new</strong> Object[] {id}, 
-<a name="312" href="#312">312</a>                                 e
-<a name="313" href="#313">313</a>                             );
-<a name="314" href="#314">314</a>                         }
-<a name="315" href="#315">315</a>                         
-<a name="316" href="#316">316</a>                         secretKey = pwcb.getKey();
-<a name="317" href="#317">317</a>                         customTokenId = id;
-<a name="318" href="#318">318</a>                         <strong class="jxr_keyword">if</strong> (secretKey == <strong class="jxr_keyword">null</strong>) {
-<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.INVALID_SECURITY,
-<a name="321" href="#321">321</a>                                 <span class="jxr_string">"unsupportedKeyInfo"</span>, 
-<a name="322" href="#322">322</a>                                 <strong class="jxr_keyword">new</strong> Object[]{el.toString()}
-<a name="323" href="#323">323</a>                             );
-<a name="324" href="#324">324</a>                         }
-<a name="325" href="#325">325</a>                     }
-<a name="326" href="#326">326</a>                 }
-<a name="327" href="#327">327</a>             } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (secRef.containsX509Data() || secRef.containsX509IssuerSerial()) {
-<a name="328" href="#328">328</a>                 certs = secRef.getX509IssuerSerial(crypto);
-<a name="329" href="#329">329</a>             } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (secRef.containsKeyIdentifier()) {
-<a name="330" href="#330">330</a>                 <strong class="jxr_keyword">if</strong> (secRef.getKeyIdentifierValueType().equals(SecurityTokenReference.ENC_KEY_SHA1_URI)) {
-<a name="331" href="#331">331</a>                     
+<a name="228" href="#228">228</a>             <strong class="jxr_keyword">if</strong> (node == <strong class="jxr_keyword">null</strong>) {
+<a name="229" href="#229">229</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="230" href="#230">230</a>                     WSSecurityException.INVALID_SECURITY, <span class="jxr_string">"unsupportedKeyInfo"</span>
+<a name="231" href="#231">231</a>                 );
+<a name="232" href="#232">232</a>             }
+<a name="233" href="#233">233</a>             <a href="../../../../../org/apache/ws/security/message/token/SecurityTokenReference.html">SecurityTokenReference</a> secRef = <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/message/token/SecurityTokenReference.html">SecurityTokenReference</a>((Element) node);
+<a name="234" href="#234">234</a>             <em class="jxr_comment">// Here we get some information about the document that is being</em>
+<a name="235" href="#235">235</a>             <em class="jxr_comment">// processed, in particular the crypto implementation, and already</em>
+<a name="236" href="#236">236</a>             <em class="jxr_comment">// detected BST that may be used later during dereferencing.</em>
+<a name="237" href="#237">237</a>             <em class="jxr_comment">//</em>
+<a name="238" href="#238">238</a> 
+<a name="239" href="#239">239</a>             <strong class="jxr_keyword">if</strong> (secRef.containsReference()) {
+<a name="240" href="#240">240</a>                 Element token = secRef.getTokenElement(elem.getOwnerDocument(), wsDocInfo, cb);
+<a name="241" href="#241">241</a>                 <em class="jxr_comment">//</em>
+<a name="242" href="#242">242</a>                 <em class="jxr_comment">// at this point check token type: UsernameToken, Binary, SAML</em>
+<a name="243" href="#243">243</a>                 <em class="jxr_comment">// Crypto required only for Binary and SAML</em>
+<a name="244" href="#244">244</a>                 <em class="jxr_comment">//</em>
+<a name="245" href="#245">245</a>                 QName el = <strong class="jxr_keyword">new</strong> QName(token.getNamespaceURI(), token.getLocalName());
+<a name="246" href="#246">246</a>                 <strong class="jxr_keyword">if</strong> (el.equals(WSSecurityEngine.usernameToken)) {
+<a name="247" href="#247">247</a>                     String id = token.getAttributeNS(WSConstants.WSU_NS, <span class="jxr_string">"Id"</span>);
+<a name="248" href="#248">248</a>                     <a href="../../../../../org/apache/ws/security/processor/UsernameTokenProcessor.html">UsernameTokenProcessor</a> utProcessor = 
+<a name="249" href="#249">249</a>                         (<a href="../../../../../org/apache/ws/security/processor/UsernameTokenProcessor.html">UsernameTokenProcessor</a>) wsDocInfo.getProcessor(id);
+<a name="250" href="#250">250</a>                     ut = utProcessor.getUt();
+<a name="251" href="#251">251</a>                     <strong class="jxr_keyword">if</strong> (ut.isDerivedKey()) {
+<a name="252" href="#252">252</a>                         secretKey = ut.getDerivedKey();
+<a name="253" href="#253">253</a>                     } <strong class="jxr_keyword">else</strong> {
+<a name="254" href="#254">254</a>                         secretKey = ut.getSecretKey();
+<a name="255" href="#255">255</a>                     }
+<a name="256" href="#256">256</a>                 } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (el.equals(WSSecurityEngine.DERIVED_KEY_TOKEN_05_02) 
+<a name="257" href="#257">257</a>                     || el.equals(WSSecurityEngine.DERIVED_KEY_TOKEN_05_12)) {
+<a name="258" href="#258">258</a>                     dkt = <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/message/token/DerivedKeyToken.html">DerivedKeyToken</a>(token);
+<a name="259" href="#259">259</a>                     String id = dkt.getID();
+<a name="260" href="#260">260</a>                     <a href="../../../../../org/apache/ws/security/processor/DerivedKeyTokenProcessor.html">DerivedKeyTokenProcessor</a> dktProcessor = 
+<a name="261" href="#261">261</a>                         (<a href="../../../../../org/apache/ws/security/processor/DerivedKeyTokenProcessor.html">DerivedKeyTokenProcessor</a>) wsDocInfo.getProcessor(id);
+<a name="262" href="#262">262</a>                     String signatureMethodURI = sig.getSignedInfo().getSignatureMethodURI();
+<a name="263" href="#263">263</a>                     <strong class="jxr_keyword">int</strong> keyLength = (dkt.getLength() &gt; 0) ? dkt.getLength() : 
+<a name="264" href="#264">264</a>                         WSSecurityUtil.getKeyLength(signatureMethodURI);
+<a name="265" href="#265">265</a>                     
+<a name="266" href="#266">266</a>                     secretKey = dktProcessor.getKeyBytes(keyLength);
+<a name="267" href="#267">267</a>                 } <strong class="jxr_keyword">else</strong> {
+<a name="268" href="#268">268</a>                     <strong class="jxr_keyword">if</strong> (el.equals(WSSecurityEngine.binaryToken)) {
+<a name="269" href="#269">269</a>                         <em class="jxr_comment">// TODO: Use results from BinarySecurityTokenProcessor</em>
+<a name="270" href="#270">270</a>                         certs = getCertificatesTokenReference(token, crypto);
+<a name="271" href="#271">271</a>                     } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (el.equals(WSSecurityEngine.SAML_TOKEN)) {
+<a name="272" href="#272">272</a>                         <strong class="jxr_keyword">if</strong> (crypto == <strong class="jxr_keyword">null</strong>) {
+<a name="273" href="#273">273</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="274" href="#274">274</a>                                 WSSecurityException.FAILURE, <span class="jxr_string">"noSigCryptoFile"</span>
+<a name="275" href="#275">275</a>                             );
+<a name="276" href="#276">276</a>                         }
+<a name="277" href="#277">277</a>                         samlKi = SAMLUtil.getSAMLKeyInfo(token, crypto, cb);
+<a name="278" href="#278">278</a>                         certs = samlKi.getCerts();
+<a name="279" href="#279">279</a>                         secretKey = samlKi.getSecret();
+<a name="280" href="#280">280</a> 
+<a name="281" href="#281">281</a>                     } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (el.equals(WSSecurityEngine.ENCRYPTED_KEY)){
+<a name="282" href="#282">282</a>                         String encryptedKeyID = token.getAttributeNS(<strong class="jxr_keyword">null</strong>,<span class="jxr_string">"Id"</span>);                   
+<a name="283" href="#283">283</a>                         <a href="../../../../../org/apache/ws/security/processor/EncryptedKeyProcessor.html">EncryptedKeyProcessor</a> encryptKeyProcessor = 
+<a name="284" href="#284">284</a>                             (<a href="../../../../../org/apache/ws/security/processor/EncryptedKeyProcessor.html">EncryptedKeyProcessor</a>)wsDocInfo.getProcessor(encryptedKeyID);
+<a name="285" href="#285">285</a>                         
+<a name="286" href="#286">286</a>                         <strong class="jxr_keyword">if</strong> (encryptKeyProcessor == <strong class="jxr_keyword">null</strong> ) {
+<a name="287" href="#287">287</a>                             <strong class="jxr_keyword">if</strong> (crypto == <strong class="jxr_keyword">null</strong>) {
+<a name="288" href="#288">288</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="289" href="#289">289</a>                                     WSSecurityException.FAILURE, <span class="jxr_string">"noSigCryptoFile"</span>
+<a name="290" href="#290">290</a>                                 );
+<a name="291" href="#291">291</a>                             }
+<a name="292" href="#292">292</a>                             encryptKeyProcessor = <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/processor/EncryptedKeyProcessor.html">EncryptedKeyProcessor</a>();
+<a name="293" href="#293">293</a>                             encryptKeyProcessor.handleEncryptedKey((Element)token, cb, crypto);
+<a name="294" href="#294">294</a>                         } 
+<a name="295" href="#295">295</a>                         secretKey = encryptKeyProcessor.getDecryptedBytes();
+<a name="296" href="#296">296</a>                     } <strong class="jxr_keyword">else</strong> {
+<a name="297" href="#297">297</a>                         <em class="jxr_comment">// Try custom token through callback handler</em>
+<a name="298" href="#298">298</a>                         <em class="jxr_comment">// try to find a custom token</em>
+<a name="299" href="#299">299</a>                         String id = secRef.getReference().getURI();
+<a name="300" href="#300">300</a>                         <strong class="jxr_keyword">if</strong> (id.charAt(0) == '#') {
+<a name="301" href="#301">301</a>                             id = id.substring(1);
+<a name="302" href="#302">302</a>                         }
+<a name="303" href="#303">303</a>                         <a href="../../../../../org/apache/ws/security/WSPasswordCallback.html">WSPasswordCallback</a> pwcb = 
+<a name="304" href="#304">304</a>                             <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSPasswordCallback.html">WSPasswordCallback</a>(id, WSPasswordCallback.CUSTOM_TOKEN);
+<a name="305" href="#305">305</a>                         <strong class="jxr_keyword">try</strong> {
+<a name="306" href="#306">306</a>                             Callback[] callbacks = <strong class="jxr_keyword">new</strong> Callback[]{pwcb};
+<a name="307" href="#307">307</a>                             cb.handle(callbacks);
+<a name="308" href="#308">308</a>                         } <strong class="jxr_keyword">catch</strong> (Exception e) {
+<a name="309" href="#309">309</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="310" href="#310">310</a>                                 WSSecurityException.FAILURE,
+<a name="311" href="#311">311</a>                                 <span class="jxr_string">"noPassword"</span>, 
+<a name="312" href="#312">312</a>                                 <strong class="jxr_keyword">new</strong> Object[] {id}, 
+<a name="313" href="#313">313</a>                                 e
+<a name="314" href="#314">314</a>                             );
+<a name="315" href="#315">315</a>                         }
+<a name="316" href="#316">316</a>                         
+<a name="317" href="#317">317</a>                         secretKey = pwcb.getKey();
+<a name="318" href="#318">318</a>                         customTokenId = id;
+<a name="319" href="#319">319</a>                         <strong class="jxr_keyword">if</strong> (secretKey == <strong class="jxr_keyword">null</strong>) {
+<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.INVALID_SECURITY,
+<a name="322" href="#322">322</a>                                 <span class="jxr_string">"unsupportedKeyInfo"</span>, 
+<a name="323" href="#323">323</a>                                 <strong class="jxr_keyword">new</strong> Object[]{el.toString()}
+<a name="324" href="#324">324</a>                             );
+<a name="325" href="#325">325</a>                         }
+<a name="326" href="#326">326</a>                     }
+<a name="327" href="#327">327</a>                 }
+<a name="328" href="#328">328</a>             } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (secRef.containsX509Data() || secRef.containsX509IssuerSerial()) {
+<a name="329" href="#329">329</a>                 certs = secRef.getX509IssuerSerial(crypto);
+<a name="330" href="#330">330</a>             } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (secRef.containsKeyIdentifier()) {
+<a name="331" href="#331">331</a>                 <strong class="jxr_keyword">if</strong> (secRef.getKeyIdentifierValueType().equals(SecurityTokenReference.ENC_KEY_SHA1_URI)) {
 <a name="332" href="#332">332</a>                     String id = secRef.getKeyIdentifierValue();
 <a name="333" href="#333">333</a>                     <a href="../../../../../org/apache/ws/security/WSPasswordCallback.html">WSPasswordCallback</a> pwcb = 
 <a name="334" href="#334">334</a>                         <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSPasswordCallback.html">WSPasswordCallback</a>(
@@ -359,239 +359,251 @@
 <a name="349" href="#349">349</a>                         );
 <a name="350" href="#350">350</a>                     }
 <a name="351" href="#351">351</a>                     secretKey = pwcb.getKey();
-<a name="352" href="#352">352</a>                 } <strong class="jxr_keyword">else</strong> {
-<a name="353" href="#353">353</a>                     certs = secRef.getKeyIdentifier(crypto);
-<a name="354" href="#354">354</a>                 }
-<a name="355" href="#355">355</a>             } <strong class="jxr_keyword">else</strong> {
-<a name="356" href="#356">356</a>                 <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a>(
-<a name="357" href="#357">357</a>                     WSSecurityException.INVALID_SECURITY,
-<a name="358" href="#358">358</a>                     <span class="jxr_string">"unsupportedKeyInfo"</span>, 
-<a name="359" href="#359">359</a>                     <strong class="jxr_keyword">new</strong> Object[]{node.toString()}
-<a name="360" href="#360">360</a>                 );
-<a name="361" href="#361">361</a>             }
-<a name="362" href="#362">362</a>         } <strong class="jxr_keyword">else</strong> {
-<a name="363" href="#363">363</a>             <strong class="jxr_keyword">if</strong> (crypto == <strong class="jxr_keyword">null</strong>) {
-<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>(WSSecurityException.FAILURE, <span class="jxr_string">"noSigCryptoFile"</span>);
-<a name="365" href="#365">365</a>             }
-<a name="366" href="#366">366</a>             <strong class="jxr_keyword">if</strong> (crypto.getDefaultX509Alias() != <strong class="jxr_keyword">null</strong>) {
-<a name="367" href="#367">367</a>                 certs = crypto.getCertificates(crypto.getDefaultX509Alias());
-<a name="368" href="#368">368</a>             } <strong class="jxr_keyword">else</strong> {
-<a name="369" href="#369">369</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="370" href="#370">370</a>                     WSSecurityException.INVALID_SECURITY, <span class="jxr_string">"unsupportedKeyInfo"</span>
-<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">if</strong> (tlog.isDebugEnabled()) {
-<a name="375" href="#375">375</a>             t1 = System.currentTimeMillis();
-<a name="376" href="#376">376</a>         }
-<a name="377" href="#377">377</a>         <strong class="jxr_keyword">if</strong> ((certs == <strong class="jxr_keyword">null</strong> || certs.length == 0 || certs[0] == <strong class="jxr_keyword">null</strong>) 
-<a name="378" href="#378">378</a>             &amp;&amp; secretKey == <strong class="jxr_keyword">null</strong>
-<a name="379" href="#379">379</a>             &amp;&amp; publicKey == <strong class="jxr_keyword">null</strong>) {
-<a name="380" href="#380">380</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a>(WSSecurityException.FAILED_CHECK);
-<a name="381" href="#381">381</a>         }
-<a name="382" href="#382">382</a>         <strong class="jxr_keyword">if</strong> (certs != <strong class="jxr_keyword">null</strong>) {
-<a name="383" href="#383">383</a>             <strong class="jxr_keyword">try</strong> {
-<a name="384" href="#384">384</a>                 certs[0].checkValidity();
-<a name="385" href="#385">385</a>             } <strong class="jxr_keyword">catch</strong> (CertificateExpiredException e) {
-<a name="386" href="#386">386</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="387" href="#387">387</a>                     WSSecurityException.FAILED_CHECK, <span class="jxr_string">"invalidCert"</span>, <strong class="jxr_keyword">null</strong>, e
-<a name="388" href="#388">388</a>                 );
-<a name="389" href="#389">389</a>             } <strong class="jxr_keyword">catch</strong> (CertificateNotYetValidException e) {
-<a name="390" href="#390">390</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="391" href="#391">391</a>                     WSSecurityException.FAILED_CHECK, <span class="jxr_string">"invalidCert"</span>, <strong class="jxr_keyword">null</strong>, e
-<a name="392" href="#392">392</a>                 );
-<a name="393" href="#393">393</a>             }
-<a name="394" href="#394">394</a>         }
-<a name="395" href="#395">395</a>         <em class="jxr_comment">//</em>
-<a name="396" href="#396">396</a>         <em class="jxr_comment">// Delegate verification of a public key to a Callback Handler</em>
-<a name="397" href="#397">397</a>         <em class="jxr_comment">//</em>
-<a name="398" href="#398">398</a>         <strong class="jxr_keyword">if</strong> (publicKey != <strong class="jxr_keyword">null</strong>) {
-<a name="399" href="#399">399</a>             <a href="../../../../../org/apache/ws/security/PublicKeyCallback.html">PublicKeyCallback</a> pwcb = 
-<a name="400" href="#400">400</a>                 <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/PublicKeyCallback.html">PublicKeyCallback</a>(publicKey);
-<a name="401" href="#401">401</a>             <strong class="jxr_keyword">try</strong> {
-<a name="402" href="#402">402</a>                 Callback[] callbacks = <strong class="jxr_keyword">new</strong> Callback[]{pwcb};
-<a name="403" href="#403">403</a>                 cb.handle(callbacks);
-<a name="404" href="#404">404</a>                 <strong class="jxr_keyword">if</strong> (!pwcb.isVerified()) {
-<a name="405" href="#405">405</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="406" href="#406">406</a>                         WSSecurityException.FAILED_AUTHENTICATION, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">null</strong>
-<a name="407" href="#407">407</a>                     );
-<a name="408" href="#408">408</a>                 }
-<a name="409" href="#409">409</a>             } <strong class="jxr_keyword">catch</strong> (Exception e) {
-<a name="410" href="#410">410</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="411" href="#411">411</a>                     WSSecurityException.FAILED_AUTHENTICATION, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">null</strong>, e
-<a name="412" href="#412">412</a>                 );
-<a name="413" href="#413">413</a>             }
-<a name="414" href="#414">414</a>         }
-<a name="415" href="#415">415</a>         <strong class="jxr_keyword">try</strong> {
-<a name="416" href="#416">416</a>             <strong class="jxr_keyword">boolean</strong> signatureOk = false;
-<a name="417" href="#417">417</a>             <strong class="jxr_keyword">if</strong> (certs != <strong class="jxr_keyword">null</strong>) {
-<a name="418" href="#418">418</a>                 signatureOk = sig.checkSignatureValue(certs[0]);
-<a name="419" href="#419">419</a>             } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (publicKey != <strong class="jxr_keyword">null</strong>) {
-<a name="420" href="#420">420</a>                 signatureOk = sig.checkSignatureValue(publicKey);
-<a name="421" href="#421">421</a>             } <strong class="jxr_keyword">else</strong> {
-<a name="422" href="#422">422</a>                 signatureOk = sig.checkSignatureValue(sig.createSecretKey(secretKey));
-<a name="423" href="#423">423</a>             }
-<a name="424" href="#424">424</a>             <strong class="jxr_keyword">if</strong> (signatureOk) {
-<a name="425" href="#425">425</a>                 <strong class="jxr_keyword">if</strong> (tlog.isDebugEnabled()) {
-<a name="426" href="#426">426</a>                     t2 = System.currentTimeMillis();
-<a name="427" href="#427">427</a>                     tlog.debug(
-<a name="428" href="#428">428</a>                         <span class="jxr_string">"Verify: total= "</span> + (t2 - t0) + <span class="jxr_string">", prepare-cert= "</span> + (t1 - t0) 
-<a name="429" href="#429">429</a>                         + <span class="jxr_string">", verify= "</span> + (t2 - t1)
-<a name="430" href="#430">430</a>                     );
-<a name="431" href="#431">431</a>                 }
-<a name="432" href="#432">432</a>                 signatureValue[0] = sig.getSignatureValue();
-<a name="433" href="#433">433</a>                 <em class="jxr_comment">//</em>
-<a name="434" href="#434">434</a>                 <em class="jxr_comment">// Now dig into the Signature element to get the elements that</em>
-<a name="435" href="#435">435</a>                 <em class="jxr_comment">// this Signature covers. Build the QName of these Elements and</em>
-<a name="436" href="#436">436</a>                 <em class="jxr_comment">// return them to caller</em>
-<a name="437" href="#437">437</a>                 <em class="jxr_comment">//</em>
-<a name="438" href="#438">438</a>                 SignedInfo si = sig.getSignedInfo();
-<a name="439" href="#439">439</a>                 <strong class="jxr_keyword">int</strong> numReferences = si.getLength();
-<a name="440" href="#440">440</a>                 <strong class="jxr_keyword">for</strong> (<strong class="jxr_keyword">int</strong> i = 0; i &lt; numReferences; i++) {
-<a name="441" href="#441">441</a>                     <a href="../../../../../org/apache/ws/security/message/token/Reference.html">Reference</a> siRef;
-<a name="442" href="#442">442</a>                     <strong class="jxr_keyword">try</strong> {
-<a name="443" href="#443">443</a>                         siRef = si.item(i);
-<a name="444" href="#444">444</a>                     } <strong class="jxr_keyword">catch</strong> (XMLSecurityException e3) {
-<a name="445" href="#445">445</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="446" href="#446">446</a>                             WSSecurityException.FAILED_CHECK, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">null</strong>, e3
-<a name="447" href="#447">447</a>                         );
-<a name="448" href="#448">448</a>                     }
-<a name="449" href="#449">449</a>                     String uri = siRef.getURI();
-<a name="450" href="#450">450</a>                     <strong class="jxr_keyword">if</strong> (uri != <strong class="jxr_keyword">null</strong> &amp;&amp; !<span class="jxr_string">""</span>.equals(uri)) {
-<a name="451" href="#451">451</a>                         Element se = WSSecurityUtil.getElementByWsuId(elem.getOwnerDocument(), uri);
-<a name="452" href="#452">452</a>                         <strong class="jxr_keyword">if</strong> (se == <strong class="jxr_keyword">null</strong>) {
-<a name="453" href="#453">453</a>                             se = WSSecurityUtil.getElementByGenId(elem.getOwnerDocument(), uri);
-<a name="454" href="#454">454</a>                         }
-<a name="455" href="#455">455</a>                         <strong class="jxr_keyword">if</strong> (se == <strong class="jxr_keyword">null</strong>) {
-<a name="456" href="#456">456</a>                             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a>(WSSecurityException.FAILED_CHECK);
-<a name="457" href="#457">457</a>                         }
-<a name="458" href="#458">458</a>                         <a href="../../../../../org/apache/ws/security/WSDataRef.html">WSDataRef</a> ref = <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSDataRef.html">WSDataRef</a>(uri);
-<a name="459" href="#459">459</a>                         ref.setWsuId(uri);
-<a name="460" href="#460">460</a>                         ref.setName(<strong class="jxr_keyword">new</strong> QName(se.getNamespaceURI(), se.getLocalName()));
-<a name="461" href="#461">461</a>                         protectedElements.add(ref);
-<a name="462" href="#462">462</a>                         returnElements.add(WSSecurityUtil.getIDFromReference(uri));
-<a name="463" href="#463">463</a>                     } <strong class="jxr_keyword">else</strong> {
-<a name="464" href="#464">464</a>                        <em class="jxr_comment">// This is the case where the signed element is identified </em>
-<a name="465" href="#465">465</a>                        <em class="jxr_comment">// by a transform such as XPath filtering</em>
-<a name="466" href="#466">466</a>                        <em class="jxr_comment">// We add the complete reference element to the return </em>
-<a name="467" href="#467">467</a>                        <em class="jxr_comment">// elements</em>
-<a name="468" href="#468">468</a>                        returnElements.add(siRef); 
-<a name="469" href="#469">469</a>                     }
-<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">if</strong> (certs != <strong class="jxr_keyword">null</strong>) {
-<a name="473" href="#473">473</a>                     returnCert[0] = certs[0];
-<a name="474" href="#474">474</a>                     <strong class="jxr_keyword">return</strong> certs[0].getSubjectDN();
-<a name="475" href="#475">475</a>                 } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (publicKey != <strong class="jxr_keyword">null</strong>) {
-<a name="476" href="#476">476</a>                     <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/PublicKeyPrincipal.html">PublicKeyPrincipal</a>(publicKey);
-<a name="477" href="#477">477</a>                 } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (ut != <strong class="jxr_keyword">null</strong>) {
-<a name="478" href="#478">478</a>                     <a href="../../../../../org/apache/ws/security/WSUsernameTokenPrincipal.html">WSUsernameTokenPrincipal</a> principal = 
-<a name="479" href="#479">479</a>                         <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSUsernameTokenPrincipal.html">WSUsernameTokenPrincipal</a>(ut.getName(), ut.isHashed());
-<a name="480" href="#480">480</a>                     principal.setNonce(ut.getNonce());
-<a name="481" href="#481">481</a>                     principal.setPassword(ut.getPassword());
-<a name="482" href="#482">482</a>                     principal.setCreatedTime(ut.getCreated());
-<a name="483" href="#483">483</a>                     <strong class="jxr_keyword">return</strong> principal;
-<a name="484" href="#484">484</a>                 } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (dkt != <strong class="jxr_keyword">null</strong>) {
-<a name="485" href="#485">485</a>                     <a href="../../../../../org/apache/ws/security/WSDerivedKeyTokenPrincipal.html">WSDerivedKeyTokenPrincipal</a> principal = <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSDerivedKeyTokenPrincipal.html">WSDerivedKeyTokenPrincipal</a>(dkt.getID());
-<a name="486" href="#486">486</a>                     principal.setNonce(dkt.getNonce());
-<a name="487" href="#487">487</a>                     principal.setLabel(dkt.getLabel());
-<a name="488" href="#488">488</a>                     principal.setLength(dkt.getLength());
-<a name="489" href="#489">489</a>                     principal.setOffset(dkt.getOffset());
-<a name="490" href="#490">490</a>                     String basetokenId = <strong class="jxr_keyword">null</strong>;
-<a name="491" href="#491">491</a>                     <a href="../../../../../org/apache/ws/security/message/token/SecurityTokenReference.html">SecurityTokenReference</a> securityTokenReference = dkt.getSecurityTokenReference();
-<a name="492" href="#492">492</a>                     <strong class="jxr_keyword">if</strong> (securityTokenReference.containsReference()) {
-<a name="493" href="#493">493</a>                         basetokenId = securityTokenReference.getReference().getURI();
-<a name="494" href="#494">494</a>                         <strong class="jxr_keyword">if</strong> (basetokenId.charAt(0) == '#') {
-<a name="495" href="#495">495</a>                             basetokenId = basetokenId.substring(1);
-<a name="496" href="#496">496</a>                         }
-<a name="497" href="#497">497</a>                     } <strong class="jxr_keyword">else</strong> {
-<a name="498" href="#498">498</a>                         <em class="jxr_comment">// KeyIdentifier</em>
-<a name="499" href="#499">499</a>                         basetokenId = securityTokenReference.getKeyIdentifierValue();
-<a name="500" href="#500">500</a>                     }
-<a name="501" href="#501">501</a>                     principal.setBasetokenId(basetokenId);
-<a name="502" href="#502">502</a>                     <strong class="jxr_keyword">return</strong> principal;
-<a name="503" href="#503">503</a>                 } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (samlKi != <strong class="jxr_keyword">null</strong>) {
-<a name="504" href="#504">504</a>                     <strong class="jxr_keyword">final</strong> SAMLAssertion assertion = samlKi.getAssertion();
-<a name="505" href="#505">505</a>                     <a href="../../../../../org/apache/ws/security/CustomTokenPrincipal.html">CustomTokenPrincipal</a> principal = <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/CustomTokenPrincipal.html">CustomTokenPrincipal</a>(assertion.getId());
-<a name="506" href="#506">506</a>                     principal.setTokenObject(assertion);
-<a name="507" href="#507">507</a>                     <strong class="jxr_keyword">return</strong> principal;
-<a name="508" href="#508">508</a>                 } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (secretKey != <strong class="jxr_keyword">null</strong>) {
-<a name="509" href="#509">509</a>                     <em class="jxr_comment">// This is the custom key scenario</em>
-<a name="510" href="#510">510</a>                     <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/CustomTokenPrincipal.html">CustomTokenPrincipal</a>(customTokenId);
-<a name="511" href="#511">511</a>                 } <strong class="jxr_keyword">else</strong> {
-<a name="512" href="#512">512</a>                     <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a>(<span class="jxr_string">"Cannot determine principal"</span>);
-<a name="513" href="#513">513</a>                 }
-<a name="514" href="#514">514</a>             } <strong class="jxr_keyword">else</strong> {
-<a name="515" href="#515">515</a>                 <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a>(WSSecurityException.FAILED_CHECK);
-<a name="516" href="#516">516</a>             }
-<a name="517" href="#517">517</a>         } <strong class="jxr_keyword">catch</strong> (XMLSignatureException e1) {
-<a name="518" href="#518">518</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="519" href="#519">519</a>                 WSSecurityException.FAILED_CHECK, <strong class="jxr_keyword">null</strong>, <strong class="jxr_keyword">null</strong>, e1
-<a name="520" href="#520">520</a>             );
-<a name="521" href="#521">521</a>         }
-<a name="522" href="#522">522</a>     }
-<a name="523" href="#523">523</a> 
-<a name="524" href="#524">524</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="525" href="#525">525</a> <em class="jxr_javadoccomment">     * Extracts the certificate(s) from the Binary Security token reference.</em>
-<a name="526" href="#526">526</a> <em class="jxr_javadoccomment">     *</em>
-<a name="527" href="#527">527</a> <em class="jxr_javadoccomment">     * @param elem The element containing the binary security token. This is</em>
-<a name="528" href="#528">528</a> <em class="jxr_javadoccomment">     *             either X509 certificate(s) or a PKIPath.</em>
-<a name="529" href="#529">529</a> <em class="jxr_javadoccomment">     * @return an array of X509 certificates</em>
-<a name="530" href="#530">530</a> <em class="jxr_javadoccomment">     * @throws WSSecurityException</em>
-<a name="531" href="#531">531</a> <em class="jxr_javadoccomment">     */</em>
-<a name="532" href="#532">532</a>     <strong class="jxr_keyword">public</strong> X509Certificate[] getCertificatesTokenReference(Element elem, <a href="../../../../../org/apache/ws/security/components/crypto/Crypto.html">Crypto</a> crypto)
-<a name="533" href="#533">533</a>         <strong class="jxr_keyword">throws</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a> {
-<a name="534" href="#534">534</a>         <strong class="jxr_keyword">if</strong> (crypto == <strong class="jxr_keyword">null</strong>) {
-<a name="535" href="#535">535</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">"noSigCryptoFile"</span>);
-<a name="536" href="#536">536</a>         }
-<a name="537" href="#537">537</a>         <a href="../../../../../org/apache/ws/security/message/token/BinarySecurity.html">BinarySecurity</a> token = createSecurityToken(elem);
-<a name="538" href="#538">538</a>         <strong class="jxr_keyword">if</strong> (token instanceof PKIPathSecurity) {
-<a name="539" href="#539">539</a>             <strong class="jxr_keyword">return</strong> ((PKIPathSecurity) token).getX509Certificates(false, crypto);
-<a name="540" href="#540">540</a>         } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (token instanceof X509Security) {
-<a name="541" href="#541">541</a>             X509Certificate cert = ((X509Security) token).getX509Certificate(crypto);
-<a name="542" href="#542">542</a>             X509Certificate[] certs = <strong class="jxr_keyword">new</strong> X509Certificate[1];
-<a name="543" href="#543">543</a>             certs[0] = cert;
-<a name="544" href="#544">544</a>             <strong class="jxr_keyword">return</strong> certs;
-<a name="545" href="#545">545</a>         }
-<a name="546" href="#546">546</a>         <strong class="jxr_keyword">return</strong> <strong class="jxr_keyword">null</strong>;
-<a name="547" href="#547">547</a>     }
-<a name="548" href="#548">548</a> 
-<a name="549" href="#549">549</a> 
-<a name="550" href="#550">550</a>     <em class="jxr_javadoccomment">/**</em>
-<a name="551" href="#551">551</a> <em class="jxr_javadoccomment">     * Checks the &lt;code&gt;element&lt;/code&gt; and creates appropriate binary security object.</em>
-<a name="552" href="#552">552</a> <em class="jxr_javadoccomment">     *</em>
-<a name="553" href="#553">553</a> <em class="jxr_javadoccomment">     * @param element The XML element that contains either a &lt;code&gt;BinarySecurityToken</em>
-<a name="554" href="#554">554</a> <em class="jxr_javadoccomment">     *                &lt;/code&gt; or a &lt;code&gt;PKIPath&lt;/code&gt; element. Other element types a not</em>
-<a name="555" href="#555">555</a> <em class="jxr_javadoccomment">     *                supported</em>
-<a name="556" href="#556">556</a> <em class="jxr_javadoccomment">     * @return the BinarySecurity object, either a &lt;code&gt;X509Security&lt;/code&gt; or a</em>
-<a name="557" href="#557">557</a> <em class="jxr_javadoccomment">     *         &lt;code&gt;PKIPathSecurity&lt;/code&gt; object.</em>
-<a name="558" href="#558">558</a> <em class="jxr_javadoccomment">     * @throws WSSecurityException</em>
-<a name="559" href="#559">559</a> <em class="jxr_javadoccomment">     */</em>
-<a name="560" href="#560">560</a>     <strong class="jxr_keyword">private</strong> <a href="../../../../../org/apache/ws/security/message/token/BinarySecurity.html">BinarySecurity</a> createSecurityToken(Element element) <strong class="jxr_keyword">throws</strong> WSSecurityException {
-<a name="561" href="#561">561</a>         <a href="../../../../../org/apache/ws/security/message/token/BinarySecurity.html">BinarySecurity</a> token = <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/message/token/BinarySecurity.html">BinarySecurity</a>(element);
-<a name="562" href="#562">562</a>         String type = token.getValueType();
-<a name="563" href="#563">563</a>         X509Security x509 = <strong class="jxr_keyword">null</strong>;
-<a name="564" href="#564">564</a>         <a href="../../../../../org/apache/ws/security/message/token/PKIPathSecurity.html">PKIPathSecurity</a> pkiPath = <strong class="jxr_keyword">null</strong>;
-<a name="565" href="#565">565</a> 
-<a name="566" href="#566">566</a>         <strong class="jxr_keyword">if</strong> (X509Security.X509_V3_TYPE.equals(type)) {
-<a name="567" href="#567">567</a>             x509 = <strong class="jxr_keyword">new</strong> X509Security(element);
-<a name="568" href="#568">568</a>             <strong class="jxr_keyword">return</strong> (BinarySecurity) x509;
-<a name="569" href="#569">569</a>         } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (PKIPathSecurity.getType().equals(type)) {
-<a name="570" href="#570">570</a>             pkiPath = <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/message/token/PKIPathSecurity.html">PKIPathSecurity</a>(element);
-<a name="571" href="#571">571</a>             <strong class="jxr_keyword">return</strong> (BinarySecurity) pkiPath;
-<a name="572" href="#572">572</a>         }
-<a name="573" href="#573">573</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="574" href="#574">574</a>             WSSecurityException.UNSUPPORTED_SECURITY_TOKEN,
-<a name="575" href="#575">575</a>             <span class="jxr_string">"unsupportedBinaryTokenType"</span>, 
-<a name="576" href="#576">576</a>             <strong class="jxr_keyword">new</strong> Object[]{type}
-<a name="577" href="#577">577</a>         );
-<a name="578" href="#578">578</a>     }
-<a name="579" href="#579">579</a> 
-<a name="580" href="#580">580</a>     <strong class="jxr_keyword">public</strong> String getId() {
-<a name="581" href="#581">581</a>         <strong class="jxr_keyword">return</strong> signatureId;
-<a name="582" href="#582">582</a>     }
-<a name="583" href="#583">583</a> 
-<a name="584" href="#584">584</a> }
+<a name="352" href="#352">352</a>                 } <strong class="jxr_keyword">else</strong> <strong class="jxr_keyword">if</strong> (WSConstants.WSS_SAML_KI_VALUE_TYPE.equals(secRef.getKeyIdentifierValueType())) { 
+<a name="353" href="#353">353</a>                     Element token = 
+<a name="354" href="#354">354</a>                         secRef.getKeyIdentifierTokenElement(elem.getOwnerDocument(), wsDocInfo, cb);
+<a name="355" href="#355">355</a>                     
+<a name="356" href="#356">356</a>                     <strong class="jxr_keyword">if</strong> (crypto == <strong class="jxr_keyword">null</strong>) {
+<a name="357" href="#357">357</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="358" href="#358">358</a>                             WSSecurityException.FAILURE, <span class="jxr_string">"noSigCryptoFile"</span>
+<a name="359" href="#359">359</a>                         );
+<a name="360" href="#360">360</a>                     }
+<a name="361" href="#361">361</a>                     samlKi = SAMLUtil.getSAMLKeyInfo(token, crypto, cb);
+<a name="362" href="#362">362</a>                     certs = samlKi.getCerts();
+<a name="363" href="#363">363</a>                     secretKey = samlKi.getSecret();
+<a name="364" href="#364">364</a>                 } <strong class="jxr_keyword">else</strong> {
+<a name="365" href="#365">365</a>                     certs = secRef.getKeyIdentifier(crypto);
+<a name="366" href="#366">366</a>                 }
+<a name="367" href="#367">367</a>             } <strong class="jxr_keyword">else</strong> {
+<a name="368" href="#368">368</a>                 <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a>(
+<a name="369" href="#369">369</a>                     WSSecurityException.INVALID_SECURITY,
+<a name="370" href="#370">370</a>                     <span class="jxr_string">"unsupportedKeyInfo"</span>, 
+<a name="371" href="#371">371</a>                     <strong class="jxr_keyword">new</strong> Object[]{node.toString()}
+<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">else</strong> {
+<a name="375" href="#375">375</a>             <strong class="jxr_keyword">if</strong> (crypto == <strong class="jxr_keyword">null</strong>) {
+<a name="376" href="#376">376</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">"noSigCryptoFile"</span>);
+<a name="377" href="#377">377</a>             }
+<a name="378" href="#378">378</a>             <strong class="jxr_keyword">if</strong> (crypto.getDefaultX509Alias() != <strong class="jxr_keyword">null</strong>) {
+<a name="379" href="#379">379</a>                 certs = crypto.getCertificates(crypto.getDefaultX509Alias());
+<a name="380" href="#380">380</a>             } <strong class="jxr_keyword">else</strong> {
+<a name="381" href="#381">381</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="382" href="#382">382</a>                     WSSecurityException.INVALID_SECURITY, <span class="jxr_string">"unsupportedKeyInfo"</span>
+<a name="383" href="#383">383</a>                 );
+<a name="384" href="#384">384</a>             }
+<a name="385" href="#385">385</a>         }
+<a name="386" href="#386">386</a>         <strong class="jxr_keyword">if</strong> (tlog.isDebugEnabled()) {
+<a name="387" href="#387">387</a>             t1 = System.currentTimeMillis();
+<a name="388" href="#388">388</a>         }
+<a name="389" href="#389">389</a>         <strong class="jxr_keyword">if</strong> ((certs == <strong class="jxr_keyword">null</strong> || certs.length == 0 || certs[0] == <strong class="jxr_keyword">null</strong>) 
+<a name="390" href="#390">390</a>             &amp;&amp; secretKey == <strong class="jxr_keyword">null</strong>
+<a name="391" href="#391">391</a>             &amp;&amp; publicKey == <strong class="jxr_keyword">null</strong>) {
+<a name="392" href="#392">392</a>             <strong class="jxr_keyword">throw</strong> <strong class="jxr_keyword">new</strong> <a href="../../../../../org/apache/ws/security/WSSecurityException.html">WSSecurityException</a>(WSSecurityException.FAILED_CHECK);
+<a name="393" href="#393">393</a>         }
+<a name="394" href="#394">394</a>         <strong class="jxr_keyword">if</strong> (certs != <strong class="jxr_keyword">null</strong>) {
+<a name="395" href="#395">395</a>             <strong class="jxr_keyword">try</strong> {
+<a name="396" href="#396">396</a>                 certs[0].checkValidity();
+<a name="397" href="#397">397</a>             } <strong class="jxr_keyword">catch</strong> (CertificateExpiredException e) {
+<a name="398" href="#398">398</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="399" href="#399">399</a>                     WSSecurityException.FAILED_CHECK, <span class="jxr_string">"invalidCert"</span>, <strong class="jxr_keyword">null</strong>, e
+<a name="400" href="#400">400</a>                 );
+<a name="401" href="#401">401</a>             } <strong class="jxr_keyword">catch</strong> (CertificateNotYetValidException e) {

[... 199 lines stripped ...]


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