SettingValidator.java
6.36 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
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.pdfg.common;
import com.adobe.native2pdf.xml.FiletypeSettings;
import com.adobe.native2pdf.xml.PDFMaker;
import com.adobe.native2pdf.xml.SecuritySettings;
import com.adobe.pdfg.common.Utils;
import com.adobe.pdfg.joboptions.parser.ParamSpecs;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
public class SettingValidator {
private Map jobOptions;
private SecuritySettings.Settings security;
private boolean jobOptionsCompatible;
private boolean securitySettingsCompatible;
private boolean encryptionPasswordsIdentical;
private boolean securityVersionExceedsPdfVersion = false;
public SettingValidator(Map jobMap, SecuritySettings.Settings security) {
if (jobMap != null) {
this.jobOptions = (Map)jobMap.get("setdistillerparams");
}
this.security = security;
this.jobOptionsCompatible = this.checkJobOptionsCompatibility();
this.securitySettingsCompatible = this.checkSecurityCompatibility();
this.encryptionPasswordsIdentical = this.checkEncryptionPasswordsUniqueness();
}
public boolean areJobOptionsCompatible() {
return this.jobOptionsCompatible;
}
public boolean areSecuritySettingsCompatible() {
return this.securitySettingsCompatible;
}
public boolean areEncryptionPasswordsIdentical() {
return this.encryptionPasswordsIdentical;
}
private int getCLevelVersion(Double clevel) {
double d = (clevel - 1.0) * 10.0;
return (int)(d + 1.5);
}
private boolean checkJobOptionsCompatibility() {
if (this.jobOptions == null) {
return true;
}
Boolean bool = (Boolean)this.jobOptions.get("EmbedJobOptions");
if (bool == null || !bool.booleanValue()) {
return true;
}
return !this.isPdfComplianceOn(false);
}
private boolean checkSecurityCompatibility() {
if (this.security == null || this.jobOptions == null) {
return true;
}
String openPwd = this.security.getDocumentOpenPasswd();
String chgPwd = this.security.getDocumentChangePasswd();
if ((openPwd == null || openPwd.equals("")) && (chgPwd == null || chgPwd.equals(""))) {
return true;
}
int securityVersionCompatibility = this.security.getAcrobatVersion();
int pdfVersionCompatibility = this.getCLevelVersion((Double)this.jobOptions.get("CompatibilityLevel"));
if (securityVersionCompatibility >= 9 && pdfVersionCompatibility >= 8) {
return true;
}
if (pdfVersionCompatibility < securityVersionCompatibility && (pdfVersionCompatibility != 3 && pdfVersionCompatibility != 4 || securityVersionCompatibility != 3 && securityVersionCompatibility != 4)) {
this.securityVersionExceedsPdfVersion = true;
return false;
}
Boolean bool = (Boolean)this.jobOptions.get("PDFXCompliantPDFOnly");
if (bool == null || !bool.booleanValue()) {
return true;
}
return !this.isPdfComplianceOn(true);
}
private boolean isPdfComplianceOn(boolean forSecurity) {
Boolean enforceCompliance = (Boolean)this.jobOptions.get("PDFXCompliantPDFOnly");
if (!enforceCompliance.booleanValue()) {
return false;
}
List complianceList = (List)this.jobOptions.get("CheckCompliance");
if (complianceList != null) {
for (String type : complianceList) {
if (ParamSpecs.CHECKCOMPLIANCE_OPTIONS[0].equals(type)) continue;
if (forSecurity) {
return true;
}
if (ParamSpecs.CHECKCOMPLIANCE_OPTIONS[1].equals(type) || ParamSpecs.CHECKCOMPLIANCE_OPTIONS[2].equals(type)) continue;
return true;
}
} else {
Boolean b = (Boolean)this.jobOptions.get("PDFX1aCheck");
if (b != null && b.booleanValue()) {
return true;
}
b = (Boolean)this.jobOptions.get("PDFX3Check");
if (b != null && b.booleanValue()) {
return true;
}
}
return false;
}
private boolean checkEncryptionPasswordsUniqueness() {
if (this.security == null) {
return false;
}
String openPasswd = this.security.getDocumentOpenPasswd();
String changePasswd = this.security.getDocumentChangePasswd();
if (openPasswd == null) {
openPasswd = "";
}
if (changePasswd == null) {
changePasswd = "";
}
if (!"".equals(openPasswd) && openPasswd.equals(changePasswd)) {
return true;
}
return false;
}
public boolean isSecurityVersionExceedsPdfVersion() {
return this.securityVersionExceedsPdfVersion;
}
public boolean isAppConfigCompliant(Serializable appConfig) {
boolean retVal = true;
if (appConfig != null && Utils.isPDFAComplianceOn(this.jobOptions)) {
PDFMaker pdfMaker = null;
if (appConfig instanceof FiletypeSettings.Settings.AutoCAD) {
pdfMaker = ((FiletypeSettings.Settings.AutoCAD)appConfig).getPDFMaker();
} else if (appConfig instanceof FiletypeSettings.Settings.MSExcel) {
pdfMaker = ((FiletypeSettings.Settings.MSExcel)appConfig).getPDFMaker();
} else if (appConfig instanceof FiletypeSettings.Settings.MSPowerpoint) {
pdfMaker = ((FiletypeSettings.Settings.MSPowerpoint)appConfig).getPDFMaker();
} else if (appConfig instanceof FiletypeSettings.Settings.MSProject) {
pdfMaker = ((FiletypeSettings.Settings.MSProject)appConfig).getPDFMaker();
} else if (appConfig instanceof FiletypeSettings.Settings.MSPublisher) {
pdfMaker = ((FiletypeSettings.Settings.MSPublisher)appConfig).getPDFMaker();
} else if (appConfig instanceof FiletypeSettings.Settings.MSVisio) {
pdfMaker = ((FiletypeSettings.Settings.MSVisio)appConfig).getPDFMaker();
} else if (appConfig instanceof FiletypeSettings.Settings.MSWord) {
pdfMaker = ((FiletypeSettings.Settings.MSWord)appConfig).getPDFMaker();
}
retVal = pdfMaker == null ? true : !pdfMaker.isAttachSourceFile();
}
return retVal;
}
}