liberic 1.1.0 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5e7deb7e6297685fa161f7503076497a044838f97a7eb7cc0152e4569919217e
4
- data.tar.gz: 5be4c0aa504af885535e022ea797fadafbba322da364ad49bb79f2aa37096489
3
+ metadata.gz: 6348962b78e06d7c6d3bcbf5a88dc4769bff77e8ce5fb58b7abb6d5bc9f6e798
4
+ data.tar.gz: c392458f17282493fb5ac485c9d53e429f35a913589ad45431c4504b3c61e215
5
5
  SHA512:
6
- metadata.gz: 127d45ca76db8a8a5478836983762aa7acf69aeee68a2e37a660c3d4c8eae95de1dae6a14375805bfae35ff6e9f9d3c03fe341c31e37e70bda4571b2a75c68d7
7
- data.tar.gz: 51a34f281440d87d4e7863b057fc472f41293c7b80311780d691dd6bcb44891107ae2ad4bb521e9b52d23cbbf0ccc218b5262dfbfae61edac24f60f8f692f0e8
6
+ metadata.gz: 702ca9b85f8078adf43b4e93d5985ee3101a7aee90f46133b3355ddc528567836aab7a33722e887c7e38346a2016c175d6e9df9b4faeb1ae34d7373b2b9ffd72
7
+ data.tar.gz: 35039a0225ef54ec6e5d6730f798e3702d7bb8f6fdcedfdb0bf70fd18b41178212a3b56318fb42132f5792622775bd7ebd6642e9534b967fbb01c93a8b2ff8e5
data/CHANGELOG.md CHANGED
@@ -5,6 +5,27 @@ 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.2.0]
9
+
10
+ Add support to sign a submission with a POZ (Portalzertifikat)
11
+
12
+ Usage:
13
+
14
+ ```ruby
15
+ # Uses the example Einkommensteuer & Zertifikat that comes with the ERIC SDK
16
+ tax_filing = File.read(File.expand_path('Beispiel/ericdemo-java/ESt_2020.xml', Liberic.eric_home))
17
+ cert_path = File.expand_path('Beispiel/ericdemo-java/test-softidnr-pse.pfx', Liberic.eric_home)
18
+ cert = Liberic::Certificate.new(cert_path, '123456')
19
+
20
+ submission = Liberic::Process.new(tax_filing, 'ESt_2020')
21
+ result = submission.execute({action: :submit, encryption: cert.encryption_params})
22
+ cert.release_handle!
23
+ ```
24
+
25
+ ### Added
26
+
27
+ - Added `Liberic::Certificate` class
28
+
8
29
  ## [1.1.0]
9
30
 
10
31
  Eric now requires a call to an initialization function. This happens
data/README.md CHANGED
@@ -49,6 +49,12 @@ For example:
49
49
  $ export ERIC_HOME_39=/opt/ERiC-39.3.2.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
@@ -0,0 +1,69 @@
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] = 2
47
+ params[:zertifikatHandle] = @handle
48
+ params[:pin] = FFI::MemoryPointer.from_string(@pin).address
49
+ params[:abrufCode] = nil
50
+
51
+ params
52
+ end
53
+
54
+ def release_handle!
55
+ SDK::API.close_handle_to_certificate(@handle)
56
+ end
57
+ end
58
+
59
+ PinFeatures = Struct.new(
60
+ :no_pin,
61
+ :requires_pin_for_signature,
62
+ :requires_pin_for_decryption,
63
+ :requires_pin_for_cert_decryption,
64
+ :supports_pin_check,
65
+ :supports_last_attempt_failed,
66
+ :supports_pin_lock_on_next_fail,
67
+ :supports_pin_is_locked
68
+ )
69
+ end
@@ -59,6 +59,7 @@ module Liberic
59
59
  def execute(options = {})
60
60
  action = options[:action] ||= :validate
61
61
  eric_action = ACTIONS[action] || (raise ExecutionError.new("Invalid action: #{action}. Valid actions are #{ACTIONS.keys.join(', ')}"))
62
+ is_printing = %w[submit print_and_submit print_and_submit_auth].include?(action.to_s)
62
63
  print_params = create_print_params(options)
63
64
  server_buffer = SDK::API.rueckgabepuffer_erzeugen
64
65
  result = Helpers::Invocation.with_result_buffer(false) do |local_buffer|
@@ -66,7 +67,7 @@ module Liberic
66
67
  eric_action,
67
68
  (action == :submit ? nil : print_params),
68
69
  options[:encryption],
69
- (action == :submit ? FFI::MemoryPointer.new(:uint32, 1) : nil), # transferHandle
70
+ (is_printing ? FFI::MemoryPointer.new(:uint32, 1) : nil), # transferHandle
70
71
  local_buffer,
71
72
  server_buffer)
72
73
  end
@@ -89,6 +90,7 @@ module Liberic
89
90
  print_and_submit_auth: :sende_auth
90
91
  }
91
92
 
93
+ # TODO: check for updates regarding version
92
94
  def create_print_params(options)
93
95
  params = SDK::Types::DruckParameter.new
94
96
  params[:version] = 2
@@ -1,3 +1,3 @@
1
1
  module Liberic
2
- VERSION = '1.1.0'
2
+ VERSION = '1.2.0'
3
3
  end
data/lib/liberic.rb CHANGED
@@ -3,6 +3,7 @@ require 'nokogiri'
3
3
  require 'logger'
4
4
  require 'liberic/version'
5
5
  require 'liberic/boot'
6
+ require 'liberic/certificate'
6
7
  require 'liberic/helpers'
7
8
  require 'liberic/response'
8
9
  require 'liberic/sdk'
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.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Malte Münchert
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-02-20 00:00:00.000000000 Z
11
+ date: 2024-09-13 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