aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/knowcenter
diff options
context:
space:
mode:
authorpdanner <pdanner@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2010-11-29 14:25:53 +0000
committerpdanner <pdanner@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2010-11-29 14:25:53 +0000
commitcd93f2465a1d4dee4e6a10771bbf5bd5bf73d7ae (patch)
tree20bd8776ae67edd5ba499f3110c7cf22799fd6ed /src/main/java/at/knowcenter
parent6ec570fd52a3b8a35f4ab39d75b3e63cff3124b0 (diff)
downloadpdf-as-3-cd93f2465a1d4dee4e6a10771bbf5bd5bf73d7ae.tar.gz
pdf-as-3-cd93f2465a1d4dee4e6a10771bbf5bd5bf73d7ae.tar.bz2
pdf-as-3-cd93f2465a1d4dee4e6a10771bbf5bd5bf73d7ae.zip
added DynamicSignatureProfile support
added override properties git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@633 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
Diffstat (limited to 'src/main/java/at/knowcenter')
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java69
1 files changed, 48 insertions, 21 deletions
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java b/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java
index 2c2c591..e1a3b8d 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java
@@ -24,12 +24,15 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
+import java.util.Properties;
import java.util.Vector;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import at.gv.egiz.pdfas.api.analyze.NonTextObjectInfo;
+import at.gv.egiz.pdfas.api.commons.DynamicSignatureProfileImpl;
+import at.gv.egiz.pdfas.api.exceptions.PdfAsException;
import at.gv.egiz.pdfas.api.commons.SignatureInformation;
import at.gv.egiz.pdfas.api.timestamp.TimeStamper;
import at.gv.egiz.pdfas.api.xmldsig.ExtendedSignatureInformation;
@@ -48,6 +51,7 @@ import at.gv.egiz.pdfas.impl.input.ByteArrayPdfDataSourceImpl;
import at.gv.egiz.pdfas.impl.input.helper.DataSourceHelper;
import at.gv.egiz.pdfas.utils.PDFASUtils;
import at.gv.egiz.pdfas.web.VerifySessionInformation;
+import at.knowcenter.wag.egov.egiz.cfg.OverridePropertyHolder;
import at.knowcenter.wag.egov.egiz.cfg.SettingsReader;
import at.knowcenter.wag.egov.egiz.exceptions.ConnectorException;
import at.knowcenter.wag.egov.egiz.exceptions.ConnectorFactoryException;
@@ -926,7 +930,14 @@ public abstract class PdfAS
cp.setVerificationTime(verificationTime);
Connector c = at.gv.egiz.pdfas.framework.ConnectorFactory.createConnector(connectorId, cp);
- return c.doVerify(sd, so, dsig);
+ SignatureResponse res = null;
+ try {
+ return c.doVerify(sd, so, dsig);
+ } catch (PdfAsException e) {
+ res = new SignatureResponse();
+ res.setVerificationImpossibleEx(e);
+ }
+ return res;
}
public static SignatureResponse verifyWeb(SignatureHolder signature_holder, String connector, String loc_ref) throws NormalizeException, PDFDocumentException, SignatureException, ConnectorException
@@ -965,7 +976,15 @@ public abstract class PdfAS
String profile = so_to_be_verified.getSignatureTypeDefinition().getType();
Connector c = ConnectorChooser.chooseWebConnectorForVerify(connector, so_to_be_verified.getKZ(), so.id, profile, loc_ref);
- return c.doVerify(sd, so, null);
+ SignatureResponse res = null;
+ try {
+ return c.doVerify(sd, so, null);
+ } catch (PdfAsException e) {
+ res = new SignatureResponse();
+ res.setVerificationImpossibleEx(e);
+ }
+
+ return res;
}
@@ -1078,29 +1097,37 @@ public abstract class PdfAS
// signCommandline(pdfDataSource, dataSink, signatorId, connectorId, profile, pos);
// }
- public static SignatorInformation signCommandline(PdfDataSource pdfDataSource, DataSink dataSink, PdfASID signatorId, String connectorId, final String profile, final String signatureKeyIdentifier, TablePos pos, TimeStamper timeStamper) throws PresentableException
+ public static SignatorInformation signCommandline(PdfDataSource pdfDataSource, DataSink dataSink, PdfASID signatorId, String connectorId, final String profile, final String signatureKeyIdentifier, TablePos pos, TimeStamper timeStamper, Properties overrideProps) throws PresentableException
{
- at.gv.egiz.pdfas.framework.signator.Signator signator = at.gv.egiz.pdfas.framework.SignatorFactory.createSignator(signatorId);
-
- ConnectorParameters cp = new ConnectorParameters();
- cp.setProfileId(profile);
- cp.setSignatureKeyIdentifier(signatureKeyIdentifier);
- Connector c = at.gv.egiz.pdfas.framework.ConnectorFactory.createConnector(connectorId, cp);
-
- // SignatorInformation si = signator.prepareSign(pdfDataSource, profile, pos, ConnectorFactory.needsSIG_ID(connector));
- SignatorInformation si = signator.prepareSign(pdfDataSource, profile, pos, timeStamper);
-
- SignSignatureObject sso = sign(si.getSignatureData(), c, timeStamper);
-
- si.setSignSignatureObject(sso);
-
- signator.finishSign(si, dataSink);
-
- return si;
+ try {
+ at.gv.egiz.pdfas.framework.signator.Signator signator = at.gv.egiz.pdfas.framework.SignatorFactory.createSignator(signatorId);
+ if (overrideProps != null) {
+ OverridePropertyHolder.setOverrideProps(overrideProps);
+ }
+
+ ConnectorParameters cp = new ConnectorParameters();
+ cp.setProfileId(profile);
+ cp.setSignatureKeyIdentifier(signatureKeyIdentifier);
+ Connector c = at.gv.egiz.pdfas.framework.ConnectorFactory.createConnector(connectorId, cp);
+
+ // SignatorInformation si = signator.prepareSign(pdfDataSource, profile, pos, ConnectorFactory.needsSIG_ID(connector));
+ SignatorInformation si = signator.prepareSign(pdfDataSource, profile, pos, timeStamper);
+
+ SignSignatureObject sso = sign(si.getSignatureData(), c, timeStamper);
+
+ si.setSignSignatureObject(sso);
+
+ signator.finishSign(si, dataSink);
+
+ return si;
+ } finally {
+ OverridePropertyHolder.removeProperties();
+ DynamicSignatureProfileImpl.disposeLocalProfile();
+ }
}
public static SignatorInformation signCommandline(PdfDataSource pdfDataSource, DataSink dataSink, PdfASID signatorId, String connectorId, final String profile, TablePos pos) throws PresentableException {
- return signCommandline(pdfDataSource, dataSink, signatorId, connectorId, profile, null, pos, null);
+ return signCommandline(pdfDataSource, dataSink, signatorId, connectorId, profile, null, pos, null, null);
}
/**