Class: AdsCommonForAdcenter::Auth::ClientLoginHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/ads_common_for_adcenter/auth/client_login_handler.rb

Overview

Overriden for Adcenter #########

Instance Method Summary collapse

Constructor Details

#initialize(config, auth_server, service_name) ⇒ ClientLoginHandler

Initializes the ClientLoginHandler with all the necessary details.



11
12
13
14
15
# File 'lib/ads_common_for_adcenter/auth/client_login_handler.rb', line 11

def initialize(config, auth_server, service_name)
  super(config)
  @server = auth_server
  @service_name = service_name
end

Instance Method Details

#auth_string(credentials, request) ⇒ Object

Returns authorization string.



37
38
39
# File 'lib/ads_common_for_adcenter/auth/client_login_handler.rb', line 37

def auth_string(credentials, request)
  return [AUTH_PREFIX, get_token(credentials)].join
end

#handle_error(error) ⇒ Object

Handle specific ClientLogin errors.



29
30
31
32
33
34
# File 'lib/ads_common_for_adcenter/auth/client_login_handler.rb', line 29

def handle_error(error)
  # TODO: Add support for automatically regenerating auth tokens when they
  # expire.
  get_logger().error(error)
  raise error
end

#property_changed(prop, value) ⇒ Object

Invalidates the stored token if the user_name, password or provided auth token have changed.



19
20
21
22
23
24
25
26
# File 'lib/ads_common_for_adcenter/auth/client_login_handler.rb', line 19

def property_changed(prop, value)
  if [:user_name, :password].include?(prop)
    @token = nil
  end
  if :auth_token.eql?(prop)
    @token = create_token_from_string(value)
  end
end