class Kiji::Client
Attributes
access_key[RW]
api_end_point[RW]
basic_auth_id[RW]
basic_auth_password[RW]
cert[RW]
private_key[RW]
software_id[RW]
Public Class Methods
new() { |self| ... }
click to toggle source
# File lib/kiji/client.rb, line 12 def initialize @software_id = software_id @api_end_point = api_end_point @basic_auth_id = basic_auth_id @basic_auth_password = basic_auth_password yield(self) if block_given? end
Private Instance Methods
connection()
click to toggle source
# File lib/kiji/client.rb, line 23 def connection Faraday.new(url: @api_end_point) do |c| # c.response :logger c.adapter Faraday.default_adapter c.basic_auth(@basic_auth_id, @basic_auth_password) unless @basic_auth_id.nil? c.headers['User-Agent'] = 'SmartHR v0.0.1' c.headers['x-eGovAPI-SoftwareID'] = software_id c.headers['x-eGovAPI-AccessKey'] = access_key unless access_key.nil? end end
sign(appl_data)
click to toggle source
# File lib/kiji/client.rb, line 34 def sign(appl_data) fail 'Please specify cert & private_key' if cert.nil? || private_key.nil? doc = appl_data.to_xml(save_with: 0) signer = Signer.new(doc) do |s| s.cert = cert s.private_key = private_key s.digest_algorithm = :sha256 s.signature_digest_algorithm = :sha256 end signer.security_node = signer.document.root signer.document.xpath('/DataRoot/ApplData').each do |node| signer.digest!(node, id: '#ApplData') end signer.sign!(issuer_serial: true) signer end