Class: ShellCardManagementApIs::BasicAuth

Inherits:
CoreLibrary::HeaderAuth
  • Object
show all
Includes:
CoreLibrary
Defined in:
lib/shell_card_management_ap_is/http/auth/basic_auth.rb

Overview

Utility class for basic authorization.

Instance Method Summary collapse

Constructor Details

#initialize(basic_auth_credentials) ⇒ BasicAuth

Initialization constructor.



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/shell_card_management_ap_is/http/auth/basic_auth.rb', line 17

def initialize(basic_auth_credentials)
  auth_params = {}
  unless basic_auth_credentials.nil? ||
         basic_auth_credentials.username.nil? ||
         basic_auth_credentials.password.nil?
    auth_params['Authorization'] =
      "Basic #{AuthHelper.get_base64_encoded_value(basic_auth_credentials.username,
                                                   basic_auth_credentials.password)}"
  end

  super auth_params
end

Instance Method Details

#error_messageObject

Display error message on occurrence of authentication failure.



12
13
14
# File 'lib/shell_card_management_ap_is/http/auth/basic_auth.rb', line 12

def error_message
  'BasicAuth: username or password is undefined.'
end