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:



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

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.



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

def cond
  @cond
end

#expected_pathObject (readonly)

Returns the value of attribute expected_path.



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

def expected_path
  @expected_path
end

#mutexObject (readonly)

Returns the value of attribute mutex.



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

def mutex
  @mutex
end

#query=(value) ⇒ Object (writeonly)

Sets the attribute query

Parameters:

  • value

    the value to set the attribute query to.



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

def query=(value)
  @query = value
end

Instance Method Details

#received_requestObject

wait for request on web server

Returns:

  • Hash the query



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

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