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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from WebServerSimple

#<<, fill_self_signed_cert, #start

Constructor Details

#initialize(endpoint_url) ⇒ WebAuth

Returns a new instance of WebAuth.

Parameters:



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

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
  # last argument (self) is provided to constructor of servlet
  mount(@expected_path, WebAuthServlet, self)
  Thread.new { start }
end

Instance Attribute Details

#condObject (readonly)

Returns the value of attribute cond.



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

def cond
  @cond
end

#expected_pathObject (readonly)

Returns the value of attribute expected_path.



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

def expected_path
  @expected_path
end

#mutexObject (readonly)

Returns the value of attribute mutex.



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

def mutex
  @mutex
end

#query=(value) ⇒ Object (writeonly)

Sets the attribute query

Parameters:

  • value

    the value to set the attribute query to.



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

def query=(value)
  @query = value
end

Instance Method Details

#received_requestObject

wait for request on web server

Returns:

  • Hash the query



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

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