GeneratePDFUtil.java
5.1 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.aemfd.docmanager.Document
* com.adobe.native2pdf.xml.SecuritySettings
* com.adobe.native2pdf.xml.SecuritySettings$Settings
* com.adobe.pdfg.common.FileUtilities
* com.adobe.pdfg.exception.InvalidParameterException
* com.adobe.pdfg.logging.PDFGLogger
* com.adobe.pdfg.service.api.PDFGConfigService
*/
package com.adobe.pdfg.impl;
import com.adobe.aemfd.docmanager.Document;
import com.adobe.native2pdf.xml.SecuritySettings;
import com.adobe.pdfg.common.FileUtilities;
import com.adobe.pdfg.exception.InvalidParameterException;
import com.adobe.pdfg.impl.Native2PdfCaller;
import com.adobe.pdfg.logging.PDFGLogger;
import com.adobe.pdfg.service.api.PDFGConfigService;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
public class GeneratePDFUtil {
private static PDFGLogger LOGGER = PDFGLogger.getPDFGLogger(GeneratePDFUtil.class);
public static final String CONVERTED_DOC_KEY = "ConvertedDoc";
public static final String LOG_DOC_KEY = "LogDoc";
private static final Native2PdfCaller NATIVE_2_PDF_CALLER = new Native2PdfCaller();
private static String ourAdobePDFSettings = null;
private static String ourFileTypeSettings = null;
private static String ourSecuritySettings = null;
private static boolean ourApplyWaterMarkVal = true;
private static long ourLastTriggerTime = 0;
private static long ourWaitTimeForEval = 120000;
public static void setPDFSettings(String pdfSettings) {
ourAdobePDFSettings = pdfSettings;
}
public static void setFiletypeSettings(String filetypeSettings) {
ourFileTypeSettings = filetypeSettings;
}
public static void setSecuritySettings(String securitySettings) {
ourSecuritySettings = securitySettings;
}
public static String getJobConfigurationString(PDFGConfigService configService, Document settingsDoc, String fileTypeSettings, String pdfSettings, String securitySettings) throws InvalidParameterException {
try {
String jobConfigurationString = null;
if (settingsDoc == null) {
if (securitySettings == null || "".equals(securitySettings)) {
securitySettings = ourSecuritySettings;
}
if (pdfSettings == null || "".equals(pdfSettings)) {
pdfSettings = ourAdobePDFSettings;
}
if (fileTypeSettings == null || "".equals(fileTypeSettings)) {
fileTypeSettings = ourFileTypeSettings;
}
jobConfigurationString = configService.getConfigurationXML(securitySettings, pdfSettings, fileTypeSettings);
} else {
jobConfigurationString = FileUtilities.inputStreamToString((InputStream)settingsDoc.getInputStream());
}
return jobConfigurationString;
}
catch (Exception e) {
throw new InvalidParameterException(1001, (Throwable)e);
}
}
public static void updateSecuritySettings(PDFGConfigService configService, SecuritySettings.Settings security) throws Exception {
String password;
Object response = null;
if (GeneratePDFUtil.isCipher(security.getDocumentOpenPasswd())) {
password = configService.getClearText(security.getDocumentOpenPasswd());
security.setDocumentOpenPasswd(password);
}
if (GeneratePDFUtil.isCipher(security.getDocumentChangePasswd())) {
password = configService.getClearText(security.getDocumentChangePasswd());
security.setDocumentChangePasswd(password);
}
}
public static Native2PdfCaller getNative2PDFCaller() {
return NATIVE_2_PDF_CALLER;
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
* Enabled force condition propagation
* Lifted jumps to return sites
*/
public static boolean applyWaterMark() {
try {
long currentTime = System.currentTimeMillis();
if (!ourApplyWaterMarkVal || currentTime - ourLastTriggerTime <= ourWaitTimeForEval) return ourApplyWaterMarkVal;
Class<GeneratePDFUtil> class_ = GeneratePDFUtil.class;
synchronized (GeneratePDFUtil.class) {
ourApplyWaterMarkVal = false;
// ** MonitorExit[var2_2] (shouldn't be in output)
return ourApplyWaterMarkVal;
}
}
catch (Exception ex) {
LOGGER.trace("Problem in getting product info: " + ex.getMessage(), null, (Throwable)ex);
return true;
}
}
private static boolean isCipher(String text) {
if (text == null) {
return false;
}
return text.startsWith("{") && text.endsWith("}");
}
private static Map<String, String> getRequestMap(String arg, String value) {
HashMap<String, String> requestMap = new HashMap<String, String>();
requestMap.put(arg, value);
return requestMap;
}
}