@@ -22,6 +22,7 @@ public class BatchPDFSign {
22
22
23
23
private static PrivateKey privateKey ;
24
24
private static Certificate [] certificateChain ;
25
+ private static String defaultTsaUri = "https://freetsa.org/tsr" ;
25
26
26
27
private final String pkcs12FileName ;
27
28
private final String PkcsPassword ;
@@ -61,14 +62,19 @@ public BatchPDFSign(String pkcs12FileName, String PkcsPassword, String pdfInputF
61
62
* @throws GeneralSecurityException Some permissions aren't right.
62
63
*/
63
64
public void signFile (int page , float rx , float ry , float rw , float rh , float fs , String signtext ) throws IOException , GeneralSecurityException {
64
-
65
+ signFile (page , rx , ry , rw , rh , fs , signtext , null );
66
+ }
67
+ public void signFile (int page , float rx , float ry , float rw , float rh , float fs , String signtext , String tsaUri ) throws IOException , GeneralSecurityException {
68
+ if (tsaUri == null ) {
69
+ tsaUri = defaultTsaUri ;
70
+ }
65
71
// Check PDF input file
66
72
if (!inputFile .exists () || inputFile .isDirectory ()) {
67
73
throw new FileNotFoundException ("File: " + this .inputFile + " wasn't found" );
68
74
}
69
75
readPrivateKeyFromPKCS12 (pkcs12FileName , PkcsPassword );
70
76
PdfReader reader = new PdfReader (pdfInputFileName );
71
- ITSAClient tsaClient = new TSAClientBouncyCastle ("https://freetsa.org/tsr" );
77
+ ITSAClient tsaClient = new TSAClientBouncyCastle (tsaUri );
72
78
StampingProperties properties = new StampingProperties ().preserveEncryption ();
73
79
PdfSigner signer = new PdfSigner (reader , new FileOutputStream (pdfOutputFileName ), properties );
74
80
if (page > 0 ) {
@@ -96,8 +102,11 @@ public void signFile(int page, float rx, float ry, float rw, float rh, float fs,
96
102
}
97
103
}
98
104
}
105
+ public void signFile (String tsaUri ) throws IOException , GeneralSecurityException {
106
+ this .signFile (0 , 0 , 0 , 0 , 0 , 10 , "" , tsaUri );
107
+ }
99
108
public void signFile () throws IOException , GeneralSecurityException {
100
- this .signFile (0 , 0 , 0 , 0 , 0 , 10 , "" );
109
+ this .signFile (null );
101
110
}
102
111
103
112
/**
0 commit comments