SecureDocumentService.java
5.12 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.aemfd.docmanager.Document
* com.adobe.fd.docassurance.client.api.DocAssuranceService
* com.adobe.fd.docassurance.client.api.EncryptionOptions
* com.adobe.fd.docassurance.client.api.ReaderExtensionOptions
* com.adobe.fd.docassurance.client.api.SignatureOptions
* com.adobe.fd.signatures.pdf.inputs.UnlockOptions
* com.adobe.granite.workflow.WorkflowException
* com.adobe.granite.workflow.WorkflowSession
* com.adobe.granite.workflow.exec.WorkItem
* com.adobe.granite.workflow.metadata.MetaDataMap
* javax.jcr.Session
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Reference
* org.apache.felix.scr.annotations.Service
* org.apache.sling.api.resource.ResourceResolver
* org.apache.sling.api.resource.ResourceResolverFactory
* org.apache.sling.jcr.api.SlingRepository
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.fd.workflow.docassurance;
import com.adobe.aemfd.docmanager.Document;
import com.adobe.fd.docassurance.client.api.DocAssuranceService;
import com.adobe.fd.docassurance.client.api.EncryptionOptions;
import com.adobe.fd.docassurance.client.api.ReaderExtensionOptions;
import com.adobe.fd.docassurance.client.api.SignatureOptions;
import com.adobe.fd.signatures.pdf.inputs.UnlockOptions;
import com.adobe.fd.workflow.docassurance.intrernal.utils.DocAssuranceObjectParser;
import com.adobe.fd.workflow.internal.common.AEMFDWorkflowProcess;
import com.adobe.granite.workflow.WorkflowException;
import com.adobe.granite.workflow.WorkflowSession;
import com.adobe.granite.workflow.exec.WorkItem;
import com.adobe.granite.workflow.metadata.MetaDataMap;
import java.util.HashMap;
import java.util.Map;
import javax.jcr.Session;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ResourceResolverFactory;
import org.apache.sling.jcr.api.SlingRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Component
@Service
public class SecureDocumentService
extends AEMFDWorkflowProcess {
@Reference
private DocAssuranceService docAssuranceService;
@Reference
private SlingRepository slingRepository;
private static final Logger log = LoggerFactory.getLogger(SecureDocumentService.class);
@Override
public void internal_execute(WorkItem item, WorkflowSession session, MetaDataMap args) throws WorkflowException {
ResourceResolver resourceResolver = null;
try {
Document inDoc = DocAssuranceObjectParser.getInputDoc(item, args);
Document outputDoc = null;
if (inDoc == null) {
log.debug("Input Document is null");
throw new WorkflowException("Input Document can not be null");
}
resourceResolver = this.getResourceResolver((Session)session.adaptTo(Session.class));
EncryptionOptions encryptionOptions = DocAssuranceObjectParser.getEncryptionOptions(args, resourceResolver);
SignatureOptions signatureOptions = DocAssuranceObjectParser.getSignatureOptions(args, resourceResolver, item);
ReaderExtensionOptions reOptions = DocAssuranceObjectParser.getREOptions(args, resourceResolver);
UnlockOptions unlockOptions = DocAssuranceObjectParser.getUnlockOptions(args, resourceResolver);
outputDoc = this.docAssuranceService.secureDocument(inDoc, encryptionOptions, signatureOptions, reOptions, unlockOptions);
DocAssuranceObjectParser.saveDoc(item, session, outputDoc);
}
catch (Exception e) {
log.debug("Exception in ECU Service", (Throwable)e);
throw new WorkflowException("Exception in ECU Service", (Throwable)e);
}
}
@Override
protected ResourceResolver getResourceResolver(Session session) throws WorkflowException {
try {
HashMap<String, Session> authenticationMap = new HashMap<String, Session>();
authenticationMap.put("user.jcr.session", session);
return this.resourceResolverFactory.getResourceResolver(authenticationMap);
}
catch (Exception e) {
log.debug("Exception in getting Resource Resolver", (Throwable)e);
throw new WorkflowException("Exception in getting Resource Resolver", (Throwable)e);
}
}
protected void bindDocAssuranceService(DocAssuranceService docAssuranceService) {
this.docAssuranceService = docAssuranceService;
}
protected void unbindDocAssuranceService(DocAssuranceService docAssuranceService) {
if (this.docAssuranceService == docAssuranceService) {
this.docAssuranceService = null;
}
}
protected void bindSlingRepository(SlingRepository slingRepository) {
this.slingRepository = slingRepository;
}
protected void unbindSlingRepository(SlingRepository slingRepository) {
if (this.slingRepository == slingRepository) {
this.slingRepository = null;
}
}
}