@@ -217,7 +217,22 @@ public PadesTwoPhaseSigningHelper setStampingProperties(StampingProperties stamp
217
217
this .stampingProperties = stampingProperties ;
218
218
return this ;
219
219
}
220
-
220
+
221
+ /**
222
+ * Creates CMS container compliant with PAdES level. Prepares document and placeholder for the future signature
223
+ * without actual signing process.
224
+ *
225
+ * @param certificates certificates to be added to the CMS container
226
+ * @param digestAlgorithm the algorithm to generate the digest with
227
+ * @param inputDocument reader {@link PdfReader} instance to read original PDF file
228
+ * @param outputStream {@link OutputStream} output stream to write the resulting PDF file into
229
+ * @param signerProperties properties to be used in the signing operations
230
+ *
231
+ * @return prepared CMS container without signature.
232
+ *
233
+ * @throws IOException if an I/O error occurs.
234
+ * @throws GeneralSecurityException if some problem with signature or security occur.
235
+ */
221
236
public CMSContainer createCMSContainerWithoutSignature (Certificate [] certificates , String digestAlgorithm ,
222
237
PdfReader inputDocument , OutputStream outputStream , SignerProperties signerProperties )
223
238
throws IOException , GeneralSecurityException {
@@ -248,6 +263,17 @@ public CMSContainer createCMSContainerWithoutSignature(Certificate[] certificate
248
263
return cms ;
249
264
}
250
265
266
+ /**
267
+ * Follow-up step that signs prepared document with PAdES Baseline-B profile.
268
+ *
269
+ * @param externalSignature external signature to do the actual signing
270
+ * @param inputDocument reader {@link PdfReader} instance to read prepared document
271
+ * @param outputStream the output PDF
272
+ * @param signatureFieldName the field to sign
273
+ * @param cmsContainer the finalized CMS container (e.g. created in the first step)
274
+ *
275
+ * @throws Exception if some exception occur.
276
+ */
251
277
public void signCMSContainerWithBaselineBProfile (IExternalSignature externalSignature , PdfReader inputDocument ,
252
278
OutputStream outputStream , String signatureFieldName , CMSContainer cmsContainer ) throws Exception {
253
279
setSignatureAlgorithmAndSignature (externalSignature , cmsContainer );
@@ -258,7 +284,18 @@ public void signCMSContainerWithBaselineBProfile(IExternalSignature externalSign
258
284
outputStream .close ();
259
285
}
260
286
}
261
-
287
+
288
+ /**
289
+ * Follow-up step that signs prepared document with PAdES Baseline-T profile.
290
+ *
291
+ * @param externalSignature external signature to do the actual signing
292
+ * @param inputDocument reader {@link PdfReader} instance to read prepared document
293
+ * @param outputStream the output PDF
294
+ * @param signatureFieldName the field to sign
295
+ * @param cmsContainer the finalized CMS container (e.g. created in the first step)
296
+ *
297
+ * @throws Exception if some exception occur.
298
+ */
262
299
public void signCMSContainerWithBaselineTProfile (IExternalSignature externalSignature , PdfReader inputDocument ,
263
300
OutputStream outputStream , String signatureFieldName , CMSContainer cmsContainer ) throws Exception {
264
301
byte [] signature = setSignatureAlgorithmAndSignature (externalSignature , cmsContainer );
@@ -281,7 +318,18 @@ public void signCMSContainerWithBaselineTProfile(IExternalSignature externalSign
281
318
outputStream .close ();
282
319
}
283
320
}
284
-
321
+
322
+ /**
323
+ * Follow-up step that signs prepared document with PAdES Baseline-LT profile.
324
+ *
325
+ * @param externalSignature external signature to do the actual signing
326
+ * @param inputDocument reader {@link PdfReader} instance to read prepared document
327
+ * @param outputStream the output PDF
328
+ * @param signatureFieldName the field to sign
329
+ * @param cmsContainer the finalized CMS container (e.g. created in the first step)
330
+ *
331
+ * @throws Exception if some exception occur.
332
+ */
285
333
public void signCMSContainerWithBaselineLTProfile (IExternalSignature externalSignature , PdfReader inputDocument ,
286
334
OutputStream outputStream , String signatureFieldName , CMSContainer cmsContainer ) throws Exception {
287
335
PdfPadesSigner padesSigner = createPadesSigner (inputDocument , outputStream );
@@ -301,6 +349,17 @@ public void signCMSContainerWithBaselineLTProfile(IExternalSignature externalSig
301
349
}
302
350
}
303
351
352
+ /**
353
+ * Follow-up step that signs prepared document with PAdES Baseline-LTA profile.
354
+ *
355
+ * @param externalSignature external signature to do the actual signing
356
+ * @param inputDocument reader {@link PdfReader} instance to read prepared document
357
+ * @param outputStream the output PDF
358
+ * @param signatureFieldName the field to sign
359
+ * @param cmsContainer the finalized CMS container (e.g. created in the first step)
360
+ *
361
+ * @throws Exception if some exception occur.
362
+ */
304
363
public void signCMSContainerWithBaselineLTAProfile (IExternalSignature externalSignature , PdfReader inputDocument ,
305
364
OutputStream outputStream , String signatureFieldName , CMSContainer cmsContainer ) throws Exception {
306
365
PdfPadesSigner padesSigner = createPadesSigner (inputDocument , outputStream );
0 commit comments