All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.pdfbox.pdmodel.encryption.StandardProtectionPolicy Maven / Gradle / Ivy

Go to download

The Apache PDFBox library is an open source Java tool for working with PDF documents.

There is a newer version: 3.0.2
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.pdfbox.pdmodel.encryption;

/**
 * This class represents the protection policy to add to a document
 * for password-based protection.
 *
 * The following example shows how to protect a PDF document with password.
 * In this example, the document will be protected so that someone opening
 * the document with the user password user_pwd will not be
 * able to modify the document.
 *
 * 
 * AccessPermission ap = new AccessPermission();
 * ap.setCanModify(false);
 * StandardProtectionPolicy policy = new StandardProtectionPolicy(owner_pwd, user_pwd, ap);
 * doc.protect(policy);
 * 
* * @author Benoit Guillon ([email protected]) * @version $Revision: 1.3 $ */ public class StandardProtectionPolicy extends ProtectionPolicy { private AccessPermission permissions; private String ownerPassword = ""; private String userPassword = ""; /** * Creates an new instance of the standard protection policy * in order to protect a PDF document with passwords. * * @param ownerPass The owner's password. * @param userPass The users's password. * @param perms The access permissions given to the user. */ public StandardProtectionPolicy(String ownerPass, String userPass, AccessPermission perms) { this.permissions = perms; this.userPassword = userPass; this.ownerPassword = ownerPass; } /** * Getter of the property permissions. * * @return Returns the permissions. */ public AccessPermission getPermissions() { return permissions; } /** * Setter of the property permissions. * * @param perms The permissions to set. */ public void setPermissions(AccessPermission perms) { this.permissions = perms; } /** * Getter of the property ownerPassword. * * @return Returns the ownerPassword. */ public String getOwnerPassword() { return ownerPassword; } /** * Setter of the property ownerPassword. * * @param ownerPass The ownerPassword to set. */ public void setOwnerPassword(String ownerPass) { this.ownerPassword = ownerPass; } /** * Getter of the property userPassword. * * @return Returns the userPassword. */ public String getUserPassword() { return userPassword; } /** * Setter of the property userPassword. * * @param userPass The userPassword to set. */ public void setUserPassword(String userPass) { this.userPassword = userPass; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy