Class: Utility

Inherits:
Object
  • Object
show all
Defined in:
lib/AuthenticationSDK/util/Utility.rb

Instance Method Summary collapse

Instance Method Details

#fetchCert(key_pass, file, key_alias) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/AuthenticationSDK/util/Utility.rb', line 36

def fetchCert(key_pass, file, key_alias)
  p12_file = OpenSSL::PKCS12.new(file, key_pass)
  x5_cert_pem = p12_file.certificate
  x5_cert_pem.subject.to_a.each do |attribute|
    return  Base64.strict_encode64(x5_cert_pem.to_der) if attribute[1].include?(key_alias)
  end
  unless p12_file.ca_certs.nil?
    p12_file.ca_certs.each do |cert|
      cert.subject.to_a.each do |attribute|
        return  Base64.strict_encode64(cert.to_der) if attribute[1].include?(key_alias)
      end
    end
  end
  nil
end

#getResponseCodeMessage(responseCode) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/AuthenticationSDK/util/Utility.rb', line 7

def getResponseCodeMessage(responseCode)
  responseCode = responseCode.to_s
  case responseCode
  when "200"
    tempResponseCodeMessage = "Transcation Successful"
  when "201"
    tempResponseCodeMessage = "Transcation Successful"
  when "400"
    tempResponseCodeMessage = "Bad Request"
  when "401"
    tempResponseCodeMessage = "Authentication Failed"
  when "404"
    tempResponseCodeMessage = "Not Found"
  when "403"
    tempResponseCodeMessage = "Forbidden"
  when "500"
    tempResponseCodeMessage = "Internal Server Error"
  when "502"
    tempResponseCodeMessage = "Bad Gateway"
  when "503"
    tempResponseCodeMessage = "Service Unavailable"
  when "504"
    tempResponseCodeMessage = "Gateway Timeout"
  else
    tempResponseCodeMessage= ''
  end
  return tempResponseCodeMessage
end