KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > fop > pdf > PDFEncryptionParams


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 /* $Id: PDFEncryptionParams.java 426576 2006-07-28 15:44:37Z jeremias $ */
19  
20 package org.apache.fop.pdf;
21
22 /**
23  * This class holds the parameters for PDF encryption.
24  */

25 public class PDFEncryptionParams {
26
27     private String JavaDoc userPassword = ""; //May not be null
28
private String JavaDoc ownerPassword = ""; //May not be null
29
private boolean allowPrint = true;
30     private boolean allowCopyContent = true;
31     private boolean allowEditContent = true;
32     private boolean allowEditAnnotations = true;
33     
34     /**
35      * Creates a new instance.
36      * @param userPassword the user password
37      * @param ownerPassword the owner password
38      * @param allowPrint true if printing is allowed
39      * @param allowCopyContent true if copying content is allowed
40      * @param allowEditContent true if editing content is allowed
41      * @param allowEditAnnotations true if editing annotations is allowed
42      */

43     public PDFEncryptionParams(String JavaDoc userPassword, String JavaDoc ownerPassword,
44                                boolean allowPrint,
45                                boolean allowCopyContent,
46                                boolean allowEditContent,
47                                boolean allowEditAnnotations) {
48         setUserPassword(userPassword);
49         setOwnerPassword(ownerPassword);
50         setAllowPrint(allowPrint);
51         setAllowCopyContent(allowCopyContent);
52         setAllowEditContent(allowEditContent);
53         setAllowEditAnnotations(allowEditAnnotations);
54     }
55     
56     /**
57      * Default constructor initializing to default values.
58      */

59     public PDFEncryptionParams() {
60         //nop
61
}
62      
63     /**
64      * Indicates whether copying content is allowed.
65      * @return true if copying is allowed
66      */

67     public boolean isAllowCopyContent() {
68         return allowCopyContent;
69     }
70
71     /**
72      * Indicates whether editing annotations is allowed.
73      * @return true is editing annotations is allowed
74      */

75     public boolean isAllowEditAnnotations() {
76         return allowEditAnnotations;
77     }
78
79     /**
80      * Indicates whether editing content is allowed.
81      * @return true if editing content is allowed
82      */

83     public boolean isAllowEditContent() {
84         return allowEditContent;
85     }
86
87     /**
88      * Indicates whether printing is allowed.
89      * @return true if printing is allowed
90      */

91     public boolean isAllowPrint() {
92         return allowPrint;
93     }
94
95     /**
96      * Returns the owner password.
97      * @return the owner password, an empty string if no password applies
98      */

99     public String JavaDoc getOwnerPassword() {
100         return ownerPassword;
101     }
102
103     /**
104      * Returns the user password.
105      * @return the user password, an empty string if no password applies
106      */

107     public String JavaDoc getUserPassword() {
108         return userPassword;
109     }
110
111     /**
112      * Sets the permission for copying content.
113      * @param allowCopyContent true if copying content is allowed
114      */

115     public void setAllowCopyContent(boolean allowCopyContent) {
116         this.allowCopyContent = allowCopyContent;
117     }
118
119     /**
120      * Sets the permission for editing annotations.
121      * @param allowEditAnnotations true if editing annotations is allowed
122      */

123     public void setAllowEditAnnotations(boolean allowEditAnnotations) {
124         this.allowEditAnnotations = allowEditAnnotations;
125     }
126
127     /**
128      * Sets the permission for editing content.
129      * @param allowEditContent true if editing annotations is allowed
130      */

131     public void setAllowEditContent(boolean allowEditContent) {
132         this.allowEditContent = allowEditContent;
133     }
134
135     /**
136      * Sets the persmission for printing.
137      * @param allowPrint true if printing is allowed
138      */

139     public void setAllowPrint(boolean allowPrint) {
140         this.allowPrint = allowPrint;
141     }
142
143     /**
144      * Sets the owner password.
145      * @param ownerPassword The owner password to set, null or an empty String
146      * if no password is applicable
147      */

148     public void setOwnerPassword(String JavaDoc ownerPassword) {
149         if (ownerPassword == null) {
150             this.ownerPassword = "";
151         } else {
152             this.ownerPassword = ownerPassword;
153         }
154     }
155
156     /**
157      * Sets the user password.
158      * @param userPassword The user password to set, null or an empty String
159      * if no password is applicable
160      */

161     public void setUserPassword(String JavaDoc userPassword) {
162         if (userPassword == null) {
163             this.userPassword = "";
164         } else {
165             this.userPassword = userPassword;
166         }
167     }
168
169 }
170
Popular Tags