liberic 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +32 -0
- data/README.md +8 -2
- data/lib/liberic/boot.rb +1 -1
- data/lib/liberic/certificate.rb +68 -0
- data/lib/liberic/process.rb +4 -4
- data/lib/liberic/sdk/types.rb +8 -8
- data/lib/liberic/version.rb +1 -1
- data/lib/liberic.rb +1 -0
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 036f583f24d5fee5d7347517bd3a2424c6155ff9a4fecc6f8241e6cc7710570a
|
4
|
+
data.tar.gz: e6d5801322f6e2a06dee3d72ffebf2455114c29722de46e89dce242c87c60695
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab255189575cf06a9a5f391a270de090db67e342c745f493c10c40ce2afad633faf5e3cd700d04ed6fa8070cd7b19171c31d1ca8163d28b9bf227733ba893c2f
|
7
|
+
data.tar.gz: 4f0cca686bf98eb4e82dcce6bda52f2fc7b99dbdcbf7e137eb78c82d186014d22bbcd06cc293478efb46ad17b60f6e7429dcbfa13e96f8442caa28d24a52c67a
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,38 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
+
## [1.3.0]
|
9
|
+
|
10
|
+
Support for ERIC 40.
|
11
|
+
|
12
|
+
### Deprecated
|
13
|
+
|
14
|
+
These features were removed from the ERIC SDK.
|
15
|
+
|
16
|
+
- `abrufCode` in `encryption_params`
|
17
|
+
- `cover_page` (`ersteSeite`) in `print_params`
|
18
|
+
|
19
|
+
## [1.2.0]
|
20
|
+
|
21
|
+
Add support to sign a submission with a POZ (Portalzertifikat)
|
22
|
+
|
23
|
+
Usage:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
# Uses the example Einkommensteuer & Zertifikat that comes with the ERIC SDK
|
27
|
+
tax_filing = File.read(File.expand_path('Beispiel/ericdemo-java/ESt_2020.xml', Liberic.eric_home))
|
28
|
+
cert_path = File.expand_path('Beispiel/ericdemo-java/test-softidnr-pse.pfx', Liberic.eric_home)
|
29
|
+
cert = Liberic::Certificate.new(cert_path, '123456')
|
30
|
+
|
31
|
+
submission = Liberic::Process.new(tax_filing, 'ESt_2020')
|
32
|
+
result = submission.execute({action: :submit, encryption: cert.encryption_params})
|
33
|
+
cert.release_handle!
|
34
|
+
```
|
35
|
+
|
36
|
+
### Added
|
37
|
+
|
38
|
+
- Added `Liberic::Certificate` class
|
39
|
+
|
8
40
|
## [1.1.0]
|
9
41
|
|
10
42
|
Eric now requires a call to an initialization function. This happens
|
data/README.md
CHANGED
@@ -40,15 +40,21 @@ include/
|
|
40
40
|
lib/
|
41
41
|
```
|
42
42
|
|
43
|
-
Currently, the environment variable `
|
43
|
+
Currently, the environment variable `ERIC_HOME_40` needs to be set to this
|
44
44
|
folder or the gem will not find the library files.
|
45
45
|
|
46
46
|
For example:
|
47
47
|
|
48
48
|
```sh
|
49
|
-
$ export
|
49
|
+
$ export ERIC_HOME_40=/opt/ERiC-40.3.4.0/Linux-x86_64
|
50
50
|
```
|
51
51
|
|
52
|
+
The gem will raise an `Liberic::InitializationError` if the environment variable is not set.
|
53
|
+
In a Rails project this can interfere with running rake (for example
|
54
|
+
when building the app in Docker). In this case, use `gem 'liberic', require: false` in your `Gemfile`.
|
55
|
+
And require the gem later in your Rails code (for example a model) by
|
56
|
+
calling `require 'liberic'`.
|
57
|
+
|
52
58
|
### Additional steps on OS X
|
53
59
|
|
54
60
|
The following OS X specific information dates back to the first version of this
|
data/lib/liberic/boot.rb
CHANGED
@@ -19,7 +19,7 @@ module Liberic
|
|
19
19
|
File.expand_path("libericapi.#{suffix}", ERIC_LIB_FOLDER)
|
20
20
|
end
|
21
21
|
|
22
|
-
ERIC_HOME = ENV['
|
22
|
+
ERIC_HOME = ENV['ERIC_HOME_40'] || raise(InitializationError.new('ERIC_HOME_40 environment variable not found (set it to the path to the ERiC libraries)'))
|
23
23
|
ERIC_LIB_FOLDER = File.expand_path('lib', ERIC_HOME)
|
24
24
|
|
25
25
|
def check_eric_version!
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module Liberic
|
2
|
+
# +Certificate+ encapsulates functionality regarding certificates (for signing).
|
3
|
+
# An instance of Certificate is passed on to +EricBearbeiteVorgang()+ where necessary.
|
4
|
+
class Certificate
|
5
|
+
attr_reader :features, :handle
|
6
|
+
|
7
|
+
# +cert_file+ path to a pfx file (Portal-Zertifikat)
|
8
|
+
# +pin+ the pin for the certificate (if applicable, string)
|
9
|
+
def initialize(cert_file, pin)
|
10
|
+
@pin = pin
|
11
|
+
ch = FFI::MemoryPointer.new(:uint32, 1)
|
12
|
+
cert_feature_flag_pointer = FFI::MemoryPointer.new(:uint32, 1)
|
13
|
+
|
14
|
+
Liberic::Helpers::Invocation.raise_on_error(
|
15
|
+
Liberic::SDK::API.get_handle_to_certificate(ch, cert_feature_flag_pointer, cert_file)
|
16
|
+
)
|
17
|
+
|
18
|
+
@handle = ch.get_uint32(0)
|
19
|
+
|
20
|
+
flags = cert_feature_flag_pointer.get_uint32(0)
|
21
|
+
@features = PinFeatures.new(
|
22
|
+
(flags & 0x00) != 0,
|
23
|
+
(flags & 0x01) != 0,
|
24
|
+
(flags & 0x02) != 0,
|
25
|
+
(flags & 0x04) != 0,
|
26
|
+
(flags & 0x10) != 0,
|
27
|
+
(flags & 0x20) != 0,
|
28
|
+
(flags & 0x40) != 0,
|
29
|
+
(flags & 0x80) != 0
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
# Returns the result of +EricHoleZertifikatEigenschaften()+
|
34
|
+
# This will be XML describing fields and properties associated with the certificate.
|
35
|
+
def properties
|
36
|
+
Helpers::Invocation.with_result_buffer do |buffer_handle|
|
37
|
+
SDK::API.hole_zertifikat_eigenschaften(@handle, @pin, buffer_handle)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# Returns a +SDK::Types::VerschluesselungsParameter+ data structure that can be passed on to
|
42
|
+
# Process.execute
|
43
|
+
def encryption_params
|
44
|
+
params = SDK::Types::VerschluesselungsParameter.new
|
45
|
+
|
46
|
+
params[:version] = 3
|
47
|
+
params[:zertifikatHandle] = @handle
|
48
|
+
params[:pin] = FFI::MemoryPointer.from_string(@pin).address
|
49
|
+
|
50
|
+
params
|
51
|
+
end
|
52
|
+
|
53
|
+
def release_handle!
|
54
|
+
SDK::API.close_handle_to_certificate(@handle)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
PinFeatures = Struct.new(
|
59
|
+
:no_pin,
|
60
|
+
:requires_pin_for_signature,
|
61
|
+
:requires_pin_for_decryption,
|
62
|
+
:requires_pin_for_cert_decryption,
|
63
|
+
:supports_pin_check,
|
64
|
+
:supports_last_attempt_failed,
|
65
|
+
:supports_pin_lock_on_next_fail,
|
66
|
+
:supports_pin_is_locked
|
67
|
+
)
|
68
|
+
end
|
data/lib/liberic/process.rb
CHANGED
@@ -37,7 +37,6 @@ module Liberic
|
|
37
37
|
# * +:filename+ (set a filename including path where to store the PDF file)
|
38
38
|
# * +:draft+ (set to +false+ to remove the the text "*** ENTWURF ***" on every page)
|
39
39
|
# * +:footer+ (set a string that will be printed on ever page footer)
|
40
|
-
# * +:cover_page+ (set to +true+ to include a cover page)
|
41
40
|
# * +:duplex+ (set to +true+ to generate pages for duplex printing (alternating margin left and right)
|
42
41
|
#
|
43
42
|
# Other options
|
@@ -59,6 +58,7 @@ module Liberic
|
|
59
58
|
def execute(options = {})
|
60
59
|
action = options[:action] ||= :validate
|
61
60
|
eric_action = ACTIONS[action] || (raise ExecutionError.new("Invalid action: #{action}. Valid actions are #{ACTIONS.keys.join(', ')}"))
|
61
|
+
is_printing = %w[submit print_and_submit print_and_submit_auth].include?(action.to_s)
|
62
62
|
print_params = create_print_params(options)
|
63
63
|
server_buffer = SDK::API.rueckgabepuffer_erzeugen
|
64
64
|
result = Helpers::Invocation.with_result_buffer(false) do |local_buffer|
|
@@ -66,7 +66,7 @@ module Liberic
|
|
66
66
|
eric_action,
|
67
67
|
(action == :submit ? nil : print_params),
|
68
68
|
options[:encryption],
|
69
|
-
(
|
69
|
+
(is_printing ? FFI::MemoryPointer.new(:uint32, 1) : nil), # transferHandle
|
70
70
|
local_buffer,
|
71
71
|
server_buffer)
|
72
72
|
end
|
@@ -89,10 +89,10 @@ module Liberic
|
|
89
89
|
print_and_submit_auth: :sende_auth
|
90
90
|
}
|
91
91
|
|
92
|
+
# TODO: check for updates regarding version
|
92
93
|
def create_print_params(options)
|
93
94
|
params = SDK::Types::DruckParameter.new
|
94
|
-
params[:version] =
|
95
|
-
params[:ersteSeite] = options[:cover_page] ? 1 : 0
|
95
|
+
params[:version] = 4
|
96
96
|
params[:duplexDruck] = options[:duplex] ? 1 : 0
|
97
97
|
params[:vorschau] = options.has_key?(:draft) ? (options[:draft] ? 1 : 0) : 1
|
98
98
|
{pdfName: :filename,
|
data/lib/liberic/sdk/types.rb
CHANGED
@@ -4,9 +4,8 @@ module Liberic
|
|
4
4
|
extend FFI::Library
|
5
5
|
|
6
6
|
class DruckParameter < FFI::Struct
|
7
|
-
layout :version, :uint, # Set version to
|
7
|
+
layout :version, :uint, # Set version to 4
|
8
8
|
:vorschau, :uint,
|
9
|
-
:ersteSeite, :uint,
|
10
9
|
:duplexDruck, :uint,
|
11
10
|
:pdfName, :pointer,
|
12
11
|
:fussText, :pointer,
|
@@ -14,10 +13,9 @@ module Liberic
|
|
14
13
|
end
|
15
14
|
|
16
15
|
class VerschluesselungsParameter < FFI::Struct
|
17
|
-
layout :version, :uint, # Set version to
|
16
|
+
layout :version, :uint, # Set version to 3
|
18
17
|
:zertifikatHandle, :uint,
|
19
|
-
:pin, :pointer
|
20
|
-
:abrufCode, :pointer
|
18
|
+
:pin, :pointer
|
21
19
|
end
|
22
20
|
|
23
21
|
class ZertifikatParameter < FFI::Struct
|
@@ -33,9 +31,11 @@ module Liberic
|
|
33
31
|
end
|
34
32
|
|
35
33
|
BearbeitungFlag = enum(
|
36
|
-
:validiere,
|
37
|
-
:sende,
|
38
|
-
:drucke,
|
34
|
+
:validiere, (1 << 1),
|
35
|
+
:sende, (1 << 2),
|
36
|
+
:drucke, (1 << 5),
|
37
|
+
:pruefe_hinweise, (1 << 7),
|
38
|
+
:validiere_ohne_freigabedatum, (1 << 8),
|
39
39
|
:sende_auth, ('00100110'.to_i(2)) # triggers all three: valiediere, sende and drucke
|
40
40
|
)
|
41
41
|
|
data/lib/liberic/version.rb
CHANGED
data/lib/liberic.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: liberic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Malte Münchert
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -104,6 +104,7 @@ files:
|
|
104
104
|
- examples/submit_ekst.rb
|
105
105
|
- lib/liberic.rb
|
106
106
|
- lib/liberic/boot.rb
|
107
|
+
- lib/liberic/certificate.rb
|
107
108
|
- lib/liberic/config.rb
|
108
109
|
- lib/liberic/helpers.rb
|
109
110
|
- lib/liberic/helpers/invocation.rb
|
@@ -123,7 +124,7 @@ homepage: https://www.github.com/mpm/liberic-ruby
|
|
123
124
|
licenses:
|
124
125
|
- MIT
|
125
126
|
metadata: {}
|
126
|
-
post_install_message:
|
127
|
+
post_install_message:
|
127
128
|
rdoc_options: []
|
128
129
|
require_paths:
|
129
130
|
- lib
|
@@ -139,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
140
|
version: '0'
|
140
141
|
requirements: []
|
141
142
|
rubygems_version: 3.5.6
|
142
|
-
signing_key:
|
143
|
+
signing_key:
|
143
144
|
specification_version: 4
|
144
145
|
summary: Ruby bindings for ELSTER/ERiC (German Tax Authority Service)
|
145
146
|
test_files: []
|