hexapdf 0.19.2 → 0.20.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +67 -0
  3. data/data/hexapdf/cert/demo_cert.rb +22 -0
  4. data/data/hexapdf/cert/root-ca.crt +119 -0
  5. data/data/hexapdf/cert/signing.crt +125 -0
  6. data/data/hexapdf/cert/signing.key +52 -0
  7. data/data/hexapdf/cert/sub-ca.crt +125 -0
  8. data/data/hexapdf/encoding/glyphlist.txt +4283 -4282
  9. data/data/hexapdf/encoding/zapfdingbats.txt +203 -202
  10. data/lib/hexapdf/cli/info.rb +21 -1
  11. data/lib/hexapdf/configuration.rb +26 -0
  12. data/lib/hexapdf/content/processor.rb +1 -1
  13. data/lib/hexapdf/document/signatures.rb +327 -0
  14. data/lib/hexapdf/document.rb +26 -0
  15. data/lib/hexapdf/font/encoding/glyph_list.rb +5 -6
  16. data/lib/hexapdf/importer.rb +1 -1
  17. data/lib/hexapdf/object.rb +5 -3
  18. data/lib/hexapdf/parser.rb +14 -9
  19. data/lib/hexapdf/rectangle.rb +0 -6
  20. data/lib/hexapdf/revision.rb +13 -6
  21. data/lib/hexapdf/task/dereference.rb +12 -4
  22. data/lib/hexapdf/task/optimize.rb +3 -3
  23. data/lib/hexapdf/type/acro_form/appearance_generator.rb +2 -4
  24. data/lib/hexapdf/type/acro_form/field.rb +2 -0
  25. data/lib/hexapdf/type/acro_form/form.rb +9 -1
  26. data/lib/hexapdf/type/annotation.rb +36 -3
  27. data/lib/hexapdf/type/font_simple.rb +1 -1
  28. data/lib/hexapdf/type/object_stream.rb +3 -1
  29. data/lib/hexapdf/type/signature/adbe_pkcs7_detached.rb +121 -0
  30. data/lib/hexapdf/type/signature/adbe_x509_rsa_sha1.rb +95 -0
  31. data/lib/hexapdf/type/signature/handler.rb +140 -0
  32. data/lib/hexapdf/type/signature/verification_result.rb +92 -0
  33. data/lib/hexapdf/type/signature.rb +236 -0
  34. data/lib/hexapdf/type.rb +1 -0
  35. data/lib/hexapdf/version.rb +1 -1
  36. data/lib/hexapdf/writer.rb +16 -8
  37. data/test/hexapdf/content/test_processor.rb +1 -1
  38. data/test/hexapdf/document/test_signatures.rb +225 -0
  39. data/test/hexapdf/task/test_optimize.rb +4 -1
  40. data/test/hexapdf/test_document.rb +28 -0
  41. data/test/hexapdf/test_object.rb +7 -2
  42. data/test/hexapdf/test_parser.rb +12 -0
  43. data/test/hexapdf/test_rectangle.rb +0 -7
  44. data/test/hexapdf/test_revision.rb +44 -14
  45. data/test/hexapdf/test_writer.rb +4 -3
  46. data/test/hexapdf/type/acro_form/test_field.rb +11 -1
  47. data/test/hexapdf/type/acro_form/test_form.rb +5 -0
  48. data/test/hexapdf/type/signature/common.rb +71 -0
  49. data/test/hexapdf/type/signature/test_adbe_pkcs7_detached.rb +99 -0
  50. data/test/hexapdf/type/signature/test_adbe_x509_rsa_sha1.rb +66 -0
  51. data/test/hexapdf/type/signature/test_handler.rb +102 -0
  52. data/test/hexapdf/type/signature/test_verification_result.rb +47 -0
  53. data/test/hexapdf/type/test_annotation.rb +40 -2
  54. data/test/hexapdf/type/test_font_simple.rb +5 -5
  55. data/test/hexapdf/type/test_object_stream.rb +9 -0
  56. data/test/hexapdf/type/test_signature.rb +131 -0
  57. metadata +21 -3
@@ -12,6 +12,8 @@
12
12
  # implied. See the License for the specific language governing
13
13
  # permissions and limitations under the License.
14
14
  # -----------------------------------------------------------
15
+ # Modified for use with HexaPDF
16
+ # -----------------------------------------------------------
15
17
  # Name: ITC Zapf Dingbats Glyph List
16
18
  # Table version: 2.0
17
19
  # Date: September 20, 2002
@@ -21,205 +23,204 @@
21
23
  # (1) glyph name--upper/lowercase letters and digits
22
24
  # (2) Unicode scalar value--four uppercase hexadecimal digits
23
25
  #
24
- a100;275E
25
- a101;2761
26
- a102;2762
27
- a103;2763
28
- a104;2764
29
- a105;2710
30
- a106;2765
31
- a107;2766
32
- a108;2767
33
- a109;2660
34
- a10;2721
35
- a110;2665
36
- a111;2666
37
- a112;2663
38
- a117;2709
39
- a118;2708
40
- a119;2707
41
- a11;261B
42
- a120;2460
43
- a121;2461
44
- a122;2462
45
- a123;2463
46
- a124;2464
47
- a125;2465
48
- a126;2466
49
- a127;2467
50
- a128;2468
51
- a129;2469
52
- a12;261E
53
- a130;2776
54
- a131;2777
55
- a132;2778
56
- a133;2779
57
- a134;277A
58
- a135;277B
59
- a136;277C
60
- a137;277D
61
- a138;277E
62
- a139;277F
63
- a13;270C
64
- a140;2780
65
- a141;2781
66
- a142;2782
67
- a143;2783
68
- a144;2784
69
- a145;2785
70
- a146;2786
71
- a147;2787
72
- a148;2788
73
- a149;2789
74
- a14;270D
75
- a150;278A
76
- a151;278B
77
- a152;278C
78
- a153;278D
79
- a154;278E
80
- a155;278F
81
- a156;2790
82
- a157;2791
83
- a158;2792
84
- a159;2793
85
- a15;270E
86
- a160;2794
87
- a161;2192
88
- a162;27A3
89
- a163;2194
90
- a164;2195
91
- a165;2799
92
- a166;279B
93
- a167;279C
94
- a168;279D
95
- a169;279E
96
- a16;270F
97
- a170;279F
98
- a171;27A0
99
- a172;27A1
100
- a173;27A2
101
- a174;27A4
102
- a175;27A5
103
- a176;27A6
104
- a177;27A7
105
- a178;27A8
106
- a179;27A9
107
- a17;2711
108
- a180;27AB
109
- a181;27AD
110
- a182;27AF
111
- a183;27B2
112
- a184;27B3
113
- a185;27B5
114
- a186;27B8
115
- a187;27BA
116
- a188;27BB
117
- a189;27BC
118
- a18;2712
119
- a190;27BD
120
- a191;27BE
121
- a192;279A
122
- a193;27AA
123
- a194;27B6
124
- a195;27B9
125
- a196;2798
126
- a197;27B4
127
- a198;27B7
128
- a199;27AC
129
- a19;2713
130
- a1;2701
131
- a200;27AE
132
- a201;27B1
133
- a202;2703
134
- a203;2750
135
- a204;2752
136
- a205;276E
137
- a206;2770
138
- a20;2714
139
- a21;2715
140
- a22;2716
141
- a23;2717
142
- a24;2718
143
- a25;2719
144
- a26;271A
145
- a27;271B
146
- a28;271C
147
- a29;2722
148
- a2;2702
149
- a30;2723
150
- a31;2724
151
- a32;2725
152
- a33;2726
153
- a34;2727
154
- a35;2605
155
- a36;2729
156
- a37;272A
157
- a38;272B
158
- a39;272C
159
- a3;2704
160
- a40;272D
161
- a41;272E
162
- a42;272F
163
- a43;2730
164
- a44;2731
165
- a45;2732
166
- a46;2733
167
- a47;2734
168
- a48;2735
169
- a49;2736
170
- a4;260E
171
- a50;2737
172
- a51;2738
173
- a52;2739
174
- a53;273A
175
- a54;273B
176
- a55;273C
177
- a56;273D
178
- a57;273E
179
- a58;273F
180
- a59;2740
181
- a5;2706
182
- a60;2741
183
- a61;2742
184
- a62;2743
185
- a63;2744
186
- a64;2745
187
- a65;2746
188
- a66;2747
189
- a67;2748
190
- a68;2749
191
- a69;274A
192
- a6;271D
193
- a70;274B
194
- a71;25CF
195
- a72;274D
196
- a73;25A0
197
- a74;274F
198
- a75;2751
199
- a76;25B2
200
- a77;25BC
201
- a78;25C6
202
- a79;2756
203
- a7;271E
204
- a81;25D7
205
- a82;2758
206
- a83;2759
207
- a84;275A
208
- a85;276F
209
- a86;2771
210
- a87;2772
211
- a88;2773
212
- a89;2768
213
- a8;271F
214
- a90;2769
215
- a91;276C
216
- a92;276D
217
- a93;276A
218
- a94;276B
219
- a95;2774
220
- a96;2775
221
- a97;275B
222
- a98;275C
223
- a99;275D
224
- a9;2720
225
- #END
26
+ a100;❞
27
+ a101;❡
28
+ a102;❢
29
+ a103;❣
30
+ a104;❤
31
+ a105;✐
32
+ a106;❥
33
+ a107;❦
34
+ a108;❧
35
+ a109;♠
36
+ a10;✡
37
+ a110;♥
38
+ a111;♦
39
+ a112;♣
40
+ a117;✉
41
+ a118;✈
42
+ a119;✇
43
+ a11;☛
44
+ a120;①
45
+ a121;②
46
+ a122;③
47
+ a123;④
48
+ a124;⑤
49
+ a125;⑥
50
+ a126;⑦
51
+ a127;⑧
52
+ a128;⑨
53
+ a129;⑩
54
+ a12;☞
55
+ a130;❶
56
+ a131;❷
57
+ a132;❸
58
+ a133;❹
59
+ a134;❺
60
+ a135;❻
61
+ a136;❼
62
+ a137;❽
63
+ a138;❾
64
+ a139;❿
65
+ a13;✌
66
+ a140;➀
67
+ a141;➁
68
+ a142;➂
69
+ a143;➃
70
+ a144;➄
71
+ a145;➅
72
+ a146;➆
73
+ a147;➇
74
+ a148;➈
75
+ a149;➉
76
+ a14;✍
77
+ a150;➊
78
+ a151;➋
79
+ a152;➌
80
+ a153;➍
81
+ a154;➎
82
+ a155;➏
83
+ a156;➐
84
+ a157;➑
85
+ a158;➒
86
+ a159;➓
87
+ a15;✎
88
+ a160;➔
89
+ a161;→
90
+ a162;➣
91
+ a163;↔
92
+ a164;↕
93
+ a165;➙
94
+ a166;➛
95
+ a167;➜
96
+ a168;➝
97
+ a169;➞
98
+ a16;✏
99
+ a170;➟
100
+ a171;➠
101
+ a172;➡
102
+ a173;➢
103
+ a174;➤
104
+ a175;➥
105
+ a176;➦
106
+ a177;➧
107
+ a178;➨
108
+ a179;➩
109
+ a17;✑
110
+ a180;➫
111
+ a181;➭
112
+ a182;➯
113
+ a183;➲
114
+ a184;➳
115
+ a185;➵
116
+ a186;➸
117
+ a187;➺
118
+ a188;➻
119
+ a189;➼
120
+ a18;✒
121
+ a190;➽
122
+ a191;➾
123
+ a192;➚
124
+ a193;➪
125
+ a194;➶
126
+ a195;➹
127
+ a196;➘
128
+ a197;➴
129
+ a198;➷
130
+ a199;➬
131
+ a19;✓
132
+ a1;✁
133
+ a200;➮
134
+ a201;➱
135
+ a202;✃
136
+ a203;❐
137
+ a204;❒
138
+ a205;❮
139
+ a206;❰
140
+ a20;✔
141
+ a21;✕
142
+ a22;✖
143
+ a23;✗
144
+ a24;✘
145
+ a25;✙
146
+ a26;✚
147
+ a27;✛
148
+ a28;✜
149
+ a29;✢
150
+ a2;✂
151
+ a30;✣
152
+ a31;✤
153
+ a32;✥
154
+ a33;✦
155
+ a34;✧
156
+ a35;★
157
+ a36;✩
158
+ a37;✪
159
+ a38;✫
160
+ a39;✬
161
+ a3;✄
162
+ a40;✭
163
+ a41;✮
164
+ a42;✯
165
+ a43;✰
166
+ a44;✱
167
+ a45;✲
168
+ a46;✳
169
+ a47;✴
170
+ a48;✵
171
+ a49;✶
172
+ a4;☎
173
+ a50;✷
174
+ a51;✸
175
+ a52;✹
176
+ a53;✺
177
+ a54;✻
178
+ a55;✼
179
+ a56;✽
180
+ a57;✾
181
+ a58;✿
182
+ a59;❀
183
+ a5;✆
184
+ a60;❁
185
+ a61;❂
186
+ a62;❃
187
+ a63;❄
188
+ a64;❅
189
+ a65;❆
190
+ a66;❇
191
+ a67;❈
192
+ a68;❉
193
+ a69;❊
194
+ a6;✝
195
+ a70;❋
196
+ a71;●
197
+ a72;❍
198
+ a73;■
199
+ a74;❏
200
+ a75;❑
201
+ a76;▲
202
+ a77;▼
203
+ a78;◆
204
+ a79;❖
205
+ a7;✞
206
+ a81;◗
207
+ a82;❘
208
+ a83;❙
209
+ a84;❚
210
+ a85;❯
211
+ a86;❱
212
+ a87;❲
213
+ a88;❳
214
+ a89;❨
215
+ a8;✟
216
+ a90;❩
217
+ a91;❬
218
+ a92;❭
219
+ a93;❪
220
+ a94;❫
221
+ a95;❴
222
+ a96;❵
223
+ a97;❛
224
+ a98;❜
225
+ a99;❝
226
+ a9;✠
@@ -130,6 +130,26 @@ module HexaPDF
130
130
  output_line("Encrypted", "yes (no or wrong password given)")
131
131
  end
132
132
 
133
+ signatures = doc.signatures.to_a
134
+ unless signatures.empty?
135
+ nr_sigs = signatures.count
136
+ output_line("Document signed", "yes - #{nr_sigs} signature#{nr_sigs > 1 ? 's' : ''}")
137
+ signatures.each do |signature|
138
+ output_line(" Signer", signature.signer_name)
139
+ output_line(" Signing time", signature.signing_time)
140
+ if (reason = signature.signing_reason)
141
+ output_line(" Reason", reason)
142
+ end
143
+ if (location = signature.signing_location)
144
+ output_line(" Location", location)
145
+ end
146
+ output_line(" Signature type", signature.signature_type)
147
+ signature.verify(allow_self_signed: true).messages.sort.each do |msg|
148
+ output_line(" #{msg.type.capitalize}", msg.content)
149
+ end
150
+ end
151
+ end
152
+
133
153
  output_line("Pages", doc.pages.count.to_s)
134
154
  output_line("Version", doc.version)
135
155
  end
@@ -162,7 +182,7 @@ module HexaPDF
162
182
  end
163
183
 
164
184
  def output_line(header, text) #:nodoc:
165
- puts(("#{header}:").ljust(COLUMN_WIDTH) << text)
185
+ puts(("#{header}:").ljust(COLUMN_WIDTH) << text.to_s)
166
186
  end
167
187
 
168
188
  end
@@ -373,6 +373,20 @@ module HexaPDF
373
373
  #
374
374
  # See HexaPDF::Layout::Style::Layers for more information.
375
375
  #
376
+ # signature.signing_handler::
377
+ # A mapping from a Symbol to a signing handler class (see
378
+ # HexaPDF::Document::Signatures::DefaultHandler). If the value is a String, it should contain
379
+ # the name of a constant to such a class.
380
+ #
381
+ # signature.sub_filter_map::
382
+ # A mapping from a PDF name (a Symbol) to a signature handler class (see
383
+ # HexaPDF::Type::Signature::Handler). If the value is a String, it should contain the name of a
384
+ # constant to such a class.
385
+ #
386
+ # The sub filter map is used for mapping specific signature algorithms to handler classes. The
387
+ # filter value of a signature dictionary is ignored since we only support the standard
388
+ # signature algorithms.
389
+ #
376
390
  # task.map::
377
391
  # A mapping from task names to callable task objects. See HexaPDF::Task for more information.
378
392
  DefaultDocumentConfiguration =
@@ -451,6 +465,14 @@ module HexaPDF
451
465
  'style.layers_map' => {
452
466
  link: 'HexaPDF::Layout::Style::LinkLayer',
453
467
  },
468
+ 'signature.signing_handler' => {
469
+ default: 'HexaPDF::Document::Signatures::DefaultHandler',
470
+ },
471
+ 'signature.sub_filter_map' => {
472
+ 'adbe.x509.rsa_sha1': 'HexaPDF::Type::Signature::AdbeX509RsaSha1',
473
+ 'adbe.pkcs7.detached': 'HexaPDF::Type::Signature::AdbePkcs7Detached',
474
+ 'ETSI.CAdES.detached': 'HexaPDF::Type::Signature::AdbePkcs7Detached',
475
+ },
454
476
  'task.map' => {
455
477
  optimize: 'HexaPDF::Task::Optimize',
456
478
  dereference: 'HexaPDF::Task::Dereference',
@@ -539,6 +561,10 @@ module HexaPDF
539
561
  SigFieldLock: 'HexaPDF::Type::AcroForm::SignatureField::LockDictionary',
540
562
  SV: 'HexaPDF::Type::AcroForm::SignatureField::SeedValueDictionary',
541
563
  SVCert: 'HexaPDF::Type::AcroForm::SignatureField::CertificateSeedValueDictionary',
564
+ Sig: 'HexaPDF::Type::Signature',
565
+ DocTimeStamp: 'HexaPDF::Type::Signature',
566
+ SigRef: 'HexaPDF::Type::Signature::SignatureReference',
567
+ TransformParams: 'HexaPDF::Type::Signature::TransformParams',
542
568
  },
543
569
  'object.subtype_map' => {
544
570
  nil => {
@@ -455,7 +455,7 @@ module HexaPDF
455
455
  # Decodes the given array containing text and positioning information while assuming that the
456
456
  # writing direction is vertical.
457
457
  def decode_vertical_text(_data)
458
- raise NotImplementedError
458
+ raise "Not yet implemented"
459
459
  end
460
460
 
461
461
  end