3131import java .nio .charset .StandardCharsets ;
3232import java .nio .file .Files ;
3333import java .nio .file .Paths ;
34+ import java .security .NoSuchAlgorithmException ;
3435import java .util .ArrayList ;
3536import java .util .List ;
3637import java .util .Map ;
@@ -81,17 +82,17 @@ class TestSymmetricKeyEncryption
8182 */
8283 private static final Logger LOG = LogManager .getLogger (TestSymmetricKeyEncryption .class );
8384
84- private static final File testResultsDir = new File ("target/test-output/crypto" );
85+ private static final File TESTRESULTSDIR = new File ("target/test-output/crypto" );
8586
8687 private static AccessPermission permission ;
8788
8889 static final String USERPASSWORD = "1234567890abcdefghijk1234567890abcdefghijk" ;
8990 static final String OWNERPASSWORD = "abcdefghijk1234567890abcdefghijk1234567890" ;
9091
9192 @ BeforeAll
92- static void setUp () throws Exception
93+ static void setUp () throws NoSuchAlgorithmException
9394 {
94- testResultsDir .mkdirs ();
95+ TESTRESULTSDIR .mkdirs ();
9596
9697 if (Cipher .getMaxAllowedKeyLength ("AES" ) != Integer .MAX_VALUE )
9798 {
@@ -325,7 +326,7 @@ void testProtectionInnerAttachment() throws Exception
325326 void testPDFBox4453 () throws IOException
326327 {
327328 final int TESTCOUNT = 1000 ;
328- File file = new File (testResultsDir ,"PDFBOX-4453.pdf" );
329+ File file = new File (TESTRESULTSDIR ,"PDFBOX-4453.pdf" );
329330 try (PDDocument doc = new PDDocument ())
330331 {
331332 doc .addPage (new PDPage ());
@@ -417,7 +418,7 @@ private void testSymmEncrForKeySize(String filename, int keyLength, boolean pref
417418 }
418419 }
419420
420- File pdfFile = new File (testResultsDir , prefix + keyLength + "-bit-" + (preferAES ? "AES" : "RC4" ) + "-decrypted.pdf" );
421+ File pdfFile = new File (TESTRESULTSDIR , prefix + keyLength + "-bit-" + (preferAES ? "AES" : "RC4" ) + "-decrypted.pdf" );
421422 encryptedDoc .setAllSecurityToBeRemoved (true );
422423 encryptedDoc .save (pdfFile );
423424 }
@@ -439,7 +440,7 @@ private PDDocument encrypt(int keyLength, boolean preferAES, int sizePriorToEncr
439440
440441 doc .protect (spp );
441442
442- File pdfFile = new File (testResultsDir , prefix + keyLength + "-bit-" + (preferAES ? "AES" : "RC4" ) + "-encrypted.pdf" );
443+ File pdfFile = new File (TESTRESULTSDIR , prefix + keyLength + "-bit-" + (preferAES ? "AES" : "RC4" ) + "-encrypted.pdf" );
443444
444445 doc .save (pdfFile );
445446 doc .close ();
@@ -493,7 +494,7 @@ private File extractEmbeddedFile(RandomAccessRead pdfSource, String name) throws
493494 PDComplexFileSpecification complexFileSpec = entry .getValue ();
494495 PDEmbeddedFile embeddedFile = complexFileSpec .getEmbeddedFile ();
495496
496- File resultFile = new File (testResultsDir , name );
497+ File resultFile = new File (TESTRESULTSDIR , name );
497498 try (FileOutputStream fos = new FileOutputStream (resultFile );
498499 InputStream is = embeddedFile .createInputStream ())
499500 {
@@ -514,7 +515,7 @@ private void testSymmEncrForKeySizeInner(int keyLength, boolean preferAES,
514515 PDDocument document = Loader .loadPDF (inputFileWithEmbeddedFileAsByteArray );
515516 try (PDDocument encryptedDoc = encrypt (keyLength , preferAES , sizePriorToEncr , document , "ContainsEmbedded-" , permission , userpassword , ownerpassword ))
516517 {
517- File decryptedFile = new File (testResultsDir , "DecryptedContainsEmbedded-" + keyLength + "-bit-" + (preferAES ? "AES" : "RC4" ) + ".pdf" );
518+ File decryptedFile = new File (TESTRESULTSDIR , "DecryptedContainsEmbedded-" + keyLength + "-bit-" + (preferAES ? "AES" : "RC4" ) + ".pdf" );
518519 encryptedDoc .setAllSecurityToBeRemoved (true );
519520 encryptedDoc .save (decryptedFile );
520521
0 commit comments