DocAssuranceObjectParser.java
52.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.aemfd.docmanager.Document
* com.adobe.fd.docassurance.client.api.DocAssuranceServiceOperationTypes
* com.adobe.fd.docassurance.client.api.EncryptionOptions
* com.adobe.fd.docassurance.client.api.ReaderExtensionOptions
* com.adobe.fd.docassurance.client.api.SignatureOptions
* com.adobe.fd.encryption.client.CertificateEncryptionCompatibility
* com.adobe.fd.encryption.client.CertificateEncryptionIdentity
* com.adobe.fd.encryption.client.CertificateEncryptionOption
* com.adobe.fd.encryption.client.CertificateEncryptionOptionSpec
* com.adobe.fd.encryption.client.CertificateEncryptionPermissions
* com.adobe.fd.encryption.client.PasswordEncryptionCompatability
* com.adobe.fd.encryption.client.PasswordEncryptionOption
* com.adobe.fd.encryption.client.PasswordEncryptionOptionSpec
* com.adobe.fd.encryption.client.PasswordEncryptionPermission
* com.adobe.fd.encryption.client.Recipient
* com.adobe.fd.readerextensions.client.ReaderExtensionsOptionSpec
* com.adobe.fd.readerextensions.client.UsageRights
* com.adobe.fd.signatures.CredentialProviderService
* com.adobe.fd.signatures.client.types.MDPPermissions
* com.adobe.fd.signatures.client.types.SigningFormat
* com.adobe.fd.signatures.client.types.VerificationTime
* com.adobe.fd.signatures.client.types.exceptions.CredentialNotFoundException
* com.adobe.fd.signatures.client.types.exceptions.InvalidArgumentException
* com.adobe.fd.signatures.pdf.inputs.CredentialContext
* com.adobe.fd.signatures.pdf.inputs.DSSPreferences
* com.adobe.fd.signatures.pdf.inputs.DSSPreferencesImpl
* com.adobe.fd.signatures.pdf.inputs.JavascriptPreferences
* com.adobe.fd.signatures.pdf.inputs.PDFSignatureAppearenceOptions
* com.adobe.fd.signatures.pdf.inputs.PDFSignatureAppearenceOptions$PDFSignatureAppearanceType
* com.adobe.fd.signatures.pdf.inputs.PDFSignatureAppearenceOptions$TextDirection
* com.adobe.fd.signatures.pdf.inputs.UnlockOptions
* com.adobe.fd.signatures.pdf.inputs.ValidationPreferences
* com.adobe.fd.signatures.pdf.inputs.ValidationPreferencesImpl
* com.adobe.fd.signatures.pki.client.spi.PKICredential
* com.adobe.fd.signatures.pki.client.types.common.HashAlgorithm
* com.adobe.fd.signatures.pki.client.types.common.OCSPURLtoConsultOption
* com.adobe.fd.signatures.pki.client.types.common.RevocationCheckOrder
* com.adobe.fd.signatures.pki.client.types.common.RevocationCheckStyle
* com.adobe.fd.signatures.pki.client.types.prefs.CRLPreferences
* com.adobe.fd.signatures.pki.client.types.prefs.CRLPreferencesImpl
* com.adobe.fd.signatures.pki.client.types.prefs.GeneralPreferences
* com.adobe.fd.signatures.pki.client.types.prefs.GeneralPreferencesImpl
* com.adobe.fd.signatures.pki.client.types.prefs.OCSPPreferences
* com.adobe.fd.signatures.pki.client.types.prefs.OCSPPreferencesImpl
* com.adobe.fd.signatures.pki.client.types.prefs.PKIPreferences
* com.adobe.fd.signatures.pki.client.types.prefs.PKIPreferencesImpl
* com.adobe.fd.signatures.pki.client.types.prefs.PathValidationPreferences
* com.adobe.fd.signatures.pki.client.types.prefs.PathValidationPreferencesImpl
* com.adobe.fd.signatures.pki.client.types.prefs.TSPPreferences
* com.adobe.fd.signatures.pki.client.types.prefs.TSPPreferencesImpl
* com.adobe.fd.signatures.pki.client.types.prefs.TransportPreferences
* com.adobe.fd.signatures.pki.client.types.prefs.TransportPreferencesImpl
* com.adobe.granite.workflow.WorkflowException
* com.adobe.granite.workflow.WorkflowSession
* com.adobe.granite.workflow.exec.WorkItem
* com.adobe.granite.workflow.metadata.MetaDataMap
* org.apache.sling.api.resource.ResourceResolver
* org.apache.sling.commons.json.JSONArray
* org.apache.sling.commons.json.JSONException
* org.apache.sling.commons.json.JSONObject
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.fd.workflow.docassurance.intrernal.utils;
import com.adobe.aemfd.docmanager.Document;
import com.adobe.fd.docassurance.client.api.DocAssuranceServiceOperationTypes;
import com.adobe.fd.docassurance.client.api.EncryptionOptions;
import com.adobe.fd.docassurance.client.api.ReaderExtensionOptions;
import com.adobe.fd.docassurance.client.api.SignatureOptions;
import com.adobe.fd.encryption.client.CertificateEncryptionCompatibility;
import com.adobe.fd.encryption.client.CertificateEncryptionIdentity;
import com.adobe.fd.encryption.client.CertificateEncryptionOption;
import com.adobe.fd.encryption.client.CertificateEncryptionOptionSpec;
import com.adobe.fd.encryption.client.CertificateEncryptionPermissions;
import com.adobe.fd.encryption.client.PasswordEncryptionCompatability;
import com.adobe.fd.encryption.client.PasswordEncryptionOption;
import com.adobe.fd.encryption.client.PasswordEncryptionOptionSpec;
import com.adobe.fd.encryption.client.PasswordEncryptionPermission;
import com.adobe.fd.encryption.client.Recipient;
import com.adobe.fd.readerextensions.client.ReaderExtensionsOptionSpec;
import com.adobe.fd.readerextensions.client.UsageRights;
import com.adobe.fd.signatures.CredentialProviderService;
import com.adobe.fd.signatures.client.types.MDPPermissions;
import com.adobe.fd.signatures.client.types.SigningFormat;
import com.adobe.fd.signatures.client.types.VerificationTime;
import com.adobe.fd.signatures.client.types.exceptions.CredentialNotFoundException;
import com.adobe.fd.signatures.client.types.exceptions.InvalidArgumentException;
import com.adobe.fd.signatures.pdf.inputs.CredentialContext;
import com.adobe.fd.signatures.pdf.inputs.DSSPreferences;
import com.adobe.fd.signatures.pdf.inputs.DSSPreferencesImpl;
import com.adobe.fd.signatures.pdf.inputs.JavascriptPreferences;
import com.adobe.fd.signatures.pdf.inputs.PDFSignatureAppearenceOptions;
import com.adobe.fd.signatures.pdf.inputs.UnlockOptions;
import com.adobe.fd.signatures.pdf.inputs.ValidationPreferences;
import com.adobe.fd.signatures.pdf.inputs.ValidationPreferencesImpl;
import com.adobe.fd.signatures.pki.client.spi.PKICredential;
import com.adobe.fd.signatures.pki.client.types.common.HashAlgorithm;
import com.adobe.fd.signatures.pki.client.types.common.OCSPURLtoConsultOption;
import com.adobe.fd.signatures.pki.client.types.common.RevocationCheckOrder;
import com.adobe.fd.signatures.pki.client.types.common.RevocationCheckStyle;
import com.adobe.fd.signatures.pki.client.types.prefs.CRLPreferences;
import com.adobe.fd.signatures.pki.client.types.prefs.CRLPreferencesImpl;
import com.adobe.fd.signatures.pki.client.types.prefs.GeneralPreferences;
import com.adobe.fd.signatures.pki.client.types.prefs.GeneralPreferencesImpl;
import com.adobe.fd.signatures.pki.client.types.prefs.OCSPPreferences;
import com.adobe.fd.signatures.pki.client.types.prefs.OCSPPreferencesImpl;
import com.adobe.fd.signatures.pki.client.types.prefs.PKIPreferences;
import com.adobe.fd.signatures.pki.client.types.prefs.PKIPreferencesImpl;
import com.adobe.fd.signatures.pki.client.types.prefs.PathValidationPreferences;
import com.adobe.fd.signatures.pki.client.types.prefs.PathValidationPreferencesImpl;
import com.adobe.fd.signatures.pki.client.types.prefs.TSPPreferences;
import com.adobe.fd.signatures.pki.client.types.prefs.TSPPreferencesImpl;
import com.adobe.fd.signatures.pki.client.types.prefs.TransportPreferences;
import com.adobe.fd.signatures.pki.client.types.prefs.TransportPreferencesImpl;
import com.adobe.fd.workflow.docassurance.SecureDocumentService;
import com.adobe.fd.workflow.utils.DocumentUtils;
import com.adobe.granite.workflow.WorkflowException;
import com.adobe.granite.workflow.WorkflowSession;
import com.adobe.granite.workflow.exec.WorkItem;
import com.adobe.granite.workflow.metadata.MetaDataMap;
import java.util.ArrayList;
import java.util.List;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.commons.json.JSONArray;
import org.apache.sling.commons.json.JSONException;
import org.apache.sling.commons.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class DocAssuranceObjectParser {
private static final Logger log = LoggerFactory.getLogger(SecureDocumentService.class);
private static final String INPUTPATH = "inputpath";
private static final String OUTPUTPATH = "output";
private static final String UNLOCK_OPEN_PASS = "Unlock_OPEN_PASS";
private static final String UNLOCK_ALIAS = "Unlock_ALIAS";
private static final String ENCRYPTION_REQUIRED = "encryptionRequired";
private static final String ENCR_TYPE = "ENCR_TYPE";
private static final String ENCR_RESOURCES = "ENCR_RESOURCES";
private static final String PASS_COMPAT = "PASS_COMPAT";
private static final String OPEN_PASS = "OPEN_PASS";
private static final String PERM_PASS = "PERM_PASS";
private static final String PASS_PERMS = "PASS_PERMS";
private static final String CERT_COMPAT = "CERT_COMPAT";
private static final String CREDENTIAL_IDENTITIES = "credentialIdentity";
private static final String RE_REQUIRED = "reRequired";
private static final String RE_ALIAS = "RE_ALIAS";
private static final String RE_MESSAGE = "RE_MESSAGE";
private static final String ENABLED_FORM_FILLIN = "enabledFormFillIn";
private static final String ENABLED_FORM_DATA_IMORT_EXPORT = "enabledFormDataImportExport";
private static final String ENABLED_SUBMIT_STANDALONE = "enabledSubmitStandalone";
private static final String ENABLED_ONLINE_FORMS = "enabledOnlineForms";
private static final String ENABLED_DNAMIC_FORM_FIELDS = "enabledDynamicFormFields";
private static final String ENABLED_DYNAMIC_FORMPAGES = "enabledDynamicFormPages";
private static final String ENABLED_BARCODE_DECODING = "enabledBarcodeDecoding";
private static final String ENABLED_DIGITALSIGNATURES = "enabledDigitalSignatures";
private static final String ENABLED_COMMENTS = "enabledComments";
private static final String ENABLED_COMMENTS_ONLINE = "enabledCommentsOnline";
private static final String ENABLED_EMBEDDED_FILES = "enabledEmbeddedFiles";
private static final String SIGN_REQUIRED = "signRequired";
private static final String OPERATION_TYPE = "operationType";
private static final String SIGNATURE_FIELDNAME = "signatureFieldName";
private static final String SIGNATURE_ALIAS = "signatureAlias";
private static final String SIGNATURE_IS_HSMCREDENTIAL = "isHSMCredentialSign";
private static final String SIGNATURE_HASHALGO = "signatureHASHALGO";
private static final String SIGNATURE_REASON = "signatureReason";
private static final String SIGNATURE_LOCATION = "signatureLocation";
private static final String SIGNATURE_CONTACTINFO = "signatureContactInfo";
private static final String SIGNATURE_LEGALATTESTATION = "signatureLegalAttestation";
private static final String SIGNATURE_APPEARANCETYPE = "signatureAppearanceType";
private static final String SIGNATURE_LOGOPDF = "signatureLogoPDF";
private static final String SIGNATURE_LOGOOPACITY = "signatureLogoOpacity";
private static final String SIGNATURE_GRAPHICPDF = "signatureGraphicPDF";
private static final String SIGNATURE_SHOWNAME = "signatureShowName";
private static final String SIGNATURE_SHOWLOCATION = "signatureShowLocation";
private static final String SIGNATURE_SHOWREASON = "signatureShowReason";
private static final String SIGNATURE_SHOWDATE = "signatureShowDate";
private static final String SIGNATURE_SHOWLABELS = "signatureShowLabels";
private static final String SIGNATURE_SHOWDEFAULTLOGO = "signatureShowDefaultLogo";
private static final String SIGNATURE_SHOWDN = "signatureShowDN";
private static final String SIGNATURE_TEXTDIRECTION = "signatureTextDirection";
private static final String SIGNATURE_SIGNING_FORMAT = "signatureSigningFormat";
private static final String CERTIFY_FIELDNAME = "certifyFieldName";
private static final String CERTIFY_ALIAS = "certifyAlias";
private static final String CERTIFY_IS_HSMCREDENTIAL = "isHSMCredentialCertify";
private static final String CERTIFY_HASHALGO = "certifyHASHALGO";
private static final String CERTIFY_REASON = "certifyReason";
private static final String CERTIFY_LOCATION = "certifyLocation";
private static final String CERTIFY_CONTACTINFO = "certifyContactInfo";
private static final String CERTIFY_LEGALATTESTATION = "certifyLegalAttestation";
private static final String CERTIFY_LOCKCERTIFYINGFIELD = "certifyLockCertifyingField";
private static final String CERTIFY_MDP = "certifyMDP";
private static final String CERTIFY_APPEARANCETYPE = "certifyAppearanceType";
private static final String CERTIFY_LOGOPDF = "certifyLogoPDF";
private static final String CERTIFY_LOGOOPACITY = "certifyLogoOpacity";
private static final String CERTIFY_GRAPHICPDF = "certifyGraphicPDF";
private static final String CERTIFY_SHOWNAME = "certifyShowName";
private static final String CERTIFY_SHOWLOCATION = "certifyShowLocation";
private static final String CERTIFY_SHOWREASON = "certifyShowReason";
private static final String CERTIFY_SHOWDATE = "certifyShowDate";
private static final String CERTIFY_SHOWLABELS = "certifyShowLabels";
private static final String CERTIFY_SHOWDEFAULTLOGO = "certifyShowDefaultLogo";
private static final String CERTIFY_SHOWDN = "certifyShowDN";
private static final String CERTIFY_TEXTDIRECTION = "certifyTextDirection";
private static final String CERTIFY_SIGNING_FORMAT = "certifySigningFormat";
private static final String CREATEFORMDOM = "createFormDOM";
private static final String USEARCHIVEDREVOCATIONINFO = "useArchivedRevocationInfo";
private static final String ENABLEDOCUMENTJAVASCRIPTS = "enableDocumentJavascripts";
private static final String ENFORCEREVOCATIONEMBEDDING = "enforceRevocationEmbedding";
private static final String EMBEDDEDREVOCATOIN = "embeddedRevocation";
private static final String USEVRI = "useVRI";
private static final String SUPPORTPRERELEASESIGNATURES = "supportPreReleaseSignatures";
private static final String MAXCLOCKSKEW = "maxClockSkew";
private static final String MAXREVINFOARCHIVESIZE = "maxRevInfoArchiveSize";
private static final String MEMORYTHRESHHOLD = "memoryThreshhold";
private static final String INSTRUCTIONCOUNT = "instructionCount";
private static final String SCRIPTTIMEOUTINTERVAL = "scriptTimeOutInterval";
private static final String MAXSESSIONS = "maxSessions";
private static final String CERTCACHELIFETIME = "certCacheLifetime";
private static final String DISABLEALLCACHES = "disableAllCaches";
private static final String REVCHECKORDER = "revCheckOrder";
private static final String ALWAYSCONSULTLOCALURL = "alwaysConsultLocalURL";
private static final String LOCALURI = "localURI";
private static final String USECACHE = "useCache";
private static final String LDAPSERVER = "ldapServer";
private static final String GOONLINE = "goOnline";
private static final String IGNOREVALIDITYDATES = "ignoreValidityDates";
private static final String REQUIREAKI = "requireAKI";
private static final String VALIDITYWIN = "validityWin";
private static final String CRLREVOKATIONCHECKSTYLE = "CRLRevokationCheckStyle";
private static final String OCSPSERVERURL = "ocspServerURL";
private static final String OCSPDIGESTALGO = "ocspDigestAlgo";
private static final String OCSPSENDNONCE = "ocspSendNonce";
private static final String OCSPMAXCLOCKSKEW = "ocspmaxClockSkew";
private static final String RESPONSEFRESHNESS = "responseFreshness";
private static final String URLTOCONSULT = "URLtoConsult";
private static final String DOSIGNREQUEST = "doSignRequest";
private static final String OCSPUSECACHE = "ocspUseCache";
private static final String OCSPIGNOREVALIDITYDATES = "ocspIgnoreValidityDates";
private static final String OCSPGOONLINE = "ocspGoOnline";
private static final String ALLOWOCSPNOCHECK = "allowOCSPNoCheck";
private static final String REQUIREOCSPCERTHASH = "requireOCSPCertHash";
private static final String OCSPREVOKATIONCHECKSTYLE = "OCSPRevokationCheckStyle";
private static final String OCSPALIAS = "ocspAlias";
private static final String TSPSERVERURL = "tspServerURL";
private static final String TSPSENdNonce = "tspSendNonce";
private static final String TSPDIGESTALGO = "tspDigestAlgo";
private static final String TSPSERVERUSERNAME = "tspServerUsername";
private static final String TSPSERVERPASSWORD = "tspServerPassword";
private static final String TSPSIZE = "tspSize";
private static final String USEEXPIREDTIMESTAMPS = "useExpiredTimestamps";
private static final String TSPREVOKATIONCHECKSTYLE = "TSPRevokationCheckStyle";
private static final String ANYPOLICYINHIBIT = "anyPolicyInhibit";
private static final String EXPLICITPOLICY = "explicitPolicy";
private static final String POLICYMAPPINGINHIBIT = "policyMappingInhibit";
private static final String CHECKALLPATHS = "checkAllPaths";
private static final String PVLDAPSERVER = "pvLDAPServer";
private static final String FOLLOWAIAURIS = "followAIAURIs";
private static final String CHECKCABASICCONSTRAINTS = "checkCABasicConstraints";
private static final String REQUIREVALIDSIGFORCHAINING = "requireValidSigForChaining";
private static final String PVDOVALIDATION = "PVdoValidation";
private static final String PROXYHOST = "proxyHost";
private static final String PROXYPORT = "proxyPort";
private static final String PROXYUSERNAME = "proxyUsername";
private static final String PROXYPASSWORD = "proxyPassword";
private static final String MAXDOWNLOADLIMIT = "maxDownloadLimit";
private static final String CONNECTIONTIMEOUT = "connectionTimeout";
private static final String SOCKETTIMEOUT = "socketTimeout";
private static final String DISABLETRANSPORT = "disableTransport";
private static final String SSLREVCHECK = "sslRevCheck";
private static final String VERIFICATION_TIME = "Verification_Time";
public static EncryptionOptions getEncryptionOptions(MetaDataMap args, ResourceResolver resourceResolver) throws JSONException {
if (!DocAssuranceObjectParser.isEncryptionRequired(args)) {
return null;
}
EncryptionOptions encryptionOptions = EncryptionOptions.getInstance();
if (DocAssuranceObjectParser.getEncryptionType(args).equals((Object)DocAssuranceServiceOperationTypes.ENCRYPT_WITH_PASSWORD)) {
encryptionOptions.setEncryptionType(DocAssuranceServiceOperationTypes.ENCRYPT_WITH_PASSWORD);
PasswordEncryptionOptionSpec passwordEncryptionOptionSpec = new PasswordEncryptionOptionSpec();
passwordEncryptionOptionSpec.setEncryptOption(DocAssuranceObjectParser.getPasswordEncryptionOption(args));
passwordEncryptionOptionSpec.setCompatability(DocAssuranceObjectParser.getPasswordEncryptionCompatability(args));
passwordEncryptionOptionSpec.setPermissionsRequested(DocAssuranceObjectParser.getPassEncryptionPermissions(args));
passwordEncryptionOptionSpec.setDocumentOpenPassword((String)args.get("OPEN_PASS", String.class));
passwordEncryptionOptionSpec.setPermissionPassword((String)args.get("PERM_PASS", String.class));
encryptionOptions.setPasswordEncryptionOptionSpec(passwordEncryptionOptionSpec);
} else {
encryptionOptions.setEncryptionType(DocAssuranceServiceOperationTypes.ENCRYPT_WITH_CERTIFCATE);
CertificateEncryptionOptionSpec ceos = new CertificateEncryptionOptionSpec();
ceos.setCompat(DocAssuranceObjectParser.getPKIEncryptionCompatability(args));
ceos.setOption(DocAssuranceObjectParser.getPKIEncryptionOption(args));
encryptionOptions.setCertOptionSpec(ceos);
encryptionOptions.setPkiIdentities(DocAssuranceObjectParser.getCertEncrIdList(args));
encryptionOptions.setResourceResolver(resourceResolver);
}
return encryptionOptions;
}
public static boolean isEncryptionRequired(MetaDataMap args) {
boolean result = false;
Object isRequired = args.get((Object)"encryptionRequired");
log.debug("ENCRYPTION_REQUIRED " + isRequired);
if (isRequired != null) {
result = true;
}
return result;
}
public static boolean isRERequired(MetaDataMap args) {
boolean result = false;
Object isRequired = args.get((Object)"reRequired");
log.debug("RE_REQUIRED " + isRequired);
if (isRequired != null) {
result = true;
}
return result;
}
public static boolean isSignatureRequired(MetaDataMap args) {
boolean result = false;
Object isRequired = args.get((Object)"signRequired");
log.debug("SIGN_REQUIRED " + isRequired);
if (isRequired != null) {
result = true;
}
return result;
}
public static DocAssuranceServiceOperationTypes getSignatureOperation(MetaDataMap args) {
DocAssuranceServiceOperationTypes result = null;
Object operationType = args.get("operationType", String.class);
log.debug("OPERATION_TYPE " + operationType);
if (operationType != null) {
if (operationType.toString().equalsIgnoreCase(DocAssuranceServiceOperationTypes.SIGN.toString())) {
result = DocAssuranceServiceOperationTypes.SIGN;
} else if (operationType.toString().equalsIgnoreCase(DocAssuranceServiceOperationTypes.CERTIFY.toString())) {
result = DocAssuranceServiceOperationTypes.CERTIFY;
}
}
return result;
}
public static DocAssuranceServiceOperationTypes getEncryptionType(MetaDataMap args) {
DocAssuranceServiceOperationTypes result = null;
Object encryptionType = args.get("ENCR_TYPE", String.class);
log.debug("ENCR_TYPE " + encryptionType);
if (encryptionType != null) {
return DocAssuranceServiceOperationTypes.valueOf((String)encryptionType.toString());
}
return result;
}
public static VerificationTime getVerificationTimeType(MetaDataMap args) {
VerificationTime result = null;
Object verificationTypeValue = args.get("Verification_Time", String.class);
log.debug("Verification Time Value " + verificationTypeValue);
if (verificationTypeValue != null) {
return VerificationTime.getValueFromString((String)verificationTypeValue.toString());
}
return result;
}
private static PasswordEncryptionOption getPasswordEncryptionOption(MetaDataMap args) {
Object resourceType = args.get("ENCR_RESOURCES", String.class);
log.debug("ENCR_RESOURCES " + resourceType);
if (resourceType != null) {
return PasswordEncryptionOption.valueOf((String)resourceType.toString());
}
return null;
}
private static CertificateEncryptionOption getPKIEncryptionOption(MetaDataMap args) {
Object resourceType = args.get("ENCR_RESOURCES", String.class);
log.debug("ENCR_RESOURCES " + resourceType);
if (resourceType != null) {
return CertificateEncryptionOption.valueOf((String)resourceType.toString());
}
return null;
}
private static PasswordEncryptionCompatability getPasswordEncryptionCompatability(MetaDataMap args) {
Object resourceType = args.get("PASS_COMPAT", String.class);
log.debug("PASS_COMPAT PASS_COMPAT");
if (resourceType != null) {
return PasswordEncryptionCompatability.valueOf((String)resourceType.toString());
}
return null;
}
private static CertificateEncryptionCompatibility getPKIEncryptionCompatability(MetaDataMap args) {
Object resourceType = args.get("CERT_COMPAT", String.class);
log.debug("CERT_COMPAT " + resourceType);
if (resourceType != null) {
return CertificateEncryptionCompatibility.valueOf((String)resourceType.toString());
}
return null;
}
private static List<PasswordEncryptionPermission> getPassEncryptionPermissions(MetaDataMap args) {
String[] perms = (String[])args.get("PASS_PERMS", String[].class);
log.debug("PASS_PERMS " + perms);
if (perms == null || perms.length == 0) {
return null;
}
ArrayList<PasswordEncryptionPermission> encrypPermissions = new ArrayList<PasswordEncryptionPermission>();
for (String perm : perms) {
encrypPermissions.add(PasswordEncryptionPermission.valueOf((String)perm));
}
return encrypPermissions;
}
private static List<CertificateEncryptionIdentity> getCertEncrIdList(MetaDataMap args) throws JSONException {
ArrayList<CertificateEncryptionIdentity> certEncrIdList = new ArrayList<CertificateEncryptionIdentity>();
String[] identities = (String[])args.get("credentialIdentity", String[].class);
log.debug("CREDENTIAL_IDENTITIES " + identities);
if (identities == null || identities.length == 0) {
return null;
}
for (String identity : identities) {
CertificateEncryptionIdentity certificateEncryptionIdentity = new CertificateEncryptionIdentity();
Recipient recipient = new Recipient();
ArrayList<CertificateEncryptionPermissions> certPerms = new ArrayList<CertificateEncryptionPermissions>();
JSONObject obj = new JSONObject(identity);
JSONArray perms = (JSONArray)obj.get("PKI_Encr_Perms");
int permsLength = perms.length();
for (int i = 0; i < permsLength; ++i) {
certPerms.add(CertificateEncryptionPermissions.valueOf((String)((String)perms.get(i))));
}
certificateEncryptionIdentity.setPerms(certPerms);
Object alias = obj.get("Certificate_Alias");
recipient.setAlias(alias.toString());
certificateEncryptionIdentity.setRecipient(recipient);
certEncrIdList.add(certificateEncryptionIdentity);
}
return certEncrIdList;
}
public static UnlockOptions getUnlockOptions(MetaDataMap args, ResourceResolver rr) {
UnlockOptions unlockOptions = new UnlockOptions();
unlockOptions.setPassword((String)args.get("Unlock_OPEN_PASS", String.class));
unlockOptions.setAlias((String)args.get("Unlock_ALIAS", String.class));
unlockOptions.setResourceResolver(rr);
return unlockOptions;
}
public static ReaderExtensionOptions getREOptions(MetaDataMap args, ResourceResolver rr) {
if (!DocAssuranceObjectParser.isRERequired(args)) {
return null;
}
ReaderExtensionOptions reOptions = ReaderExtensionOptions.getInstance();
UsageRights uRights = new UsageRights();
if (args.get((Object)"enabledBarcodeDecoding") != null) {
uRights.setEnabledBarcodeDecoding(true);
}
if (args.get((Object)"enabledComments") != null) {
uRights.setEnabledComments(true);
}
if (args.get((Object)"enabledCommentsOnline") != null) {
uRights.setEnabledCommentsOnline(true);
}
if (args.get((Object)"enabledDigitalSignatures") != null) {
uRights.setEnabledDigitalSignatures(true);
}
if (args.get((Object)"enabledDynamicFormPages") != null) {
uRights.setEnabledDynamicFormPages(true);
}
if (args.get((Object)"enabledDynamicFormFields") != null) {
uRights.setEnabledDynamicFormFields(true);
}
if (args.get((Object)"enabledEmbeddedFiles") != null) {
uRights.setEnabledEmbeddedFiles(true);
}
if (args.get((Object)"enabledFormFillIn") != null) {
uRights.setEnabledFormFillIn(true);
}
if (args.get((Object)"enabledFormDataImportExport") != null) {
uRights.setEnabledFormDataImportExport(true);
}
if (args.get((Object)"enabledOnlineForms") != null) {
uRights.setEnabledOnlineForms(true);
}
if (args.get((Object)"enabledSubmitStandalone") != null) {
uRights.setEnabledSubmitStandalone(true);
}
log.debug("USAGE_RIGHTS " + (Object)uRights);
reOptions.setReOptions(new ReaderExtensionsOptionSpec(uRights, (String)args.get("RE_MESSAGE", String.class)));
reOptions.setCredentialAlias((String)args.get("RE_ALIAS", String.class));
log.debug("RE_ALIAS " + (String)args.get("RE_ALIAS", String.class));
reOptions.setResourceResolver(rr);
return reOptions;
}
public static SignatureOptions getSignatureOptions(MetaDataMap args, ResourceResolver resourceResolver, WorkItem item) throws InvalidArgumentException, CredentialNotFoundException, WorkflowException {
if (!DocAssuranceObjectParser.isSignatureRequired(args)) {
return null;
}
SignatureOptions signatureOptions = SignatureOptions.getInstance();
DocAssuranceServiceOperationTypes operationTypes = DocAssuranceObjectParser.getSignatureOperation(args);
signatureOptions.setOperationType(operationTypes);
signatureOptions.setDssPref(DocAssuranceObjectParser.getDSSPreferences(args, resourceResolver));
if (operationTypes.equals((Object)DocAssuranceServiceOperationTypes.SIGN)) {
signatureOptions.setAlgo(HashAlgorithm.valueOf((String)((String)args.get("signatureHASHALGO", String.class))));
signatureOptions.setContactInfo((String)args.get("signatureContactInfo", String.class));
signatureOptions.setLegalAttestation((String)args.get("signatureLegalAttestation", String.class));
signatureOptions.setLocation((String)args.get("signatureLocation", String.class));
signatureOptions.setReason((String)args.get("signatureReason", String.class));
signatureOptions.setSignatureFieldName((String)args.get("signatureFieldName", String.class));
boolean isHSMCredential = Boolean.parseBoolean((String)args.get("isHSMCredentialSign", String.class));
CredentialContext credentialContext = new CredentialContext((String)args.get("signatureAlias", String.class), resourceResolver, isHSMCredential);
signatureOptions.setCredential(credentialContext);
signatureOptions.setSigAppearence(DocAssuranceObjectParser.getSignatureAppearenceOptions(args, true, item));
} else {
signatureOptions.setAlgo(HashAlgorithm.valueOf((String)((String)args.get("certifyHASHALGO", String.class))));
signatureOptions.setContactInfo((String)args.get("certifyContactInfo", String.class));
signatureOptions.setLegalAttestation((String)args.get("certifyLegalAttestation", String.class));
signatureOptions.setLocation((String)args.get("certifyLocation", String.class));
signatureOptions.setReason((String)args.get("certifyReason", String.class));
signatureOptions.setSignatureFieldName((String)args.get("certifyFieldName", String.class));
signatureOptions.setLockCertifyingField(Boolean.parseBoolean((String)args.get("certifyLockCertifyingField", String.class)));
signatureOptions.setMdpPermissions(MDPPermissions.valueOf((String)((String)args.get("certifyMDP", String.class))));
boolean isHSMCredential = Boolean.parseBoolean((String)args.get("isHSMCredentialCertify", String.class));
CredentialContext credentialContext = new CredentialContext((String)args.get("certifyAlias", String.class), resourceResolver, isHSMCredential);
signatureOptions.setCredential(credentialContext);
signatureOptions.setSigAppearence(DocAssuranceObjectParser.getSignatureAppearenceOptions(args, false, item));
}
return signatureOptions;
}
private static PDFSignatureAppearenceOptions getSignatureAppearenceOptions(MetaDataMap args, boolean forSign, WorkItem item) throws WorkflowException {
PDFSignatureAppearenceOptions sigAppearence = null;
if (forSign) {
PDFSignatureAppearenceOptions.PDFSignatureAppearanceType appType = null;
String appearance = (String)args.get("signatureAppearanceType", String.class);
if (appearance.equals("NOGRAPHIC")) {
appType = PDFSignatureAppearenceOptions.PDFSignatureAppearanceType.NOGRAPHIC;
} else if (appearance.equals("GRAPHIC")) {
appType = PDFSignatureAppearenceOptions.PDFSignatureAppearanceType.GRAPHIC;
} else if (appearance.equals("NAME")) {
appType = PDFSignatureAppearenceOptions.PDFSignatureAppearanceType.NAME;
}
Document logoPdf = DocumentUtils.getInputDocument(item, "signatureLogoPDF");
Document graphicPDF = DocumentUtils.getInputDocument(item, "signatureGraphicPDF");
double logoOpacity = Double.parseDouble((String)args.get("signatureLogoOpacity", String.class));
boolean showName = Boolean.parseBoolean((String)args.get("signatureShowName", String.class));
boolean showLocation = Boolean.parseBoolean((String)args.get("signatureShowLocation", String.class));
boolean showReason = Boolean.parseBoolean((String)args.get("signatureShowReason", String.class));
boolean showDate = Boolean.parseBoolean((String)args.get("signatureShowDate", String.class));
boolean showLabels = Boolean.parseBoolean((String)args.get("signatureShowLabels", String.class));
boolean showLogo = Boolean.parseBoolean((String)args.get("signatureShowDefaultLogo", String.class));
boolean showDN = Boolean.parseBoolean((String)args.get("signatureShowDN", String.class));
PDFSignatureAppearenceOptions.TextDirection textDirection = null;
String direction = (String)args.get("signatureTextDirection", String.class);
if (direction.equals("AUTO")) {
textDirection = PDFSignatureAppearenceOptions.TextDirection.AUTO;
} else if (appearance.equals("LEFT")) {
textDirection = PDFSignatureAppearenceOptions.TextDirection.LEFT;
} else if (appearance.equals("RIGHT")) {
textDirection = PDFSignatureAppearenceOptions.TextDirection.RIGHT;
}
SigningFormat signingFormat = SigningFormat.PKCS7Detached;
String format = (String)args.get("signatureSigningFormat", String.class);
if ("PKCS7Detached".equals(format)) {
signingFormat = SigningFormat.PKCS7Detached;
} else if ("CAdES".equals(format)) {
signingFormat = SigningFormat.CAdES;
}
sigAppearence = new PDFSignatureAppearenceOptions(appType, logoPdf, logoOpacity, graphicPDF, showName, showLocation, showDN, showReason, showDate, showLabels, showLogo, textDirection);
sigAppearence.setSigningFormat(signingFormat);
} else {
PDFSignatureAppearenceOptions.PDFSignatureAppearanceType appType = null;
String appearance = (String)args.get("certifyAppearanceType", String.class);
if (appearance.equals("NOGRAPHIC")) {
appType = PDFSignatureAppearenceOptions.PDFSignatureAppearanceType.NOGRAPHIC;
} else if (appearance.equals("GRAPHIC")) {
appType = PDFSignatureAppearenceOptions.PDFSignatureAppearanceType.GRAPHIC;
} else if (appearance.equals("NAME")) {
appType = PDFSignatureAppearenceOptions.PDFSignatureAppearanceType.NAME;
}
Document logoPdf = DocumentUtils.getInputDocument(item, "certifyLogoPDF");
Document graphicPDF = DocumentUtils.getInputDocument(item, "certifyGraphicPDF");
double logoOpacity = Double.parseDouble((String)args.get("certifyLogoOpacity", String.class));
boolean showName = Boolean.parseBoolean((String)args.get("certifyShowName", String.class));
boolean showLocation = Boolean.parseBoolean((String)args.get("certifyShowLocation", String.class));
boolean showReason = Boolean.parseBoolean((String)args.get("certifyShowReason", String.class));
boolean showDate = Boolean.parseBoolean((String)args.get("certifyShowDate", String.class));
boolean showLabels = Boolean.parseBoolean((String)args.get("certifyShowLabels", String.class));
boolean showLogo = Boolean.parseBoolean((String)args.get("certifyShowDefaultLogo", String.class));
boolean showDN = Boolean.parseBoolean((String)args.get("certifyShowDN", String.class));
PDFSignatureAppearenceOptions.TextDirection textDirection = null;
String direction = (String)args.get("certifyTextDirection", String.class);
if (direction.equals("AUTO")) {
textDirection = PDFSignatureAppearenceOptions.TextDirection.AUTO;
} else if (appearance.equals("LEFT")) {
textDirection = PDFSignatureAppearenceOptions.TextDirection.LEFT;
} else if (appearance.equals("RIGHT")) {
textDirection = PDFSignatureAppearenceOptions.TextDirection.RIGHT;
}
SigningFormat signingFormat = null;
String format = (String)args.get("certifySigningFormat", String.class);
if ("PKCS7Detached".equals(format)) {
signingFormat = SigningFormat.PKCS7Detached;
} else if ("CAdES".equals(format)) {
signingFormat = SigningFormat.CAdES;
}
sigAppearence = new PDFSignatureAppearenceOptions(appType, logoPdf, logoOpacity, graphicPDF, showName, showLocation, showDN, showReason, showDate, showLabels, showLogo, textDirection);
sigAppearence.setSigningFormat(signingFormat);
}
return sigAppearence;
}
private static DSSPreferences getDSSPreferences(MetaDataMap args, ResourceResolver resourceResolver) throws WorkflowException {
DSSPreferencesImpl dssPreferences = new DSSPreferencesImpl();
dssPreferences.setJSPreferences(DocAssuranceObjectParser.getJSPreferences(args));
dssPreferences.setPKIPreferences(DocAssuranceObjectParser.getPKIPreferences(args, resourceResolver));
try {
dssPreferences.setCreateFormDOM(Boolean.parseBoolean((String)args.get("createFormDOM", String.class)));
dssPreferences.setEnableDocumentJavascripts(Boolean.parseBoolean((String)args.get("enableDocumentJavascripts", String.class)));
dssPreferences.setEnforceRevocationEmbedding(Boolean.parseBoolean((String)args.get("enforceRevocationEmbedding", String.class)));
dssPreferences.setSupportPreReleaseSignatures(Boolean.parseBoolean((String)args.get("supportPreReleaseSignatures", String.class)));
dssPreferences.setUseArchivedRevocationInfo(Boolean.parseBoolean((String)args.get("useArchivedRevocationInfo", String.class)));
dssPreferences.setUseVRI(Boolean.parseBoolean((String)args.get("useVRI", String.class)));
dssPreferences.setVerificationTimeClockSkew(Long.parseLong((String)args.get("maxClockSkew", String.class)));
dssPreferences.setMaxRevInfoArchiveSize(Integer.parseInt((String)args.get("maxRevInfoArchiveSize", String.class)));
dssPreferences.setEmbeddedRevocation(Boolean.parseBoolean((String)args.get("embeddedRevocation", String.class)));
return dssPreferences;
}
catch (Exception e) {
log.debug("Exception in creating DSSPreferences", (Throwable)e);
throw new WorkflowException("Exception in creating DSSPreferences", (Throwable)e);
}
}
private static JavascriptPreferences getJSPreferences(MetaDataMap args) throws WorkflowException {
try {
JavascriptPreferences javascriptPreferences = new JavascriptPreferences();
javascriptPreferences.setInstructionCount(Integer.parseInt((String)args.get("instructionCount", String.class)));
javascriptPreferences.setMemoryThreshhold(Double.parseDouble((String)args.get("memoryThreshhold", String.class)));
javascriptPreferences.setScriptTimeOutInterval(Integer.parseInt((String)args.get("scriptTimeOutInterval", String.class)));
return javascriptPreferences;
}
catch (Exception e) {
log.debug("Exception in creating JavascriptPreferences", (Throwable)e);
throw new WorkflowException("Exception in creating JavascriptPreferences", (Throwable)e);
}
}
private static PKIPreferences getPKIPreferences(MetaDataMap args, ResourceResolver resourceResolver) throws WorkflowException {
PKIPreferencesImpl pkiPreferences = new PKIPreferencesImpl();
pkiPreferences.setGeneralPreferences(DocAssuranceObjectParser.getGeneralPreferences(args));
pkiPreferences.setCRLPreferences(DocAssuranceObjectParser.getCRLPreferences(args));
pkiPreferences.setOCSPPreferences(DocAssuranceObjectParser.getOCSPPreferences(args, resourceResolver));
pkiPreferences.setTSPPreferences(DocAssuranceObjectParser.getTSPPreferences(args));
pkiPreferences.setPathPreferences(DocAssuranceObjectParser.getPathValidationPrefs(args));
pkiPreferences.setTransportPreferences(DocAssuranceObjectParser.getTransPortPreferences(args));
return pkiPreferences;
}
private static GeneralPreferences getGeneralPreferences(MetaDataMap args) throws WorkflowException {
try {
GeneralPreferencesImpl generalPreferences = new GeneralPreferencesImpl();
generalPreferences.setDisableCache(Boolean.parseBoolean((String)args.get("disableAllCaches", String.class)));
generalPreferences.setCertCacheLifetime(Long.valueOf((String)args.get("certCacheLifetime", String.class)).longValue());
generalPreferences.setMaxSessions(Integer.valueOf((String)args.get("maxSessions", String.class)).intValue());
generalPreferences.setRevCheckOrder(RevocationCheckOrder.valueOf((String)((String)args.get("revCheckOrder", String.class))));
return generalPreferences;
}
catch (Exception e) {
log.debug("Exception in creating GeneralPreferences", (Throwable)e);
throw new WorkflowException("Exception in creating GeneralPreferences", (Throwable)e);
}
}
private static CRLPreferences getCRLPreferences(MetaDataMap args) throws WorkflowException {
try {
CRLPreferencesImpl crlPreferences = new CRLPreferencesImpl();
crlPreferences.setAlwaysConsultLocalURL(Boolean.parseBoolean((String)args.get("alwaysConsultLocalURL", String.class)));
crlPreferences.setGoOnline(Boolean.parseBoolean((String)args.get("goOnline", String.class)));
crlPreferences.setIgnoreValidityDates(Boolean.parseBoolean((String)args.get("ignoreValidityDates", String.class)));
crlPreferences.setRequireAKI(Boolean.parseBoolean((String)args.get("requireAKI", String.class)));
crlPreferences.setUseCache(Boolean.parseBoolean((String)args.get("useCache", String.class)));
crlPreferences.setLocalURI((String)args.get("localURI", String.class));
crlPreferences.setLDAPServer((String)args.get("ldapServer", String.class));
crlPreferences.setValidityWindow(Long.parseLong((String)args.get("validityWin", String.class)));
crlPreferences.setRevocationCheck(RevocationCheckStyle.valueOf((String)((String)args.get("CRLRevokationCheckStyle", String.class))));
return crlPreferences;
}
catch (Exception e) {
log.debug("Exception in creating CRLPreferences", (Throwable)e);
throw new WorkflowException("Exception in creating CRLPreferences", (Throwable)e);
}
}
private static OCSPPreferences getOCSPPreferences(MetaDataMap args, ResourceResolver resourceResolver) throws WorkflowException {
try {
String alias;
OCSPPreferencesImpl ocspPreferences = new OCSPPreferencesImpl();
ocspPreferences.setAllowOCSPNoCheck(Boolean.parseBoolean((String)args.get("allowOCSPNoCheck", String.class)));
ocspPreferences.setDigestAlgorithm(HashAlgorithm.valueOf((String)((String)args.get("ocspDigestAlgo", String.class))));
ocspPreferences.setDoSignRequest(Boolean.parseBoolean((String)args.get("doSignRequest", String.class)));
ocspPreferences.setGoOnline(Boolean.parseBoolean((String)args.get("ocspGoOnline", String.class)));
ocspPreferences.setIgnoreValidityDates(Boolean.parseBoolean((String)args.get("ocspIgnoreValidityDates", String.class)));
ocspPreferences.setMaxClockSkew(Long.parseLong((String)args.get("ocspmaxClockSkew", String.class)));
ocspPreferences.setOcspServerURL((String)args.get("ocspServerURL", String.class));
ocspPreferences.setRequireOCSPCertHash(Boolean.parseBoolean((String)args.get("requireOCSPCertHash", String.class)));
ocspPreferences.setResponseFreshness(Long.parseLong((String)args.get("responseFreshness", String.class)));
ocspPreferences.setRevocationCheck(RevocationCheckStyle.valueOf((String)((String)args.get("OCSPRevokationCheckStyle", String.class))));
ocspPreferences.setSendNonce(Boolean.parseBoolean((String)args.get("ocspSendNonce", String.class)));
ocspPreferences.setUseCache(Boolean.parseBoolean((String)args.get("ocspUseCache", String.class)));
ocspPreferences.setURLtoConsult(OCSPURLtoConsultOption.valueOf((String)((String)args.get("URLtoConsult", String.class))));
if (Boolean.parseBoolean((String)args.get("doSignRequest", String.class)) && (alias = (String)args.get("ocspAlias", String.class)) != null) {
PKICredential cred = CredentialProviderService.getInstance().getCredential(alias, resourceResolver);
ocspPreferences.setRequestSignerCredential(cred);
}
return ocspPreferences;
}
catch (Exception e) {
log.debug("Exception in creating OCSPPreferences", (Throwable)e);
throw new WorkflowException("Exception in creating OCSPPreferences", (Throwable)e);
}
}
private static TSPPreferences getTSPPreferences(MetaDataMap args) throws WorkflowException {
try {
TSPPreferencesImpl tspPreferences = new TSPPreferencesImpl();
String pass = (String)args.get("tspServerPassword", String.class);
if (pass != null) {
tspPreferences.setPassword(pass.toCharArray());
}
tspPreferences.setRevocationCheck(RevocationCheckStyle.valueOf((String)((String)args.get("TSPRevokationCheckStyle", String.class))));
tspPreferences.setSendNonce(Boolean.parseBoolean((String)args.get("tspSendNonce", String.class)));
tspPreferences.setSize(Integer.valueOf((String)args.get("tspSize", String.class)).intValue());
tspPreferences.setTSPHashAlgorithm(HashAlgorithm.valueOf((String)((String)args.get("tspDigestAlgo", String.class))));
tspPreferences.setTspServerURL((String)args.get("tspServerURL", String.class));
tspPreferences.setUseExpiredTimestamps(Boolean.parseBoolean((String)args.get("useExpiredTimestamps", String.class)));
tspPreferences.setUsername((String)args.get("tspServerUsername", String.class));
return tspPreferences;
}
catch (Exception e) {
log.debug("Exception in creating TSPPreferences", (Throwable)e);
throw new WorkflowException("Exception in creating TSPPreferences", (Throwable)e);
}
}
private static PathValidationPreferences getPathValidationPrefs(MetaDataMap args) throws WorkflowException {
try {
PathValidationPreferencesImpl pathValidationPreferences = new PathValidationPreferencesImpl();
pathValidationPreferences.setAnyPolicyInhibit(Boolean.parseBoolean((String)args.get("anyPolicyInhibit", String.class)));
pathValidationPreferences.setCheckAllPaths(Boolean.parseBoolean((String)args.get("checkAllPaths", String.class)));
pathValidationPreferences.setCheckCABasicConstraints(Boolean.parseBoolean((String)args.get("checkCABasicConstraints", String.class)));
pathValidationPreferences.setDoValidation(Boolean.parseBoolean((String)args.get("PVdoValidation", String.class)));
pathValidationPreferences.setExplicitPolicy(Boolean.parseBoolean((String)args.get("explicitPolicy", String.class)));
pathValidationPreferences.setFollowAIAURIs(Boolean.parseBoolean((String)args.get("followAIAURIs", String.class)));
pathValidationPreferences.setPolicyMappingInhibit(Boolean.parseBoolean((String)args.get("policyMappingInhibit", String.class)));
pathValidationPreferences.setRequireValidSigForChaining(Boolean.parseBoolean((String)args.get("requireValidSigForChaining", String.class)));
pathValidationPreferences.setLDAPServer((String)args.get("pvLDAPServer", String.class));
return pathValidationPreferences;
}
catch (Exception e) {
log.debug("Exception in creating PathValidationPreferences", (Throwable)e);
throw new WorkflowException("Exception in creating PathValidationPreferences", (Throwable)e);
}
}
private static TransportPreferences getTransPortPreferences(MetaDataMap args) throws WorkflowException {
try {
TransportPreferencesImpl transportPreferences = new TransportPreferencesImpl();
transportPreferences.setConnectionTimeout(Integer.valueOf((String)args.get("connectionTimeout", String.class)).intValue());
transportPreferences.setMaxDownloadLimit(Integer.valueOf((String)args.get("maxDownloadLimit", String.class)).intValue());
transportPreferences.setProxyPort(Integer.valueOf((String)args.get("proxyPort", String.class)).intValue());
transportPreferences.setTransportDisabled(Boolean.parseBoolean((String)args.get("disableTransport", String.class)));
transportPreferences.setSSLRevCheckStyle(RevocationCheckStyle.valueOf((String)((String)args.get("sslRevCheck", String.class))));
transportPreferences.setSocketTimeout(Integer.valueOf((String)args.get("socketTimeout", String.class)).intValue());
transportPreferences.setProxyHost((String)args.get("proxyHost", String.class));
transportPreferences.setProxyPassword((String)args.get("proxyPassword", String.class));
transportPreferences.setProxyUsername((String)args.get("proxyUsername", String.class));
return transportPreferences;
}
catch (Exception e) {
log.debug("Exception in creating TransportPreferences", (Throwable)e);
throw new WorkflowException("Exception in creating TransportPreferences", (Throwable)e);
}
}
public static ValidationPreferences getValidationPreferences(MetaDataMap args, ResourceResolver resourceResolver) throws WorkflowException {
DSSPreferences dssPreference = DocAssuranceObjectParser.getDSSPreferences(args, resourceResolver);
ValidationPreferencesImpl validationPreferences = new ValidationPreferencesImpl();
validationPreferences.setJSPreferences(DocAssuranceObjectParser.getJSPreferences(args));
validationPreferences.setPKIPreferences(dssPreference.getPKIPreferences());
try {
validationPreferences.setCreateFormDOM(dssPreference.getCreateFormDom());
validationPreferences.setEnableDocumentJavascripts(dssPreference.getEnableDocumentJavascripts());
validationPreferences.setEnforceRevocationEmbedding(dssPreference.getEnforceRevocationEmbedding());
validationPreferences.setSupportPreReleaseSignatures(dssPreference.getSupportPreReleaseSignatures());
validationPreferences.setUseArchivedRevocationInfo(dssPreference.getUseArchivedRevocationInfo());
validationPreferences.setUseVRI(dssPreference.getUseVRI());
validationPreferences.setVerificationTimeClockSkew(dssPreference.getVerificationTimeClockSkew());
validationPreferences.setMaxRevInfoArchiveSize(dssPreference.getMaxRevInfoArchiveSize());
return validationPreferences;
}
catch (Exception e) {
log.debug("Exception in creating ValidationPreferences", (Throwable)e);
throw new WorkflowException("Exception in creating ValidationPreferences", (Throwable)e);
}
}
public static Document getInputDoc(WorkItem workItem, MetaDataMap args) throws WorkflowException {
return DocumentUtils.getInputDocument(workItem, "inputpath");
}
public static void saveDoc(WorkItem workItem, WorkflowSession workflowSession, Document outDoc) throws Exception {
DocumentUtils.saveOutputDocument(workItem, workflowSession, "output", outDoc);
}
}