clavem 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ Gemfile.lock
2
+ tester.rb
3
+ coverage/
4
+ pkg/
5
+ .idea/
6
+ .yardoc/
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - 2.0.0
6
+ script: bundle exec rake spec:coverage
7
+ notifications:
8
+ email: false
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ -m markdown
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ # encoding: utf-8
2
+ #
3
+ # This file is part of the clavem gem. Copyright (C) 2013 and above Shogun <shogun_panda@me.com>.
4
+ # Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
5
+ #
6
+
7
+ source "http://rubygems.org"
8
+
9
+ gemspec
data/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # Introduction
2
+
3
+ [![Build Status](https://secure.travis-ci.org/ShogunPanda/clavem.png?branch=master)](https://travis-ci.org/ShogunPanda/clavem)
4
+ [![Dependency Status](https://gemnasium.com/ShogunPanda/clavem.png?travis)](https://gemnasium.com/ShogunPanda/clavem)
5
+ [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/ShogunPanda/clavem)
6
+
7
+ A local callback server for oAuth web-flow.
8
+
9
+ http://sw.cow.tc/clavem
10
+
11
+ http://rdoc.info/gems/clavem
12
+
13
+ ## Usage
14
+
15
+ clavem allows you to handle a full oAuth authentication flow directly from the console.
16
+
17
+ Simply instantiate the authorizer and run the authorize method with the URL:
18
+
19
+ ```
20
+ require "clavem"
21
+
22
+ # Initalize your oAuth access.
23
+
24
+ authorizer = Clavem::Authorizer.new
25
+
26
+ # Get your authorization URL and append the callback.
27
+
28
+ url += "?oauth_callback=#{authorizer.callback_url}"
29
+ authorizer.authorize(url)
30
+
31
+ if authorizer.status == :succeded then
32
+ access_token = authorizer.token
33
+
34
+ # Go on!
35
+ else
36
+ # Authorization denied
37
+ end
38
+ ```
39
+
40
+ Alternatively, you can also specify a timeout and a block to the constructor to customizer the response handling.
41
+
42
+ See the [documentation](http://rdoc.info/gems/clavem) for more information.
43
+
44
+ ## Contributing to clavem
45
+
46
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
47
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
48
+ * Fork the project.
49
+ * Start a feature/bugfix branch.
50
+ * Commit and push until you are happy with your contribution.
51
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
52
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
53
+
54
+ ## Copyright
55
+
56
+ Copyright (C) 2013 and above Shogun (shogun_panda@me.com).
57
+
58
+ Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
data/Rakefile ADDED
@@ -0,0 +1,18 @@
1
+ # encoding: utf-8
2
+ #
3
+ # This file is part of the clavem gem. Copyright (C) 2013 and above Shogun <shogun_panda@me.com>.
4
+ # Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
5
+ #
6
+
7
+ require "bundler/gem_tasks"
8
+ require "rspec/core/rake_task"
9
+
10
+ RSpec::Core::RakeTask.new("spec")
11
+
12
+ namespace :spec do
13
+ desc "Run all specs with coverage"
14
+ task :coverage do
15
+ ENV["CLAVEM_COVERAGE"] = "TRUE"
16
+ Rake::Task["spec"].invoke
17
+ end
18
+ end
data/bin/clavem ADDED
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+ #
4
+ # This file is part of the clavem gem. Copyright (C) 2013 and above Shogun <shogun_panda@me.com>.
5
+ # Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
6
+ #
7
+
8
+ require "clavem"
9
+ require "mamertes"
10
+
11
+ Mamertes.App(name: "Clavem", version: Clavem::Version::STRING, description: "A local callback server for oAuth web-flow.") do
12
+ # @param url [String] The URL where to send the user to start authorization.
13
+ # @param ip [String] The IP address on which listening for replies. Default is `127.0.0.1`.
14
+ # @param port [Fixnum] The port on which listening for replies. Default is `2501`.
15
+ # @param command [String|nil] The command to open the URL. `{{URL}}` is replaced with the specified URL. Default is `open "{{URL}}"`.
16
+ # @param title [String|nil] The title for response template. Default is `Clavem Authorization`
17
+ # @param template [String|nil] Alternative template to show progress in user's browser.
18
+ # @param timeout [Fixnum] The amount of seconds to wait for response from the remote endpoint before returning a failure. Default is `0`, which means *disabled*.
19
+
20
+ option(:url, ["u", "url"], {type: String, help: "The URL where to send the user to start authorization.", meta: "URL", :required => true})
21
+ option(:ip, ["i", "ip"], {type: String, help: "The IP address on which listening for replies. Default is 127.0.0.1.", meta: "IP", default: "127.0.0.1"})
22
+ option(:port, ["p", "port"], {type: Integer, help: "The port on which listening for replies. Default is `2501`.", meta: "PORT", default: 2501})
23
+ option(:command, ["c", "command"], {type: String, help: "The command to open the URL. {{URL}} is replaced with the specified URL. Default is 'open \"{{URL}}\"'.", meta: "COMMAND", :default => "open \"{{URL}}\""})
24
+ option(:title, ["t", "title"], {type: String, help: "The title for response template. Default is \"Clavem Authorization\".", meta: "TITLE"})
25
+ option(:template, ["v", "template"], {type: String, help: "Alternative template to show progress in user's browser.", meta: "TEMPLATE"})
26
+ option(:timeout, ["n", "timeout"], {type: Integer, help: "The amount of seconds to wait for response from the remote endpoint before returning a failure.", meta: "TIMEOUT"})
27
+ option(:quiet, ["q", "quiet"], {help: "Do not print anything but errors."})
28
+
29
+ action do |command|
30
+ quiet = command.options["quiet"].value
31
+ authorizer = nil
32
+
33
+ command.console.task(!quiet ? "Running Clavem on #{command.options["ip"].value}:#{command.options["port"].value}" : nil) do
34
+ rv = :ok
35
+ authorizer = Clavem::Authorizer.instance(command.options["url"].value, command.options["ip"].value, command.options["port"].value, command.options["command"].value, command.options["title"].value, command.options["template"].value, command.options["timeout"].value).authorize
36
+ rv
37
+ end
38
+
39
+ command.console.info("Obtained access token is: #{authorizer.token}") if !quiet
40
+ end
41
+ end
data/clavem.gemspec ADDED
@@ -0,0 +1,39 @@
1
+ # encoding: utf-8
2
+ #
3
+ # This file is part of the clavem gem. Copyright (C) 2013 and above Shogun <shogun_panda@me.com>.
4
+ # Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
5
+ #
6
+
7
+ require File.expand_path('../lib/clavem/version', __FILE__)
8
+
9
+ Gem::Specification.new do |gem|
10
+ gem.name = "clavem"
11
+ gem.version = Clavem::Version::STRING
12
+ gem.homepage = "http://github.com/ShogunPanda/clavem"
13
+ gem.summary = "A local callback server for oAuth web-flow."
14
+ gem.description = "A local callback server for oAuth web-flow."
15
+ gem.rubyforge_project = "clavem"
16
+
17
+ gem.authors = ["Shogun"]
18
+ gem.email = ["shogun_panda@me.com"]
19
+
20
+ gem.files = `git ls-files`.split($\)
21
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
22
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
23
+ gem.require_paths = ["lib"]
24
+
25
+ gem.required_ruby_version = ">= 1.9.2"
26
+
27
+ gem.add_dependency("r18n-desktop", "~> 1.1.3")
28
+ gem.add_dependency("lazier", "~> 1.0.7")
29
+ gem.add_dependency("mamertes", "~> 1.2.0")
30
+ gem.add_dependency("webrick", "~> 1.3.1")
31
+
32
+ gem.add_development_dependency("rspec", "~> 2.12.0")
33
+ gem.add_development_dependency("rake", "~> 10.0.3")
34
+ gem.add_development_dependency("simplecov", "~> 0.7.1")
35
+ gem.add_development_dependency("pry", ">= 0.9.11.4")
36
+ gem.add_development_dependency("yard", "~> 0.8.3")
37
+ gem.add_development_dependency("redcarpet", "~> 2.2.2")
38
+ gem.add_development_dependency("github-markup", "~> 0.7.5")
39
+ end
data/clavem.yml ADDED
@@ -0,0 +1 @@
1
+ summary: A local callback server for oAuth web-flow.
data/doc/Clavem.html ADDED
@@ -0,0 +1,129 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Module: Clavem
8
+
9
+ &mdash; Documentation by YARD 0.8.3
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ hasFrames = window.top.frames.main ? true : false;
19
+ relpath = '';
20
+ framesUrl = "frames.html#!" + escape(window.location.href);
21
+ </script>
22
+
23
+
24
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
25
+
26
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
27
+
28
+
29
+ </head>
30
+ <body>
31
+ <div id="header">
32
+ <div id="menu">
33
+
34
+ <a href="_index.html">Index (C)</a> &raquo;
35
+
36
+
37
+ <span class="title">Clavem</span>
38
+
39
+
40
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41
+ </div>
42
+
43
+ <div id="search">
44
+
45
+ <a class="full_list_link" id="class_list_link"
46
+ href="class_list.html">
47
+ Class List
48
+ </a>
49
+
50
+ <a class="full_list_link" id="method_list_link"
51
+ href="method_list.html">
52
+ Method List
53
+ </a>
54
+
55
+ <a class="full_list_link" id="file_list_link"
56
+ href="file_list.html">
57
+ File List
58
+ </a>
59
+
60
+ </div>
61
+ <div class="clear"></div>
62
+ </div>
63
+
64
+ <iframe id="search_frame"></iframe>
65
+
66
+ <div id="content"><h1>Module: Clavem
67
+
68
+
69
+
70
+ </h1>
71
+
72
+ <dl class="box">
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+ <dt class="r1 last">Defined in:</dt>
82
+ <dd class="r1 last">lib/clavem/version.rb<span class="defines">,<br />
83
+ lib/clavem/authorizer.rb</span>
84
+ </dd>
85
+
86
+ </dl>
87
+ <div class="clear"></div>
88
+
89
+ <h2>Overview</h2><div class="docstring">
90
+ <div class="discussion">
91
+ <p>A local callback server for oAuth web-flow.</p>
92
+
93
+
94
+ </div>
95
+ </div>
96
+ <div class="tags">
97
+
98
+
99
+ </div><h2>Defined Under Namespace</h2>
100
+ <p class="children">
101
+
102
+
103
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="Clavem/Exceptions.html" title="Clavem::Exceptions (module)">Exceptions</a></span>, <span class='object_link'><a href="Clavem/Version.html" title="Clavem::Version (module)">Version</a></span>
104
+
105
+
106
+
107
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="Clavem/Authorizer.html" title="Clavem::Authorizer (class)">Authorizer</a></span>
108
+
109
+
110
+ </p>
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+ </div>
121
+
122
+ <div id="footer">
123
+ Generated on Sun Jan 27 14:14:59 2013 by
124
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
125
+ 0.8.3 (ruby-1.9.3).
126
+ </div>
127
+
128
+ </body>
129
+ </html>
@@ -0,0 +1,1976 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Class: Clavem::Authorizer
8
+
9
+ &mdash; Documentation by YARD 0.8.3
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" media="screen" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" media="screen" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ hasFrames = window.top.frames.main ? true : false;
19
+ relpath = '../';
20
+ framesUrl = "../frames.html#!" + escape(window.location.href);
21
+ </script>
22
+
23
+
24
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
25
+
26
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
27
+
28
+
29
+ </head>
30
+ <body>
31
+ <div id="header">
32
+ <div id="menu">
33
+
34
+ <a href="../_index.html">Index (A)</a> &raquo;
35
+ <span class='title'><span class='object_link'><a href="../Clavem.html" title="Clavem (module)">Clavem</a></span></span>
36
+ &raquo;
37
+ <span class="title">Authorizer</span>
38
+
39
+
40
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41
+ </div>
42
+
43
+ <div id="search">
44
+
45
+ <a class="full_list_link" id="class_list_link"
46
+ href="../class_list.html">
47
+ Class List
48
+ </a>
49
+
50
+ <a class="full_list_link" id="method_list_link"
51
+ href="../method_list.html">
52
+ Method List
53
+ </a>
54
+
55
+ <a class="full_list_link" id="file_list_link"
56
+ href="../file_list.html">
57
+ File List
58
+ </a>
59
+
60
+ </div>
61
+ <div class="clear"></div>
62
+ </div>
63
+
64
+ <iframe id="search_frame"></iframe>
65
+
66
+ <div id="content"><h1>Class: Clavem::Authorizer
67
+
68
+
69
+
70
+ </h1>
71
+
72
+ <dl class="box">
73
+
74
+ <dt class="r1">Inherits:</dt>
75
+ <dd class="r1">
76
+ <span class="inheritName">Object</span>
77
+
78
+ <ul class="fullTree">
79
+ <li>Object</li>
80
+
81
+ <li class="next">Clavem::Authorizer</li>
82
+
83
+ </ul>
84
+ <a href="#" class="inheritanceTree">show all</a>
85
+
86
+ </dd>
87
+
88
+
89
+
90
+
91
+
92
+
93
+ <dt class="r2">Includes:</dt>
94
+ <dd class="r2">R18n::Helpers</dd>
95
+
96
+
97
+
98
+
99
+
100
+ <dt class="r1 last">Defined in:</dt>
101
+ <dd class="r1 last">lib/clavem/authorizer.rb</dd>
102
+
103
+ </dl>
104
+ <div class="clear"></div>
105
+
106
+ <h2>Overview</h2><div class="docstring">
107
+ <div class="discussion">
108
+ <p>A class to handle oAuth authorizations.</p>
109
+
110
+
111
+ </div>
112
+ </div>
113
+ <div class="tags">
114
+
115
+
116
+ </div>
117
+
118
+
119
+
120
+ <h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
121
+ <ul class="summary">
122
+
123
+ <li class="public ">
124
+ <span class="summary_signature">
125
+
126
+ <a href="#command-instance_method" title="#command (instance method)">- (String) <strong>command</strong> </a>
127
+
128
+
129
+
130
+ </span>
131
+
132
+
133
+
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+
143
+ <span class="summary_desc"><div class='inline'><p>The command to open the URL.</p>
144
+ </div></span>
145
+
146
+ </li>
147
+
148
+
149
+ <li class="public ">
150
+ <span class="summary_signature">
151
+
152
+ <a href="#i18n-instance_method" title="#i18n (instance method)">- (Object) <strong>i18n</strong> </a>
153
+
154
+
155
+
156
+ </span>
157
+
158
+
159
+
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+ <span class="summary_desc"><div class='inline'><p>Returns the value of attribute i18n.</p>
170
+ </div></span>
171
+
172
+ </li>
173
+
174
+
175
+ <li class="public ">
176
+ <span class="summary_signature">
177
+
178
+ <a href="#ip-instance_method" title="#ip (instance method)">- (String) <strong>ip</strong> </a>
179
+
180
+
181
+
182
+ </span>
183
+
184
+
185
+
186
+
187
+
188
+
189
+
190
+
191
+
192
+
193
+
194
+
195
+ <span class="summary_desc"><div class='inline'><p>The IP address on which listening for replies.</p>
196
+ </div></span>
197
+
198
+ </li>
199
+
200
+
201
+ <li class="public ">
202
+ <span class="summary_signature">
203
+
204
+ <a href="#localizer-instance_method" title="#localizer (instance method)">- (R18N::Translation) <strong>localizer</strong> </a>
205
+
206
+
207
+
208
+ </span>
209
+
210
+
211
+
212
+
213
+
214
+
215
+
216
+
217
+
218
+
219
+
220
+
221
+ <span class="summary_desc"><div class='inline'><p>A localizer object.</p>
222
+ </div></span>
223
+
224
+ </li>
225
+
226
+
227
+ <li class="public ">
228
+ <span class="summary_signature">
229
+
230
+ <a href="#port-instance_method" title="#port (instance method)">- (Fixnum) <strong>port</strong> </a>
231
+
232
+
233
+
234
+ </span>
235
+
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+
244
+
245
+
246
+
247
+ <span class="summary_desc"><div class='inline'><p>The port on which listening for replies.</p>
248
+ </div></span>
249
+
250
+ </li>
251
+
252
+
253
+ <li class="public ">
254
+ <span class="summary_signature">
255
+
256
+ <a href="#response_handler-instance_method" title="#response_handler (instance method)">- (Proc) <strong>response_handler</strong> </a>
257
+
258
+
259
+
260
+ </span>
261
+
262
+
263
+
264
+
265
+
266
+
267
+
268
+
269
+
270
+
271
+
272
+
273
+ <span class="summary_desc"><div class='inline'><p>A Ruby block to handle response and check for success.</p>
274
+ </div></span>
275
+
276
+ </li>
277
+
278
+
279
+ <li class="public ">
280
+ <span class="summary_signature">
281
+
282
+ <a href="#status-instance_method" title="#status (instance method)">- (Object) <strong>status</strong> </a>
283
+
284
+
285
+
286
+ </span>
287
+
288
+
289
+
290
+
291
+
292
+
293
+
294
+
295
+
296
+
297
+
298
+
299
+ <span class="summary_desc"><div class='inline'><p>Returns the value of attribute status.</p>
300
+ </div></span>
301
+
302
+ </li>
303
+
304
+
305
+ <li class="public ">
306
+ <span class="summary_signature">
307
+
308
+ <a href="#template-instance_method" title="#template (instance method)">- (String) <strong>template</strong> </a>
309
+
310
+
311
+
312
+ </span>
313
+
314
+
315
+
316
+
317
+
318
+
319
+
320
+
321
+
322
+
323
+
324
+
325
+ <span class="summary_desc"><div class='inline'><p>Alternative template to show progress in user&#39;s browser.</p>
326
+ </div></span>
327
+
328
+ </li>
329
+
330
+
331
+ <li class="public ">
332
+ <span class="summary_signature">
333
+
334
+ <a href="#timeout-instance_method" title="#timeout (instance method)">- (Fixnum) <strong>timeout</strong> </a>
335
+
336
+
337
+
338
+ </span>
339
+
340
+
341
+
342
+
343
+
344
+
345
+
346
+
347
+
348
+
349
+
350
+
351
+ <span class="summary_desc"><div class='inline'><p>The amount of milliseconds to wait for response from the remote endpoint before returning a failure.</p>
352
+ </div></span>
353
+
354
+ </li>
355
+
356
+
357
+ <li class="public ">
358
+ <span class="summary_signature">
359
+
360
+ <a href="#title-instance_method" title="#title (instance method)">- (String) <strong>title</strong> </a>
361
+
362
+
363
+
364
+ </span>
365
+
366
+
367
+
368
+
369
+
370
+
371
+
372
+
373
+
374
+
375
+
376
+
377
+ <span class="summary_desc"><div class='inline'><p>The title for response template.</p>
378
+ </div></span>
379
+
380
+ </li>
381
+
382
+
383
+ <li class="public ">
384
+ <span class="summary_signature">
385
+
386
+ <a href="#token-instance_method" title="#token (instance method)">- (String) <strong>token</strong> </a>
387
+
388
+
389
+
390
+ </span>
391
+
392
+
393
+
394
+
395
+
396
+
397
+
398
+
399
+
400
+
401
+
402
+
403
+ <span class="summary_desc"><div class='inline'><p>The token obtained by the remote endpoint.</p>
404
+ </div></span>
405
+
406
+ </li>
407
+
408
+
409
+ <li class="public ">
410
+ <span class="summary_signature">
411
+
412
+ <a href="#url-instance_method" title="#url (instance method)">- (String) <strong>url</strong> </a>
413
+
414
+
415
+
416
+ </span>
417
+
418
+
419
+
420
+
421
+
422
+
423
+
424
+
425
+
426
+
427
+
428
+
429
+ <span class="summary_desc"><div class='inline'><p>The URL where to send the user to start authorization..</p>
430
+ </div></span>
431
+
432
+ </li>
433
+
434
+
435
+ </ul>
436
+
437
+
438
+
439
+
440
+
441
+ <h2>
442
+ Class Method Summary
443
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
444
+ </h2>
445
+
446
+ <ul class="summary">
447
+
448
+ <li class="public ">
449
+ <span class="summary_signature">
450
+
451
+ <a href="#instance-class_method" title="instance (class method)">+ (Authorizer) <strong>instance</strong>(ip = &quot;127.0.0.1&quot;, port = 2501, command = nil, title = nil, template = nil, timeout = 0, force = false, &amp;response_handler) </a>
452
+
453
+
454
+
455
+ </span>
456
+
457
+
458
+
459
+
460
+
461
+
462
+
463
+
464
+
465
+ <span class="summary_desc"><div class='inline'><p>Returns a unique (singleton) instance of the authorizer.</p>
466
+ </div></span>
467
+
468
+ </li>
469
+
470
+
471
+ </ul>
472
+
473
+ <h2>
474
+ Instance Method Summary
475
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
476
+ </h2>
477
+
478
+ <ul class="summary">
479
+
480
+ <li class="public ">
481
+ <span class="summary_signature">
482
+
483
+ <a href="#authorize-instance_method" title="#authorize (instance method)">- (Authorizer) <strong>authorize</strong>(url) </a>
484
+
485
+
486
+
487
+ </span>
488
+
489
+
490
+
491
+
492
+
493
+
494
+
495
+
496
+
497
+ <span class="summary_desc"><div class='inline'><p>Starts the authorization flow.</p>
498
+ </div></span>
499
+
500
+ </li>
501
+
502
+
503
+ <li class="public ">
504
+ <span class="summary_signature">
505
+
506
+ <a href="#callback_url-instance_method" title="#callback_url (instance method)">- (String) <strong>callback_url</strong> </a>
507
+
508
+
509
+
510
+ </span>
511
+
512
+
513
+
514
+
515
+
516
+
517
+
518
+
519
+
520
+ <span class="summary_desc"><div class='inline'><p>Returns the callback_url for this authorizer.</p>
521
+ </div></span>
522
+
523
+ </li>
524
+
525
+
526
+ <li class="public ">
527
+ <span class="summary_signature">
528
+
529
+ <a href="#default_response_handler-instance_method" title="#default_response_handler (instance method)">- (String|nil) <strong>default_response_handler</strong>(authorizer, request, response) </a>
530
+
531
+
532
+
533
+ </span>
534
+
535
+
536
+
537
+
538
+
539
+
540
+
541
+
542
+
543
+ <span class="summary_desc"><div class='inline'><p>Handles a response from the remote endpoint.</p>
544
+ </div></span>
545
+
546
+ </li>
547
+
548
+
549
+ <li class="public ">
550
+ <span class="summary_signature">
551
+
552
+ <a href="#initialize-instance_method" title="#initialize (instance method)">- (Authorizer) <strong>initialize</strong>(ip = &quot;127.0.0.1&quot;, port = 2501, command = nil, title = nil, template = nil, timeout = 0, &amp;response_handler) </a>
553
+
554
+
555
+
556
+ </span>
557
+
558
+
559
+ <span class="note title constructor">constructor</span>
560
+
561
+
562
+
563
+
564
+
565
+
566
+
567
+
568
+ <span class="summary_desc"><div class='inline'><p>Creates a new authorizer.</p>
569
+ </div></span>
570
+
571
+ </li>
572
+
573
+
574
+ </ul>
575
+
576
+
577
+
578
+ <div id="constructor_details" class="method_details_list">
579
+ <h2>Constructor Details</h2>
580
+
581
+ <div class="method_details first">
582
+ <h3 class="signature first" id="initialize-instance_method">
583
+
584
+ - (<tt><span class='object_link'><a href="" title="Clavem::Authorizer (class)">Authorizer</a></span></tt>) <strong>initialize</strong>(ip = &quot;127.0.0.1&quot;, port = 2501, command = nil, title = nil, template = nil, timeout = 0, &amp;response_handler)
585
+
586
+
587
+
588
+
589
+
590
+ </h3><div class="docstring">
591
+ <div class="discussion">
592
+ <p>Creates a new authorizer.</p>
593
+
594
+
595
+ </div>
596
+ </div>
597
+ <div class="tags">
598
+ <p class="tag_title">Parameters:</p>
599
+ <ul class="param">
600
+
601
+ <li>
602
+
603
+ <span class='name'>ip</span>
604
+
605
+
606
+ <span class='type'>(<tt>String</tt>)</span>
607
+
608
+
609
+ <em class="default">(defaults to: <tt>&quot;127.0.0.1&quot;</tt>)</em>
610
+
611
+
612
+ &mdash;
613
+ <div class='inline'><p>The IP address on which listening for replies. Default is <code>127.0.0.1</code>.</p>
614
+ </div>
615
+
616
+ </li>
617
+
618
+ <li>
619
+
620
+ <span class='name'>port</span>
621
+
622
+
623
+ <span class='type'>(<tt>Fixnum</tt>)</span>
624
+
625
+
626
+ <em class="default">(defaults to: <tt>2501</tt>)</em>
627
+
628
+
629
+ &mdash;
630
+ <div class='inline'><p>The port on which listening for replies. Default is <code>2501</code>.</p>
631
+ </div>
632
+
633
+ </li>
634
+
635
+ <li>
636
+
637
+ <span class='name'>command</span>
638
+
639
+
640
+ <span class='type'>(<tt>String|nil</tt>)</span>
641
+
642
+
643
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
644
+
645
+
646
+ &mdash;
647
+ <div class='inline'><p>The command to open the URL. <code>{{URL}}</code> is replaced with the specified URL. Default is <code>open &quot;{{URL}}&quot;</code>.</p>
648
+ </div>
649
+
650
+ </li>
651
+
652
+ <li>
653
+
654
+ <span class='name'>title</span>
655
+
656
+
657
+ <span class='type'>(<tt>String|nil</tt>)</span>
658
+
659
+
660
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
661
+
662
+
663
+ &mdash;
664
+ <div class='inline'><p>The title for response template. Default is <code>Clavem Authorization</code></p>
665
+ </div>
666
+
667
+ </li>
668
+
669
+ <li>
670
+
671
+ <span class='name'>template</span>
672
+
673
+
674
+ <span class='type'>(<tt>String|nil</tt>)</span>
675
+
676
+
677
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
678
+
679
+
680
+ &mdash;
681
+ <div class='inline'><p>Alternative template to show progress in user&#39;s browser.</p>
682
+ </div>
683
+
684
+ </li>
685
+
686
+ <li>
687
+
688
+ <span class='name'>timeout</span>
689
+
690
+
691
+ <span class='type'>(<tt>Fixnum</tt>)</span>
692
+
693
+
694
+ <em class="default">(defaults to: <tt>0</tt>)</em>
695
+
696
+
697
+ &mdash;
698
+ <div class='inline'><p>The amount of milliseconds to wait for response from the remote endpoint before returning a failure. Default is <code>0</code>, which means <em>disabled</em>.</p>
699
+ </div>
700
+
701
+ </li>
702
+
703
+ <li>
704
+
705
+ <span class='name'>response_handler</span>
706
+
707
+
708
+ <span class='type'>(<tt>Proc</tt>)</span>
709
+
710
+
711
+
712
+ &mdash;
713
+ <div class='inline'><p>A Ruby block to handle response and check for success. See <span class='object_link'><a href="#default_response_handler-instance_method" title="Clavem::Authorizer#default_response_handler (method)">#default_response_handler</a></span>.</p>
714
+ </div>
715
+
716
+ </li>
717
+
718
+ </ul>
719
+
720
+
721
+ </div><table class="source_code">
722
+ <tr>
723
+ <td>
724
+ <pre class="lines">
725
+
726
+
727
+ 80
728
+ 81
729
+ 82
730
+ 83
731
+ 84
732
+ 85
733
+ 86
734
+ 87
735
+ 88
736
+ 89
737
+ 90
738
+ 91
739
+ 92
740
+ 93
741
+ 94
742
+ 95
743
+ 96
744
+ 97</pre>
745
+ </td>
746
+ <td>
747
+ <pre class="code"><span class="info file"># File 'lib/clavem/authorizer.rb', line 80</span>
748
+
749
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_ip'>ip</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>127.0.0.1</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_port'>port</span> <span class='op'>=</span> <span class='int'>2501</span><span class='comma'>,</span> <span class='id identifier rubyid_command'>command</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_title'>title</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_template'>template</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_timeout'>timeout</span> <span class='op'>=</span> <span class='int'>0</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_response_handler'>response_handler</span><span class='rparen'>)</span>
750
+ <span class='ivar'>@ip</span> <span class='op'>=</span> <span class='id identifier rubyid_ip'>ip</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>?</span> <span class='id identifier rubyid_ip'>ip</span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>127.0.0.1</span><span class='tstring_end'>&quot;</span></span>
751
+ <span class='ivar'>@port</span> <span class='op'>=</span> <span class='id identifier rubyid_port'>port</span><span class='period'>.</span><span class='id identifier rubyid_to_integer'>to_integer</span> <span class='op'>&lt;</span> <span class='int'>1</span> <span class='op'>?</span> <span class='int'>2501</span> <span class='op'>:</span> <span class='id identifier rubyid_port'>port</span><span class='period'>.</span><span class='id identifier rubyid_to_integer'>to_integer</span>
752
+ <span class='ivar'>@command</span> <span class='op'>=</span> <span class='id identifier rubyid_command'>command</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>?</span> <span class='id identifier rubyid_command'>command</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>open \&quot;{{URL}}\&quot;</span><span class='tstring_end'>&quot;</span></span>
753
+ <span class='ivar'>@title</span> <span class='op'>=</span> <span class='id identifier rubyid_title'>title</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>?</span> <span class='id identifier rubyid_title'>title</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span> <span class='op'>:</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Clavem Authorization</span><span class='tstring_end'>&quot;</span></span>
754
+ <span class='ivar'>@template</span> <span class='op'>=</span> <span class='id identifier rubyid_template'>template</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span> <span class='op'>?</span> <span class='id identifier rubyid_template'>template</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span> <span class='op'>:</span> <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span><span class='lparen'>(</span><span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_dirname'>dirname</span><span class='lparen'>(</span><span class='kw'>__FILE__</span><span class='rparen'>)</span> <span class='op'>+</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/template.html.erb</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
755
+ <span class='ivar'>@timeout</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='id identifier rubyid_timeout'>timeout</span><span class='period'>.</span><span class='id identifier rubyid_to_integer'>to_integer</span><span class='comma'>,</span> <span class='int'>0</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_max'>max</span>
756
+ <span class='ivar'>@response_handler</span> <span class='op'>=</span> <span class='id identifier rubyid_response_handler'>response_handler</span>
757
+
758
+ <span class='ivar'>@token</span> <span class='op'>=</span> <span class='kw'>nil</span>
759
+ <span class='ivar'>@status</span> <span class='op'>=</span> <span class='symbol'>:waiting</span>
760
+ <span class='ivar'>@compiled_template</span> <span class='op'>||=</span> <span class='op'>::</span><span class='const'>ERB</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='ivar'>@template</span><span class='rparen'>)</span>
761
+ <span class='ivar'>@i18n</span> <span class='op'>=</span> <span class='id identifier rubyid_t'>t</span>
762
+ <span class='ivar'>@timeout_expired</span> <span class='op'>=</span> <span class='kw'>false</span>
763
+ <span class='ivar'>@timeout_thread</span> <span class='op'>=</span> <span class='kw'>nil</span>
764
+
765
+ <span class='kw'>self</span>
766
+ <span class='kw'>end</span></pre>
767
+ </td>
768
+ </tr>
769
+ </table>
770
+ </div>
771
+
772
+ </div>
773
+
774
+ <div id="instance_attr_details" class="attr_details">
775
+ <h2>Instance Attribute Details</h2>
776
+
777
+
778
+ <span id="command=-instance_method"></span>
779
+ <div class="method_details first">
780
+ <h3 class="signature first" id="command-instance_method">
781
+
782
+ - (<tt>String</tt>) <strong>command</strong>
783
+
784
+
785
+
786
+
787
+
788
+ </h3><div class="docstring">
789
+ <div class="discussion">
790
+ <p>The command to open the URL. <code>{{URL}}</code> is replaced with the specified URL. Default is <code>open &quot;{{URL}}&quot;</code>.</p>
791
+
792
+
793
+ </div>
794
+ </div>
795
+ <div class="tags">
796
+
797
+ <p class="tag_title">Returns:</p>
798
+ <ul class="return">
799
+
800
+ <li>
801
+
802
+
803
+ <span class='type'>(<tt>String</tt>)</span>
804
+
805
+
806
+
807
+ &mdash;
808
+ <div class='inline'><p>the current value of command</p>
809
+ </div>
810
+
811
+ </li>
812
+
813
+ </ul>
814
+
815
+ </div><table class="source_code">
816
+ <tr>
817
+ <td>
818
+ <pre class="lines">
819
+
820
+
821
+ 39
822
+ 40
823
+ 41</pre>
824
+ </td>
825
+ <td>
826
+ <pre class="code"><span class="info file"># File 'lib/clavem/authorizer.rb', line 39</span>
827
+
828
+ <span class='kw'>def</span> <span class='id identifier rubyid_command'>command</span>
829
+ <span class='ivar'>@command</span>
830
+ <span class='kw'>end</span></pre>
831
+ </td>
832
+ </tr>
833
+ </table>
834
+ </div>
835
+
836
+
837
+ <span id="i18n=-instance_method"></span>
838
+ <div class="method_details ">
839
+ <h3 class="signature " id="i18n-instance_method">
840
+
841
+ - (<tt>Object</tt>) <strong>i18n</strong>
842
+
843
+
844
+
845
+
846
+
847
+ </h3><div class="docstring">
848
+ <div class="discussion">
849
+ <p>Returns the value of attribute i18n</p>
850
+
851
+
852
+ </div>
853
+ </div>
854
+ <div class="tags">
855
+
856
+
857
+ </div><table class="source_code">
858
+ <tr>
859
+ <td>
860
+ <pre class="lines">
861
+
862
+
863
+ 51
864
+ 52
865
+ 53</pre>
866
+ </td>
867
+ <td>
868
+ <pre class="code"><span class="info file"># File 'lib/clavem/authorizer.rb', line 51</span>
869
+
870
+ <span class='kw'>def</span> <span class='id identifier rubyid_i18n'>i18n</span>
871
+ <span class='ivar'>@i18n</span>
872
+ <span class='kw'>end</span></pre>
873
+ </td>
874
+ </tr>
875
+ </table>
876
+ </div>
877
+
878
+
879
+ <span id="ip=-instance_method"></span>
880
+ <div class="method_details ">
881
+ <h3 class="signature " id="ip-instance_method">
882
+
883
+ - (<tt>String</tt>) <strong>ip</strong>
884
+
885
+
886
+
887
+
888
+
889
+ </h3><div class="docstring">
890
+ <div class="discussion">
891
+ <p>The IP address on which listening for replies. Default is <code>127.0.0.1</code>.</p>
892
+
893
+
894
+ </div>
895
+ </div>
896
+ <div class="tags">
897
+
898
+ <p class="tag_title">Returns:</p>
899
+ <ul class="return">
900
+
901
+ <li>
902
+
903
+
904
+ <span class='type'>(<tt>String</tt>)</span>
905
+
906
+
907
+
908
+ &mdash;
909
+ <div class='inline'><p>the current value of ip</p>
910
+ </div>
911
+
912
+ </li>
913
+
914
+ </ul>
915
+
916
+ </div><table class="source_code">
917
+ <tr>
918
+ <td>
919
+ <pre class="lines">
920
+
921
+
922
+ 39
923
+ 40
924
+ 41</pre>
925
+ </td>
926
+ <td>
927
+ <pre class="code"><span class="info file"># File 'lib/clavem/authorizer.rb', line 39</span>
928
+
929
+ <span class='kw'>def</span> <span class='id identifier rubyid_ip'>ip</span>
930
+ <span class='ivar'>@ip</span>
931
+ <span class='kw'>end</span></pre>
932
+ </td>
933
+ </tr>
934
+ </table>
935
+ </div>
936
+
937
+
938
+ <span id="localizer=-instance_method"></span>
939
+ <div class="method_details ">
940
+ <h3 class="signature " id="localizer-instance_method">
941
+
942
+ - (<tt>R18N::Translation</tt>) <strong>localizer</strong>
943
+
944
+
945
+
946
+
947
+
948
+ </h3><div class="docstring">
949
+ <div class="discussion">
950
+ <p>A localizer object.</p>
951
+
952
+
953
+ </div>
954
+ </div>
955
+ <div class="tags">
956
+
957
+ <p class="tag_title">Returns:</p>
958
+ <ul class="return">
959
+
960
+ <li>
961
+
962
+
963
+ <span class='type'>(<tt>R18N::Translation</tt>)</span>
964
+
965
+
966
+
967
+ &mdash;
968
+ <div class='inline'><p>the current value of localizer</p>
969
+ </div>
970
+
971
+ </li>
972
+
973
+ </ul>
974
+
975
+ </div><table class="source_code">
976
+ <tr>
977
+ <td>
978
+ <pre class="lines">
979
+
980
+
981
+ 39
982
+ 40
983
+ 41</pre>
984
+ </td>
985
+ <td>
986
+ <pre class="code"><span class="info file"># File 'lib/clavem/authorizer.rb', line 39</span>
987
+
988
+ <span class='kw'>def</span> <span class='id identifier rubyid_localizer'>localizer</span>
989
+ <span class='ivar'>@localizer</span>
990
+ <span class='kw'>end</span></pre>
991
+ </td>
992
+ </tr>
993
+ </table>
994
+ </div>
995
+
996
+
997
+ <span id="port=-instance_method"></span>
998
+ <div class="method_details ">
999
+ <h3 class="signature " id="port-instance_method">
1000
+
1001
+ - (<tt>Fixnum</tt>) <strong>port</strong>
1002
+
1003
+
1004
+
1005
+
1006
+
1007
+ </h3><div class="docstring">
1008
+ <div class="discussion">
1009
+ <p>The port on which listening for replies. Default is <code>2501</code>.</p>
1010
+
1011
+
1012
+ </div>
1013
+ </div>
1014
+ <div class="tags">
1015
+
1016
+ <p class="tag_title">Returns:</p>
1017
+ <ul class="return">
1018
+
1019
+ <li>
1020
+
1021
+
1022
+ <span class='type'>(<tt>Fixnum</tt>)</span>
1023
+
1024
+
1025
+
1026
+ &mdash;
1027
+ <div class='inline'><p>the current value of port</p>
1028
+ </div>
1029
+
1030
+ </li>
1031
+
1032
+ </ul>
1033
+
1034
+ </div><table class="source_code">
1035
+ <tr>
1036
+ <td>
1037
+ <pre class="lines">
1038
+
1039
+
1040
+ 39
1041
+ 40
1042
+ 41</pre>
1043
+ </td>
1044
+ <td>
1045
+ <pre class="code"><span class="info file"># File 'lib/clavem/authorizer.rb', line 39</span>
1046
+
1047
+ <span class='kw'>def</span> <span class='id identifier rubyid_port'>port</span>
1048
+ <span class='ivar'>@port</span>
1049
+ <span class='kw'>end</span></pre>
1050
+ </td>
1051
+ </tr>
1052
+ </table>
1053
+ </div>
1054
+
1055
+
1056
+ <span id="response_handler=-instance_method"></span>
1057
+ <div class="method_details ">
1058
+ <h3 class="signature " id="response_handler-instance_method">
1059
+
1060
+ - (<tt>Proc</tt>) <strong>response_handler</strong>
1061
+
1062
+
1063
+
1064
+
1065
+
1066
+ </h3><div class="docstring">
1067
+ <div class="discussion">
1068
+ <p>A Ruby block to handle response and check for success. @see <span class='object_link'><a href="#default_response_handler-instance_method" title="Clavem::Authorizer#default_response_handler (method)">#default_response_handler</a></span>.</p>
1069
+
1070
+
1071
+ </div>
1072
+ </div>
1073
+ <div class="tags">
1074
+
1075
+ <p class="tag_title">Returns:</p>
1076
+ <ul class="return">
1077
+
1078
+ <li>
1079
+
1080
+
1081
+ <span class='type'>(<tt>Proc</tt>)</span>
1082
+
1083
+
1084
+
1085
+ &mdash;
1086
+ <div class='inline'><p>the current value of response_handler</p>
1087
+ </div>
1088
+
1089
+ </li>
1090
+
1091
+ </ul>
1092
+
1093
+ </div><table class="source_code">
1094
+ <tr>
1095
+ <td>
1096
+ <pre class="lines">
1097
+
1098
+
1099
+ 39
1100
+ 40
1101
+ 41</pre>
1102
+ </td>
1103
+ <td>
1104
+ <pre class="code"><span class="info file"># File 'lib/clavem/authorizer.rb', line 39</span>
1105
+
1106
+ <span class='kw'>def</span> <span class='id identifier rubyid_response_handler'>response_handler</span>
1107
+ <span class='ivar'>@response_handler</span>
1108
+ <span class='kw'>end</span></pre>
1109
+ </td>
1110
+ </tr>
1111
+ </table>
1112
+ </div>
1113
+
1114
+
1115
+ <span id="status=-instance_method"></span>
1116
+ <div class="method_details ">
1117
+ <h3 class="signature " id="status-instance_method">
1118
+
1119
+ - (<tt>Object</tt>) <strong>status</strong>
1120
+
1121
+
1122
+
1123
+
1124
+
1125
+ </h3><div class="docstring">
1126
+ <div class="discussion">
1127
+ <p>Returns the value of attribute status</p>
1128
+
1129
+
1130
+ </div>
1131
+ </div>
1132
+ <div class="tags">
1133
+
1134
+
1135
+ </div><table class="source_code">
1136
+ <tr>
1137
+ <td>
1138
+ <pre class="lines">
1139
+
1140
+
1141
+ 50
1142
+ 51
1143
+ 52</pre>
1144
+ </td>
1145
+ <td>
1146
+ <pre class="code"><span class="info file"># File 'lib/clavem/authorizer.rb', line 50</span>
1147
+
1148
+ <span class='kw'>def</span> <span class='id identifier rubyid_status'>status</span>
1149
+ <span class='ivar'>@status</span>
1150
+ <span class='kw'>end</span></pre>
1151
+ </td>
1152
+ </tr>
1153
+ </table>
1154
+ </div>
1155
+
1156
+
1157
+ <span id="template=-instance_method"></span>
1158
+ <div class="method_details ">
1159
+ <h3 class="signature " id="template-instance_method">
1160
+
1161
+ - (<tt>String</tt>) <strong>template</strong>
1162
+
1163
+
1164
+
1165
+
1166
+
1167
+ </h3><div class="docstring">
1168
+ <div class="discussion">
1169
+ <p>Alternative template to show progress in user&#39;s browser.</p>
1170
+
1171
+
1172
+ </div>
1173
+ </div>
1174
+ <div class="tags">
1175
+
1176
+ <p class="tag_title">Returns:</p>
1177
+ <ul class="return">
1178
+
1179
+ <li>
1180
+
1181
+
1182
+ <span class='type'>(<tt>String</tt>)</span>
1183
+
1184
+
1185
+
1186
+ &mdash;
1187
+ <div class='inline'><p>the current value of template</p>
1188
+ </div>
1189
+
1190
+ </li>
1191
+
1192
+ </ul>
1193
+
1194
+ </div><table class="source_code">
1195
+ <tr>
1196
+ <td>
1197
+ <pre class="lines">
1198
+
1199
+
1200
+ 39
1201
+ 40
1202
+ 41</pre>
1203
+ </td>
1204
+ <td>
1205
+ <pre class="code"><span class="info file"># File 'lib/clavem/authorizer.rb', line 39</span>
1206
+
1207
+ <span class='kw'>def</span> <span class='id identifier rubyid_template'>template</span>
1208
+ <span class='ivar'>@template</span>
1209
+ <span class='kw'>end</span></pre>
1210
+ </td>
1211
+ </tr>
1212
+ </table>
1213
+ </div>
1214
+
1215
+
1216
+ <span id="timeout=-instance_method"></span>
1217
+ <div class="method_details ">
1218
+ <h3 class="signature " id="timeout-instance_method">
1219
+
1220
+ - (<tt>Fixnum</tt>) <strong>timeout</strong>
1221
+
1222
+
1223
+
1224
+
1225
+
1226
+ </h3><div class="docstring">
1227
+ <div class="discussion">
1228
+ <p>The amount of milliseconds to wait for response from the remote endpoint before returning a failure. Default is <code>0</code>, which means <em>disabled</em>.</p>
1229
+
1230
+
1231
+ </div>
1232
+ </div>
1233
+ <div class="tags">
1234
+
1235
+ <p class="tag_title">Returns:</p>
1236
+ <ul class="return">
1237
+
1238
+ <li>
1239
+
1240
+
1241
+ <span class='type'>(<tt>Fixnum</tt>)</span>
1242
+
1243
+
1244
+
1245
+ &mdash;
1246
+ <div class='inline'><p>the current value of timeout</p>
1247
+ </div>
1248
+
1249
+ </li>
1250
+
1251
+ </ul>
1252
+
1253
+ </div><table class="source_code">
1254
+ <tr>
1255
+ <td>
1256
+ <pre class="lines">
1257
+
1258
+
1259
+ 39
1260
+ 40
1261
+ 41</pre>
1262
+ </td>
1263
+ <td>
1264
+ <pre class="code"><span class="info file"># File 'lib/clavem/authorizer.rb', line 39</span>
1265
+
1266
+ <span class='kw'>def</span> <span class='id identifier rubyid_timeout'>timeout</span>
1267
+ <span class='ivar'>@timeout</span>
1268
+ <span class='kw'>end</span></pre>
1269
+ </td>
1270
+ </tr>
1271
+ </table>
1272
+ </div>
1273
+
1274
+
1275
+ <span id="title=-instance_method"></span>
1276
+ <div class="method_details ">
1277
+ <h3 class="signature " id="title-instance_method">
1278
+
1279
+ - (<tt>String</tt>) <strong>title</strong>
1280
+
1281
+
1282
+
1283
+
1284
+
1285
+ </h3><div class="docstring">
1286
+ <div class="discussion">
1287
+ <p>The title for response template. Default is <code>Clavem Authorization</code>.</p>
1288
+
1289
+
1290
+ </div>
1291
+ </div>
1292
+ <div class="tags">
1293
+
1294
+ <p class="tag_title">Returns:</p>
1295
+ <ul class="return">
1296
+
1297
+ <li>
1298
+
1299
+
1300
+ <span class='type'>(<tt>String</tt>)</span>
1301
+
1302
+
1303
+
1304
+ &mdash;
1305
+ <div class='inline'><p>the current value of title</p>
1306
+ </div>
1307
+
1308
+ </li>
1309
+
1310
+ </ul>
1311
+
1312
+ </div><table class="source_code">
1313
+ <tr>
1314
+ <td>
1315
+ <pre class="lines">
1316
+
1317
+
1318
+ 39
1319
+ 40
1320
+ 41</pre>
1321
+ </td>
1322
+ <td>
1323
+ <pre class="code"><span class="info file"># File 'lib/clavem/authorizer.rb', line 39</span>
1324
+
1325
+ <span class='kw'>def</span> <span class='id identifier rubyid_title'>title</span>
1326
+ <span class='ivar'>@title</span>
1327
+ <span class='kw'>end</span></pre>
1328
+ </td>
1329
+ </tr>
1330
+ </table>
1331
+ </div>
1332
+
1333
+
1334
+ <span id="token=-instance_method"></span>
1335
+ <div class="method_details ">
1336
+ <h3 class="signature " id="token-instance_method">
1337
+
1338
+ - (<tt>String</tt>) <strong>token</strong>
1339
+
1340
+
1341
+
1342
+
1343
+
1344
+ </h3><div class="docstring">
1345
+ <div class="discussion">
1346
+ <p>The token obtained by the remote endpoint.</p>
1347
+
1348
+
1349
+ </div>
1350
+ </div>
1351
+ <div class="tags">
1352
+
1353
+ <p class="tag_title">Returns:</p>
1354
+ <ul class="return">
1355
+
1356
+ <li>
1357
+
1358
+
1359
+ <span class='type'>(<tt>String</tt>)</span>
1360
+
1361
+
1362
+
1363
+ &mdash;
1364
+ <div class='inline'><p>the current value of token</p>
1365
+ </div>
1366
+
1367
+ </li>
1368
+
1369
+ </ul>
1370
+
1371
+ </div><table class="source_code">
1372
+ <tr>
1373
+ <td>
1374
+ <pre class="lines">
1375
+
1376
+
1377
+ 39
1378
+ 40
1379
+ 41</pre>
1380
+ </td>
1381
+ <td>
1382
+ <pre class="code"><span class="info file"># File 'lib/clavem/authorizer.rb', line 39</span>
1383
+
1384
+ <span class='kw'>def</span> <span class='id identifier rubyid_token'>token</span>
1385
+ <span class='ivar'>@token</span>
1386
+ <span class='kw'>end</span></pre>
1387
+ </td>
1388
+ </tr>
1389
+ </table>
1390
+ </div>
1391
+
1392
+
1393
+ <span id="url=-instance_method"></span>
1394
+ <div class="method_details ">
1395
+ <h3 class="signature " id="url-instance_method">
1396
+
1397
+ - (<tt>String</tt>) <strong>url</strong>
1398
+
1399
+
1400
+
1401
+
1402
+
1403
+ </h3><div class="docstring">
1404
+ <div class="discussion">
1405
+ <p>The URL where to send the user to start authorization..</p>
1406
+
1407
+
1408
+ </div>
1409
+ </div>
1410
+ <div class="tags">
1411
+
1412
+ <p class="tag_title">Returns:</p>
1413
+ <ul class="return">
1414
+
1415
+ <li>
1416
+
1417
+
1418
+ <span class='type'>(<tt>String</tt>)</span>
1419
+
1420
+
1421
+
1422
+ &mdash;
1423
+ <div class='inline'><p>the current value of url</p>
1424
+ </div>
1425
+
1426
+ </li>
1427
+
1428
+ </ul>
1429
+
1430
+ </div><table class="source_code">
1431
+ <tr>
1432
+ <td>
1433
+ <pre class="lines">
1434
+
1435
+
1436
+ 39
1437
+ 40
1438
+ 41</pre>
1439
+ </td>
1440
+ <td>
1441
+ <pre class="code"><span class="info file"># File 'lib/clavem/authorizer.rb', line 39</span>
1442
+
1443
+ <span class='kw'>def</span> <span class='id identifier rubyid_url'>url</span>
1444
+ <span class='ivar'>@url</span>
1445
+ <span class='kw'>end</span></pre>
1446
+ </td>
1447
+ </tr>
1448
+ </table>
1449
+ </div>
1450
+
1451
+ </div>
1452
+
1453
+
1454
+ <div id="class_method_details" class="method_details_list">
1455
+ <h2>Class Method Details</h2>
1456
+
1457
+
1458
+ <div class="method_details first">
1459
+ <h3 class="signature first" id="instance-class_method">
1460
+
1461
+ + (<tt><span class='object_link'><a href="" title="Clavem::Authorizer (class)">Authorizer</a></span></tt>) <strong>instance</strong>(ip = &quot;127.0.0.1&quot;, port = 2501, command = nil, title = nil, template = nil, timeout = 0, force = false, &amp;response_handler)
1462
+
1463
+
1464
+
1465
+
1466
+
1467
+ </h3><div class="docstring">
1468
+ <div class="discussion">
1469
+ <p>Returns a unique (singleton) instance of the authorizer.</p>
1470
+
1471
+
1472
+ </div>
1473
+ </div>
1474
+ <div class="tags">
1475
+ <p class="tag_title">Parameters:</p>
1476
+ <ul class="param">
1477
+
1478
+ <li>
1479
+
1480
+ <span class='name'>ip</span>
1481
+
1482
+
1483
+ <span class='type'>(<tt>String</tt>)</span>
1484
+
1485
+
1486
+ <em class="default">(defaults to: <tt>&quot;127.0.0.1&quot;</tt>)</em>
1487
+
1488
+
1489
+ &mdash;
1490
+ <div class='inline'><p>The IP address on which listening for replies. Default is <code>127.0.0.1</code>.</p>
1491
+ </div>
1492
+
1493
+ </li>
1494
+
1495
+ <li>
1496
+
1497
+ <span class='name'>port</span>
1498
+
1499
+
1500
+ <span class='type'>(<tt>Fixnum</tt>)</span>
1501
+
1502
+
1503
+ <em class="default">(defaults to: <tt>2501</tt>)</em>
1504
+
1505
+
1506
+ &mdash;
1507
+ <div class='inline'><p>The port on which listening for replies. Default is <code>2501</code>.</p>
1508
+ </div>
1509
+
1510
+ </li>
1511
+
1512
+ <li>
1513
+
1514
+ <span class='name'>command</span>
1515
+
1516
+
1517
+ <span class='type'>(<tt>String|nil</tt>)</span>
1518
+
1519
+
1520
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
1521
+
1522
+
1523
+ &mdash;
1524
+ <div class='inline'><p>The command to open the URL. <code>{{URL}}</code> is replaced with the specified URL. Default is <code>open &quot;{{URL}}&quot;</code>.</p>
1525
+ </div>
1526
+
1527
+ </li>
1528
+
1529
+ <li>
1530
+
1531
+ <span class='name'>title</span>
1532
+
1533
+
1534
+ <span class='type'>(<tt>String|nil</tt>)</span>
1535
+
1536
+
1537
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
1538
+
1539
+
1540
+ &mdash;
1541
+ <div class='inline'><p>The title for response template. Default is <code>Clavem Authorization</code></p>
1542
+ </div>
1543
+
1544
+ </li>
1545
+
1546
+ <li>
1547
+
1548
+ <span class='name'>template</span>
1549
+
1550
+
1551
+ <span class='type'>(<tt>String|nil</tt>)</span>
1552
+
1553
+
1554
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
1555
+
1556
+
1557
+ &mdash;
1558
+ <div class='inline'><p>Alternative template to show progress in user&#39;s browser.</p>
1559
+ </div>
1560
+
1561
+ </li>
1562
+
1563
+ <li>
1564
+
1565
+ <span class='name'>timeout</span>
1566
+
1567
+
1568
+ <span class='type'>(<tt>Fixnum</tt>)</span>
1569
+
1570
+
1571
+ <em class="default">(defaults to: <tt>0</tt>)</em>
1572
+
1573
+
1574
+ &mdash;
1575
+ <div class='inline'><p>The amount of milliseconds to wait for response from the remote endpoint before returning a failure. Default is <code>0</code>, which means <em>disabled</em>.</p>
1576
+ </div>
1577
+
1578
+ </li>
1579
+
1580
+ <li>
1581
+
1582
+ <span class='name'>response_handler</span>
1583
+
1584
+
1585
+ <span class='type'>(<tt>Proc</tt>)</span>
1586
+
1587
+
1588
+
1589
+ &mdash;
1590
+ <div class='inline'><p>A Ruby block to handle response and check for success. See <span class='object_link'><a href="#default_response_handler-instance_method" title="Clavem::Authorizer#default_response_handler (method)">#default_response_handler</a></span>.</p>
1591
+ </div>
1592
+
1593
+ </li>
1594
+
1595
+ <li>
1596
+
1597
+ <span class='name'>force</span>
1598
+
1599
+
1600
+ <span class='type'>(<tt>Boolean</tt>)</span>
1601
+
1602
+
1603
+ <em class="default">(defaults to: <tt>false</tt>)</em>
1604
+
1605
+
1606
+ &mdash;
1607
+ <div class='inline'><p>If to force recreation of the instance.</p>
1608
+ </div>
1609
+
1610
+ </li>
1611
+
1612
+ </ul>
1613
+
1614
+ <p class="tag_title">Returns:</p>
1615
+ <ul class="return">
1616
+
1617
+ <li>
1618
+
1619
+
1620
+ <span class='type'>(<tt><span class='object_link'><a href="" title="Clavem::Authorizer (class)">Authorizer</a></span></tt>)</span>
1621
+
1622
+
1623
+
1624
+ &mdash;
1625
+ <div class='inline'><p>The unique (singleton) instance of the authorizer.</p>
1626
+ </div>
1627
+
1628
+ </li>
1629
+
1630
+ </ul>
1631
+
1632
+ </div><table class="source_code">
1633
+ <tr>
1634
+ <td>
1635
+ <pre class="lines">
1636
+
1637
+
1638
+ 64
1639
+ 65
1640
+ 66
1641
+ 67
1642
+ 68</pre>
1643
+ </td>
1644
+ <td>
1645
+ <pre class="code"><span class="info file"># File 'lib/clavem/authorizer.rb', line 64</span>
1646
+
1647
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_instance'>instance</span><span class='lparen'>(</span><span class='id identifier rubyid_ip'>ip</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>127.0.0.1</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_port'>port</span> <span class='op'>=</span> <span class='int'>2501</span><span class='comma'>,</span> <span class='id identifier rubyid_command'>command</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_title'>title</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_template'>template</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_timeout'>timeout</span> <span class='op'>=</span> <span class='int'>0</span><span class='comma'>,</span> <span class='id identifier rubyid_force'>force</span> <span class='op'>=</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_response_handler'>response_handler</span><span class='rparen'>)</span>
1648
+ <span class='ivar'>@instance</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='kw'>if</span> <span class='id identifier rubyid_force'>force</span>
1649
+ <span class='ivar'>@instance</span> <span class='op'>||=</span> <span class='const'>Clavem</span><span class='op'>::</span><span class='const'>Authorizer</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_ip'>ip</span><span class='comma'>,</span> <span class='id identifier rubyid_port'>port</span><span class='comma'>,</span> <span class='id identifier rubyid_command'>command</span><span class='comma'>,</span> <span class='id identifier rubyid_title'>title</span><span class='comma'>,</span> <span class='id identifier rubyid_template'>template</span><span class='comma'>,</span> <span class='id identifier rubyid_timeout'>timeout</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_response_handler'>response_handler</span><span class='rparen'>)</span>
1650
+ <span class='ivar'>@instance</span>
1651
+ <span class='kw'>end</span></pre>
1652
+ </td>
1653
+ </tr>
1654
+ </table>
1655
+ </div>
1656
+
1657
+ </div>
1658
+
1659
+ <div id="instance_method_details" class="method_details_list">
1660
+ <h2>Instance Method Details</h2>
1661
+
1662
+
1663
+ <div class="method_details first">
1664
+ <h3 class="signature first" id="authorize-instance_method">
1665
+
1666
+ - (<tt><span class='object_link'><a href="" title="Clavem::Authorizer (class)">Authorizer</a></span></tt>) <strong>authorize</strong>(url)
1667
+
1668
+
1669
+
1670
+
1671
+
1672
+ </h3><div class="docstring">
1673
+ <div class="discussion">
1674
+ <p>Starts the authorization flow.</p>
1675
+
1676
+
1677
+ </div>
1678
+ </div>
1679
+ <div class="tags">
1680
+ <p class="tag_title">Parameters:</p>
1681
+ <ul class="param">
1682
+
1683
+ <li>
1684
+
1685
+ <span class='name'>url</span>
1686
+
1687
+
1688
+ <span class='type'>(<tt>String</tt>)</span>
1689
+
1690
+
1691
+
1692
+ &mdash;
1693
+ <div class='inline'><p>The URL where to send the user to start authorization.</p>
1694
+ </div>
1695
+
1696
+ </li>
1697
+
1698
+ </ul>
1699
+
1700
+ <p class="tag_title">Returns:</p>
1701
+ <ul class="return">
1702
+
1703
+ <li>
1704
+
1705
+
1706
+ <span class='type'>(<tt><span class='object_link'><a href="" title="Clavem::Authorizer (class)">Authorizer</a></span></tt>)</span>
1707
+
1708
+
1709
+
1710
+ &mdash;
1711
+ <div class='inline'><p>The authorizer.</p>
1712
+ </div>
1713
+
1714
+ </li>
1715
+
1716
+ </ul>
1717
+ <p class="tag_title">Raises:</p>
1718
+ <ul class="raise">
1719
+
1720
+ <li>
1721
+
1722
+
1723
+ <span class='type'>(<tt><span class='object_link'><a href="Exceptions/AuthorizationDenied.html" title="Clavem::Exceptions::AuthorizationDenied (class)">Clavem::Exceptions::AuthorizationDenied</a></span></tt>)</span>
1724
+
1725
+
1726
+
1727
+ </li>
1728
+
1729
+ </ul>
1730
+
1731
+ </div><table class="source_code">
1732
+ <tr>
1733
+ <td>
1734
+ <pre class="lines">
1735
+
1736
+
1737
+ 103
1738
+ 104
1739
+ 105
1740
+ 106
1741
+ 107
1742
+ 108
1743
+ 109
1744
+ 110
1745
+ 111
1746
+ 112
1747
+ 113
1748
+ 114
1749
+ 115
1750
+ 116
1751
+ 117
1752
+ 118
1753
+ 119
1754
+ 120
1755
+ 121
1756
+ 122
1757
+ 123
1758
+ 124
1759
+ 125
1760
+ 126
1761
+ 127
1762
+ 128
1763
+ 129
1764
+ 130</pre>
1765
+ </td>
1766
+ <td>
1767
+ <pre class="code"><span class="info file"># File 'lib/clavem/authorizer.rb', line 103</span>
1768
+
1769
+ <span class='kw'>def</span> <span class='id identifier rubyid_authorize'>authorize</span><span class='lparen'>(</span><span class='id identifier rubyid_url'>url</span><span class='rparen'>)</span>
1770
+ <span class='ivar'>@url</span> <span class='op'>=</span> <span class='id identifier rubyid_url'>url</span>
1771
+ <span class='ivar'>@status</span> <span class='op'>=</span> <span class='symbol'>:waiting</span>
1772
+
1773
+ <span class='kw'>begin</span>
1774
+ <span class='comment'># Setup stuff
1775
+ </span> <span class='id identifier rubyid_setup_webserver'>setup_webserver</span>
1776
+ <span class='id identifier rubyid_setup_interruptions_handling'>setup_interruptions_handling</span>
1777
+ <span class='id identifier rubyid_setup_timeout_handling'>setup_timeout_handling</span>
1778
+
1779
+ <span class='comment'># Open the endpoint then start the server
1780
+ </span> <span class='id identifier rubyid_open_endpoint'>open_endpoint</span>
1781
+ <span class='ivar'>@server</span><span class='period'>.</span><span class='id identifier rubyid_start'>start</span>
1782
+
1783
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>Clavem</span><span class='op'>::</span><span class='const'>Exceptions</span><span class='op'>::</span><span class='const'>Timeout</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='kw'>if</span> <span class='ivar'>@timeout_expired</span>
1784
+ <span class='kw'>rescue</span> <span class='const'>Clavem</span><span class='op'>::</span><span class='const'>Exceptions</span><span class='op'>::</span><span class='const'>Timeout</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_t'>t</span>
1785
+ <span class='ivar'>@status</span> <span class='op'>=</span> <span class='symbol'>:failure</span>
1786
+ <span class='id identifier rubyid_raise'>raise</span> <span class='id identifier rubyid_t'>t</span>
1787
+ <span class='kw'>rescue</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
1788
+ <span class='ivar'>@status</span> <span class='op'>=</span> <span class='symbol'>:failure</span>
1789
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>Clavem</span><span class='op'>::</span><span class='const'>Exceptions</span><span class='op'>::</span><span class='const'>Failure</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Cannot handle response: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='rbrace'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
1790
+ <span class='kw'>ensure</span>
1791
+ <span class='id identifier rubyid_cleanup'>cleanup</span>
1792
+ <span class='kw'>end</span>
1793
+
1794
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>Clavem</span><span class='op'>::</span><span class='const'>Exceptions</span><span class='op'>::</span><span class='const'>AuthorizationDenied</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='kw'>if</span> <span class='ivar'>@status</span> <span class='op'>==</span> <span class='symbol'>:denied</span>
1795
+ <span class='kw'>self</span>
1796
+ <span class='kw'>end</span></pre>
1797
+ </td>
1798
+ </tr>
1799
+ </table>
1800
+ </div>
1801
+
1802
+ <div class="method_details ">
1803
+ <h3 class="signature " id="callback_url-instance_method">
1804
+
1805
+ - (<tt>String</tt>) <strong>callback_url</strong>
1806
+
1807
+
1808
+
1809
+
1810
+
1811
+ </h3><div class="docstring">
1812
+ <div class="discussion">
1813
+ <p>Returns the callback_url for this authorizer.</p>
1814
+
1815
+
1816
+ </div>
1817
+ </div>
1818
+ <div class="tags">
1819
+
1820
+ <p class="tag_title">Returns:</p>
1821
+ <ul class="return">
1822
+
1823
+ <li>
1824
+
1825
+
1826
+ <span class='type'>(<tt>String</tt>)</span>
1827
+
1828
+
1829
+
1830
+ &mdash;
1831
+ <div class='inline'><p>The callback_url for this authorizer.</p>
1832
+ </div>
1833
+
1834
+ </li>
1835
+
1836
+ </ul>
1837
+
1838
+ </div><table class="source_code">
1839
+ <tr>
1840
+ <td>
1841
+ <pre class="lines">
1842
+
1843
+
1844
+ 135
1845
+ 136
1846
+ 137</pre>
1847
+ </td>
1848
+ <td>
1849
+ <pre class="code"><span class="info file"># File 'lib/clavem/authorizer.rb', line 135</span>
1850
+
1851
+ <span class='kw'>def</span> <span class='id identifier rubyid_callback_url'>callback_url</span>
1852
+ <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>http://</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_ip'>ip</span><span class='rbrace'>}</span><span class='tstring_content'>:</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_port'>port</span><span class='rbrace'>}</span><span class='tstring_content'>/</span><span class='tstring_end'>&quot;</span></span>
1853
+ <span class='kw'>end</span></pre>
1854
+ </td>
1855
+ </tr>
1856
+ </table>
1857
+ </div>
1858
+
1859
+ <div class="method_details ">
1860
+ <h3 class="signature " id="default_response_handler-instance_method">
1861
+
1862
+ - (<tt>String|nil</tt>) <strong>default_response_handler</strong>(authorizer, request, response)
1863
+
1864
+
1865
+
1866
+
1867
+
1868
+ </h3><div class="docstring">
1869
+ <div class="discussion">
1870
+ <p>Handles a response from the remote endpoint.</p>
1871
+
1872
+
1873
+ </div>
1874
+ </div>
1875
+ <div class="tags">
1876
+ <p class="tag_title">Parameters:</p>
1877
+ <ul class="param">
1878
+
1879
+ <li>
1880
+
1881
+ <span class='name'>authorizer</span>
1882
+
1883
+
1884
+ <span class='type'>(<tt><span class='object_link'><a href="" title="Clavem::Authorizer (class)">Authorizer</a></span></tt>)</span>
1885
+
1886
+
1887
+
1888
+ &mdash;
1889
+ <div class='inline'><p>The current authorizer.</p>
1890
+ </div>
1891
+
1892
+ </li>
1893
+
1894
+ <li>
1895
+
1896
+ <span class='name'>request</span>
1897
+
1898
+
1899
+ <span class='type'>(<tt>WEBrick::HTTPRequest</tt>)</span>
1900
+
1901
+
1902
+
1903
+ &mdash;
1904
+ <div class='inline'><p>The request that the remote endpoint made to notify authorization status.</p>
1905
+ </div>
1906
+
1907
+ </li>
1908
+
1909
+ <li>
1910
+
1911
+ <span class='name'>response</span>
1912
+
1913
+
1914
+ <span class='type'>(<tt>WEBrick::HTTPResponse</tt>)</span>
1915
+
1916
+
1917
+
1918
+ &mdash;
1919
+ <div class='inline'><p>The request to send to the browser.</p>
1920
+ </div>
1921
+
1922
+ </li>
1923
+
1924
+ </ul>
1925
+
1926
+ <p class="tag_title">Returns:</p>
1927
+ <ul class="return">
1928
+
1929
+ <li>
1930
+
1931
+
1932
+ <span class='type'>(<tt>String|nil</tt>)</span>
1933
+
1934
+
1935
+
1936
+ &mdash;
1937
+ <div class='inline'><p>The oAuth access token. Returning <code>nil</code> means <em>authorization denied</em>.</p>
1938
+ </div>
1939
+
1940
+ </li>
1941
+
1942
+ </ul>
1943
+
1944
+ </div><table class="source_code">
1945
+ <tr>
1946
+ <td>
1947
+ <pre class="lines">
1948
+
1949
+
1950
+ 145
1951
+ 146
1952
+ 147</pre>
1953
+ </td>
1954
+ <td>
1955
+ <pre class="code"><span class="info file"># File 'lib/clavem/authorizer.rb', line 145</span>
1956
+
1957
+ <span class='kw'>def</span> <span class='id identifier rubyid_default_response_handler'>default_response_handler</span><span class='lparen'>(</span><span class='id identifier rubyid_authorizer'>authorizer</span><span class='comma'>,</span> <span class='id identifier rubyid_request'>request</span><span class='comma'>,</span> <span class='id identifier rubyid_response'>response</span><span class='rparen'>)</span>
1958
+ <span class='id identifier rubyid_request'>request</span><span class='period'>.</span><span class='id identifier rubyid_query'>query</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>oauth_token</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span>
1959
+ <span class='kw'>end</span></pre>
1960
+ </td>
1961
+ </tr>
1962
+ </table>
1963
+ </div>
1964
+
1965
+ </div>
1966
+
1967
+ </div>
1968
+
1969
+ <div id="footer">
1970
+ Generated on Sun Jan 27 14:14:59 2013 by
1971
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1972
+ 0.8.3 (ruby-1.9.3).
1973
+ </div>
1974
+
1975
+ </body>
1976
+ </html>