52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/omniauth-polaris/adaptor.rb', line 52
def bind_as(args = {})
response = false
pin = args[:pin]
barcode = args[:barcode]
http_date = Time.now.in_time_zone("GMT").strftime("%a, %d %b %Y %H:%M:%S %Z")
http_uri_with_barcode = @http_uri + barcode
concated_string = @method + @http_uri + barcode + http_date + pin
sha1_sig = Base64.strict_encode64("#{OpenSSL::HMAC.digest('sha1',@access_key, concated_string)}")
xml_response = RestClient.get http_uri_with_barcode, {'PolarisDate' => http_date, 'Authorization' => "PWS " + @access_id + ":" + sha1_sig}
authorization_response = Hash.from_xml xml_response
http_basic_data_get = @http_uri + barcode + '/basicdata'
concated_string = @method + http_basic_data_get + http_date + pin
sha1_sig = Base64.strict_encode64("#{OpenSSL::HMAC.digest('sha1',@access_key, concated_string)}")
xml_response = RestClient.get http_basic_data_get, {'PolarisDate' => http_date, 'Authorization' => "PWS " + @access_id + ":" + sha1_sig}
details_response = Hash.from_xml xml_response
authorization_response["PatronValidateResult"]["NameFirst"] = details_response["PatronBasicDataGetResult"]["PatronBasicData"]["NameFirst"]
authorization_response["PatronValidateResult"]["NameLast"] = details_response["PatronBasicDataGetResult"]["PatronBasicData"]["NameLast"]
authorization_response["PatronValidateResult"]["NameMiddle"] = details_response["PatronBasicDataGetResult"]["PatronBasicData"]["NameMiddle"]
authorization_response["PatronValidateResult"]["PhoneNumber"] = details_response["PatronBasicDataGetResult"]["PatronBasicData"]["PhoneNumber"]
authorization_response["PatronValidateResult"]["EmailAddress"] = details_response["PatronBasicDataGetResult"]["PatronBasicData"]["EmailAddress"]
authorization_response["PatronValidateResult"]
end
|