本文整理汇总了Java中org.sejda.model.pdf.encryption.PdfAccessPermission类的典型用法代码示例。如果您正苦于以下问题:Java PdfAccessPermission类的具体用法?Java PdfAccessPermission怎么用?Java PdfAccessPermission使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PdfAccessPermission类属于org.sejda.model.pdf.encryption包,在下文中一共展示了PdfAccessPermission类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: arc128WithOwner
import org.sejda.model.pdf.encryption.PdfAccessPermission; //导入依赖的package包/类
@Test
public void arc128WithOwner() throws IOException {
setUpParameters(PdfEncryption.STANDARD_ENC_128);
parameters.setOwnerPassword("test");
parameters.addPermission(PdfAccessPermission.COPY_AND_EXTRACT);
parameters.addPermission(PdfAccessPermission.FILL_FORMS);
testContext.directoryOutputTo(parameters);
execute(parameters);
testContext.assertTaskCompleted();
testContext.assertCreator().assertVersion(PdfVersion.VERSION_1_6).forEachPdfOutput(d -> {
assertTrue(d.isEncrypted());
assertTrue(d.getCurrentAccessPermission().canExtractContent());
assertTrue(d.getCurrentAccessPermission().canFillInForm());
});
}
示例2: aes256WithOwner
import org.sejda.model.pdf.encryption.PdfAccessPermission; //导入依赖的package包/类
@Test
public void aes256WithOwner() throws IOException {
setUpParameters(PdfEncryption.AES_ENC_256);
parameters.setVersion(PdfVersion.VERSION_1_7);
parameters.setOwnerPassword("Chuck");
parameters.setUserPassword("Norris");
parameters.addPermission(PdfAccessPermission.COPY_AND_EXTRACT);
parameters.addPermission(PdfAccessPermission.FILL_FORMS);
testContext.directoryOutputTo(parameters);
execute(parameters);
testContext.assertTaskCompleted("Norris");
testContext.assertCreator().assertVersion(PdfVersion.VERSION_1_7).forEachPdfOutput(d -> {
assertTrue(d.isEncrypted());
assertTrue(d.getCurrentAccessPermission().canExtractContent());
assertTrue(d.getCurrentAccessPermission().canFillInForm());
});
}
示例3: testSecurityFromParams
import org.sejda.model.pdf.encryption.PdfAccessPermission; //导入依赖的package包/类
@Test
public void testSecurityFromParams() {
EncryptParameters params = new EncryptParameters(PdfEncryption.AES_ENC_256);
params.setOwnerPassword("Chuck");
params.setUserPassword("Norris");
params.addPermission(PdfAccessPermission.MODIFY);
params.addPermission(PdfAccessPermission.ANNOTATION);
StandardSecurity security = EncryptionUtils.securityFromParams(params);
assertEquals("Chuck", security.ownerPassword);
assertEquals("Norris", security.userPassword);
assertEquals(StandardSecurityEncryption.AES_256, security.encryption);
assertTrue(security.permissions.canModify());
assertTrue(security.permissions.canModifyAnnotations());
assertTrue(security.permissions.canExtractForAccessibility());
assertFalse(security.permissions.canPrint());
assertFalse(security.permissions.canPrintDegraded());
assertFalse(security.permissions.canAssembleDocument());
assertFalse(security.permissions.canExtractContent());
assertFalse(security.permissions.canFillInForm());
}
示例4: before
import org.sejda.model.pdf.encryption.PdfAccessPermission; //导入依赖的package包/类
public void before(EncryptParameters parameters) {
totalSteps = parameters.getSourceList().size();
sourceOpener = new DefaultPdfSourceOpener();
outputWriter = OutputWriters.newMultipleOutputWriter(parameters.isOverwrite());
for (PdfAccessPermission permission : parameters.getPermissions()) {
permissions |= getAccessPermission(permission);
}
}
示例5: testGetAccessPermission
import org.sejda.model.pdf.encryption.PdfAccessPermission; //导入依赖的package包/类
@Test
public void testGetAccessPermission() {
assertEquals(PdfWriter.ALLOW_ASSEMBLY, getAccessPermission(PdfAccessPermission.ASSEMBLE).intValue());
assertEquals(PdfWriter.ALLOW_COPY, getAccessPermission(PdfAccessPermission.COPY_AND_EXTRACT).intValue());
assertEquals(PdfWriter.ALLOW_DEGRADED_PRINTING, getAccessPermission(PdfAccessPermission.DEGRADATED_PRINT)
.intValue());
assertEquals(PdfWriter.ALLOW_FILL_IN, getAccessPermission(PdfAccessPermission.FILL_FORMS).intValue());
assertEquals(PdfWriter.ALLOW_MODIFY_ANNOTATIONS, getAccessPermission(PdfAccessPermission.ANNOTATION).intValue());
assertEquals(PdfWriter.ALLOW_MODIFY_CONTENTS, getAccessPermission(PdfAccessPermission.MODIFY).intValue());
assertEquals(PdfWriter.ALLOW_PRINTING, getAccessPermission(PdfAccessPermission.PRINT).intValue());
assertEquals(PdfWriter.ALLOW_SCREENREADERS, getAccessPermission(PdfAccessPermission.EXTRACTION_FOR_DISABLES)
.intValue());
}
示例6: setUp
import org.sejda.model.pdf.encryption.PdfAccessPermission; //导入依赖的package包/类
@Before
public void setUp() {
TestUtils.setProperty(victim, "context", context);
parameters = new EncryptParameters(PdfEncryption.AES_ENC_128);
parameters.setCompress(true);
parameters.setOutputPrefix("test_prefix_");
parameters.setVersion(PdfVersion.VERSION_1_6);
parameters.setOwnerPassword("test");
parameters.addPermission(PdfAccessPermission.COPY_AND_EXTRACT);
parameters.setOutput(getOutput());
}
示例7: execute
import org.sejda.model.pdf.encryption.PdfAccessPermission; //导入依赖的package包/类
@Override
public void execute(BulkRotateParameters parameters) throws TaskException {
int currentStep = 0;
for (PdfRotationInput input : parameters.getInputSet()) {
executionContext().assertTaskNotCancelled();
currentStep++;
LOG.debug("Opening {}", input.source);
try {
documentHandler = input.source.open(documentLoader);
documentHandler.getPermissions().ensurePermission(PdfAccessPermission.ASSEMBLE);
documentHandler.setCreatorOnPDDocument();
File tmpFile = createTemporaryBuffer(parameters.getOutput());
LOG.debug("Created output on temporary buffer {}", tmpFile);
PdfRotator rotator = new PdfRotator(documentHandler.getUnderlyingPDDocument());
for (Integer page : input.getPages(documentHandler.getNumberOfPages())) {
executionContext().assertTaskNotCancelled();
rotator.rotate(page, input.rotation);
}
documentHandler.setVersionOnPDDocument(parameters.getVersion());
documentHandler.setCompress(parameters.isCompress());
documentHandler.savePDDocument(tmpFile);
String outName = nameGenerator(parameters.getOutputPrefix())
.generate(nameRequest().originalName(input.source.getName()).fileNumber(currentStep));
outputWriter.addOutput(file(tmpFile).name(outName));
} finally {
nullSafeCloseQuietly(documentHandler);
}
notifyEvent(executionContext().notifiableTaskMetadata()).stepsCompleted(currentStep).outOf(totalSteps);
}
parameters.getOutput().accept(outputWriter);
LOG.debug("Input documents rotated and written to {}", parameters.getOutput());
}
示例8: testClear
import org.sejda.model.pdf.encryption.PdfAccessPermission; //导入依赖的package包/类
@Test
public void testClear() {
EncryptParameters victim = new EncryptParameters(PdfEncryption.STANDARD_ENC_40);
victim.addPermission(PdfAccessPermission.ANNOTATION);
assertEquals(1, victim.getPermissions().size());
victim.clearPermissions();
assertEquals(0, victim.getPermissions().size());
}
示例9: testEqual
import org.sejda.model.pdf.encryption.PdfAccessPermission; //导入依赖的package包/类
@Test
public void testEqual() {
EncryptParameters eq1 = new EncryptParameters(PdfEncryption.STANDARD_ENC_40);
eq1.addPermission(PdfAccessPermission.COPY_AND_EXTRACT);
EncryptParameters eq2 = new EncryptParameters(PdfEncryption.STANDARD_ENC_40);
eq2.addPermission(PdfAccessPermission.COPY_AND_EXTRACT);
EncryptParameters eq3 = new EncryptParameters(PdfEncryption.STANDARD_ENC_40);
eq3.addPermission(PdfAccessPermission.COPY_AND_EXTRACT);
EncryptParameters diff = new EncryptParameters(PdfEncryption.STANDARD_ENC_40);
diff.addPermission(PdfAccessPermission.ASSEMBLE);
diff.setVersion(PdfVersion.VERSION_1_2);
TestUtils.testEqualsAndHashCodes(eq1, eq2, eq3, diff);
}
示例10: testPermissions
import org.sejda.model.pdf.encryption.PdfAccessPermission; //导入依赖的package包/类
@Test
public void testPermissions() {
EncryptParameters parameters = defaultCommandLine().with("--allow",
"print modify copy modifyannotations fill screenreaders assembly degradedprinting")
.invokeSejdaConsole();
assertThat(parameters.getPermissions(), hasItems(PdfAccessPermission.values()));
}
示例11: enablingPrintDegraded
import org.sejda.model.pdf.encryption.PdfAccessPermission; //导入依赖的package包/类
@Test
public void enablingPrintDegraded() throws IOException {
setUpParameters(PdfEncryption.STANDARD_ENC_128);
parameters.setOwnerPassword("test");
parameters.addPermission(PdfAccessPermission.DEGRADATED_PRINT);
testContext.directoryOutputTo(parameters);
execute(parameters);
testContext.assertTaskCompleted();
testContext.forEachPdfOutput(d -> {
assertTrue(d.isEncrypted());
assertFalse(d.getCurrentAccessPermission().canPrint());
assertTrue(d.getCurrentAccessPermission().canPrintDegraded());
});
}
示例12: enablingPrint
import org.sejda.model.pdf.encryption.PdfAccessPermission; //导入依赖的package包/类
@Test
public void enablingPrint() throws IOException {
setUpParameters(PdfEncryption.STANDARD_ENC_128);
parameters.setOwnerPassword("test");
parameters.addPermission(PdfAccessPermission.PRINT);
testContext.directoryOutputTo(parameters);
execute(parameters);
testContext.assertTaskCompleted();
testContext.forEachPdfOutput(d -> {
assertTrue(d.isEncrypted());
assertTrue(d.getCurrentAccessPermission().canPrint());
assertFalse(d.getCurrentAccessPermission().canPrintDegraded());
});
}
示例13: execute
import org.sejda.model.pdf.encryption.PdfAccessPermission; //导入依赖的package包/类
@Override
public void execute(EncryptParameters parameters) throws TaskException {
int currentStep = 0;
for (PdfSource<?> source : parameters.getSourceList()) {
executionContext().assertTaskNotCancelled();
currentStep++;
LOG.debug("Opening {}", source);
try {
documentHandler = source.open(documentLoader);
documentHandler.setCreatorOnPDDocument();
File tmpFile = createTemporaryBuffer(parameters.getOutput());
LOG.debug("Created output on temporary buffer {}", tmpFile);
documentHandler.setVersionOnPDDocument(parameters.getVersion());
documentHandler.setCompress(parameters.isCompress());
documentHandler.savePDDocument(tmpFile, security);
String outName = nameGenerator(parameters.getOutputPrefix())
.generate(nameRequest().originalName(source.getName()).fileNumber(currentStep));
outputWriter.addOutput(file(tmpFile).name(outName));
} finally {
nullSafeCloseQuietly(documentHandler);
}
notifyEvent(executionContext().notifiableTaskMetadata()).stepsCompleted(currentStep).outOf(totalSteps);
}
parameters.getOutput().accept(outputWriter);
LOG.debug("Input documents encrypted using {}, standard security handler revision {} and written to {}",
security.encryption, security.encryption.revision.revisionNumber, parameters.getOutput());
LOG.debug("Permissions: {}", parameters.getPermissions().stream().map(PdfAccessPermission::getFriendlyName)
.collect(Collectors.joining(", ")));
}
示例14: getPermissionsFrom
import org.sejda.model.pdf.encryption.PdfAccessPermission; //导入依赖的package包/类
private static AccessPermission getPermissionsFrom(Set<PdfAccessPermission> permissions) {
int perm = 0b11111111111111111111001000000000;
for (PdfAccessPermission permission : permissions) {
perm |= permission.bits;
}
return new AccessPermission(perm);
}
示例15: valueFromPdfAccessPermission
import org.sejda.model.pdf.encryption.PdfAccessPermission; //导入依赖的package包/类
static ForwardingPdfAccessPermission valueFromPdfAccessPermission(PdfAccessPermission accessPermission) {
for (ForwardingPdfAccessPermission current : ForwardingPdfAccessPermission.values()) {
if (current.permission == accessPermission) {
return current;
}
}
throw new IllegalArgumentException(String.format("No Forwarding access permission found for %s",
accessPermission));
}