pki_express 1.3.0 → 1.3.2

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.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.gitattributes +2 -2
  3. data/.github/workflows/test.yml +22 -0
  4. data/.gitignore +27 -27
  5. data/.rspec +1 -0
  6. data/CHANGELOG.md +19 -12
  7. data/Gemfile +9 -4
  8. data/README.md +24 -24
  9. data/Rakefile +7 -1
  10. data/lib/pki_express/auth_complete_result.rb +21 -21
  11. data/lib/pki_express/auth_start_result.rb +76 -76
  12. data/lib/pki_express/authentication.rb +284 -284
  13. data/lib/pki_express/base_signer.rb +54 -54
  14. data/lib/pki_express/cades_signature.rb +89 -89
  15. data/lib/pki_express/cades_signature_starter.rb +242 -242
  16. data/lib/pki_express/check_service_result.rb +15 -15
  17. data/lib/pki_express/command_error.rb +13 -13
  18. data/lib/pki_express/commands.rb +24 -24
  19. data/lib/pki_express/digest_algorithm.rb +118 -118
  20. data/lib/pki_express/digest_algorithm_and_value.rb +30 -30
  21. data/lib/pki_express/discovery_service_result.rb +25 -25
  22. data/lib/pki_express/enum.rb +9 -9
  23. data/lib/pki_express/error_codes.rb +46 -46
  24. data/lib/pki_express/installation_not_found_error.rb +8 -8
  25. data/lib/pki_express/name.rb +47 -47
  26. data/lib/pki_express/oids.rb +30 -30
  27. data/lib/pki_express/pades_certification_level.rb +7 -7
  28. data/lib/pki_express/pades_horizontal_align.rb +9 -9
  29. data/lib/pki_express/pades_measurement_units.rb +8 -8
  30. data/lib/pki_express/pades_page_optimization.rb +50 -50
  31. data/lib/pki_express/pades_page_orientation.rb +9 -9
  32. data/lib/pki_express/pades_paper_size.rb +21 -21
  33. data/lib/pki_express/pades_signature.rb +16 -16
  34. data/lib/pki_express/pades_signature_explorer.rb +30 -30
  35. data/lib/pki_express/pades_signature_starter.rb +251 -251
  36. data/lib/pki_express/pades_signer.rb +274 -274
  37. data/lib/pki_express/pades_signer_info.rb +9 -9
  38. data/lib/pki_express/pades_size.rb +17 -17
  39. data/lib/pki_express/pades_text_horizontal_align.rb +8 -8
  40. data/lib/pki_express/pades_vertical_align.rb +9 -9
  41. data/lib/pki_express/pades_visual_auto_positioning.rb +21 -21
  42. data/lib/pki_express/pades_visual_image.rb +51 -51
  43. data/lib/pki_express/pades_visual_manual_positioning.rb +16 -16
  44. data/lib/pki_express/pades_visual_positioning.rb +27 -27
  45. data/lib/pki_express/pades_visual_rectangle.rb +74 -74
  46. data/lib/pki_express/pades_visual_representation.rb +22 -22
  47. data/lib/pki_express/pades_visual_text.rb +35 -35
  48. data/lib/pki_express/pk_algorithms.rb +157 -157
  49. data/lib/pki_express/pk_certificate.rb +61 -61
  50. data/lib/pki_express/pki_brazil_certificate_fields.rb +57 -57
  51. data/lib/pki_express/pki_brazil_certificate_types.rb +19 -19
  52. data/lib/pki_express/pki_express_config.rb +39 -26
  53. data/lib/pki_express/pki_express_operator.rb +240 -234
  54. data/lib/pki_express/pki_italy_certificate_fields.rb +15 -15
  55. data/lib/pki_express/pki_italy_certificate_types.rb +11 -11
  56. data/lib/pki_express/signature_algorithm_and_value.rb +34 -34
  57. data/lib/pki_express/signature_explorer.rb +74 -74
  58. data/lib/pki_express/signature_finisher.rb +314 -314
  59. data/lib/pki_express/signature_policy_identifier.rb +20 -20
  60. data/lib/pki_express/signature_start_result.rb +12 -12
  61. data/lib/pki_express/signature_starter.rb +116 -116
  62. data/lib/pki_express/signer.rb +151 -151
  63. data/lib/pki_express/standard_signature_policies.rb +58 -58
  64. data/lib/pki_express/timestamp_authority.rb +50 -50
  65. data/lib/pki_express/trust_service_auth_parameters.rb +20 -20
  66. data/lib/pki_express/trust_service_info.rb +37 -37
  67. data/lib/pki_express/trust_service_manager.rb +258 -258
  68. data/lib/pki_express/trust_service_session_result.rb +29 -29
  69. data/lib/pki_express/trust_service_session_types.rb +7 -7
  70. data/lib/pki_express/tsa_authentication_type.rb +14 -14
  71. data/lib/pki_express/validation_error.rb +8 -8
  72. data/lib/pki_express/validation_item.rb +43 -43
  73. data/lib/pki_express/validation_item_types.rb +103 -103
  74. data/lib/pki_express/validation_results.rb +120 -120
  75. data/lib/pki_express/version.rb +3 -3
  76. data/lib/pki_express/version_manager.rb +20 -20
  77. data/lib/pki_express.rb +69 -69
  78. data/pki_express.gemspec +26 -26
  79. data/spec/pki_express/pki_express_config_spec.rb +73 -0
  80. data/spec/pki_express/pki_express_operator_spec.rb +31 -0
  81. data/spec/spec_helper.rb +13 -0
  82. metadata +17 -9
@@ -1,52 +1,52 @@
1
- module PkiExpress
2
- class PadesVisualImage
3
- attr_reader :horizontal_align, :vertical_align
4
- attr_accessor :opacity, :content, :url,
5
- :mime_type
6
-
7
- def initialize(image_content=nil, image_url = nil, image_mime_type=nil)
8
- @opacity = 100
9
- @horizontal_align = PadesHorizontalAlign::CENTER
10
- @vertical_align = PadesVerticalAlign::CENTER
11
- @content = image_content
12
- @url = image_url
13
- @mime_type = image_mime_type
14
- end
15
-
16
- def horizontal_align=(value)
17
- unless PadesHorizontalAlign.contains?(value)
18
- raise 'The provided "horizontal_align" is not valid. Try using PadesHorizontalAlign constants'
19
- end
20
-
21
- @horizontal_align = value
22
- end
23
-
24
- def vertical_align=(value)
25
- unless PadesVerticalAlign.contains?(value)
26
- raise 'The provided "vertical_align" is not valid. Try using PadesVerticalAlign constants'
27
- end
28
-
29
- @vertical_align = value
30
- end
31
-
32
- def to_model
33
- resource_model = {
34
- 'mimeType': @mime_type,
35
- }
36
- if @content
37
- resource_model['content'] = Base64.encode64(@content)
38
- elsif @url
39
- resource_model['url'] = @url
40
- else
41
- raise 'The image content was not set, neither its URL'
42
- end
43
-
44
- {
45
- resource: resource_model,
46
- opacity: @opacity,
47
- horizontal_align: @horizontal_align,
48
- vertical_align: @vertical_align,
49
- }
50
- end
51
- end
1
+ module PkiExpress
2
+ class PadesVisualImage
3
+ attr_reader :horizontal_align, :vertical_align
4
+ attr_accessor :opacity, :content, :url,
5
+ :mime_type
6
+
7
+ def initialize(image_content=nil, image_url = nil, image_mime_type=nil)
8
+ @opacity = 100
9
+ @horizontal_align = PadesHorizontalAlign::CENTER
10
+ @vertical_align = PadesVerticalAlign::CENTER
11
+ @content = image_content
12
+ @url = image_url
13
+ @mime_type = image_mime_type
14
+ end
15
+
16
+ def horizontal_align=(value)
17
+ unless PadesHorizontalAlign.contains?(value)
18
+ raise 'The provided "horizontal_align" is not valid. Try using PadesHorizontalAlign constants'
19
+ end
20
+
21
+ @horizontal_align = value
22
+ end
23
+
24
+ def vertical_align=(value)
25
+ unless PadesVerticalAlign.contains?(value)
26
+ raise 'The provided "vertical_align" is not valid. Try using PadesVerticalAlign constants'
27
+ end
28
+
29
+ @vertical_align = value
30
+ end
31
+
32
+ def to_model
33
+ resource_model = {
34
+ 'mimeType': @mime_type,
35
+ }
36
+ if @content
37
+ resource_model['content'] = Base64.encode64(@content)
38
+ elsif @url
39
+ resource_model['url'] = @url
40
+ else
41
+ raise 'The image content was not set, neither its URL'
42
+ end
43
+
44
+ {
45
+ resource: resource_model,
46
+ opacity: @opacity,
47
+ horizontal_align: @horizontal_align,
48
+ vertical_align: @vertical_align,
49
+ }
50
+ end
51
+ end
52
52
  end
@@ -1,17 +1,17 @@
1
- module PkiExpress
2
- class PadesVisualManualPositioning < PadesVisualPositioning
3
- attr_accessor :signature_rectangle
4
-
5
- def initialize(page_number=nil, measurement_units=nil, signature_rectangle=nil)
6
- super(page_number, measurement_units)
7
- @signature_rectangle = signature_rectangle
8
- end
9
-
10
- def to_model
11
- model = super
12
- model['manual'] = @signature_rectangle&.to_model
13
- model
14
- end
15
-
16
- end
1
+ module PkiExpress
2
+ class PadesVisualManualPositioning < PadesVisualPositioning
3
+ attr_accessor :signature_rectangle
4
+
5
+ def initialize(page_number=nil, measurement_units=nil, signature_rectangle=nil)
6
+ super(page_number, measurement_units)
7
+ @signature_rectangle = signature_rectangle
8
+ end
9
+
10
+ def to_model
11
+ model = super
12
+ model['manual'] = @signature_rectangle&.to_model
13
+ model
14
+ end
15
+
16
+ end
17
17
  end
@@ -1,28 +1,28 @@
1
- module PkiExpress
2
- class PadesVisualPositioning
3
- attr_reader :measurement_units
4
- attr_accessor :page_number, :page_optimization
5
-
6
- def initialize(page_number=nil, measurement_units=nil)
7
- @page_number = page_number
8
- @measurement_units = measurement_units
9
- @page_optimization = nil
10
- end
11
-
12
- def measurement_units=(value)
13
- unless PadesMeasurementUnits.contains?(value)
14
- raise 'The provided "measurement_units" is not valid. Try using PadesMeasurementUnits constants'
15
- end
16
-
17
- @measurement_units = value
18
- end
19
-
20
- def to_model
21
- {
22
- 'pageNumber': @page_number,
23
- 'measurementUnits': @measurement_units,
24
- 'pageOptimization': @page_optimization&.to_model
25
- }
26
- end
27
- end
1
+ module PkiExpress
2
+ class PadesVisualPositioning
3
+ attr_reader :measurement_units
4
+ attr_accessor :page_number, :page_optimization
5
+
6
+ def initialize(page_number=nil, measurement_units=nil)
7
+ @page_number = page_number
8
+ @measurement_units = measurement_units
9
+ @page_optimization = nil
10
+ end
11
+
12
+ def measurement_units=(value)
13
+ unless PadesMeasurementUnits.contains?(value)
14
+ raise 'The provided "measurement_units" is not valid. Try using PadesMeasurementUnits constants'
15
+ end
16
+
17
+ @measurement_units = value
18
+ end
19
+
20
+ def to_model
21
+ {
22
+ 'pageNumber': @page_number,
23
+ 'measurementUnits': @measurement_units,
24
+ 'pageOptimization': @page_optimization&.to_model
25
+ }
26
+ end
27
+ end
28
28
  end
@@ -1,74 +1,74 @@
1
- module PkiExpress
2
- class PadesVisualRectangle
3
- attr_accessor :left, :top, :right, :bottom, :width, :height
4
-
5
- def initialize
6
- @left = nil
7
- @top = nil
8
- @right = nil
9
- @bottom = nil
10
- @width = nil
11
- @height = nil
12
- end
13
-
14
- def set_width_centered(width)
15
- @width = width
16
- @left = nil
17
- @right = nil
18
- end
19
-
20
- def set_width_left_anchored(width, left)
21
- @width = width
22
- @left = left
23
- @right = nil
24
- end
25
-
26
- def set_width_right_anchored(width, right)
27
- @width = width
28
- @left = nil
29
- @right = right
30
- end
31
-
32
- def set_horizontal_stretch(left, right)
33
- @width = nil
34
- @left = left
35
- @right = right
36
- end
37
-
38
- def set_height_centered(height)
39
- @height = height
40
- @top = nil
41
- @bottom = nil
42
- end
43
-
44
- def set_height_top_anchored(height, top)
45
- @height = height
46
- @top = top
47
- @bottom = nil
48
- end
49
-
50
- def set_height_bottom_anchored(height, bottom)
51
- @height = height
52
- @top = nil
53
- @bottom = bottom
54
- end
55
-
56
- def set_vertical_stretch(top, bottom)
57
- @height = nil
58
- @top = top
59
- @bottom = bottom
60
- end
61
-
62
- def to_model
63
- {
64
- left: @left,
65
- top: @top,
66
- right: @right,
67
- bottom: @bottom,
68
- width: @width,
69
- height: @height,
70
- }
71
- end
72
-
73
- end
74
- end
1
+ module PkiExpress
2
+ class PadesVisualRectangle
3
+ attr_accessor :left, :top, :right, :bottom, :width, :height
4
+
5
+ def initialize
6
+ @left = nil
7
+ @top = nil
8
+ @right = nil
9
+ @bottom = nil
10
+ @width = nil
11
+ @height = nil
12
+ end
13
+
14
+ def set_width_centered(width)
15
+ @width = width
16
+ @left = nil
17
+ @right = nil
18
+ end
19
+
20
+ def set_width_left_anchored(width, left)
21
+ @width = width
22
+ @left = left
23
+ @right = nil
24
+ end
25
+
26
+ def set_width_right_anchored(width, right)
27
+ @width = width
28
+ @left = nil
29
+ @right = right
30
+ end
31
+
32
+ def set_horizontal_stretch(left, right)
33
+ @width = nil
34
+ @left = left
35
+ @right = right
36
+ end
37
+
38
+ def set_height_centered(height)
39
+ @height = height
40
+ @top = nil
41
+ @bottom = nil
42
+ end
43
+
44
+ def set_height_top_anchored(height, top)
45
+ @height = height
46
+ @top = top
47
+ @bottom = nil
48
+ end
49
+
50
+ def set_height_bottom_anchored(height, bottom)
51
+ @height = height
52
+ @top = nil
53
+ @bottom = bottom
54
+ end
55
+
56
+ def set_vertical_stretch(top, bottom)
57
+ @height = nil
58
+ @top = top
59
+ @bottom = bottom
60
+ end
61
+
62
+ def to_model
63
+ {
64
+ left: @left,
65
+ top: @top,
66
+ right: @right,
67
+ bottom: @bottom,
68
+ width: @width,
69
+ height: @height,
70
+ }
71
+ end
72
+
73
+ end
74
+ end
@@ -1,22 +1,22 @@
1
- module PkiExpress
2
- class PadesVisualRepresentation
3
- attr_accessor :text, :image, :position
4
-
5
- def initialize(text=nil, image=nil, position=nil)
6
- @text = text
7
- @image = image
8
- @position = position
9
- end
10
-
11
- def to_model
12
- unless @position
13
- raise new 'The visual representation position was not set'
14
- end
15
- {
16
- position: @position&.to_model,
17
- text: @text&.to_model,
18
- image: @image&.to_model,
19
- }
20
- end
21
- end
22
- end
1
+ module PkiExpress
2
+ class PadesVisualRepresentation
3
+ attr_accessor :text, :image, :position
4
+
5
+ def initialize(text=nil, image=nil, position=nil)
6
+ @text = text
7
+ @image = image
8
+ @position = position
9
+ end
10
+
11
+ def to_model
12
+ unless @position
13
+ raise new 'The visual representation position was not set'
14
+ end
15
+ {
16
+ position: @position&.to_model,
17
+ text: @text&.to_model,
18
+ image: @image&.to_model,
19
+ }
20
+ end
21
+ end
22
+ end
@@ -1,35 +1,35 @@
1
- module PkiExpress
2
- class PadesVisualText
3
- attr_reader :horizontal_align
4
- attr_accessor :text, :include_signing_time, :font_size,
5
- :container, :signing_time_format
6
-
7
- def initialize(text=nil, include_signing_time=nil, font_size=nil)
8
- @horizontal_align = :left
9
- @text = text
10
- @include_signing_time = include_signing_time
11
- @font_size = font_size
12
- @container = nil
13
- @signing_time_format = nil
14
- end
15
-
16
- def horizontal_align=(value)
17
- unless PadesTextHorizontalAlign.contains?(value)
18
- raise 'The provided "horizontal_align" is not valid. Try using PadesTextHorizontalAlign constants'
19
- end
20
-
21
- @horizontal_align = value
22
- end
23
-
24
- def to_model
25
- {
26
- 'fontSize': @font_size,
27
- 'text': @text,
28
- 'includeSigningTime': @include_signing_time,
29
- 'signingTimeFormat': @signing_time_format,
30
- 'container': @container&.to_model,
31
- 'horizontalAlign': @horizontal_align
32
- }
33
- end
34
- end
35
- end
1
+ module PkiExpress
2
+ class PadesVisualText
3
+ attr_reader :horizontal_align
4
+ attr_accessor :text, :include_signing_time, :font_size,
5
+ :container, :signing_time_format
6
+
7
+ def initialize(text=nil, include_signing_time=nil, font_size=nil)
8
+ @horizontal_align = :left
9
+ @text = text
10
+ @include_signing_time = include_signing_time
11
+ @font_size = font_size
12
+ @container = nil
13
+ @signing_time_format = nil
14
+ end
15
+
16
+ def horizontal_align=(value)
17
+ unless PadesTextHorizontalAlign.contains?(value)
18
+ raise 'The provided "horizontal_align" is not valid. Try using PadesTextHorizontalAlign constants'
19
+ end
20
+
21
+ @horizontal_align = value
22
+ end
23
+
24
+ def to_model
25
+ {
26
+ 'fontSize': @font_size,
27
+ 'text': @text,
28
+ 'includeSigningTime': @include_signing_time,
29
+ 'signingTimeFormat': @signing_time_format,
30
+ 'container': @container&.to_model,
31
+ 'horizontalAlign': @horizontal_align
32
+ }
33
+ end
34
+ end
35
+ end