Skip to content

Commit ad761fc

Browse files
author
Eugene Bochilo
committed
Add PDF MAC support for BCFips mode
DEVSIX-8620
1 parent 84ae14f commit ad761fc

File tree

4 files changed

+100
-13
lines changed

4 files changed

+100
-13
lines changed

bouncy-castle-fips-adapter/src/main/java/com/itextpdf/bouncycastlefips/BouncyCastleFipsFactory.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,12 @@ This file is part of the iText (R) project.
323323
import org.bouncycastle.cms.jcajce.JceKeyAgreeEnvelopedRecipient;
324324
import org.bouncycastle.cms.jcajce.JceKeyTransEnvelopedRecipient;
325325
import org.bouncycastle.crypto.CryptoServicesRegistrar;
326+
import org.bouncycastle.crypto.KDFCalculator;
327+
import org.bouncycastle.crypto.fips.FipsKDF;
328+
import org.bouncycastle.crypto.fips.FipsKDF.AgreementKDFPRF;
329+
import org.bouncycastle.crypto.fips.FipsKDF.AgreementKDFParameters;
330+
import org.bouncycastle.crypto.fips.FipsKDF.AgreementOperatorFactory;
331+
import org.bouncycastle.crypto.fips.FipsKDF.HKDFKeyBuilder;
326332
import org.bouncycastle.crypto.fips.FipsUnapprovedOperationError;
327333
import org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider;
328334
import org.bouncycastle.openssl.PEMParser;
@@ -1873,7 +1879,14 @@ public void isEncryptionFeatureSupported(int encryptionType, boolean withCertifi
18731879
*/
18741880
@Override
18751881
public byte[] generateHKDF(byte[] inputKey, byte[] salt, byte[] info) {
1876-
throw new UnsupportedOperationException("HKDF algorithm is not supported in bouncy-castle FIPS mode.");
1882+
HKDFKeyBuilder hkdfKeyBuilder = FipsKDF.HKDF_KEY_BUILDER.withSalt(salt).withPrf(AgreementKDFPRF.SHA256_HMAC);
1883+
byte[] extractedKey = hkdfKeyBuilder.build(inputKey).getKey();
1884+
AgreementOperatorFactory factory = new AgreementOperatorFactory();
1885+
KDFCalculator<AgreementKDFParameters> kdfCalculator = factory.createKDFCalculator(FipsKDF.HKDF.withPRF(
1886+
AgreementKDFPRF.SHA256_HMAC).using(extractedKey).withIV(info));
1887+
byte[] hkdf = new byte[32];
1888+
kdfCalculator.generateBytes(hkdf);
1889+
return hkdf;
18771890
}
18781891

18791892
/**

kernel/src/test/java/com/itextpdf/kernel/mac/MacIntegrityProtectorCreationTest.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ This file is part of the iText (R) project.
3131
import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant;
3232
import com.itextpdf.kernel.exceptions.PdfException;
3333
import com.itextpdf.kernel.geom.Rectangle;
34+
import com.itextpdf.kernel.logs.KernelLogMessageConstant;
3435
import com.itextpdf.kernel.pdf.EncryptionConstants;
3536
import com.itextpdf.kernel.pdf.PdfDocument;
3637
import com.itextpdf.kernel.pdf.PdfVersion;
3738
import com.itextpdf.kernel.pdf.PdfWriter;
38-
import com.itextpdf.kernel.pdf.VersionConforming;
3939
import com.itextpdf.kernel.pdf.WriterProperties;
4040
import com.itextpdf.kernel.mac.MacProperties.KeyWrappingAlgorithm;
4141
import com.itextpdf.kernel.mac.MacProperties.MacAlgorithm;
@@ -70,7 +70,6 @@ public class MacIntegrityProtectorCreationTest extends ExtendedITextTest {
7070

7171
@BeforeAll
7272
public static void beforeClass() {
73-
Assumptions.assumeTrue("BC".equals(PROVIDER_NAME));
7473
createOrClearDestinationFolder(DESTINATION_FOLDER);
7574
Security.addProvider(BouncyCastleFactoryCreator.getFactory().getProvider());
7675
}
@@ -81,6 +80,8 @@ public static void afterClass() {
8180
}
8281

8382
@Test
83+
@LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT,
84+
ignore = true))
8485
public void standaloneMacStandardEncryptionTest() throws IOException, InterruptedException {
8586
String fileName = "standaloneMacStandardEncryptionTest.pdf";
8687
String outputFileName = DESTINATION_FOLDER + fileName;
@@ -99,6 +100,8 @@ public void standaloneMacStandardEncryptionTest() throws IOException, Interrupte
99100
}
100101

101102
@Test
103+
@LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT,
104+
ignore = true))
102105
public void macEncryptionWithAesGsmTest() throws IOException, InterruptedException {
103106
String fileName = "macEncryptionWithAesGsmTest.pdf";
104107
String outputFileName = DESTINATION_FOLDER + fileName;
@@ -116,6 +119,8 @@ public void macEncryptionWithAesGsmTest() throws IOException, InterruptedExcepti
116119
}
117120

118121
@Test
122+
@LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT,
123+
ignore = true))
119124
public void standaloneMacUnwritableStreamTest() throws IOException {
120125
MacProperties macProperties = new MacProperties(MacDigestAlgorithm.SHA_256, MacAlgorithm.HMAC_WITH_SHA_256,
121126
KeyWrappingAlgorithm.AES_256_NO_PADD);
@@ -139,6 +144,8 @@ public void write(byte[] b, int off, int len) {
139144
}
140145

141146
@Test
147+
@LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT,
148+
ignore = true))
142149
public void standaloneMacWithAllHashAlgorithmsTest() throws IOException, InterruptedException {
143150
for (int i = 0; i < EnumUtil.getAllValuesOfEnum(MacDigestAlgorithm.class).size(); i++) {
144151
String fileName = "standaloneMacWithAllHashAlgorithmsTest" + (i + 1) + ".pdf";
@@ -160,6 +167,8 @@ public void standaloneMacWithAllHashAlgorithmsTest() throws IOException, Interru
160167
}
161168

162169
@Test
170+
@LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT,
171+
ignore = true))
163172
public void standaloneMacPdfVersionNotSetTest() {
164173
String fileName = "standaloneMacPdfVersionNotSetTest.pdf";
165174
String outputFileName = DESTINATION_FOLDER + fileName;
@@ -178,6 +187,8 @@ public void standaloneMacPdfVersionNotSetTest() {
178187
}
179188

180189
@Test
190+
@LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT,
191+
ignore = true))
181192
public void standaloneMacOldEncryptionAlgorithmTest() {
182193
String fileName = "standaloneMacOldEncryptionAlgorithmTest.pdf";
183194
String outputFileName = DESTINATION_FOLDER + fileName;
@@ -197,6 +208,12 @@ public void standaloneMacOldEncryptionAlgorithmTest() {
197208

198209
@Test
199210
public void standaloneMacPublicKeyEncryptionTest() throws Exception {
211+
try {
212+
BouncyCastleFactoryCreator.getFactory().isEncryptionFeatureSupported(0, true);
213+
} catch (Exception ignored) {
214+
Assumptions.assumeTrue(false);
215+
}
216+
Assumptions.assumeTrue(!BouncyCastleFactoryCreator.getFactory().isInApprovedOnlyMode());
200217
String fileName = "standaloneMacPublicKeyEncryptionTest.pdf";
201218
String outputFileName = DESTINATION_FOLDER + fileName;
202219
String cmpFileName = SOURCE_FOLDER + "cmp_" + fileName;

kernel/src/test/java/com/itextpdf/kernel/mac/MacIntegrityProtectorReadingAndRewritingTest.java

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ This file is part of the iText (R) project.
2828
import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant;
2929
import com.itextpdf.kernel.exceptions.PdfException;
3030
import com.itextpdf.kernel.geom.Rectangle;
31+
import com.itextpdf.kernel.logs.KernelLogMessageConstant;
3132
import com.itextpdf.kernel.mac.MacProperties.MacDigestAlgorithm;
3233
import com.itextpdf.kernel.pdf.EncryptionConstants;
3334
import com.itextpdf.kernel.pdf.PdfDocument;
@@ -40,6 +41,8 @@ This file is part of the iText (R) project.
4041
import com.itextpdf.kernel.utils.CompareTool;
4142
import com.itextpdf.test.AssertUtil;
4243
import com.itextpdf.test.ExtendedITextTest;
44+
import com.itextpdf.test.annotations.LogMessage;
45+
import com.itextpdf.test.annotations.LogMessages;
4346

4447
import java.io.IOException;
4548
import java.security.PrivateKey;
@@ -62,7 +65,6 @@ public class MacIntegrityProtectorReadingAndRewritingTest extends ExtendedITextT
6265

6366
@BeforeAll
6467
public static void beforeClass() {
65-
Assumptions.assumeTrue("BC".equals(PROVIDER_NAME));
6668
createOrClearDestinationFolder(DESTINATION_FOLDER);
6769
Security.addProvider(BouncyCastleFactoryCreator.getFactory().getProvider());
6870
}
@@ -73,6 +75,8 @@ public static void afterClass() {
7375
}
7476

7577
@Test
78+
@LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT,
79+
ignore = true))
7680
public void appendModeTest() throws IOException, InterruptedException {
7781
String fileName = "appendModeTest.pdf";
7882
String outputFileName = DESTINATION_FOLDER + fileName;
@@ -88,6 +92,8 @@ public void appendModeTest() throws IOException, InterruptedException {
8892
}
8993

9094
@Test
95+
@LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT,
96+
ignore = true))
9197
public void preserveEncryptionTest() throws IOException, InterruptedException {
9298
String fileName = "preserveEncryptionTest.pdf";
9399
String outputFileName = DESTINATION_FOLDER + fileName;
@@ -104,6 +110,8 @@ public void preserveEncryptionTest() throws IOException, InterruptedException {
104110
}
105111

106112
@Test
113+
@LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT,
114+
ignore = true))
107115
public void writerPropertiesTest() throws IOException, InterruptedException {
108116
String fileName = "writerPropertiesTest.pdf";
109117
String outputFileName = DESTINATION_FOLDER + fileName;
@@ -123,6 +131,8 @@ public void writerPropertiesTest() throws IOException, InterruptedException {
123131
}
124132

125133
@Test
134+
@LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT,
135+
ignore = true))
126136
public void macShouldNotBePreservedWithEncryptionTest() throws IOException, InterruptedException {
127137
String fileName = "macShouldNotBePreservedWithEncryptionTest.pdf";
128138
String outputFileName = DESTINATION_FOLDER + fileName;
@@ -139,6 +149,8 @@ public void macShouldNotBePreservedWithEncryptionTest() throws IOException, Inte
139149
}
140150

141151
@Test
152+
@LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT,
153+
ignore = true))
142154
public void macShouldNotBePreservedTest() throws IOException, InterruptedException {
143155
String fileName = "macShouldNotBePreservedTest.pdf";
144156
String outputFileName = DESTINATION_FOLDER + fileName;
@@ -154,6 +166,8 @@ public void macShouldNotBePreservedTest() throws IOException, InterruptedExcepti
154166
}
155167

156168
@Test
169+
@LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT,
170+
ignore = true))
157171
public void invalidMacTokenTest() {
158172
String fileName = "invalidMacTokenTest.pdf";
159173
String outputFileName = DESTINATION_FOLDER + fileName;
@@ -168,7 +182,14 @@ public void invalidMacTokenTest() {
168182
}
169183

170184
@Test
185+
@LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT,
186+
ignore = true))
171187
public void invalidPublicKeyMacProtectedDocumentTest() throws Exception {
188+
try {
189+
BouncyCastleFactoryCreator.getFactory().isEncryptionFeatureSupported(0, true);
190+
} catch (Exception ignored) {
191+
Assumptions.assumeTrue(false);
192+
}
172193
String fileName = "invalidPublicKeyMacProtectedDocumentTest.pdf";
173194
String outputFileName = DESTINATION_FOLDER + fileName;
174195

@@ -188,59 +209,76 @@ public void invalidPublicKeyMacProtectedDocumentTest() throws Exception {
188209
}
189210

190211
@Test
212+
@LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT,
213+
ignore = true))
191214
public void readSignedMacProtectedDocumentWithoutAttributeTest() {
192215
String message = Assertions.assertThrows(PdfException.class, () -> {
193-
try (PdfDocument pdfDoc = new PdfDocument(new PdfReader(SOURCE_FOLDER + "signedMacProtectedDocWithoutAttribute.pdf",
216+
try (PdfDocument ignored = new PdfDocument(new PdfReader(SOURCE_FOLDER + "signedMacProtectedDocWithoutAttribute.pdf",
194217
new ReaderProperties().setPassword(PASSWORD)))) {
195218
}
196219
}).getMessage();
197220
Assertions.assertEquals(KernelExceptionMessageConstant.MAC_ATTRIBUTE_NOT_SPECIFIED, message);
198221
}
199222

200223
@Test
224+
@LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT,
225+
ignore = true))
201226
public void macProtectionStrippedTest() {
202227
String message = Assertions.assertThrows(PdfException.class, () -> {
203-
try (PdfDocument pdfDoc = new PdfDocument(new PdfReader(SOURCE_FOLDER + "macProtectionStrippedTest.pdf",
228+
try (PdfDocument ignored = new PdfDocument(new PdfReader(SOURCE_FOLDER + "macProtectionStrippedTest.pdf",
204229
new ReaderProperties().setPassword(PASSWORD)))) {
205230
}
206231
}).getMessage();
207232
Assertions.assertEquals(KernelExceptionMessageConstant.MAC_PERMS_WITHOUT_MAC, message);
208233
}
209234

210235
@Test
236+
@LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT,
237+
ignore = true))
211238
public void readSignedMacProtectedDocumentTest() {
212239
AssertUtil.doesNotThrow(() -> {
213-
try (PdfDocument pdfDoc = new PdfDocument(new PdfReader(SOURCE_FOLDER + "signedMacProtectedDocument.pdf",
240+
try (PdfDocument ignored = new PdfDocument(new PdfReader(SOURCE_FOLDER + "signedMacProtectedDocument.pdf",
214241
new ReaderProperties().setPassword(PASSWORD)))) {
215242
}
216243
});
217244
}
218245

219246
@Test
247+
@LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT,
248+
ignore = true))
220249
public void readThirdPartyMacProtectedDocumentTest() {
221250
AssertUtil.doesNotThrow(() -> {
222-
try (PdfDocument pdfDoc = new PdfDocument(new PdfReader(SOURCE_FOLDER + "thirdPartyMacProtectedDocument.pdf",
251+
try (PdfDocument ignored = new PdfDocument(new PdfReader(SOURCE_FOLDER + "thirdPartyMacProtectedDocument.pdf",
223252
new ReaderProperties().setPassword(PASSWORD)))) {
224253
}
225254
});
226255
}
227256

228257
@Test
258+
@LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT,
259+
ignore = true))
229260
public void readThirdPartyPublicKeyMacProtectedDocumentTest() throws Exception {
261+
try {
262+
BouncyCastleFactoryCreator.getFactory().isEncryptionFeatureSupported(0, true);
263+
} catch (Exception ignored) {
264+
Assumptions.assumeTrue(false);
265+
}
230266
PrivateKey privateKey = MacIntegrityProtectorCreationTest.getPrivateKey(CERTS_SRC + "keyForEncryption.pem");
231267
Certificate certificate = CryptoUtil.readPublicCertificate(
232268
FileUtil.getInputStreamForFile(CERTS_SRC + "certForEncryption.crt"));
233269
AssertUtil.doesNotThrow(() -> {
234-
try (PdfDocument pdfDoc = new PdfDocument(new PdfReader(SOURCE_FOLDER + "thirdPartyPublicKeyMacProtectedDocument.pdf",
270+
try (PdfDocument ignored = new PdfDocument(new PdfReader(SOURCE_FOLDER + "thirdPartyPublicKeyMacProtectedDocument.pdf",
235271
new ReaderProperties().setPublicKeySecurityParams(certificate, privateKey, PROVIDER_NAME, null)))) {
236272
}
237273
});
238274
}
239275

240276
@Test
277+
@LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT,
278+
ignore = true))
241279
public void readMacProtectedPdf1_7() {
242280
AssertUtil.doesNotThrow(() -> {
243-
try (PdfDocument pdfDoc = new PdfDocument(new PdfReader(SOURCE_FOLDER + "macProtectedDocumentPdf1_7.pdf",
281+
try (PdfDocument ignored = new PdfDocument(new PdfReader(SOURCE_FOLDER + "macProtectedDocumentPdf1_7.pdf",
244282
new ReaderProperties().setPassword(PASSWORD)))) {
245283
}
246284
});

sign/src/test/java/com/itextpdf/signatures/mac/SignedDocumentWithMacTest.java

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ This file is part of the iText (R) project.
2929
import com.itextpdf.kernel.crypto.DigestAlgorithms;
3030
import com.itextpdf.kernel.exceptions.KernelExceptionMessageConstant;
3131
import com.itextpdf.kernel.exceptions.PdfException;
32+
import com.itextpdf.kernel.logs.KernelLogMessageConstant;
3233
import com.itextpdf.kernel.pdf.PdfDocument;
3334
import com.itextpdf.kernel.pdf.PdfReader;
3435
import com.itextpdf.kernel.pdf.PdfWriter;
@@ -41,6 +42,8 @@ This file is part of the iText (R) project.
4142
import com.itextpdf.signatures.testutils.PemFileHelper;
4243
import com.itextpdf.signatures.testutils.SignaturesCompareTool;
4344
import com.itextpdf.test.ExtendedITextTest;
45+
import com.itextpdf.test.annotations.LogMessage;
46+
import com.itextpdf.test.annotations.LogMessages;
4447

4548
import java.io.OutputStream;
4649
import java.security.PrivateKey;
@@ -63,12 +66,13 @@ public class SignedDocumentWithMacTest extends ExtendedITextTest {
6366

6467
@BeforeAll
6568
public static void before() {
66-
Assumptions.assumeTrue("BC".equals(FACTORY.getProviderName()));
6769
Security.addProvider(FACTORY.getProvider());
6870
createOrClearDestinationFolder(DESTINATION_FOLDER);
6971
}
7072

7173
@Test
74+
@LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT,
75+
ignore = true))
7276
public void signMacProtectedDocTest() throws Exception {
7377
String fileName = "signMacProtectedDocTest.pdf";
7478
String srcFileName = SOURCE_FOLDER + "macEncryptedDoc.pdf";
@@ -90,6 +94,8 @@ public void signMacProtectedDocTest() throws Exception {
9094
}
9195

9296
@Test
97+
@LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT,
98+
ignore = true))
9399
public void signMacProtectedDocInAppendModeTest() throws Exception {
94100
String fileName = "signMacProtectedDocInAppendModeTest.pdf";
95101
String srcFileName = SOURCE_FOLDER + "macEncryptedDoc.pdf";
@@ -111,6 +117,8 @@ public void signMacProtectedDocInAppendModeTest() throws Exception {
111117
}
112118

113119
@Test
120+
@LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT,
121+
ignore = true))
114122
public void signMacProtectedDocWithSHA3_384Test() throws Exception {
115123
String fileName = "signMacProtectedDocWithSHA3_384Test.pdf";
116124
String srcFileName = SOURCE_FOLDER + "macEncryptedDocSHA3_384.pdf";
@@ -132,7 +140,14 @@ public void signMacProtectedDocWithSHA3_384Test() throws Exception {
132140
}
133141

134142
@Test
143+
@LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT,
144+
ignore = true))
135145
public void signMacPublicEncryptionDocTest() throws Exception {
146+
try {
147+
BouncyCastleFactoryCreator.getFactory().isEncryptionFeatureSupported(0, true);
148+
} catch (Exception ignored) {
149+
Assumptions.assumeTrue(false);
150+
}
136151
String fileName = "signMacPublicEncryptionDocTest.pdf";
137152
String srcFileName = SOURCE_FOLDER + "macEncryptedWithPublicHandlerDoc.pdf";
138153
String outputFileName = DESTINATION_FOLDER + fileName;
@@ -155,11 +170,13 @@ public void signMacPublicEncryptionDocTest() throws Exception {
155170
}
156171

157172
@Test
173+
@LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT,
174+
ignore = true))
158175
public void readSignedMacProtectedInvalidDocTest() {
159176
String srcFileName = SOURCE_FOLDER + "signedMacProtectedInvalidDoc.pdf";
160177

161178
String exceptionMessage = Assertions.assertThrows(PdfException.class, () -> {
162-
try (PdfDocument document = new PdfDocument(
179+
try (PdfDocument ignored = new PdfDocument(
163180
new PdfReader(srcFileName, new ReaderProperties().setPassword(ENCRYPTION_PASSWORD)))) {
164181
// Do nothing.
165182
}
@@ -168,13 +185,15 @@ public void readSignedMacProtectedInvalidDocTest() {
168185
}
169186

170187
@Test
188+
@LogMessages(messages = @LogMessage(messageTemplate = KernelLogMessageConstant.MD5_IS_NOT_FIPS_COMPLIANT,
189+
ignore = true))
171190
public void updateSignedMacProtectedDocumentTest() throws Exception {
172191
String fileName = "updateSignedMacProtectedDocumentTest.pdf";
173192
String srcFileName = SOURCE_FOLDER + "thirdPartyMacProtectedAndSignedDocument.pdf";
174193
String outputFileName = DESTINATION_FOLDER + fileName;
175194
String cmpFileName = SOURCE_FOLDER + "cmp_" + fileName;
176195

177-
try (PdfDocument document = new PdfDocument(
196+
try (PdfDocument ignored = new PdfDocument(
178197
new PdfReader(srcFileName, new ReaderProperties().setPassword(ENCRYPTION_PASSWORD)),
179198
new PdfWriter(FileUtil.getFileOutputStream(outputFileName)),
180199
new StampingProperties().useAppendMode())) {

0 commit comments

Comments
 (0)