1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>sign (OpenID::Server::Signatory)</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="../../../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
<pre><span class="ruby-comment cmt"># File lib/openid/server.rb, line 1040</span>
<span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sign</span>(<span class="ruby-identifier">response</span>)
<span class="ruby-identifier">signed_response</span> = <span class="ruby-identifier">response</span>.<span class="ruby-identifier">copy</span>
<span class="ruby-identifier">assoc_handle</span> = <span class="ruby-identifier">response</span>.<span class="ruby-identifier">request</span>.<span class="ruby-identifier">assoc_handle</span>
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">assoc_handle</span>
<span class="ruby-comment cmt"># normal mode disabling expiration check because even if the</span>
<span class="ruby-comment cmt"># association is expired, we still need to know some</span>
<span class="ruby-comment cmt"># properties of the association so that we may preserve</span>
<span class="ruby-comment cmt"># those properties when creating the fallback association.</span>
<span class="ruby-identifier">assoc</span> = <span class="ruby-identifier">get_association</span>(<span class="ruby-identifier">assoc_handle</span>, <span class="ruby-keyword kw">false</span>, <span class="ruby-keyword kw">false</span>)
<span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">assoc</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">assoc</span>.<span class="ruby-identifier">expires_in</span> <span class="ruby-operator"><=</span> <span class="ruby-value">0</span>
<span class="ruby-comment cmt"># fall back to dumb mode</span>
<span class="ruby-identifier">signed_response</span>.<span class="ruby-identifier">fields</span>.<span class="ruby-identifier">set_arg</span>(
<span class="ruby-constant">OPENID_NS</span>, <span class="ruby-value str">'invalidate_handle'</span>, <span class="ruby-identifier">assoc_handle</span>)
<span class="ruby-identifier">assoc_type</span> = <span class="ruby-identifier">assoc</span> <span class="ruby-value">? </span><span class="ruby-identifier">assoc</span>.<span class="ruby-identifier">assoc_type</span> <span class="ruby-operator">:</span> <span class="ruby-value str">'HMAC-SHA1'</span>
<span class="ruby-keyword kw">if</span> <span class="ruby-identifier">assoc</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">assoc</span>.<span class="ruby-identifier">expires_in</span> <span class="ruby-operator"><=</span> <span class="ruby-value">0</span>
<span class="ruby-comment cmt"># now do the clean-up that the disabled checkExpiration</span>
<span class="ruby-comment cmt"># code didn't get to do.</span>
<span class="ruby-identifier">invalidate</span>(<span class="ruby-identifier">assoc_handle</span>, <span class="ruby-keyword kw">false</span>)
<span class="ruby-keyword kw">end</span>
<span class="ruby-identifier">assoc</span> = <span class="ruby-identifier">create_association</span>(<span class="ruby-keyword kw">true</span>, <span class="ruby-identifier">assoc_type</span>)
<span class="ruby-keyword kw">end</span>
<span class="ruby-keyword kw">else</span>
<span class="ruby-comment cmt"># dumb mode.</span>
<span class="ruby-identifier">assoc</span> = <span class="ruby-identifier">create_association</span>(<span class="ruby-keyword kw">true</span>)
<span class="ruby-keyword kw">end</span>
<span class="ruby-keyword kw">begin</span>
<span class="ruby-identifier">signed_response</span>.<span class="ruby-identifier">fields</span> = <span class="ruby-identifier">assoc</span>.<span class="ruby-identifier">sign_message</span>(<span class="ruby-identifier">signed_response</span>.<span class="ruby-identifier">fields</span>)
<span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">KVFormError</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">err</span>
<span class="ruby-identifier">raise</span> <span class="ruby-constant">EncodingError</span>, <span class="ruby-identifier">err</span>
<span class="ruby-keyword kw">end</span>
<span class="ruby-keyword kw">return</span> <span class="ruby-identifier">signed_response</span>
<span class="ruby-keyword kw">end</span></pre>
</body>
</html>
|