PDFCertificateSeedValue.java
13.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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
/*
* 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.PDFInvalidParameterException
* com.adobe.internal.pdftoolkit.core.exceptions.PDFSecurityException
* com.adobe.internal.pdftoolkit.core.types.ASName
* com.adobe.internal.pdftoolkit.core.types.ASString
*/
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.PDFInvalidParameterException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFSecurityException;
import com.adobe.internal.pdftoolkit.core.types.ASName;
import com.adobe.internal.pdftoolkit.core.types.ASString;
import com.adobe.internal.pdftoolkit.pdf.digsig.PDFSubjectDNList;
import com.adobe.internal.pdftoolkit.pdf.document.PDFCosDictionary;
import com.adobe.internal.pdftoolkit.pdf.document.PDFCosObject;
import com.adobe.internal.pdftoolkit.pdf.document.PDFDocument;
import java.util.List;
public class PDFCertificateSeedValue
extends PDFCosDictionary {
public static final int kSubject = 1;
public static final int kIssuer = 2;
public static final int kOID = 4;
public static final int kSubjectDN = 8;
public static final int kKeyUsage = 32;
public static final int kURL = 64;
public static final ASName k_SVCert = ASName.create((String)"SVCert");
public static final ASName k_Subject = ASName.create((String)"Subject");
public static final ASName k_Issuer = ASName.create((String)"Issuer");
public static final ASName k_OID = ASName.create((String)"OID");
public static final ASName k_URL = ASName.create((String)"URL");
public static final ASName k_Ff = ASName.create((String)"Ff");
public static final ASName k_SubjectDN = ASName.create((String)"SubjectDN");
public static final ASName k_KeyUsage = ASName.create((String)"KeyUsage");
public static final ASName k_URLType = ASName.create((String)"URLType");
public static final ASName k_Browser = ASName.create((String)"Browser");
public static final ASName k_ASSP = ASName.create((String)"ASSP");
private PDFCertificateSeedValue(CosObject cosObject) throws PDFInvalidDocumentException {
super(cosObject);
}
public static PDFCertificateSeedValue getInstance(CosObject cosObject) throws PDFInvalidDocumentException {
if (PDFCosObject.checkNullCosObject(cosObject) == null) {
return null;
}
PDFCertificateSeedValue pdfObject = PDFCosObject.getCachedInstance(cosObject, PDFCertificateSeedValue.class);
if (pdfObject == null) {
pdfObject = new PDFCertificateSeedValue(cosObject);
}
return pdfObject;
}
public static PDFCertificateSeedValue newInstance(PDFDocument pdfDocument) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosDictionary cosObject = PDFCosObject.newCosDictionary(pdfDocument);
PDFCertificateSeedValue pdfObject = new PDFCertificateSeedValue((CosObject)cosObject);
pdfObject.setDictionaryNameValue(ASName.k_Type, k_SVCert);
return pdfObject;
}
public byte[][] getSubjects() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosArray cosArray = this.getDictionaryArrayValue(ASName.k_Subject);
if (cosArray == null) {
return null;
}
byte[][] subjects = new byte[cosArray.size()][];
for (int i = 0; i < subjects.length; ++i) {
subjects[i] = cosArray.getString(i).getBytes();
}
return subjects;
}
public void setSubjects(byte[][] subjects) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (subjects == null) {
this.removeValue(k_Subject);
} else {
CosArray cosArray = PDFCosObject.newCosArray(this.getPDFDocument());
for (int i = 0; i < subjects.length; ++i) {
if (subjects[i] == null || subjects[i].length <= 0) continue;
cosArray.addString(new ASString(subjects[i]));
}
if (cosArray.size() > 0) {
this.setDictionaryArrayValue(k_Subject, cosArray);
} else {
this.removeValue(k_Subject);
}
}
}
public PDFSubjectDNList getSubjectDN() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return PDFSubjectDNList.getInstance(this.getDictionaryCosObjectValue(k_SubjectDN));
}
public void setSubjectDN(List dnList) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException, PDFInvalidParameterException {
PDFSubjectDNList subjectDNList = PDFSubjectDNList.newInstance(this.getPDFDocument(), dnList);
if (subjectDNList.size() > 0) {
this.setDictionaryArrayValue(k_SubjectDN, subjectDNList.getCosArray());
} else {
this.removeValue(k_SubjectDN);
}
}
public String[] getKeyUsage() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosArray cosArray = this.getDictionaryArrayValue(k_KeyUsage);
if (cosArray == null) {
return null;
}
String[] keyUsages = new String[cosArray.size()];
for (int i = 0; i < keyUsages.length; ++i) {
keyUsages[i] = cosArray.getString(i).asString();
}
return keyUsages;
}
public void setKeyUsage(String[] keyUsages) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException, PDFInvalidParameterException {
if (keyUsages == null) {
this.removeValue(k_KeyUsage);
} else {
CosArray cosArray = PDFCosObject.newCosArray(this.getPDFDocument());
for (int i = 0; i < keyUsages.length; ++i) {
if (keyUsages[i] == null || keyUsages[i].length() <= 0) continue;
if (keyUsages[i].length() > 9) {
throw new PDFInvalidParameterException("The key usage bit string has more than 9 bits.");
}
cosArray.addText(keyUsages[i]);
}
if (cosArray.size() > 0) {
this.setDictionaryArrayValue(k_KeyUsage, cosArray);
} else {
this.removeValue(k_KeyUsage);
}
}
}
public byte[][] getIssuers() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosArray cosArray = this.getDictionaryArrayValue(k_Issuer);
if (cosArray == null) {
return null;
}
byte[][] issuers = new byte[cosArray.size()][];
for (int i = 0; i < issuers.length; ++i) {
issuers[i] = cosArray.getString(i).getBytes();
}
return issuers;
}
public void setIssuers(byte[][] issuers) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (issuers == null) {
this.removeValue(k_Issuer);
} else {
CosArray cosArray = PDFCosObject.newCosArray(this.getPDFDocument());
for (int i = 0; i < issuers.length; ++i) {
if (issuers[i] == null || issuers[i].length <= 0) continue;
cosArray.addString(new ASString(issuers[i]));
}
if (cosArray.size() > 0) {
this.setDictionaryArrayValue(k_Issuer, cosArray);
} else {
this.removeValue(k_Issuer);
}
}
}
public String[] getOIDs() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosArray cosArray = this.getDictionaryArrayValue(k_OID);
if (cosArray == null) {
return null;
}
String[] oids = new String[cosArray.size()];
for (int i = 0; i < oids.length; ++i) {
oids[i] = cosArray.getString(i).asString();
}
return oids;
}
public void setOIDs(String[] oids) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (oids == null) {
this.removeValue(k_OID);
} else {
CosArray cosArray = PDFCosObject.newCosArray(this.getPDFDocument());
for (int i = 0; i < oids.length; ++i) {
if (oids[i] == null || oids[i].length() <= 0) continue;
cosArray.addText(oids[i]);
}
if (cosArray.size() > 0) {
this.setDictionaryArrayValue(k_OID, cosArray);
} else {
this.removeValue(k_OID);
}
}
}
public String getURL() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
ASString asStr = this.getDictionaryStringValue(k_URL);
return asStr != null ? asStr.asString() : null;
}
public void setURL(String url) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryStringValue(k_URL, url);
}
public ASName getURLType() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (this.getCosDictionary().containsKey((Object)k_URLType)) {
return this.getDictionaryNameValue(k_URLType);
}
return k_Browser;
}
public void setURLType(ASName urlType) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryNameValue(k_URLType, urlType);
}
public int getFlags() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (this.getCosDictionary().containsKey((Object)k_Ff)) {
return this.getDictionaryIntValue(k_Ff);
}
return 0;
}
public void setFlags(Integer flags) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (flags == null) {
this.removeValue(k_Ff);
} else {
this.setDictionaryIntValue(k_Ff, flags.intValue());
}
}
public String getSignaturePolicyOID() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
ASString asStr = this.getDictionaryStringValue(ASName.k_SignaturePolicyOID);
return asStr != null ? asStr.asString() : null;
}
public void setSignaturePolicyOID(String signaturePolicyOID) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryStringValue(ASName.k_SignaturePolicyOID, signaturePolicyOID);
}
public String getSignaturePolicyHashValue() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
ASString asStr = this.getDictionaryStringValue(ASName.k_SignaturePolicyHashValue);
return asStr != null ? asStr.asString() : null;
}
public void setSignaturePolicyHashValue(String signaturePolicyHashValue) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryStringValue(ASName.k_SignaturePolicyHashValue, signaturePolicyHashValue);
}
public ASName getSignaturePolicyHashAlgorithm() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getDictionaryNameValue(ASName.k_SignaturePolicyHashAlgorithm);
}
public void setSignaturePolicyHashAlgorithm(ASName signaturePolicyHashAlgorithm) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryNameValue(ASName.k_SignaturePolicyHashAlgorithm, signaturePolicyHashAlgorithm);
}
public String[] getSignaturePolicyCommitmentType() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosArray cosArray = this.getDictionaryArrayValue(ASName.k_SignaturePolicyCommitmentType);
if (cosArray == null) {
return null;
}
String[] keyUsages = new String[cosArray.size()];
for (int i = 0; i < keyUsages.length; ++i) {
keyUsages[i] = cosArray.getString(i).asString();
}
return keyUsages;
}
public void setSignaturePolicyCommitmentType(String[] signaturePolicyCommitmentTypes) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException, PDFInvalidParameterException {
if (signaturePolicyCommitmentTypes == null) {
this.removeValue(ASName.k_SignaturePolicyCommitmentType);
} else {
CosArray cosArray = PDFCosObject.newCosArray(this.getPDFDocument());
for (int i = 0; i < signaturePolicyCommitmentTypes.length; ++i) {
if (signaturePolicyCommitmentTypes[i] == null || signaturePolicyCommitmentTypes[i].length() <= 0) continue;
cosArray.addText(signaturePolicyCommitmentTypes[i]);
}
if (cosArray.size() > 0) {
this.setDictionaryArrayValue(ASName.k_SignaturePolicyCommitmentType, cosArray);
} else {
this.removeValue(ASName.k_SignaturePolicyCommitmentType);
}
}
}
}