001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: /* $Id: PDFEncryptionParams.java 426576 2006-07-28 15:44:37Z jeremias $ */
019:
020: package org.apache.fop.pdf;
021:
022: /**
023: * This class holds the parameters for PDF encryption.
024: */
025: public class PDFEncryptionParams {
026:
027: private String userPassword = ""; //May not be null
028: private String ownerPassword = ""; //May not be null
029: private boolean allowPrint = true;
030: private boolean allowCopyContent = true;
031: private boolean allowEditContent = true;
032: private boolean allowEditAnnotations = true;
033:
034: /**
035: * Creates a new instance.
036: * @param userPassword the user password
037: * @param ownerPassword the owner password
038: * @param allowPrint true if printing is allowed
039: * @param allowCopyContent true if copying content is allowed
040: * @param allowEditContent true if editing content is allowed
041: * @param allowEditAnnotations true if editing annotations is allowed
042: */
043: public PDFEncryptionParams(String userPassword,
044: String ownerPassword, boolean allowPrint,
045: boolean allowCopyContent, boolean allowEditContent,
046: boolean allowEditAnnotations) {
047: setUserPassword(userPassword);
048: setOwnerPassword(ownerPassword);
049: setAllowPrint(allowPrint);
050: setAllowCopyContent(allowCopyContent);
051: setAllowEditContent(allowEditContent);
052: setAllowEditAnnotations(allowEditAnnotations);
053: }
054:
055: /**
056: * Default constructor initializing to default values.
057: */
058: public PDFEncryptionParams() {
059: //nop
060: }
061:
062: /**
063: * Indicates whether copying content is allowed.
064: * @return true if copying is allowed
065: */
066: public boolean isAllowCopyContent() {
067: return allowCopyContent;
068: }
069:
070: /**
071: * Indicates whether editing annotations is allowed.
072: * @return true is editing annotations is allowed
073: */
074: public boolean isAllowEditAnnotations() {
075: return allowEditAnnotations;
076: }
077:
078: /**
079: * Indicates whether editing content is allowed.
080: * @return true if editing content is allowed
081: */
082: public boolean isAllowEditContent() {
083: return allowEditContent;
084: }
085:
086: /**
087: * Indicates whether printing is allowed.
088: * @return true if printing is allowed
089: */
090: public boolean isAllowPrint() {
091: return allowPrint;
092: }
093:
094: /**
095: * Returns the owner password.
096: * @return the owner password, an empty string if no password applies
097: */
098: public String getOwnerPassword() {
099: return ownerPassword;
100: }
101:
102: /**
103: * Returns the user password.
104: * @return the user password, an empty string if no password applies
105: */
106: public String getUserPassword() {
107: return userPassword;
108: }
109:
110: /**
111: * Sets the permission for copying content.
112: * @param allowCopyContent true if copying content is allowed
113: */
114: public void setAllowCopyContent(boolean allowCopyContent) {
115: this .allowCopyContent = allowCopyContent;
116: }
117:
118: /**
119: * Sets the permission for editing annotations.
120: * @param allowEditAnnotations true if editing annotations is allowed
121: */
122: public void setAllowEditAnnotations(boolean allowEditAnnotations) {
123: this .allowEditAnnotations = allowEditAnnotations;
124: }
125:
126: /**
127: * Sets the permission for editing content.
128: * @param allowEditContent true if editing annotations is allowed
129: */
130: public void setAllowEditContent(boolean allowEditContent) {
131: this .allowEditContent = allowEditContent;
132: }
133:
134: /**
135: * Sets the persmission for printing.
136: * @param allowPrint true if printing is allowed
137: */
138: public void setAllowPrint(boolean allowPrint) {
139: this .allowPrint = allowPrint;
140: }
141:
142: /**
143: * Sets the owner password.
144: * @param ownerPassword The owner password to set, null or an empty String
145: * if no password is applicable
146: */
147: public void setOwnerPassword(String ownerPassword) {
148: if (ownerPassword == null) {
149: this .ownerPassword = "";
150: } else {
151: this .ownerPassword = ownerPassword;
152: }
153: }
154:
155: /**
156: * Sets the user password.
157: * @param userPassword The user password to set, null or an empty String
158: * if no password is applicable
159: */
160: public void setUserPassword(String userPassword) {
161: if (userPassword == null) {
162: this .userPassword = "";
163: } else {
164: this.userPassword = userPassword;
165: }
166: }
167:
168: }
|