pki_express 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/.gitattributes +2 -2
  3. data/.github/workflows/test.yml +21 -21
  4. data/.gitignore +27 -27
  5. data/CHANGELOG.md +19 -16
  6. data/Gemfile +8 -7
  7. data/README.md +24 -24
  8. data/Rakefile +6 -6
  9. data/lib/pki_express/auth_complete_result.rb +21 -21
  10. data/lib/pki_express/auth_start_result.rb +76 -76
  11. data/lib/pki_express/authentication.rb +284 -284
  12. data/lib/pki_express/base_signer.rb +54 -54
  13. data/lib/pki_express/cades_signature.rb +89 -89
  14. data/lib/pki_express/cades_signature_starter.rb +242 -242
  15. data/lib/pki_express/check_service_result.rb +15 -15
  16. data/lib/pki_express/command_error.rb +13 -13
  17. data/lib/pki_express/commands.rb +24 -24
  18. data/lib/pki_express/digest_algorithm.rb +118 -118
  19. data/lib/pki_express/digest_algorithm_and_value.rb +30 -30
  20. data/lib/pki_express/discovery_service_result.rb +25 -25
  21. data/lib/pki_express/enum.rb +9 -9
  22. data/lib/pki_express/error_codes.rb +46 -46
  23. data/lib/pki_express/installation_not_found_error.rb +8 -8
  24. data/lib/pki_express/name.rb +47 -47
  25. data/lib/pki_express/oids.rb +30 -30
  26. data/lib/pki_express/pades_certification_level.rb +7 -7
  27. data/lib/pki_express/pades_horizontal_align.rb +9 -9
  28. data/lib/pki_express/pades_measurement_units.rb +8 -8
  29. data/lib/pki_express/pades_page_optimization.rb +50 -50
  30. data/lib/pki_express/pades_page_orientation.rb +9 -9
  31. data/lib/pki_express/pades_paper_size.rb +21 -21
  32. data/lib/pki_express/pades_signature.rb +16 -16
  33. data/lib/pki_express/pades_signature_explorer.rb +30 -30
  34. data/lib/pki_express/pades_signature_starter.rb +251 -251
  35. data/lib/pki_express/pades_signer.rb +274 -274
  36. data/lib/pki_express/pades_signer_info.rb +9 -9
  37. data/lib/pki_express/pades_size.rb +17 -17
  38. data/lib/pki_express/pades_text_horizontal_align.rb +8 -8
  39. data/lib/pki_express/pades_vertical_align.rb +9 -9
  40. data/lib/pki_express/pades_visual_auto_positioning.rb +21 -21
  41. data/lib/pki_express/pades_visual_image.rb +51 -51
  42. data/lib/pki_express/pades_visual_manual_positioning.rb +16 -16
  43. data/lib/pki_express/pades_visual_positioning.rb +27 -27
  44. data/lib/pki_express/pades_visual_rectangle.rb +74 -74
  45. data/lib/pki_express/pades_visual_representation.rb +22 -22
  46. data/lib/pki_express/pades_visual_text.rb +35 -35
  47. data/lib/pki_express/pk_algorithms.rb +157 -157
  48. data/lib/pki_express/pk_certificate.rb +61 -61
  49. data/lib/pki_express/pki_brazil_certificate_fields.rb +57 -57
  50. data/lib/pki_express/pki_brazil_certificate_types.rb +19 -19
  51. data/lib/pki_express/pki_express_config.rb +39 -26
  52. data/lib/pki_express/pki_express_operator.rb +240 -240
  53. data/lib/pki_express/pki_italy_certificate_fields.rb +15 -15
  54. data/lib/pki_express/pki_italy_certificate_types.rb +11 -11
  55. data/lib/pki_express/signature_algorithm_and_value.rb +34 -34
  56. data/lib/pki_express/signature_explorer.rb +74 -74
  57. data/lib/pki_express/signature_finisher.rb +314 -314
  58. data/lib/pki_express/signature_policy_identifier.rb +20 -20
  59. data/lib/pki_express/signature_start_result.rb +12 -12
  60. data/lib/pki_express/signature_starter.rb +116 -116
  61. data/lib/pki_express/signer.rb +151 -151
  62. data/lib/pki_express/standard_signature_policies.rb +58 -58
  63. data/lib/pki_express/timestamp_authority.rb +50 -50
  64. data/lib/pki_express/trust_service_auth_parameters.rb +20 -20
  65. data/lib/pki_express/trust_service_info.rb +37 -37
  66. data/lib/pki_express/trust_service_manager.rb +258 -258
  67. data/lib/pki_express/trust_service_session_result.rb +29 -29
  68. data/lib/pki_express/trust_service_session_types.rb +7 -7
  69. data/lib/pki_express/tsa_authentication_type.rb +14 -14
  70. data/lib/pki_express/validation_error.rb +8 -8
  71. data/lib/pki_express/validation_item.rb +43 -43
  72. data/lib/pki_express/validation_item_types.rb +103 -103
  73. data/lib/pki_express/validation_results.rb +120 -120
  74. data/lib/pki_express/version.rb +3 -3
  75. data/lib/pki_express/version_manager.rb +20 -20
  76. data/lib/pki_express.rb +69 -69
  77. data/pki_express.gemspec +26 -26
  78. data/spec/pki_express/pki_express_config_spec.rb +73 -0
  79. data/spec/pki_express/pki_express_operator_spec.rb +30 -30
  80. metadata +4 -2
@@ -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