CosUtils.java
3.98 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.internal.io.stream.InputByteStream
*/
package com.adobe.internal.pdftoolkit.core.cos;
import com.adobe.internal.io.stream.InputByteStream;
import com.adobe.internal.pdftoolkit.core.cos.CosCloneMgr;
import com.adobe.internal.pdftoolkit.core.cos.CosDictionary;
import com.adobe.internal.pdftoolkit.core.cos.CosDocument;
import com.adobe.internal.pdftoolkit.core.cos.CosObject;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFCosParseException;
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.core.util.Utility;
import java.io.IOException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Collection;
import java.util.Iterator;
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
public final class CosUtils {
private CosUtils() {
}
public static CosDictionary cloneOrdinaryKeys(CosDictionary cloned, CosCloneMgr cloneHandler, CosDictionary dict, ASName[] specialKeys) throws PDFCosParseException, PDFIOException, PDFSecurityException {
Iterator<ASName> keyIterator = dict.keyIterator();
while (keyIterator.hasNext()) {
ASName curKey = keyIterator.next();
if (Utility.nameInArray(curKey, specialKeys)) continue;
cloned.put(curKey, cloneHandler.clone(dict.get(curKey)));
}
return cloned;
}
public static CosDictionary cloneOrdinaryKeys(CosDocument toDoc, CosCloneMgr cloneHandler, CosDictionary dict, ASName[] specialKeys) throws PDFCosParseException, PDFIOException, PDFSecurityException {
CosDictionary cloned = toDoc.createCosDictionary();
return CosUtils.cloneOrdinaryKeys(cloned, cloneHandler, dict, specialKeys);
}
/*
* Loose catch block
* Enabled aggressive block sorting
* Enabled unnecessary exception pruning
* Enabled aggressive exception aggregation
* Lifted jumps to return sites
*/
static byte[] digestStream(InputByteStream ibs, String digestAlgorithm) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
byte[] byteStream = new byte[8192];
MessageDigest digester = null;
try {
digester = MessageDigest.getInstance(digestAlgorithm);
while (ibs.bytesAvailable() > 0) {
int numBytesRead = ibs.read(byteStream);
digester.update(byteStream, 0, numBytesRead);
}
Object var6_7 = null;
try {
if (ibs == null) return digester.digest();
ibs.close();
return digester.digest();
}
catch (IOException e) {
throw new PDFIOException("Problem occured while closing the input byte stream.", e);
}
catch (IOException e) {
throw new PDFIOException(e);
}
catch (NoSuchAlgorithmException e2) {
throw new PDFSecurityException(e2);
}
}
catch (Throwable throwable) {
Object var6_8 = null;
try {}
catch (IOException e) {
throw new PDFIOException("Problem occured while closing the input byte stream.", e);
}
if (ibs == null) throw throwable;
ibs.close();
throw throwable;
}
}
public static <T extends CosObject> int indexOfCosObjectRef(Collection<T> objectList, T obj) {
int index = 0;
Iterator<T> itr = objectList.iterator();
while (itr.hasNext()) {
if (obj == itr.next()) {
return index;
}
++index;
}
return -1;
}
}