Class: Aspera::WebAuthServlet

Inherits:
WEBrick::HTTPServlet::AbstractServlet
  • Object
show all
Defined in:
lib/aspera/web_auth.rb

Overview

servlet called on callback: it records the callback request

Instance Method Summary collapse

Constructor Details

#initialize(server, web_auth) ⇒ WebAuthServlet

Returns a new instance of WebAuthServlet.

Parameters:

  • server (WEBrick::HTTPServer)
  • web_auth (WebAuth)


10
11
12
13
14
# File 'lib/aspera/web_auth.rb', line 10

def initialize(server, web_auth)
  Log.log.debug('WebAuthServlet initialize')
  super(server)
  @web_auth = web_auth
end

Instance Method Details

#service(request, response) ⇒ Object

Raises:

  • (WEBrick::HTTPStatus::MethodNotAllowed)


16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/aspera/web_auth.rb', line 16

def service(request, response)
  Log.log.debug{"received request from browser #{request.request_method} #{request.path}"}
  raise WEBrick::HTTPStatus::MethodNotAllowed, "unexpected method: #{request.request_method}" unless request.request_method.eql?('GET')
  raise WEBrick::HTTPStatus::NotFound, "unexpected path: #{request.path}" unless request.path.eql?(@web_auth.expected_path)
  # acquire lock and signal change
  @web_auth.mutex.synchronize do
    @web_auth.query = request.query
    @web_auth.cond.signal
  end
  response.status = 200
  response.content_type = 'text/html'
  response.body = '<html><head><title>Ok</title></head><body><h1>Thank you !</h1><p>You can close this window.</p></body></html>'
  return nil
end