eet 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/Gemfile +1 -2
- data/README.md +82 -17
- data/eet.gemspec +1 -1
- data/lib/eet.rb +25 -5
- data/lib/eet/message.rb +71 -12
- data/lib/eet/sender.rb +13 -3
- data/lib/eet/utils.rb +26 -7
- data/lib/eet/version.rb +1 -1
- metadata +7 -10
- data/bin/send_test.rb +0 -23
- data/lib/eet/signer_x.rb +0 -21
- data/signed_message.xml +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81e95c809f51220e5ab21912d137f820334ddc47
|
4
|
+
data.tar.gz: 358fff045feaece15adf956d75f219eb98cc88d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 163a8b9839a72fd6e92e0deb27b7aa9c0c54400d9a7263c949bdcc6ece11c7ce7bd6f38811f08da10db3e217978a8c5992cce4bead165ada29a126cbafd46166
|
7
|
+
data.tar.gz: 4ccd17ca76cf5420adde063ffe0336040ac0512d6b2ad785550ea5e6552551b817f06e0032ff417d9a9a7af868960898365c7d32314dcf1049e946b73d59266b
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
-
# Specify your gem's dependencies in
|
4
|
-
gem 'signer', git: 'https://github.com/ucetnictvi-on-line/signer', ref: '4b22053c6854b4fd15f3ce2b8e09153684606288'
|
3
|
+
# Specify your gem's dependencies in eet.gemspec
|
5
4
|
gemspec
|
data/README.md
CHANGED
@@ -1,41 +1,106 @@
|
|
1
1
|
# Eet
|
2
|
+
[![Build Status](https://travis-ci.org/ucetnictvi-on-line/eet.svg?branch=master)](https://travis-ci.org/ucetnictvi-on-line/eet)
|
2
3
|
|
3
|
-
|
4
|
+
Hi everybody! This is Ruby wrapper for [Czech registration of sales system - EET](http://www.etrzby.cz/cs/index)
|
4
5
|
|
5
|
-
|
6
|
+
If you want to help Czech republic avoid bankruptcy please register all your cash registers and have fun!
|
6
7
|
|
7
8
|
## Installation
|
8
9
|
|
9
|
-
|
10
|
+
You know how to install a gem right? Ok..
|
11
|
+
|
12
|
+
## Usage
|
13
|
+
|
14
|
+
Let's see some demo first. Fire up your console and type:
|
10
15
|
|
11
16
|
```ruby
|
12
|
-
|
17
|
+
require 'eet'
|
18
|
+
|
19
|
+
puts Eet.test_playground.body
|
20
|
+
```
|
21
|
+
You should see something like this:
|
22
|
+
```shell
|
23
|
+
=> {:odpoved=>{:hlavicka=>{:@uuid_zpravy=>"e21047f2-185d-4f58-a3ca-52679f8c3cb2", :@bkp=>"677503F4-58C5AE1E-0101736A-450F4D7C-31ABAED9", :@dat_prij=>"2017-03-14T21:45:27+01:00"}, :potvrzeni=>{:@fik=>"00dc6277-be9d-4bbb-9824-9fad513168ea-ff", :@test=>"true"}},
|
24
|
+
:"@wsu:id"=>"Body-b64214c0-cf1c-42e1-91ec-495c34c27e65"}
|
13
25
|
```
|
14
26
|
|
15
|
-
|
27
|
+
**Cool right!? You just sended your first message to EET playground and got back some fik!** That means it's not that hard and you can do it. Now follow me:
|
28
|
+
|
29
|
+
### Real usage
|
16
30
|
|
17
|
-
|
31
|
+
First you of all you need to create a EET message:
|
18
32
|
|
19
|
-
|
33
|
+
```ruby
|
34
|
+
require 'eet'
|
35
|
+
|
36
|
+
message = Eet::Message.new
|
37
|
+
|
38
|
+
# Now to set message attributes use classic:
|
39
|
+
message.celk_trzba = '100.00'
|
40
|
+
message.dic_popl = 'CZ00000019'
|
41
|
+
message.id_pokl = 'p1'
|
42
|
+
message.id_provoz = '11'
|
43
|
+
message.porad_cis = '1'
|
44
|
+
|
45
|
+
# or pass a hash to #new method as you would do with ActiveModel model:
|
46
|
+
message = Eet::Message.new({ celk_trzba: '0.00',
|
47
|
+
dic_popl: 'CZ00000019',
|
48
|
+
id_pokl: 'p1',
|
49
|
+
id_provoz: '11',
|
50
|
+
porad_cis: '1' })
|
51
|
+
```
|
20
52
|
|
21
|
-
|
53
|
+
Attributes above are the basic ones you always need to provide to form valid message. Without these the message won't be valid and you won't get any fik back. Setting other attributes works the same. Visit [official EET documentation](http://www.etrzby.cz/cs/technicka-specifikace) for theirs full list.
|
22
54
|
|
23
|
-
|
55
|
+
To create and set security codes(pkp & bkp) use Utils module:
|
56
|
+
```ruby
|
57
|
+
certificate = Eet.playground_certificate
|
58
|
+
|
59
|
+
message.pkp = Eet::Utils.create_pkp(message, certificate)
|
60
|
+
message.bkp = Eet::Utils.create_bkp(message.pkp)
|
61
|
+
```
|
24
62
|
|
25
|
-
|
63
|
+
To sign the message:
|
64
|
+
```ruby
|
65
|
+
signed_message = Eet::Utils.sign(message.to_xml, certificate)
|
66
|
+
```
|
67
|
+
|
68
|
+
And finally, to send a message:
|
69
|
+
```ruby
|
70
|
+
sender = Eet::Sender.new
|
71
|
+
response = sender.send_to_playground(signed_message)
|
72
|
+
```
|
73
|
+
|
74
|
+
And that's it! This is the same code used inside of `Eet.test_playground` method. Now inspect response body to get your fik!
|
75
|
+
|
76
|
+
When you are ready to switch to production just use the `::send_to_production` method:
|
77
|
+
```ruby
|
78
|
+
sender = Eet::Sender.new
|
79
|
+
response = sender.send_to_production(signed_message)
|
80
|
+
```
|
81
|
+
But you will need to create security codes and sign the message with your own certificate. Certificate has to be `OpenSS::PKCS12` instance which you can initialize like this:
|
82
|
+
```ruby
|
83
|
+
OpenSSL::PKCS12.new(File.open('EET_CA1_Playground-CZ00000019.p12'), 'eet') # (substitute your path and password)
|
84
|
+
```
|
26
85
|
|
27
|
-
|
86
|
+
#### Default values
|
28
87
|
|
29
|
-
|
88
|
+
`Message` sets few default values for some of required attributes. These are:
|
30
89
|
|
31
|
-
|
90
|
+
* `uuid_zpravy` - `SecureRandom.uuid`
|
91
|
+
* `dat_odesl` - `Time.now` formatted to proper eet date format
|
92
|
+
* `prvni_zaslani` - `true`
|
93
|
+
* `rezim` - `0`
|
94
|
+
* `dat_trzby` - `Time.now` formatted to proper eet date format
|
32
95
|
|
33
|
-
|
96
|
+
Overwrite them at will.
|
34
97
|
|
35
|
-
|
98
|
+
#### Message XML
|
36
99
|
|
100
|
+
Want to get the message xml? Call `#to_xml` on the message at any time. It returns classic `Nokogiri` document
|
37
101
|
|
38
|
-
##
|
102
|
+
## Read the official docs please
|
39
103
|
|
40
|
-
|
104
|
+
We urge everybody to read the official EET docs before implementing any service connected to it. Sometimes the case can get tricky. After all there are 27 settable attributes for the message! And this is just a dumb API wrapper which let's you send anything you want...
|
41
105
|
|
106
|
+
**http://www.etrzby.cz/cs/technicka-specifikace**
|
data/eet.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
22
|
spec.add_dependency "savon"
|
23
|
-
spec.add_dependency "
|
23
|
+
spec.add_dependency "eet_signer", "~> 1.6"
|
24
24
|
|
25
25
|
spec.add_development_dependency "bundler", "~> 1.13"
|
26
26
|
spec.add_development_dependency "rake", "~> 10.0"
|
data/lib/eet.rb
CHANGED
@@ -1,8 +1,28 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require "eet/utils"
|
1
|
+
require 'eet/version'
|
2
|
+
require 'eet/message'
|
3
|
+
require 'eet/sender'
|
4
|
+
require 'eet/utils'
|
6
5
|
|
7
6
|
module Eet
|
7
|
+
def self.test_playground
|
8
|
+
data = { celk_trzba: '0.00',
|
9
|
+
dic_popl: 'CZ00000019',
|
10
|
+
id_pokl: 'p1',
|
11
|
+
id_provoz: '11',
|
12
|
+
porad_cis: '1' }
|
13
|
+
|
14
|
+
message = Message.new(data)
|
15
|
+
|
16
|
+
message.pkp = Utils.create_pkp(message, playground_certificate)
|
17
|
+
message.bkp = Utils.create_bkp(message.pkp)
|
18
|
+
|
19
|
+
signed_message = Utils.sign(message.to_xml, playground_certificate)
|
20
|
+
|
21
|
+
sender = Sender.new
|
22
|
+
response = sender.send_to_playground(signed_message)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.playground_certificate
|
26
|
+
OpenSSL::PKCS12.new(File.open('spec/fixtures/EET_CA1_Playground-CZ00000019.p12'), 'eet')
|
27
|
+
end
|
8
28
|
end
|
data/lib/eet/message.rb
CHANGED
@@ -5,32 +5,39 @@ require 'securerandom'
|
|
5
5
|
|
6
6
|
module Eet
|
7
7
|
class Message
|
8
|
-
SOAP_ENV_SCHEMA =
|
9
|
-
WSSE_SCHEMA =
|
10
|
-
WSU_SCHEMA =
|
8
|
+
SOAP_ENV_SCHEMA = 'http://schemas.xmlsoap.org/soap/envelope/'
|
9
|
+
WSSE_SCHEMA = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'
|
10
|
+
WSU_SCHEMA = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd'
|
11
11
|
WSU_ID = 'artificial_id'
|
12
|
+
BEZNY_REZIM = 0
|
13
|
+
DATE_FORMAT = '%FT%T%:z'
|
12
14
|
|
13
|
-
|
15
|
+
attr_writer :uuid_zpravy, :dat_odesl, :prvni_zaslani, :rezim
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
-
|
17
|
+
attr_accessor :pkp, :bkp, :overeni, :dic_poverujiciho, :zakl_nepodl_dph, :zakl_dan1, :dan1, :dic_popl,
|
18
|
+
:zakl_dan2, :dan2, :zakl_dan3, :dan3, :cest_sluz, :pouzit_zboz1, :pouzit_zboz2, :pouzit_zboz3,
|
19
|
+
:urceno_cerp_zuct, :cerp_zuct, :id_provoz, :id_pokl, :porad_cis, :dat_trzby, :celk_trzba
|
20
|
+
|
21
|
+
def initialize(attributes = {})
|
22
|
+
attributes.each do |k, v|
|
23
|
+
public_send("#{k}=", v)
|
24
|
+
end
|
18
25
|
end
|
19
26
|
|
20
27
|
def body
|
21
28
|
Nokogiri::XML::Builder.new('encoding' => 'UTF-8') do |xml|
|
22
29
|
xml.Trzba(xmlns: 'http://fs.mfcr.cz/eet/schema/v3') do
|
23
|
-
xml.Hlavicka(
|
30
|
+
xml.Hlavicka(head_attributes)
|
24
31
|
|
25
|
-
xml.Data(
|
32
|
+
xml.Data(data_attributes)
|
26
33
|
|
27
34
|
xml.KontrolniKody do
|
28
35
|
xml.pkp(cipher: 'RSA2048', digest: 'SHA256', encoding: 'base64') do
|
29
|
-
xml.text(
|
36
|
+
xml.text(pkp)
|
30
37
|
end
|
31
38
|
|
32
39
|
xml.bkp(digest: 'SHA1', encoding: 'base16') do
|
33
|
-
xml.text(
|
40
|
+
xml.text(bkp)
|
34
41
|
end
|
35
42
|
end
|
36
43
|
end
|
@@ -57,6 +64,58 @@ module Eet
|
|
57
64
|
|
58
65
|
msg
|
59
66
|
end
|
67
|
+
|
68
|
+
def uuid_zpravy
|
69
|
+
@uuid_zpravy ||= SecureRandom.uuid
|
70
|
+
end
|
71
|
+
|
72
|
+
def dat_odesl
|
73
|
+
@dat_odesl ||= Time.now.strftime(DATE_FORMAT)
|
74
|
+
end
|
75
|
+
|
76
|
+
def prvni_zaslani
|
77
|
+
@prvni_zaslani.nil? ? true : @prvni_zaslani
|
78
|
+
end
|
79
|
+
|
80
|
+
def rezim
|
81
|
+
@rezim ||= BEZNY_REZIM
|
82
|
+
end
|
83
|
+
|
84
|
+
def dat_trzby
|
85
|
+
@dat_trzby ||= Time.now.strftime(DATE_FORMAT)
|
86
|
+
end
|
87
|
+
|
88
|
+
def head_attributes
|
89
|
+
{ uuid_zpravy: uuid_zpravy,
|
90
|
+
dat_odesl: dat_odesl,
|
91
|
+
prvni_zaslani: prvni_zaslani,
|
92
|
+
overeni: overeni
|
93
|
+
}.reject { |_, v| v.nil? }
|
94
|
+
end
|
95
|
+
|
96
|
+
def data_attributes
|
97
|
+
{ dic_popl: dic_popl,
|
98
|
+
dic_poverujiciho: dic_poverujiciho,
|
99
|
+
id_provoz: id_provoz,
|
100
|
+
id_pokl: id_pokl,
|
101
|
+
porad_cis: porad_cis,
|
102
|
+
dat_trzby: dat_trzby,
|
103
|
+
celk_trzba: celk_trzba,
|
104
|
+
zakl_nepodl_dph: zakl_nepodl_dph,
|
105
|
+
zakl_dan1: zakl_dan1,
|
106
|
+
dan1: dan2,
|
107
|
+
zakl_dan2: zakl_dan2,
|
108
|
+
dan2: dan2,
|
109
|
+
zakl_dan3: zakl_dan3,
|
110
|
+
dan3: dan3,
|
111
|
+
cest_sluz: cest_sluz,
|
112
|
+
pouzit_zboz1: pouzit_zboz1,
|
113
|
+
pouzit_zboz2: pouzit_zboz2,
|
114
|
+
pouzit_zboz3: pouzit_zboz3,
|
115
|
+
urceno_cerp_zuct: urceno_cerp_zuct,
|
116
|
+
cerp_zuct: cerp_zuct,
|
117
|
+
rezim: rezim,
|
118
|
+
}.reject { |_, v| v.nil? }
|
119
|
+
end
|
60
120
|
end
|
61
|
-
# <Data celk_trzba="34113.00" cerp_zuct="679.00" cest_sluz="5460.00" dan1="-172.39" dan2="-530.73" dan3="975.65" dat_trzby="2016-08-05T00:30:12+02:00" dic_popl="CZ00000019" dic_poverujiciho="CZ683555118" id_pokl="/5546/RO24" id_provoz="273" porad_cis="0/6460/ZQ42" pouzit_zboz1="784.00" pouzit_zboz2="967.00" pouzit_zboz3="189.00" rezim="0" urceno_cerp_zuct="324.00" zakl_dan1="-820.92" zakl_dan2="-3538.20" zakl_dan3="9756.46" zakl_nepodl_dph="3036.00"/>
|
62
121
|
end
|
data/lib/eet/sender.rb
CHANGED
@@ -2,11 +2,21 @@ require 'savon'
|
|
2
2
|
|
3
3
|
module Eet
|
4
4
|
class Sender
|
5
|
+
PLAYGROUND_WSDL = 'https://pg.eet.cz:443/eet/services/EETServiceSOAP/v3?wsdl'
|
6
|
+
PRODUCTION_WSDL = 'https://prod.eet.cz:443/eet/services/EETServiceSOAP/v3?wsdl'
|
7
|
+
TIMEOUT = 2
|
8
|
+
ENDPOINT = :odeslani_trzby
|
5
9
|
attr_reader :message
|
6
10
|
|
7
|
-
def
|
8
|
-
client = Savon.client(wsdl:
|
9
|
-
response = client.call(
|
11
|
+
def send_to_playground(xml, wsdl = PLAYGROUND_WSDL, timeout = TIMEOUT, endpoint = ENDPOINT)
|
12
|
+
client = Savon.client(wsdl: wsdl, open_timeout: timeout)
|
13
|
+
response = client.call(endpoint, xml: xml)
|
14
|
+
response
|
15
|
+
end
|
16
|
+
|
17
|
+
def send_to_production(xml, wsdl = PRODUCTION_WSDL, timeout = TIMEOUT, endpoint = ENDPOINT)
|
18
|
+
client = Savon.client(wsdl: wsdl, open_timeout: timeout)
|
19
|
+
response = client.call(endpoint, xml: xml)
|
10
20
|
response
|
11
21
|
end
|
12
22
|
end
|
data/lib/eet/utils.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
+
require 'signer'
|
2
|
+
|
1
3
|
module Eet
|
2
4
|
module Utils
|
3
|
-
def self.create_pkp(
|
5
|
+
def self.create_pkp(message, certificate)
|
4
6
|
digest = OpenSSL::Digest::SHA256.new
|
5
|
-
signature = certificate.key.sign(digest, serialize_pkp_data(
|
7
|
+
signature = certificate.key.sign(digest, serialize_pkp_data(message))
|
6
8
|
Base64.encode64(signature).delete("\n")
|
7
9
|
end
|
8
10
|
|
@@ -18,15 +20,32 @@ module Eet
|
|
18
20
|
ret += ch
|
19
21
|
end
|
20
22
|
|
21
|
-
# '9356D566-A3E48838-FB403790-D201244E-95DCBD92'
|
22
23
|
ret.upcase.chars.each_slice(8).map(&:join).join('-')
|
23
24
|
end
|
24
25
|
|
25
|
-
|
26
|
+
def self.sign(xml, certificate)
|
27
|
+
signer = Signer.new(xml)
|
28
|
+
signer.cert = OpenSSL::X509::Certificate.new(certificate.certificate)
|
29
|
+
signer.private_key = OpenSSL::PKey::RSA.new(certificate.key, 'eet')
|
30
|
+
|
31
|
+
signer.security_node = signer.document.children.first.children.first.children.first
|
32
|
+
signer.digest_algorithm = :sha256
|
33
|
+
signer.signature_digest_algorithm = :sha256
|
34
|
+
signer.ds_namespace_prefix = 'ds'
|
35
|
+
signer.security_token_id = 'A79845F15C5549CA0514761283545705'
|
36
|
+
signer.digest!(signer.document.at_xpath('//soap:Body'), inclusive_namespaces: [''])
|
37
|
+
signer.sign!(security_token: true, inclusive_namespaces: ['soap'])
|
38
|
+
|
39
|
+
signer.to_xml
|
40
|
+
end
|
26
41
|
|
27
|
-
def self.serialize_pkp_data(
|
28
|
-
|
29
|
-
|
42
|
+
def self.serialize_pkp_data(message)
|
43
|
+
[message.dic_popl,
|
44
|
+
message.id_provoz,
|
45
|
+
message.id_pokl,
|
46
|
+
message.porad_cis,
|
47
|
+
message.dat_trzby,
|
48
|
+
message.celk_trzba].join('|')
|
30
49
|
end
|
31
50
|
end
|
32
51
|
end
|
data/lib/eet/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Premysl Donat
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: savon
|
@@ -25,19 +25,19 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: eet_signer
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '1.6'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '1.6'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -137,16 +137,13 @@ files:
|
|
137
137
|
- README.md
|
138
138
|
- Rakefile
|
139
139
|
- bin/console
|
140
|
-
- bin/send_test.rb
|
141
140
|
- bin/setup
|
142
141
|
- eet.gemspec
|
143
142
|
- lib/eet.rb
|
144
143
|
- lib/eet/message.rb
|
145
144
|
- lib/eet/sender.rb
|
146
|
-
- lib/eet/signer_x.rb
|
147
145
|
- lib/eet/utils.rb
|
148
146
|
- lib/eet/version.rb
|
149
|
-
- signed_message.xml
|
150
147
|
homepage:
|
151
148
|
licenses:
|
152
149
|
- MIT
|
data/bin/send_test.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'bundler/setup'
|
4
|
-
require 'eet'
|
5
|
-
|
6
|
-
certificate = OpenSSL::PKCS12.new(File.open('spec/fixtures/EET_CA1_Playground-CZ00000019.p12'), 'eet')
|
7
|
-
|
8
|
-
data_to_register = { celk_trzba: '0.00', dat_trzby: "2017-02-04T13:09:55+00:00", dic_popl: "CZ00000019", id_pokl: "p1_czk", id_provoz: '11', porad_cis: '158', rezim: '0' }
|
9
|
-
|
10
|
-
pkp = Eet::Utils.create_pkp(data_to_register, certificate)
|
11
|
-
bkp = Eet::Utils.create_bkp(pkp)
|
12
|
-
|
13
|
-
data = { timestamp: Time.now.strftime('%FT%T%:z'), pkp: pkp, bkp: bkp, data: data_to_register }
|
14
|
-
|
15
|
-
message = Eet::Message.new(data)
|
16
|
-
|
17
|
-
signer = Eet::SignerX.new
|
18
|
-
signed_message = signer.sign(message.to_xml, certificate)
|
19
|
-
|
20
|
-
sender = Eet::Sender.new
|
21
|
-
response = sender.call(signed_message)
|
22
|
-
|
23
|
-
puts response.body
|
data/lib/eet/signer_x.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'signer'
|
2
|
-
|
3
|
-
module Eet
|
4
|
-
class SignerX
|
5
|
-
def sign(xml, certificate)
|
6
|
-
signer = Signer.new(xml)
|
7
|
-
signer.cert = OpenSSL::X509::Certificate.new(certificate.certificate)
|
8
|
-
signer.private_key = OpenSSL::PKey::RSA.new(certificate.key, 'eet')
|
9
|
-
|
10
|
-
signer.security_node = signer.document.children.first.children.first.children.first
|
11
|
-
signer.digest_algorithm = :sha256
|
12
|
-
signer.signature_digest_algorithm = :sha256
|
13
|
-
signer.ds_namespace_prefix = 'ds'
|
14
|
-
signer.security_token_id = 'A79845F15C5549CA0514761283545705'
|
15
|
-
signer.digest!(signer.document.at_xpath('//soap:Body'), inclusive_namespaces: [''])
|
16
|
-
signer.sign!(security_token: true, inclusive_namespaces: ['soap'])
|
17
|
-
|
18
|
-
signer.to_xml
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
data/signed_message.xml
DELETED
@@ -1,2 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" soap:mustUnderstand="1"><wsse:BinarySecurityToken ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" wsu:Id="A79845F15C5549CA0514761283545705">MIIEmDCCA4CgAwIBAgIEdHOXJzANBgkqhkiG9w0BAQsFADB3MRIwEAYKCZImiZPyLGQBGRYCQ1oxQzBBBgNVBAoMOsSMZXNrw6EgUmVwdWJsaWthIOKAkyBHZW5lcsOhbG7DrSBmaW5hbsSNbsOtIMWZZWRpdGVsc3R2w60xHDAaBgNVBAMTE0VFVCBDQSAxIFBsYXlncm91bmQwHhcNMTYwOTMwMDkwMzU5WhcNMTkwOTMwMDkwMzU5WjBDMRIwEAYKCZImiZPyLGQBGRYCQ1oxEzARBgNVBAMTCkNaMDAwMDAwMTkxGDAWBgNVBA0TD3ByYXZuaWNrYSBvc29iYTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJnNUPW8rAlLi2KAwu12W1vqLj02mWIifq/Jp0/tUjf9B8RpkDAD3GOqDdVuHSfxej92WiEouDy7X8uXzIDdZu4pXA3t3KntxM8rAlu2U6SqtF3kTR+AJCdwfkM53U3z4/qoyKqdQ8lGuMxJKs7X5uIjcY/UDSXMK9OTmXRhndjYcX1oILr5F2ONf1Z0kWyl/S9wI0cl0gQ1F91mzqgnlH80u2inMmmBp42ndR4TGS1nvjer5D73bkLg07TdeqnUg609WwjUJN96OKZMsKXzBMzt09NbhQcABWnAWbRTSVhsAdDO8vfmWx2C+gXUlkIvtO+9fbj81GS1xdNoAkpARUcCAwEAAaOCAV4wggFaMAkGA1UdEwQCMAAwHQYDVR0OBBYEFL/0b0Iw6FY33UT8iJEy1V7nZVR6MB8GA1UdIwQYMBaAFHwwdqzM1ofR7Mkf4nAILONf3gwHMA4GA1UdDwEB/wQEAwIGwDBjBgNVHSAEXDBaMFgGCmCGSAFlAwIBMAEwSjBIBggrBgEFBQcCAjA8DDpUZW50byBjZXJ0aWZpa8OhdCBieWwgdnlkw6FuIHBvdXplIHBybyB0ZXN0b3ZhY8OtIMO6xI1lbHkuMIGXBgNVHR8EgY8wgYwwgYmggYaggYOGKWh0dHA6Ly9jcmwuY2ExLXBnLmVldC5jei9lZXRjYTFwZy9hbGwuY3JshipodHRwOi8vY3JsMi5jYTEtcGcuZWV0LmN6L2VldGNhMXBnL2FsbC5jcmyGKmh0dHA6Ly9jcmwzLmNhMS1wZy5lZXQuY3ovZWV0Y2ExcGcvYWxsLmNybDANBgkqhkiG9w0BAQsFAAOCAQEAvXdWsU+Ibd1VysKnjoy6RCYVcI9+oRUSSTvQQDJLFjwn5Sm6Hebhci8ERGwAzd2R6uqPdzl1KCjmHOitypZ66e+/e9wj3BaDqgBKRZYvxZykaVUdtQgG0819JZmiXTbGgOCKiUPIXO80cnP7U1ZPkVNV7WZwh0I2k/fg1VLTI5HA/x4BeD77wiEOExa7eqePJET0jpTVK3LxSW59LLIJROh4/kfKQbTvDL5Ypw8WagAMVCPvWnGJIcUru+ApLU4pZD9bdHSa1Ib4LpFhtWrkHYM/XqKbj2bNKKjTo5T3sU0Bf2QD3QzkmcjlNVG0V+qAgimwTdPueU/mtExw+7z1/A==</wsse:BinarySecurityToken><ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="SIG-A79845F15C5549CA0514761283545705"><ds:SignedInfo><ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"><ec:InclusiveNamespaces xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList="soap"/></ds:CanonicalizationMethod><ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/><ds:Reference URI="#id-A79845F15C5549CA0514761283545594"><ds:Transforms><ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"><ec:InclusiveNamespaces xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList=""/></ds:Transform></ds:Transforms><ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/><ds:DigestValue>oS2z6lczmYZH/h43TyGdNym/D0luvr+EcrdhBKAvJdk=</ds:DigestValue></ds:Reference></ds:SignedInfo><ds:SignatureValue>kJfGdND8bjLgz/9PzmU1yPODpwY1itokVCcKOp7egFGQ4Klfu0aNMYTu6Og3KHOHO/776jzuvdoL91FExIKRzgg3KRl+qtiRNFkc/4Wtq7vqsDUJAiEEBSRnb2ndsZsRqOvGtnTxSxFCX9UkzTz10kqEaReWKpsqW9E1YsyX7MBzMIgH2jVyvr7+f/s0Ec7SYgNzPhRffYZqwgVtf/Elqib6pfPw3Wa+zUvJjS4712rmxKcgaMfh0NK8vORFQ4UkcJq3T4ZXvI5LRJnP0KoHA0cx0nHkZ34MCGfhKfsOVgFi3KU9PiLME3v3NF5YRKBerdJgwH6GfaeJ20xnAqgKQg==</ds:SignatureValue><ds:KeyInfo><wsse:SecurityTokenReference><wsse:Reference ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" URI="#A79845F15C5549CA0514761283545705"/></wsse:SecurityTokenReference></ds:KeyInfo></ds:Signature></wsse:Security></SOAP-ENV:Header><soap:Body xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="id-A79845F15C5549CA0514761283545594"><Trzba xmlns="http://fs.mfcr.cz/eet/schema/v3"><Hlavicka dat_odesl="2017-02-19T13:02:18+01:00" prvni_zaslani="true" uuid_zpravy="5de35318-409b-441d-a5ae-ae1bcbc521fe"/><Data celk_trzba="0.00" dat_trzby="2017-02-04T13:09:55+00:00" dic_popl="CZ00000019" id_pokl="p1_czk" id_provoz="11" porad_cis="158" rezim="0"/><KontrolniKody><pkp cipher="RSA2048" digest="SHA256" encoding="base64">K/Jdtya/dZnZezhdI695kuQrS5WplQ78pJ+mpUuDXLZ4T6efyjCmYOYntG7GJ4nIW1m9K7cWuZQqmHnzPJsilgrX9hmHyAHHEztKdxnUUNFzg7jXsk/pP1RnNe8bfzLXIRc7OBDu9XlcbdltDqMcl7hTGZHzPN/s2/V/OAnzpT7rjzgGid9KTcwqEL2LEbTTxGbPmFsEKAgAsSrmhsQhgjwuyVmWTI17sWkvBaSE7y5pvTs81trszSrgwTRZ3PFg7MulpSA86fvZeuuqRjOrQGBMEGQJ3ade4kPV/f8edDCVb5B3mE9ZoDSsQpS0pZ8smHHcmrzkE5ZG6WxgBBsp9Q==</pkp><bkp digest="SHA1" encoding="base16">490A3B21-40AB90CC-43A91EA7-AE96C145-358FC380</bkp></KontrolniKody></Trzba></soap:Body></soap:Envelope>
|