Class: Aspera::WebAuth

Inherits:
WebServerSimple show all
Defined in:
lib/aspera/web_auth.rb

Overview

start a local web server, then start a browser that will callback the local server upon authentication

Constant Summary

Constants inherited from WebServerSimple

Aspera::WebServerSimple::CERT_PARAMETERS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from WebServerSimple

#<<, fill_self_signed_cert

Constructor Details

#initialize(endpoint_url) ⇒ WebAuth

Returns a new instance of WebAuth.

Parameters:



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/aspera/web_auth.rb', line 37

def initialize(endpoint_url)
  uri = URI.parse(endpoint_url)
  super(uri)
  # parameters for servlet
  @mutex = Mutex.new
  @cond = ConditionVariable.new
  @expected_path = uri.path.empty? ? '/' : uri.path
  @query = nil
  mount(@expected_path, WebAuthServlet, self) # additional args provided to constructor
  Thread.new { start }
end

Instance Attribute Details

#condObject (readonly)

Returns the value of attribute cond.



33
34
35
# File 'lib/aspera/web_auth.rb', line 33

def cond
  @cond
end

#expected_pathObject (readonly)

Returns the value of attribute expected_path.



33
34
35
# File 'lib/aspera/web_auth.rb', line 33

def expected_path
  @expected_path
end

#mutexObject (readonly)

Returns the value of attribute mutex.



33
34
35
# File 'lib/aspera/web_auth.rb', line 33

def mutex
  @mutex
end

#query=(value) ⇒ Object (writeonly)

Sets the attribute query

Parameters:

  • value

    the value to set the attribute query to.



34
35
36
# File 'lib/aspera/web_auth.rb', line 34

def query=(value)
  @query = value
end

Instance Method Details

#received_requestObject

wait for request on web server

Returns:

  • Hash the query



51
52
53
54
55
56
57
# File 'lib/aspera/web_auth.rb', line 51

def received_request
  # wait for signal from thread
  @mutex.synchronize{@cond.wait(@mutex)}
  # tell server thread to stop
  shutdown
  return @query
end