Skip to content

Commit 916acd9

Browse files
committed
Add javadocs for the PadesTwoPhaseSigningHelper
DEVSIX-7807
1 parent 244cfd2 commit 916acd9

File tree

3 files changed

+64
-5
lines changed

3 files changed

+64
-5
lines changed

sign/src/main/java/com/itextpdf/signatures/PadesTwoPhaseSigningHelper.java

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,22 @@ public PadesTwoPhaseSigningHelper setStampingProperties(StampingProperties stamp
217217
this.stampingProperties = stampingProperties;
218218
return this;
219219
}
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+
*/
221236
public CMSContainer createCMSContainerWithoutSignature(Certificate[] certificates, String digestAlgorithm,
222237
PdfReader inputDocument, OutputStream outputStream, SignerProperties signerProperties)
223238
throws IOException, GeneralSecurityException {
@@ -248,6 +263,17 @@ public CMSContainer createCMSContainerWithoutSignature(Certificate[] certificate
248263
return cms;
249264
}
250265

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+
*/
251277
public void signCMSContainerWithBaselineBProfile(IExternalSignature externalSignature, PdfReader inputDocument,
252278
OutputStream outputStream, String signatureFieldName, CMSContainer cmsContainer) throws Exception {
253279
setSignatureAlgorithmAndSignature(externalSignature, cmsContainer);
@@ -258,7 +284,18 @@ public void signCMSContainerWithBaselineBProfile(IExternalSignature externalSign
258284
outputStream.close();
259285
}
260286
}
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+
*/
262299
public void signCMSContainerWithBaselineTProfile(IExternalSignature externalSignature, PdfReader inputDocument,
263300
OutputStream outputStream, String signatureFieldName, CMSContainer cmsContainer) throws Exception {
264301
byte[] signature = setSignatureAlgorithmAndSignature(externalSignature, cmsContainer);
@@ -281,7 +318,18 @@ public void signCMSContainerWithBaselineTProfile(IExternalSignature externalSign
281318
outputStream.close();
282319
}
283320
}
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+
*/
285333
public void signCMSContainerWithBaselineLTProfile(IExternalSignature externalSignature, PdfReader inputDocument,
286334
OutputStream outputStream, String signatureFieldName, CMSContainer cmsContainer) throws Exception {
287335
PdfPadesSigner padesSigner = createPadesSigner(inputDocument, outputStream);
@@ -301,6 +349,17 @@ public void signCMSContainerWithBaselineLTProfile(IExternalSignature externalSig
301349
}
302350
}
303351

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+
*/
304363
public void signCMSContainerWithBaselineLTAProfile(IExternalSignature externalSignature, PdfReader inputDocument,
305364
OutputStream outputStream, String signatureFieldName, CMSContainer cmsContainer) throws Exception {
306365
PdfPadesSigner padesSigner = createPadesSigner(inputDocument, outputStream);

sign/src/main/java/com/itextpdf/signatures/cms/CMSContainer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ public void addCertificates(X509Certificate[] certs) {
250250
/**
251251
* Retrieves a copy of the list of certificates.
252252
*
253-
* @return the list of certificates to be used for signing and certificate validation
253+
* @return the list of certificates to be used for signing and certificate validation
254254
*/
255255
public Collection<X509Certificate> getCertificates() {
256256
return Collections.unmodifiableCollection(certificates);

sign/src/main/java/com/itextpdf/signatures/exceptions/SignExceptionMessageConstant.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public final class SignExceptionMessageConstant {
8686
public static final String THIS_TSA_FAILED_TO_RETURN_TIME_STAMP_TOKEN = "TSA {0} failed to return time stamp "
8787
+ "token: {1}.";
8888
public static final String TOO_BIG_KEY = "The key is too big.";
89-
public static final String TSA_CLIENT_IS_MISSING = "ITSAClient must be present to rich this PAdES level. "
89+
public static final String TSA_CLIENT_IS_MISSING = "ITSAClient must be present to reach this PAdES level. "
9090
+ "Please use setTSAClient method to provide it.";
9191
public static final String UNEXPECTED_CLOSE_BRACKET = "Unexpected close bracket.";
9292
public static final String UNEXPECTED_GT_GT = "unexpected >>.";

0 commit comments

Comments
 (0)