Class: Epics::GenericUploadRequest
Instance Attribute Summary collapse
#client, #transaction_id
Instance Method Summary
collapse
#auth_signature, #nonce, #root, #timestamp, #to_receipt_xml, #to_transfer_xml, #to_xml
Constructor Details
Returns a new instance of GenericUploadRequest.
6
7
8
9
10
|
# File 'lib/epics/generic_upload_request.rb', line 6
def initialize(client, document)
super(client)
self.document = document
self.key ||= cipher.random_key
end
|
Instance Attribute Details
#document ⇒ Object
Returns the value of attribute document.
4
5
6
|
# File 'lib/epics/generic_upload_request.rb', line 4
def document
@document
end
|
#key ⇒ Object
Returns the value of attribute key.
3
4
5
|
# File 'lib/epics/generic_upload_request.rb', line 3
def key
@key
end
|
Instance Method Details
#body ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/epics/generic_upload_request.rb', line 20
def body
{
"DataTransfer" => {
"DataEncryptionInfo" => {
:@authenticate => true,
"EncryptionPubKeyDigest" => {
:"@Version" => "E002",
:"@Algorithm" => "http://www.w3.org/2001/04/xmlenc#sha256",
:content! => client.bank_e.public_digest
},
"TransactionKey" => Base64.encode64(client.bank_e.key.public_encrypt(self.key)).gsub(/\n/,'')
},
"SignatureData" => {
:@authenticate => true,
:content! => encrypted_order_signature
}
}
}
end
|
#cipher ⇒ Object
12
13
14
|
# File 'lib/epics/generic_upload_request.rb', line 12
def cipher
@cipher ||= OpenSSL::Cipher.new("aes-128-cbc")
end
|
#digester ⇒ Object
16
17
18
|
# File 'lib/epics/generic_upload_request.rb', line 16
def digester
@digester ||= OpenSSL::Digest::SHA256.new
end
|
#encrypt(d) ⇒ Object
58
59
60
61
62
63
64
|
# File 'lib/epics/generic_upload_request.rb', line 58
def encrypt(d)
cipher.reset
cipher.encrypt
cipher.padding = 0
cipher.key = self.key
(cipher.update(pad(d)) + cipher.final)
end
|
#encrypted_order_data ⇒ Object
66
67
68
69
70
|
# File 'lib/epics/generic_upload_request.rb', line 66
def encrypted_order_data
dst = Zlib::Deflate.deflate(document)
Base64.encode64(encrypt(dst)).gsub(/\n/,'')
end
|
#encrypted_order_signature ⇒ Object
72
73
74
75
76
|
# File 'lib/epics/generic_upload_request.rb', line 72
def encrypted_order_signature
dst = Zlib::Deflate.deflate(order_signature)
Base64.encode64(encrypt(dst)).gsub(/\n/,'')
end
|
#order_signature ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/epics/generic_upload_request.rb', line 40
def order_signature
Gyoku.xml("UserSignatureData" => {
:"@xmlns" => "http://www.ebics.org/S001",
:"@xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
:"@xsi:schemaLocation" => "http://www.ebics.org/S001 http://www.ebics.org/S001/ebics_signature.xsd",
"OrderSignatureData" => {
"SignatureVersion" => "A006",
"SignatureValue" => signature_value,
"PartnerID" => partner_id,
"UserID" => user_id
}
})
end
|
#pad(d) ⇒ Object
78
79
80
81
82
83
84
|
# File 'lib/epics/generic_upload_request.rb', line 78
def pad(d)
len = cipher.block_size*((d.size / cipher.block_size)+1)
d.ljust(len, [0].pack("C*")).tap do |padded|
padded[-1] = [len - d.size].pack("C*")
end
end
|
#signature_value ⇒ Object
54
55
56
|
# File 'lib/epics/generic_upload_request.rb', line 54
def signature_value
client.a.sign( digester.digest(document.gsub(/\n|\r/, "")) )
end
|