PDFTransformParametersUR.java
9.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.internal.pdftoolkit.core.cos.CosArray
* com.adobe.internal.pdftoolkit.core.cos.CosDictionary
* com.adobe.internal.pdftoolkit.core.cos.CosObject
* com.adobe.internal.pdftoolkit.core.exceptions.PDFIOException
* com.adobe.internal.pdftoolkit.core.exceptions.PDFInvalidDocumentException
* com.adobe.internal.pdftoolkit.core.exceptions.PDFSecurityException
* com.adobe.internal.pdftoolkit.core.types.ASName
*/
package com.adobe.internal.pdftoolkit.pdf.digsig;
import com.adobe.internal.pdftoolkit.core.cos.CosArray;
import com.adobe.internal.pdftoolkit.core.cos.CosDictionary;
import com.adobe.internal.pdftoolkit.core.cos.CosObject;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFIOException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFInvalidDocumentException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFSecurityException;
import com.adobe.internal.pdftoolkit.core.types.ASName;
import com.adobe.internal.pdftoolkit.pdf.digsig.PDFTransformParameters;
import com.adobe.internal.pdftoolkit.pdf.digsig.PDFURAnnots;
import com.adobe.internal.pdftoolkit.pdf.digsig.PDFURDocument;
import com.adobe.internal.pdftoolkit.pdf.digsig.PDFUREmbeddedFiles;
import com.adobe.internal.pdftoolkit.pdf.digsig.PDFURForm;
import com.adobe.internal.pdftoolkit.pdf.digsig.PDFURSignature;
import com.adobe.internal.pdftoolkit.pdf.digsig.PDFUsageRight;
import com.adobe.internal.pdftoolkit.pdf.document.PDFCosObject;
import com.adobe.internal.pdftoolkit.pdf.document.PDFDocument;
import java.util.HashSet;
public class PDFTransformParametersUR
extends PDFTransformParameters {
private static final ASName k_Document = ASName.create((String)"Document");
private static final ASName k_Msg = ASName.create((String)"Msg");
private static final ASName k_EF = ASName.create((String)"EF");
protected PDFTransformParametersUR(CosObject cosObject) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
super(cosObject);
}
static PDFTransformParametersUR getInstance(CosObject cosObject) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (PDFCosObject.checkNullCosObject(cosObject) == null) {
return null;
}
PDFTransformParametersUR pdfObject = PDFCosObject.getCachedInstance(cosObject, PDFTransformParametersUR.class);
if (pdfObject == null) {
pdfObject = new PDFTransformParametersUR(cosObject);
}
return pdfObject;
}
public static PDFTransformParametersUR newInstance(PDFDocument pdfDocument) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosDictionary cosObject = PDFCosObject.newCosDirectDictionary(pdfDocument);
PDFTransformParametersUR pdfObject = new PDFTransformParametersUR((CosObject)cosObject);
pdfObject.setVersion("2.2");
pdfObject.setType();
return pdfObject;
}
private void setRights(ASName key, PDFUsageRight[] rights) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (rights == null || rights.length == 0) {
this.getCosDictionary().remove(key);
} else {
CosArray cosRights = PDFCosObject.newCosArray(this.getPDFDocument());
HashSet<ASName> rightsAdded = new HashSet<ASName>();
for (int i = 0; i < rights.length; ++i) {
ASName right = rights[i].getValue();
if (right == null || !rightsAdded.add(right)) continue;
cosRights.addName(right);
}
this.setDictionaryArrayValue(key, cosRights);
}
}
public PDFURDocument[] getDocumentUsageRights() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosArray cosArray = this.getDictionaryArrayValue(k_Document);
if (cosArray == null || cosArray.size() == 0) {
return null;
}
PDFURDocument[] rights = new PDFURDocument[cosArray.size()];
for (int i = 0; i < cosArray.size(); ++i) {
ASName right = cosArray.getName(i);
if (right == null) continue;
rights[i] = PDFURDocument.getInstance(right);
}
return rights;
}
public void setDocumentUsageRights(PDFURDocument[] rights) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setRights(k_Document, rights);
}
public PDFURAnnots[] getAnnotationUsageRights() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosArray cosArray = this.getDictionaryArrayValue(ASName.k_Annots);
if (cosArray == null || cosArray.size() == 0) {
return null;
}
PDFURAnnots[] rights = new PDFURAnnots[cosArray.size()];
for (int i = 0; i < cosArray.size(); ++i) {
rights[i] = PDFURAnnots.getInstance(cosArray.getName(i));
}
return rights;
}
public void setAnnotationUsageRights(PDFURAnnots[] rights) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setRights(ASName.k_Annots, rights);
}
public PDFURForm[] getFormUsageRights() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
PDFURForm[] formExUsageRights;
HashSet<PDFURForm> rights = new HashSet<PDFURForm>();
CosArray cosArray = this.getDictionaryArrayValue(ASName.k_Form);
if (cosArray != null && cosArray.size() != 0) {
for (int i = 0; i < cosArray.size(); ++i) {
rights.add(PDFURForm.getInstance(cosArray.getName(i)));
}
}
if ((formExUsageRights = this.getFormExUsageRights()) != null && formExUsageRights.length != 0) {
for (int i = 0; i < formExUsageRights.length; ++i) {
rights.add(formExUsageRights[i]);
}
}
PDFURForm[] combinedRights = rights.toArray(new PDFURForm[rights.size()]);
return combinedRights;
}
public void setFormUsageRights(PDFURForm[] rights) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setRights(ASName.k_Form, rights);
}
PDFURForm[] getFormExUsageRights() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosArray cosArray = this.getDictionaryArrayValue(ASName.k_FormEx);
if (cosArray == null || cosArray.size() == 0) {
return null;
}
PDFURForm[] rights = new PDFURForm[cosArray.size()];
for (int i = 0; i < cosArray.size(); ++i) {
ASName right = cosArray.getName(i);
if (right == null) continue;
rights[i] = PDFURForm.getInstance(right);
}
return rights;
}
void setFormExUsageRights(PDFURForm[] rights) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setRights(ASName.k_FormEx, rights);
}
public PDFURSignature[] getSignatureUsageRights() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosArray cosArray = this.getDictionaryArrayValue(ASName.k_Signature);
if (cosArray == null || cosArray.size() == 0) {
return null;
}
PDFURSignature[] rights = new PDFURSignature[cosArray.size()];
for (int i = 0; i < cosArray.size(); ++i) {
rights[i] = PDFURSignature.getInstance(cosArray.getName(i));
}
return rights;
}
public void setSignatureUsageRights(PDFURSignature[] rights) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setRights(ASName.k_Signature, rights);
}
public PDFUREmbeddedFiles[] getEFUsageRights() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosArray cosArray = this.getDictionaryArrayValue(k_EF);
if (cosArray == null || cosArray.size() == 0) {
return null;
}
PDFUREmbeddedFiles[] rights = new PDFUREmbeddedFiles[cosArray.size()];
for (int i = 0; i < cosArray.size(); ++i) {
rights[i] = PDFUREmbeddedFiles.getInstance(cosArray.getName(i));
}
return rights;
}
public void setEFUsageRights(PDFUsageRight[] rights) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setRights(k_EF, rights);
}
public String getMessage() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (this.getCosDictionary().containsKey((Object)k_Msg)) {
return this.getDictionaryTextStringValue(k_Msg);
}
return "";
}
public void setMessage(String msg) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryStringValue(k_Msg, msg);
}
public boolean getRestrictPermissions() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosObject cosObject = this.getCosDictionary().get(ASName.k_P);
if (cosObject != null) {
return cosObject.booleanValue();
}
return false;
}
public void setRestrictPermissions(boolean value) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryBooleanValue(ASName.k_P, value);
}
}