Class: Aspera::WebAuth::Server
- Inherits:
-
Aspera::WebServerSimple
- Object
- WEBrick::HTTPServer
- Aspera::WebServerSimple
- Aspera::WebAuth::Server
- Defined in:
- lib/aspera/web_auth/server.rb
Overview
start a local web server then start a browser that will callback the local server upon authentication store the final query
Constant Summary
Constants inherited from Aspera::WebServerSimple
Aspera::WebServerSimple::DEFAULT_URL, Aspera::WebServerSimple::PARAMS
Instance Attribute Summary collapse
-
#info_html ⇒ Object
readonly
Returns the value of attribute info_html.
Instance Method Summary collapse
-
#initialize(endpoint_url, additional_info = nil) ⇒ Server
constructor
A new instance of Server.
-
#received_request ⇒ Hash
wait for request on web server (main thread).
-
#signal_request(request) ⇒ nil
Called by web server thread on received request.
Methods inherited from Aspera::WebServerSimple
#<<, read_chain_file, self_signed_cert, #start
Constructor Details
#initialize(endpoint_url, additional_info = nil) ⇒ Server
Returns a new instance of Server.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/aspera/web_auth/server.rb', line 43 def initialize(endpoint_url, additional_info = nil) uri = URI.parse(endpoint_url) super(uri) @mutex = Mutex.new @cond = ConditionVariable.new @expected_path = uri.path.empty? ? '/' : uri.path @query = nil @info_html = additional_info.to_s @info_html = "<p>#{ERB::Util.html_escape(@info_html)}</p>" unless @info_html.empty? # last argument (self) is provided to constructor of servlet mount(@expected_path, Servlet, self) # server runs in thread Thread.new { start } end |
Instance Attribute Details
#info_html ⇒ Object (readonly)
Returns the value of attribute info_html.
39 40 41 |
# File 'lib/aspera/web_auth/server.rb', line 39 def info_html @info_html end |
Instance Method Details
#received_request ⇒ Hash
wait for request on web server (main thread)
72 73 74 75 76 77 78 |
# File 'lib/aspera/web_auth/server.rb', line 72 def received_request # wait for signal from thread @mutex.synchronize { @cond.wait(@mutex) } # tell server thread to stop shutdown return @query end |
#signal_request(request) ⇒ nil
Called by web server thread on received request
60 61 62 63 64 65 66 67 68 |
# File 'lib/aspera/web_auth/server.rb', line 60 def signal_request(request) raise WEBrick::HTTPStatus::NotFound, "unexpected path: #{request.path}" unless request.path.eql?(@expected_path) # acquire lock and signal change @mutex.synchronize do @query = request.query @cond.signal end nil end |