PDFGConfigServiceImpl.java
55.8 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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.aemds.bedrock.CoreConfigService
* com.adobe.colorprofile.CSFInfo
* com.adobe.colorprofile.ColorProfileService
* com.adobe.colorprofile.ColorProfileServiceHelper
* com.adobe.colorprofile.ProfilesInfo
* com.adobe.granite.crypto.CryptoException
* com.adobe.granite.crypto.CryptoSupport
* com.adobe.pdfg.common.AESProperties
* com.adobe.pdfg.common.FileUtilities
* com.adobe.pdfg.common.StreamGobbler
* com.adobe.pdfg.common.Utils
* com.adobe.pdfg.config.PDFGConfigUtility
* com.adobe.pdfg.exception.ConfigException
* com.adobe.pdfg.exception.ConversionException
* com.adobe.pdfg.exception.ErrorCode
* com.adobe.pdfg.exception.PDFGBaseException
* com.adobe.pdfg.logging.PDFGLogger
* com.adobe.pdfg.service.api.PDFGConfigService
* com.adobe.ps2pdf.FontsInFolder
* com.adobe.ps2pdf.PsToPdfFontPaths
* com.adobe.ps2pdf.PsToPdfService
* com.adobe.ps2pdf.PsToPdfServiceHelper
* com.adobe.service.ConnectionFactory
* com.day.cq.dam.handler.gibson.fontmanager.FontManagerService
* javax.transaction.TransactionManager
* org.apache.commons.io.FileUtils
* org.apache.felix.scr.annotations.Activate
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Deactivate
* org.apache.felix.scr.annotations.Reference
* org.apache.felix.scr.annotations.Service
* org.apache.sling.jcr.api.SlingRepository
* org.osgi.framework.BundleContext
* org.osgi.framework.ServiceRegistration
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.pdfg.impl;
import com.adobe.aemds.bedrock.CoreConfigService;
import com.adobe.colorprofile.CSFInfo;
import com.adobe.colorprofile.ColorProfileService;
import com.adobe.colorprofile.ColorProfileServiceHelper;
import com.adobe.colorprofile.ProfilesInfo;
import com.adobe.granite.crypto.CryptoException;
import com.adobe.granite.crypto.CryptoSupport;
import com.adobe.pdfg.common.AESProperties;
import com.adobe.pdfg.common.FileUtilities;
import com.adobe.pdfg.common.StreamGobbler;
import com.adobe.pdfg.common.Utils;
import com.adobe.pdfg.config.PDFGConfigUtility;
import com.adobe.pdfg.exception.ConfigException;
import com.adobe.pdfg.exception.ConversionException;
import com.adobe.pdfg.exception.ErrorCode;
import com.adobe.pdfg.exception.PDFGBaseException;
import com.adobe.pdfg.impl.CleanUpAcrFilesTask;
import com.adobe.pdfg.impl.CleanupTask;
import com.adobe.pdfg.logging.PDFGLogger;
import com.adobe.pdfg.service.api.PDFGConfigService;
import com.adobe.pdfg.transaction.TransactionCallback;
import com.adobe.pdfg.transaction.TransactionTemplate;
import com.adobe.ps2pdf.FontsInFolder;
import com.adobe.ps2pdf.PsToPdfFontPaths;
import com.adobe.ps2pdf.PsToPdfService;
import com.adobe.ps2pdf.PsToPdfServiceHelper;
import com.adobe.service.ConnectionFactory;
import com.day.cq.dam.handler.gibson.fontmanager.FontManagerService;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Dictionary;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;
import javax.transaction.TransactionManager;
import org.apache.commons.io.FileUtils;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.jcr.api.SlingRepository;
import org.omg.CORBA.Object;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
@Component(metatype=1, immediate=0, label="%pdfg.config.name", description="%pdfg.config.description")
@Service
public class PDFGConfigServiceImpl
implements PDFGConfigService {
private static final PDFGLogger log = PDFGLogger.getPDFGLogger(PDFGConfigServiceImpl.class);
private static final String osName = System.getProperty("os.name").toLowerCase();
private static final String PDFG_JOB_OPTIONS_DIR = "pdfg_jo_dir";
private static final String PDFG_PS_STARTUP_DIR = "pdfg_ps_dir";
private static final String PDFG_PS_STARTUP_FILE = "pdfg_ps_file";
private static final String PDFG_CONVERSION_TIMEOUT = "pdfg_conv_timeout";
private static final String PDFG_GLOBAL_TIMEOUT = "pdfg_global_timeout";
private static final String PDFG_JOB_OPTIONS_PREFIX = "pdfg_jo_prefix";
private static final String PDFG_NON_UNICODE_APPS = "pdfg_non_unicode_apps";
private static final String PDFG_CLEANUP_SCAN_SECONDS = "pdfg_cleanup_scan";
private static final String PDFG_JOB_EXPIRATION_SECONDS = "pdfg_job_expiration";
private static final String PDFG_DEFAULT_LOCALE = "pdfg_def_locale";
private static PDFGConfigUtility ch = null;
private static List<List<String>> listOfCSFAndEmbeddedProfiles = null;
private static List<List<String>> listOfColorProfiles = null;
private static String ContentMSODir = "Content.MSO";
private static String ContentWordDir = "Content.Word";
private static String CacheRegKey = "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\\Cache";
private Logger logger;
private CleanUpAcrFilesTask acrobatFilesCleanUpTask;
@Reference
private FontManagerService fontManager;
@Reference(target="(bmc.service.name=PsToPdfSvc)")
private ConnectionFactory psToPdfSvc;
@Reference(target="(bmc.service.name=ColorProfileSvc)")
private ConnectionFactory colorProfileSvc;
@Reference
private CryptoSupport cryptoSupport;
@Reference
private SlingRepository repository;
@Reference
private CoreConfigService coreConfigService;
@Reference
private TransactionManager transactionManager;
private boolean credentialsValidated;
private String pdfgTempDirPath;
private BundleContext bundleContext;
private List<ServiceRegistration> services;
private Map configSettingsMap;
public PDFGConfigServiceImpl() {
this.logger = LoggerFactory.getLogger(this.getClass());
this.acrobatFilesCleanUpTask = null;
this.services = new ArrayList<ServiceRegistration>();
this.configSettingsMap = new HashMap();
}
@Activate
private void activate(BundleContext ctx, Map<String, java.lang.Object> config) throws ConfigException, CryptoException, IOException {
this.bundleContext = ctx;
this.initConfig(true);
}
@Deactivate
private void deactivate() {
this.unregisterJobs();
}
private void unregisterJobs() {
for (ServiceRegistration sr : this.services) {
if (sr == null) continue;
sr.unregister();
}
}
private void initConfig(boolean activating) throws ConfigException, CryptoException, IOException {
ch = PDFGConfigUtility.getInstance((SlingRepository)this.repository, (CryptoSupport)this.cryptoSupport);
String locale = ((String[])ch.getGeneralConfigMap().get("pdfg_def_locale"))[0];
String userJobOptionsDir = ((String[])ch.getGeneralConfigMap().get("pdfg_jo_dir"))[0];
String psStartupDir = ((String[])ch.getGeneralConfigMap().get("pdfg_ps_dir"))[0];
String psStartupFile = ((String[])ch.getGeneralConfigMap().get("pdfg_ps_file"))[0];
String jobOptionsPrefix = ((String[])ch.getGeneralConfigMap().get("pdfg_jo_prefix"))[0];
String nonunicodeApps = ((String[])ch.getGeneralConfigMap().get("pdfg_non_unicode_apps"))[0];
String cleanupScanSeconds = ((String[])ch.getGeneralConfigMap().get("pdfg_cleanup_scan"))[0];
String jobExpirationSeconds = ((String[])ch.getGeneralConfigMap().get("pdfg_job_expiration"))[0];
String conversionTimeout = ((String[])ch.getGeneralConfigMap().get("pdfg_conv_timeout"))[0];
String globalTimeout = ((String[])ch.getGeneralConfigMap().get("pdfg_global_timeout"))[0];
this.setDefaultLocale(locale);
this.setUserJobOptionsDir(userJobOptionsDir);
this.setPsStartupDir(psStartupDir);
this.setPsStartupFile(psStartupFile);
this.setJobOptionsPrefix(jobOptionsPrefix);
this.setNonunicodeApps(nonunicodeApps);
this.setCleanupScanSeconds(cleanupScanSeconds);
this.setJobExpirationSeconds(jobExpirationSeconds);
this.setConversionTimeout(conversionTimeout);
this.setGlobalTimeout(globalTimeout);
AESProperties.initialize((Map)this.configSettingsMap);
if (activating) {
this.createTempDirectory();
} else {
this.unregisterJobs();
this.services.clear();
}
this.acrobatFilesCleanUpTask = new CleanUpAcrFilesTask();
this.acrobatFilesCleanUpTask.populateUsersSet(ch.getUserAccounts());
this.services.add(this.scheduleJob(this.acrobatFilesCleanUpTask, Long.parseLong(cleanupScanSeconds)));
this.services.add(this.scheduleJob(new CleanupTask(this), Long.parseLong(cleanupScanSeconds)));
}
private ServiceRegistration scheduleJob(Runnable r, long periodInSeconds) {
String[] interfaces = new String[]{Runnable.class.getName()};
Hashtable<String, Comparable> properties = new Hashtable<String, Comparable>();
properties.put("scheduler.concurrent", Boolean.FALSE);
properties.put("scheduler.period", (Long)periodInSeconds);
return this.bundleContext.registerService(interfaces, (java.lang.Object)r, properties);
}
public Map getJobOptionsMap() throws ConfigException {
try {
if (!Utils.isCallerAuthorizedUser()) {
throw new ConfigException(80015, (java.lang.Object)"PDFGConfigService.getJobOptionsMap()");
}
}
catch (ConfigException e) {
throw e;
}
catch (PDFGBaseException e) {
log.trace(e.getMessage(), null, (Throwable)e);
throw new ConfigException(e.getErrorCode());
}
catch (Exception e) {
throw new ConfigException(1000, (Throwable)e);
}
this.loadConfig(ch);
return ch.getJobOptionsMap();
}
public Map getSecuritySettingsMap() throws ConfigException {
try {
if (!Utils.isCallerAuthorizedUser()) {
throw new ConfigException(80015, (java.lang.Object)"PDFGConfigService.getSecuritySettingsMap()");
}
}
catch (ConfigException e) {
throw e;
}
catch (PDFGBaseException e) {
log.trace(e.getMessage(), null, (Throwable)e);
throw new ConfigException(e.getErrorCode());
}
catch (Exception e) {
throw new ConfigException(1000, (Throwable)e);
}
this.loadConfig(ch);
return ch.getSecuritySettingsMap();
}
public Map getFiletypeSettingsMap() throws ConfigException {
try {
if (!Utils.isCallerAuthorizedUser()) {
throw new ConfigException(80015, (java.lang.Object)"PDFGConfigService.getFiletypeSettingsMap()");
}
}
catch (ConfigException e) {
throw e;
}
catch (PDFGBaseException e) {
log.trace(e.getMessage(), null, (Throwable)e);
throw new ConfigException(e.getErrorCode());
}
catch (Exception e) {
throw new ConfigException(1000, (Throwable)e);
}
this.loadConfig(ch);
return ch.getFiletypeSettingsMap();
}
public String getClearText(String enc) throws ConfigException {
try {
if (!Utils.isCallerAuthorizedUser()) {
throw new ConfigException(80015, (java.lang.Object)"PDFGConfigService.getClearText()");
}
return ch.getClearText(enc);
}
catch (ConfigException e) {
throw e;
}
catch (PDFGBaseException e) {
log.trace(e.getMessage(), null, (Throwable)e);
throw new ConfigException(e.getErrorCode());
}
catch (Exception e) {
throw new ConfigException(1000, (Throwable)e);
}
}
public Map getJobOptionMapByName(String jname) throws ConfigException {
try {
if (!Utils.isCallerAuthorizedUser()) {
throw new ConfigException(80015, (java.lang.Object)"PDFGConfigService.getJobOptionMapByName()");
}
}
catch (ConfigException e) {
throw e;
}
catch (PDFGBaseException e) {
log.trace(e.getMessage(), null, (Throwable)e);
throw new ConfigException(e.getErrorCode());
}
catch (Exception e) {
throw new ConfigException(1000, (Throwable)e);
}
this.loadConfig(ch);
return ch.getJobOptionsMapByName(jname);
}
public String getJobOptionStringByName(String jname) throws ConfigException {
try {
if (!Utils.isCallerAuthorizedUser()) {
throw new ConfigException(80015, (java.lang.Object)"PDFGConfigService.getJobOptionStringByName()");
}
}
catch (ConfigException e) {
throw e;
}
catch (PDFGBaseException e) {
log.trace(e.getMessage(), null, (Throwable)e);
throw new ConfigException(e.getErrorCode());
}
catch (Exception e) {
throw new ConfigException(1000, (Throwable)e);
}
this.loadConfig(ch);
return ch.getJobOptionsStringByName(jname);
}
public Map getSecuritySettingByName(String sname) throws ConfigException {
try {
if (!Utils.isCallerAuthorizedUser()) {
throw new ConfigException(80015, (java.lang.Object)"PDFGConfigService.getSecuritySettingByName()");
}
}
catch (ConfigException e) {
throw e;
}
catch (PDFGBaseException e) {
log.trace(e.getMessage(), null, (Throwable)e);
throw new ConfigException(e.getErrorCode());
}
catch (Exception e) {
throw new ConfigException(1000, (Throwable)e);
}
this.loadConfig(ch);
return ch.getSecuritySettingMapByName(sname);
}
public Map getFiletypeSettingByName(String fsname) throws ConfigException {
try {
if (!Utils.isCallerAuthorizedUser()) {
throw new ConfigException(80015, (java.lang.Object)"PDFGConfigService.getFiletypeSettingByName()");
}
}
catch (ConfigException e) {
throw e;
}
catch (PDFGBaseException e) {
log.trace(e.getMessage(), null, (Throwable)e);
throw new ConfigException(e.getErrorCode());
}
catch (Exception e) {
throw new ConfigException(1000, (Throwable)e);
}
this.loadConfig(ch);
return ch.getFiletypeSettingMapByName(fsname);
}
public String getConfigurationXML() throws ConfigException {
return ch.getDefaultConfigurationXML();
}
public String getConfigurationXML(String sName, String jName, String fName) throws ConfigException {
return ch.getNamedConfigurationXML(sName, jName, fName);
}
public String getPDFExportXML(String exportFormat, int timeout) throws ConfigException, ConversionException {
try {
if (!Utils.isCallerAuthorizedUser()) {
throw new ConfigException(80015, (java.lang.Object)"PDFGConfigService.getPDFExportXML()");
}
}
catch (ConfigException e) {
throw e;
}
catch (PDFGBaseException e) {
log.trace(e.getMessage(), null, (Throwable)e);
throw new ConfigException(e.getErrorCode());
}
catch (Exception e) {
throw new ConfigException(1000, (Throwable)e);
}
this.loadConfig(ch);
return ch.getPDFExportXML(exportFormat, timeout);
}
public String getActionTaggedXML(String sName, String jName, String fName, int timeout, boolean skipValidation) throws ConfigException, ConversionException {
try {
if (!Utils.isCallerAuthorizedUser()) {
throw new ConfigException(80015, (java.lang.Object)"PDFGConfigService.getActionTaggedXML()");
}
}
catch (ConfigException e) {
throw e;
}
catch (PDFGBaseException e) {
log.trace(e.getMessage(), null, (Throwable)e);
throw new ConfigException(e.getErrorCode());
}
catch (Exception e) {
throw new ConfigException(1000, (Throwable)e);
}
this.loadConfig(ch);
return ch.getActionTaggedXML(sName, jName, fName, timeout, skipValidation);
}
public Map getDefaultSettingsNames() throws ConfigException {
try {
if (!Utils.isCallerAuthorizedUser()) {
throw new ConfigException(80015, (java.lang.Object)"PDFGConfigService.getDefaultSettingsNames()");
}
}
catch (ConfigException e) {
throw e;
}
catch (PDFGBaseException e) {
log.trace(e.getMessage(), null, (Throwable)e);
throw new ConfigException(e.getErrorCode());
}
catch (Exception e) {
throw new ConfigException(1000, (Throwable)e);
}
this.loadConfig(ch);
return ch.getDefaultSettingsNames();
}
public Map getPDFGProductInfo() throws ConfigException {
this.loadConfig(ch);
return ch.getPDFGProductInfo();
}
public Map getPrologue() throws ConfigException {
try {
if (!Utils.isCallerAuthorizedUser()) {
throw new ConfigException(80015, (java.lang.Object)"PDFGConfigService.getPrologue()");
}
}
catch (ConfigException e) {
throw e;
}
catch (PDFGBaseException e) {
log.trace(e.getMessage(), null, (Throwable)e);
throw new ConfigException(e.getErrorCode());
}
catch (Exception e) {
throw new ConfigException(1000, (Throwable)e);
}
this.loadConfig(ch);
return ch.getPrologue();
}
public List getFontFolders() throws ConfigException {
try {
if (!Utils.isCallerAuthorizedUser()) {
throw new ConfigException(80015, (java.lang.Object)"PDFGConfigService.getFontFolders()");
}
}
catch (ConfigException e) {
throw e;
}
catch (PDFGBaseException e) {
log.trace(e.getMessage(), null, (Throwable)e);
throw new ConfigException(e.getErrorCode());
}
catch (Exception e) {
throw new ConfigException(1000, (Throwable)e);
}
try {
PsToPdfFontPaths fontPaths = this.retrievePsToPdfFontPaths();
LinkedList<String> folders = new LinkedList<String>();
if (!"".equals(fontPaths.customerFontPath)) {
folders.add(fontPaths.customerFontPath);
}
if (!"".equals(fontPaths.systemFontPath)) {
StringTokenizer tokenizer = new StringTokenizer(fontPaths.systemFontPath, ";");
while (tokenizer.hasMoreTokens()) {
String sysFont = tokenizer.nextToken();
if ("".equals(sysFont.trim())) continue;
folders.add(sysFont);
}
}
if (!"".equals(fontPaths.adobeFontPath)) {
folders.add(fontPaths.adobeFontPath);
}
return folders;
}
catch (Exception e) {
throw new ConfigException((Throwable)e);
}
}
public boolean validateUserCredentials(String userName, String domainName, String password) throws ConfigException {
boolean result;
block16 : {
if (userName == null) {
return false;
}
if ("".equals(userName = userName.trim())) {
return false;
}
if (osName.contains("windows")) {
if (password != null) {
password = password.trim();
}
if (domainName == null) {
domainName = "";
int indexOfForwardSlash = (userName = userName.replaceAll("\\\\", "/")).indexOf("/");
if (indexOfForwardSlash != -1) {
String usrName = userName.substring(indexOfForwardSlash + 1);
domainName = userName.substring(0, indexOfForwardSlash);
userName = usrName;
if ("".equals(userName) || "".equals(domainName)) {
return false;
}
}
}
try {
final String finalUserName = userName;
final String finalDomainName = domainName;
final String finalPassword = password;
boolean isValidUser = (Boolean)this.getTransactionTemplate().execute(new TransactionCallback<Boolean>(){
@Override
public Boolean doInTransaction() {
try {
return PDFGConfigServiceImpl.this.getColorProfileService().validateUserCredentials(finalUserName, finalDomainName, finalPassword);
}
catch (Exception e) {
throw new RuntimeException(e);
}
}
});
if (!isValidUser) {
this.logger.warn("User credentials not found to be valid for user {}", (java.lang.Object)userName);
}
return isValidUser;
}
catch (Exception e) {
throw new ConfigException((Throwable)e);
}
}
result = false;
try {
int retValue = this.runCmd(new String[]{"sudo", "-u", userName, "id"});
if (0 == retValue) {
result = true;
break block16;
}
if (-1 != retValue) break block16;
if (!osName.contains("sunos")) {
throw new ConfigException(80030, (java.lang.Object)"PDFGConfigService:validateUserCredentials");
}
File sudoLoc = new File("/opt/sfw/bin/sudo");
if (sudoLoc.exists()) {
if (0 == this.runCmd(new String[]{"/opt/sfw/bin/sudo", "-u", userName, "id"})) {
result = true;
}
break block16;
}
throw new ConfigException(80030, (java.lang.Object)"PDFGConfigService:validateUserCredentials");
}
catch (Exception exc) {
throw new ConfigException((Throwable)exc);
}
}
return result;
}
private int runCmd(String[] cmd) {
Process proc;
int retVal;
try {
proc = Runtime.getRuntime().exec(cmd);
}
catch (IOException e) {
log.trace(e.getMessage(), null, (Throwable)e);
return -1;
}
try {
proc.getOutputStream().close();
}
catch (IOException e) {
log.trace(e.getMessage(), null, (Throwable)e);
}
String cmdLine = Utils.unsplit((String[])cmd);
StreamGobbler errorGobbler = new StreamGobbler("error stream consumer for cmd: " + cmdLine, proc.getErrorStream(), (OutputStream)System.err);
errorGobbler.start();
StreamGobbler outputGobbler = new StreamGobbler("output stream consumer for cmd: " + cmdLine, proc.getInputStream(), (OutputStream)System.out);
outputGobbler.start();
do {
try {
retVal = proc.waitFor();
break;
}
catch (InterruptedException e) {
log.trace(e.getMessage(), null, (Throwable)e);
continue;
}
break;
} while (true);
errorGobbler.collectThread();
outputGobbler.collectThread();
return retVal;
}
public Map getAllValidUsersAccounts() throws ConfigException {
HashMap<String, String> result = null;
Map<String, String> userAccountsMap = this.getUserAccountsMap();
if (this.credentialsValidated) {
return userAccountsMap;
}
if (userAccountsMap != null) {
result = new HashMap<String, String>();
Set<String> userKeySet = userAccountsMap.keySet();
if (userKeySet != null) {
for (String userName : userKeySet) {
String password;
if (!this.validateUserCredentials(userName, null, password = userAccountsMap.get(userName))) continue;
result.put(userName, password);
}
}
}
return result;
}
public Map validateAllUsersCredentials() throws ConfigException {
HashMap<String, Boolean> result = null;
Map<String, String> userAccountsMap = this.getUserAccountsMap();
boolean allUsersValid = true;
if (userAccountsMap != null) {
result = new HashMap<String, Boolean>();
Set<String> userKeySet = userAccountsMap.keySet();
if (userKeySet != null) {
for (String userName : userKeySet) {
String password;
boolean isValid = this.validateUserCredentials(userName, null, password = userAccountsMap.get(userName));
if (!isValid) {
allUsersValid = false;
}
result.put(userName, isValid);
}
}
}
this.credentialsValidated = allUsersValid;
return result;
}
public List<List<String>> getCSFAndEmbeddedProfiles(String noneLocalized) throws ConfigException {
try {
if (listOfCSFAndEmbeddedProfiles != null) {
return listOfCSFAndEmbeddedProfiles;
}
CSFInfo[] info = (CSFInfo[])this.getTransactionTemplate().execute(new TransactionCallback<CSFInfo[]>(){
@Override
public CSFInfo[] doInTransaction() {
try {
return PDFGConfigServiceImpl.this.getColorProfileService().getCSFAndEmbeddedProfiles();
}
catch (Exception e) {
throw new RuntimeException(e);
}
}
});
listOfCSFAndEmbeddedProfiles = new ArrayList<List<String>>();
ArrayList<String> listOfSettingNames = new ArrayList<String>();
ArrayList<String> listOfProfileNames = new ArrayList<String>();
listOfSettingNames.add(noneLocalized);
for (CSFInfo csinfo : info) {
if ("null".equalsIgnoreCase(csinfo.fileName)) continue;
listOfSettingNames.add(csinfo.fileName);
listOfProfileNames.add(csinfo.embeddedGRAYProfileName);
listOfProfileNames.add(csinfo.embeddedRGBProfileName);
listOfProfileNames.add(csinfo.embeddedCMYKProfileName);
}
listOfCSFAndEmbeddedProfiles.add(listOfSettingNames);
listOfCSFAndEmbeddedProfiles.add(listOfProfileNames);
return listOfCSFAndEmbeddedProfiles;
}
catch (Exception e) {
throw new ConfigException((Throwable)e);
}
}
public List<List<String>> getColorProfiles() throws ConfigException {
try {
if (listOfColorProfiles != null) {
return listOfColorProfiles;
}
final String profilesDir = this.getPs2PdfService().getColorProfilesDirectory();
File file = new File(profilesDir);
final String[] allNames = file.list();
ProfilesInfo[] info = (ProfilesInfo[])this.getTransactionTemplate().execute(new TransactionCallback<ProfilesInfo[]>(){
@Override
public ProfilesInfo[] doInTransaction() {
try {
return PDFGConfigServiceImpl.this.getColorProfileService().getColorProfiles(allNames, profilesDir);
}
catch (Exception e) {
throw new RuntimeException(e);
}
}
});
listOfColorProfiles = new ArrayList<List<String>>();
ArrayList<String> grayList = new ArrayList<String>();
ArrayList<String> rgbList = new ArrayList<String>();
ArrayList<String> cmykList = new ArrayList<String>();
int counter = -1;
for (ProfilesInfo profileInfo : info) {
++counter;
if ("1".equalsIgnoreCase(profileInfo.type)) {
grayList.add(profileInfo.name);
continue;
}
if ("2".equalsIgnoreCase(profileInfo.type)) {
rgbList.add(profileInfo.name);
continue;
}
if (!"3".equalsIgnoreCase(profileInfo.type)) continue;
cmykList.add(profileInfo.name);
}
listOfColorProfiles.add(grayList);
listOfColorProfiles.add(rgbList);
listOfColorProfiles.add(cmykList);
return listOfColorProfiles;
}
catch (Exception e) {
throw new ConfigException((Throwable)e);
}
}
public List getFontsInFolder(String folderPath) throws ConfigException {
try {
if (!Utils.isCallerAuthorizedUser()) {
throw new ConfigException(80015, (java.lang.Object)"PDFGConfigService.getFontsInFolder()");
}
}
catch (ConfigException e) {
throw e;
}
catch (PDFGBaseException e) {
log.trace(e.getMessage(), null, (Throwable)e);
throw new ConfigException(e.getErrorCode());
}
catch (Exception e) {
throw new ConfigException(1000, (Throwable)e);
}
try {
PsToPdfFontPaths fontPaths = this.retrievePsToPdfFontPaths();
FontsInFolder[] fontsInFolder = this.getPs2PdfService().getFontsInFolder(fontPaths, folderPath);
List<String> baseFonts = Arrays.asList(fontsInFolder[0].fontNames);
List<String> folderFonts = Arrays.asList(fontsInFolder[1].fontNames);
TreeSet<String> fontSet = new TreeSet<String>();
fontSet.addAll(folderFonts);
fontSet.removeAll(baseFonts);
ArrayList<String> fontsList = new ArrayList<String>();
for (String fontName : fontSet) {
int startIndex = fontName.indexOf(40);
int endIndex = fontName.lastIndexOf(41);
fontsList.add(fontName.substring(startIndex + 1, endIndex));
}
return fontsList;
}
catch (Exception e) {
throw new ConfigException((Throwable)e);
}
}
public void setPrologue(Map pmap) throws ConfigException {
try {
if (!Utils.isCallerAuthorizedAdmin()) {
throw new ConfigException(80015, (java.lang.Object)"PDFGConfigService.setPrologue()");
}
}
catch (ConfigException e) {
throw e;
}
catch (PDFGBaseException e) {
log.trace(e.getMessage(), null, (Throwable)e);
throw new ConfigException(e.getErrorCode());
}
catch (Exception e) {
throw new ConfigException(1000, (Throwable)e);
}
ch.setPrologue(pmap);
}
public void updateJobOptions(Map jobOptionsMap, boolean createNew) throws ConfigException {
try {
if (!Utils.isCallerAuthorizedAdmin()) {
throw new ConfigException(80015, (java.lang.Object)"PDFGConfigService.updateJobOptions()");
}
}
catch (ConfigException e) {
throw e;
}
catch (PDFGBaseException e) {
log.trace(e.getMessage(), null, (Throwable)e);
throw new ConfigException(e.getErrorCode());
}
catch (Exception e) {
throw new ConfigException(1000, (Throwable)e);
}
this.loadConfig(ch);
ch.updateJobOptionSettings(jobOptionsMap, createNew);
this.storeConfig(ch);
}
public void setJobOptionsByName(String jobName, String jobOptionData) throws ConfigException {
try {
if (!Utils.isCallerAuthorizedAdmin()) {
throw new ConfigException(80015, (java.lang.Object)"PDFGConfigService.setJobOptionsByName()");
}
}
catch (ConfigException e) {
throw e;
}
catch (PDFGBaseException e) {
log.trace(e.getMessage(), null, (Throwable)e);
throw new ConfigException(e.getErrorCode());
}
catch (Exception e) {
throw new ConfigException(1000, (Throwable)e);
}
this.loadConfig(ch);
ch.setJobOptionsByName(jobName, jobOptionData);
this.storeConfig(ch);
}
public void updateSecuritySetting(String settingName, String openPassword, String permPassword) throws ConfigException {
try {
if (!Utils.isCallerAuthorizedAdmin()) {
throw new ConfigException(80015, (java.lang.Object)"PDFGConfigService.updateSecuritySettings()");
}
}
catch (ConfigException e) {
throw e;
}
catch (PDFGBaseException e) {
log.trace(e.getMessage(), null, (Throwable)e);
throw new ConfigException(e.getErrorCode());
}
catch (Exception e) {
throw new ConfigException(1000, (Throwable)e);
}
this.loadConfig(ch);
ch.updateSecuritySetting(settingName, openPassword, permPassword);
this.storeConfig(ch);
}
public void updateSecuritySettings(Map ssMap, boolean createNew) throws ConfigException {
try {
if (!Utils.isCallerAuthorizedAdmin()) {
throw new ConfigException(80015, (java.lang.Object)"PDFGConfigService.updateSecuritySettings()");
}
}
catch (ConfigException e) {
throw e;
}
catch (PDFGBaseException e) {
log.trace(e.getMessage(), null, (Throwable)e);
throw new ConfigException(e.getErrorCode());
}
catch (Exception e) {
throw new ConfigException(1000, (Throwable)e);
}
this.loadConfig(ch);
ch.updateSecuritySettings(ssMap, createNew);
this.storeConfig(ch);
}
public void updateUserAccountsSettings(Map userInfoMap, boolean createNew) throws ConfigException {
String newPsswd;
try {
if (!Utils.isCallerAuthorizedAdmin()) {
throw new ConfigException(80015, (java.lang.Object)"PDFGConfigService.updateSecuritySettings()");
}
}
catch (ConfigException e) {
throw e;
}
catch (PDFGBaseException e) {
log.trace(e.getMessage(), null, (Throwable)e);
throw new ConfigException(e.getErrorCode());
}
catch (Exception e) {
throw new ConfigException(1000, (Throwable)e);
}
String newUsrName = (String)userInfoMap.get("username");
boolean isValidCred = this.validateUserCredentials(newUsrName, null, newPsswd = (String)userInfoMap.get("password"));
if (!isValidCred) {
String machineDetail = "";
try {
InetAddress localhost = InetAddress.getLocalHost();
machineDetail = localhost.getHostName() + " (" + localhost.getHostAddress() + ")";
}
catch (UnknownHostException e) {
log.trace(e.getMessage(), null, (Throwable)e);
}
throw new ConfigException(ErrorCode.INVALID_USER_CRED, (java.lang.Object)newUsrName, (java.lang.Object)machineDetail);
}
ch.updateUserAccount(newUsrName, newPsswd, createNew);
if (!this.acrobatFilesCleanUpTask.addUser(newUsrName)) {
log.debug("Could not add user " + newUsrName + " to the users set maintained by CleanUpAcrFilesTask");
}
}
public Map<String, String> getUserAccountsMap() throws ConfigException {
try {
if (!Utils.isCallerAuthorizedAdmin()) {
throw new ConfigException(80015, (java.lang.Object)"PDFGConfigService.updateSecuritySettings()");
}
}
catch (ConfigException e) {
throw e;
}
catch (PDFGBaseException e) {
log.trace(e.getMessage(), null, (Throwable)e);
throw new ConfigException(e.getErrorCode());
}
catch (Exception e) {
throw new ConfigException(1000, (Throwable)e);
}
return ch.getUserAccounts();
}
public Map<String, String[]> getGeneralConfigMap() throws ConfigException {
try {
if (!Utils.isCallerAuthorizedUser()) {
throw new ConfigException(80015, (java.lang.Object)"PDFGConfigService.getGeneralConfigMap()");
}
}
catch (ConfigException e) {
throw e;
}
catch (PDFGBaseException e) {
log.trace(e.getMessage(), null, (Throwable)e);
throw new ConfigException(e.getErrorCode());
}
catch (Exception e) {
throw new ConfigException(1000, (Throwable)e);
}
return ch.getGeneralConfigMap();
}
public void updateGeneralConfig(Map<String, String[]> generalConfig) throws ConfigException {
try {
if (!Utils.isCallerAuthorizedUser()) {
throw new ConfigException(80015, (java.lang.Object)"PDFGConfigService.updateGeneralConfig()");
}
ch.updateGeneralConfig(generalConfig);
this.initConfig(false);
}
catch (ConfigException e) {
throw e;
}
catch (PDFGBaseException e) {
log.trace(e.getMessage(), null, (Throwable)e);
throw new ConfigException(e.getErrorCode());
}
catch (Exception e) {
throw new ConfigException(1000, (Throwable)e);
}
}
public void removeUserAccounts(List users) throws ConfigException {
try {
if (!Utils.isCallerAuthorizedAdmin()) {
throw new ConfigException(80015, (java.lang.Object)"PDFGConfigService.removeUserAccounts()");
}
}
catch (ConfigException e) {
throw e;
}
catch (PDFGBaseException e) {
log.trace(e.getMessage(), null, (Throwable)e);
throw new ConfigException(e.getErrorCode());
}
catch (Exception e) {
throw new ConfigException(1000, (Throwable)e);
}
ListIterator liter = users.listIterator();
while (liter.hasNext()) {
String userName = (String)liter.next();
ch.removeUserAccount(userName);
if (this.acrobatFilesCleanUpTask.removeUser(userName)) continue;
log.debug("Could not remove user " + userName + " from the users set maintained by CleanUpAcrFilesTask");
}
}
public Map getIPPSettings(Map ippMap, boolean createNew) throws ConfigException {
return null;
}
public void updateIPPSettings(Map ippMap, boolean createNew) throws Exception {
}
private static void checkIPPProcessConfig(String serviceName, String OperationName, String inParamName) throws Exception {
}
public void updateFiletypeSettings(Map fsMap, boolean createNew) throws ConfigException {
try {
if (!Utils.isCallerAuthorizedAdmin()) {
throw new ConfigException(80015, (java.lang.Object)"PDFGConfigService.updateFiletypeSettings()");
}
}
catch (ConfigException e) {
throw e;
}
catch (PDFGBaseException e) {
log.trace(e.getMessage(), null, (Throwable)e);
throw new ConfigException(e.getErrorCode());
}
catch (Exception e) {
throw new ConfigException(1000, (Throwable)e);
}
this.loadConfig(ch);
ch.updateFiletypeSettings(fsMap, createNew);
this.storeConfig(ch);
}
public void removeSecuritySettings(List secSettNames) throws ConfigException {
try {
if (!Utils.isCallerAuthorizedAdmin()) {
throw new ConfigException(80015, (java.lang.Object)"PDFGConfigService.removeSecuritySettings()");
}
}
catch (ConfigException e) {
throw e;
}
catch (PDFGBaseException e) {
log.trace(e.getMessage(), null, (Throwable)e);
throw new ConfigException(e.getErrorCode());
}
catch (Exception e) {
throw new ConfigException(1000, (Throwable)e);
}
this.loadConfig(ch);
ListIterator liter = secSettNames.listIterator();
while (liter.hasNext()) {
ch.removeSecuritySettings((String)liter.next());
}
this.storeConfig(ch);
}
public void removeFiletypeSettings(List fnames) throws ConfigException {
try {
if (!Utils.isCallerAuthorizedAdmin()) {
throw new ConfigException(80015, (java.lang.Object)"PDFGConfigService.removeFiletypeSettings()");
}
}
catch (ConfigException e) {
throw e;
}
catch (PDFGBaseException e) {
log.trace(e.getMessage(), null, (Throwable)e);
throw new ConfigException(e.getErrorCode());
}
catch (Exception e) {
throw new ConfigException(1000, (Throwable)e);
}
this.loadConfig(ch);
ListIterator liter = fnames.listIterator();
while (liter.hasNext()) {
ch.removeFiletypeSettings((String)liter.next());
}
this.storeConfig(ch);
}
public void removeJobOptionSettings(List jobOptNames) throws ConfigException {
try {
if (!Utils.isCallerAuthorizedAdmin()) {
throw new ConfigException(80015, (java.lang.Object)"PDFGConfigService.removeJobOptionSettings()");
}
}
catch (ConfigException e) {
throw e;
}
catch (PDFGBaseException e) {
log.trace(e.getMessage(), null, (Throwable)e);
throw new ConfigException(e.getErrorCode());
}
catch (Exception e) {
throw new ConfigException(1000, (Throwable)e);
}
this.loadConfig(ch);
ListIterator liter = jobOptNames.listIterator();
while (liter.hasNext()) {
ch.removeJobOptionSettings((String)liter.next());
}
this.storeConfig(ch);
}
public void setDefaultSettings(String sname, String jname, String aname) throws ConfigException, ConversionException {
try {
if (!Utils.isCallerAuthorizedAdmin()) {
throw new ConfigException(80015, (java.lang.Object)"PDFGConfigService.setDefaultSettings()");
}
}
catch (ConfigException e) {
throw e;
}
catch (PDFGBaseException e) {
log.trace(e.getMessage(), null, (Throwable)e);
throw new ConfigException(e.getErrorCode());
}
catch (Exception e) {
throw new ConfigException(1000, (Throwable)e);
}
this.loadConfig(ch);
ch.setDefaultSettings(sname, jname, aname);
this.storeConfig(ch);
}
public void importConfigurationXML(String configXML) throws ConfigException {
try {
if (!Utils.isCallerAuthorizedAdmin()) {
throw new ConfigException(80015, (java.lang.Object)"PDFGConfigService.importConfigurationXML()");
}
}
catch (ConfigException e) {
throw e;
}
catch (PDFGBaseException e) {
log.trace(e.getMessage(), null, (Throwable)e);
throw new ConfigException(e.getErrorCode());
}
catch (Exception e) {
throw new ConfigException(1000, (Throwable)e);
}
ch.importConfigurationXML(configXML, (PDFGConfigService)this);
this.storeConfig(ch);
}
public void resetConfigurationToDefault() throws ConfigException {
try {
if (!Utils.isCallerAuthorizedAdmin()) {
throw new ConfigException(80015, (java.lang.Object)"PDFGConfigService.resetConfigurationToDefault()");
}
}
catch (ConfigException e) {
throw e;
}
catch (PDFGBaseException e) {
log.trace(e.getMessage(), null, (Throwable)e);
throw new ConfigException(e.getErrorCode());
}
catch (Exception e) {
throw new ConfigException(1000, (Throwable)e);
}
ch.resetConfiguration();
this.storeConfig(ch);
}
private PsToPdfService getPs2PdfService() throws Exception {
ConnectionFactory psToPdfFactory = this.psToPdfSvc;
psToPdfFactory.setServiceTimeout((long)AESProperties.getGlobalTimeout());
Object psToPdfObject = (Object)psToPdfFactory.getConnection();
PsToPdfService psToPdfService = PsToPdfServiceHelper.narrow((Object)psToPdfObject);
return psToPdfService;
}
private ColorProfileService getColorProfileService() throws Exception {
ConnectionFactory colorProfileFactory = this.colorProfileSvc;
colorProfileFactory.setServiceTimeout((long)AESProperties.getGlobalTimeout());
Object colorProfileObject = (Object)colorProfileFactory.getConnection();
ColorProfileService colorProfileService = ColorProfileServiceHelper.narrow((Object)colorProfileObject);
return colorProfileService;
}
public void loadConfig(PDFGConfigUtility ch) throws ConfigException {
log.info("Loading the configuration");
ch.loadConfig();
}
public void storeConfig(PDFGConfigUtility ch) throws ConfigException {
log.info("Storing the configuration");
ch.storeConfig();
}
private PsToPdfFontPaths retrievePsToPdfFontPaths() {
PsToPdfFontPaths fontPaths = new PsToPdfFontPaths();
fontPaths.customerFontPath = this.getNormalizerFontPath(this.fontManager.getCustomerFontDirectory());
fontPaths.systemFontPath = this.getNormalizerFontPath(this.fontManager.getSystemFontDirectory());
fontPaths.adobeFontPath = this.getNormalizerFontPath(this.fontManager.getAdobeServerFontDirectory());
return fontPaths;
}
private String getNormalizerFontPath(String path) {
String fileSeparator = System.getProperty("file.separator");
String modifiedPath = "";
if (path != null && !"".equals(path)) {
modifiedPath = !path.endsWith(fileSeparator) ? path + fileSeparator : path;
}
return modifiedPath;
}
public Map getConfigurationSettingsMap() {
return this.configSettingsMap;
}
public String getConfigurationSetting(String key) {
return (String)this.configSettingsMap.get(key);
}
public void setCleanupScanSeconds(String cleanupScanSeconds) {
this.putProperty("server.pdfg.cleanup.scan.seconds", cleanupScanSeconds);
}
public void setConversionTimeout(String conversionTimeout) {
this.putProperty("server.conversion.timeout", conversionTimeout);
}
public void setGlobalTimeout(String globalTimeout) {
this.putProperty("server.global.timeout", globalTimeout);
}
public void setJobExpirationSeconds(String jobExpirationSeconds) {
this.putProperty("server.pdfg.job.expiration.seconds", jobExpirationSeconds);
}
public void setJobOptionsPrefix(String jobOptionsPrefix) {
this.putProperty("server.acrobat.job.options.prefix", jobOptionsPrefix);
}
public void setNonunicodeApps(String nonunicodeApps) {
this.putProperty("server.pdfg.nonunicode.apps", nonunicodeApps);
}
public void setPsStartupDir(String psStartupDir) {
String appData = System.getenv("APPDATA");
String newValue = psStartupDir;
if (psStartupDir != null && appData != null) {
newValue = psStartupDir.replace("[app.data]", appData);
}
this.putProperty("server.acrobat.ps.startup.dir", newValue);
}
public void setPsStartupFile(String psStartupFile) {
this.putProperty("server.acrobat.ps.startup.file", psStartupFile);
}
public void setDefaultLocale(String locale) {
if (locale == null || "".equals(locale.trim())) {
Locale defaultLocale = Locale.getDefault();
String localeSet = defaultLocale.getLanguage();
locale = localeSet.equalsIgnoreCase("en") || localeSet.equalsIgnoreCase("fr") || localeSet.equalsIgnoreCase("de") || localeSet.equalsIgnoreCase("ja") ? localeSet : "en";
}
this.putProperty("server.locale", locale.toLowerCase());
}
public void setUserJobOptionsDir(String userJobOptionsDir) {
String appData = System.getenv("APPDATA");
String newValue = userJobOptionsDir;
if (userJobOptionsDir != null && appData != null) {
newValue = userJobOptionsDir.replace("[app.data]", appData);
}
this.putProperty("server.acrobat.user.job.options.dir", newValue);
}
private void putProperty(String key, String value) {
this.configSettingsMap.put(key, value);
}
public Map<String, Map> getAllSettingsMapWithDefault() throws ConfigException {
Map allFiletypeSettings = this.getFiletypeSettingsMap();
Map allPdfSettings = this.getJobOptionsMap();
Map allSecuritySettings = this.getSecuritySettingsMap();
HashMap<String, Map> allSettingsMap = new HashMap<String, Map>();
allSettingsMap.put("fileTypeSettingsMap", allFiletypeSettings);
allSettingsMap.put("pdfSettingsMap", allPdfSettings);
allSettingsMap.put("securitySettingsMap", allSecuritySettings);
return allSettingsMap;
}
public Map<String, List<String>> getOSAndUsers() throws ConfigException {
Map<String, String> userMap = this.getUserAccountsMap();
Set<String> userSet = userMap.keySet();
ArrayList<String> returnList = new ArrayList<String>();
returnList.addAll(userSet);
String osName = System.getProperty("os.name");
HashMap<String, List<String>> returnMap = new HashMap<String, List<String>>();
returnMap.put(osName, returnList);
return returnMap;
}
private void createTempDirectory() throws IOException {
File tempDir = new File(this.coreConfigService.getServerTempDir());
String userId = System.getProperty("user.name");
userId = userId.replaceAll("[\\$,\\\\,\\/,\\?,\\@,\\*,\\+,\\\",\\|,\\:,\\;\\,\\=,>,<,\\[,\\]]", "_");
File pdfgTempDir = new File(tempDir, "pdfg-" + userId);
FileUtils.forceMkdir((File)pdfgTempDir);
this.pdfgTempDirPath = pdfgTempDir.getAbsolutePath();
FileUtilities.setGuidRootDir((File)pdfgTempDir);
}
private File getPDFGRootDir() {
return new File(this.pdfgTempDirPath);
}
private List<String> getMSWordTempDirectory() {
ArrayList<String> retVal = new ArrayList<String>();
try {
Set<String> userKeySet;
Map<String, String> userAccountsMap = this.getUserAccountsMap();
if (userAccountsMap != null && (userKeySet = userAccountsMap.keySet()) != null) {
for (final String UserName : userKeySet) {
final String Password = userAccountsMap.get(UserName);
String defaultUserDir = (String)this.getTransactionTemplate().execute(new TransactionCallback<String>(){
@Override
public String doInTransaction() {
try {
return PDFGConfigServiceImpl.this.getColorProfileService().getRegistryKeyValue(CacheRegKey, UserName, "", Password);
}
catch (Exception e) {
throw new RuntimeException(e);
}
}
});
log.debug("The Temporary user directory is " + defaultUserDir);
String MSOPath = new File(defaultUserDir, ContentMSODir).getPath();
String WordPath = new File(defaultUserDir, ContentWordDir).getPath();
retVal.add(MSOPath);
retVal.add(WordPath);
}
}
}
catch (Exception e) {
log.trace(e.getMessage(), null, (Throwable)e);
}
return retVal;
}
public List<File> getPDFGTempFolders() throws ConfigException {
ArrayList<File> listOfFolders = new ArrayList<File>();
listOfFolders.add(this.getPDFGRootDir());
if (System.getProperty("os.name").toLowerCase().contains("windows")) {
List<String> tempDirPathList = this.getMSWordTempDirectory();
for (String tempDirPath : tempDirPathList) {
File dir2;
if (tempDirPath == null || !(dir2 = new File(tempDirPath)).exists() || !dir2.isDirectory()) continue;
listOfFolders.add(dir2);
}
}
return listOfFolders;
}
private TransactionTemplate getTransactionTemplate() {
return new TransactionTemplate(this.transactionManager);
}
protected void bindFontManager(FontManagerService fontManagerService) {
this.fontManager = fontManagerService;
}
protected void unbindFontManager(FontManagerService fontManagerService) {
if (this.fontManager == fontManagerService) {
this.fontManager = null;
}
}
protected void bindPsToPdfSvc(ConnectionFactory connectionFactory) {
this.psToPdfSvc = connectionFactory;
}
protected void unbindPsToPdfSvc(ConnectionFactory connectionFactory) {
if (this.psToPdfSvc == connectionFactory) {
this.psToPdfSvc = null;
}
}
protected void bindColorProfileSvc(ConnectionFactory connectionFactory) {
this.colorProfileSvc = connectionFactory;
}
protected void unbindColorProfileSvc(ConnectionFactory connectionFactory) {
if (this.colorProfileSvc == connectionFactory) {
this.colorProfileSvc = null;
}
}
protected void bindCryptoSupport(CryptoSupport cryptoSupport) {
this.cryptoSupport = cryptoSupport;
}
protected void unbindCryptoSupport(CryptoSupport cryptoSupport) {
if (this.cryptoSupport == cryptoSupport) {
this.cryptoSupport = null;
}
}
protected void bindRepository(SlingRepository slingRepository) {
this.repository = slingRepository;
}
protected void unbindRepository(SlingRepository slingRepository) {
if (this.repository == slingRepository) {
this.repository = null;
}
}
protected void bindCoreConfigService(CoreConfigService coreConfigService) {
this.coreConfigService = coreConfigService;
}
protected void unbindCoreConfigService(CoreConfigService coreConfigService) {
if (this.coreConfigService == coreConfigService) {
this.coreConfigService = null;
}
}
protected void bindTransactionManager(TransactionManager transactionManager) {
this.transactionManager = transactionManager;
}
protected void unbindTransactionManager(TransactionManager transactionManager) {
if (this.transactionManager == transactionManager) {
this.transactionManager = null;
}
}
}