}
else
{
encryptedDoc = PDDocument.load(pdfFile);
Assert.assertTrue(encryptedDoc.isEncrypted());
DecryptionMaterial decryptionMaterial = new StandardDecryptionMaterial(ownerpassword);
encryptedDoc.openProtection(decryptionMaterial);
}
Assert.assertTrue(encryptedDoc.getCurrentAccessPermission().isOwnerPermission());
encryptedDoc.close();
// test with owner password => restricted permissions
if (nonSeq)
{
encryptedDoc = PDDocument.loadNonSeq(pdfFile, userpassword);
}
else
{
encryptedDoc = PDDocument.load(pdfFile);
Assert.assertTrue(encryptedDoc.isEncrypted());
DecryptionMaterial decryptionMaterial = new StandardDecryptionMaterial(userpassword);
encryptedDoc.openProtection(decryptionMaterial);
}
Assert.assertFalse(encryptedDoc.getCurrentAccessPermission().isOwnerPermission());
assertEquals(permission.getPermissionBytes(), encryptedDoc.getCurrentAccessPermission().getPermissionBytes());