aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/gv/egiz
diff options
context:
space:
mode:
authorpdanner <pdanner@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2010-12-06 17:46:57 +0000
committerpdanner <pdanner@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2010-12-06 17:46:57 +0000
commit0572beadfd4805e26114cd92a24492d9cf14fec0 (patch)
treedb0a3676d11e347a5c2b34b4453e0b88de644fb3 /src/main/java/at/gv/egiz
parent9ad21b127c7093a663e697d0f8a66fa9ad7e365b (diff)
downloadpdf-as-3-0572beadfd4805e26114cd92a24492d9cf14fec0.tar.gz
pdf-as-3-0572beadfd4805e26114cd92a24492d9cf14fec0.tar.bz2
pdf-as-3-0572beadfd4805e26114cd92a24492d9cf14fec0.zip
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@687 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
Diffstat (limited to 'src/main/java/at/gv/egiz')
-rw-r--r--src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java130
1 files changed, 60 insertions, 70 deletions
diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java b/src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java
index e630aa3..2c9a9ad 100644
--- a/src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java
+++ b/src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java
@@ -624,58 +624,53 @@ public class PdfAsObject implements PdfAs
* @see PdfAs#prepareSign(SignParameters)
*/
public SignatureDetailInformation prepareSign(SignParameters signParameters) throws PdfAsException {
- try{
- CheckHelper.checkSignParameters(signParameters, true);
-
- if (signParameters.getProfileOverrideProperties() != null) {
- OverridePropertyHolder.setOverrideProps(signParameters.getProfileOverrideProperties());
- }
-
- signParameters.setDocument(PdfAS.applyStrictMode(signParameters.getDocument()));
-
- SignaturePlaceholderData spd = null;
- SignaturePlaceholderContext.setSignaturePlaceholderData(null);
- if (signParameters.isCheckForPlaceholder()) {
- spd = SignaturePlaceholderExtractor.extract(signParameters.getDocument().createInputStream(), signParameters.getPlaceholderId(), signParameters.getPlaceholderMatchMode());
- if (spd != null){
- if (spd.getProfile() != null)
- signParameters.setSignatureProfileId(spd.getProfile());
- if (spd.getType() != null)
- signParameters.setSignatureType(spd.getType());
- if (spd.getKey() != null)
- signParameters.setSignatureKeyIdentifier(spd.getKey());
- }
- }
- CheckHelper.checkSignParameters(signParameters, true);
-
- if (signParameters.getSignatureProfileId() == null)
- {
- SettingsReader settings = SettingsReader.getInstance();
- String defaultProfile = settings.getValueFromKey(SignatureTypes.DEFAULT_TYPE);
- signParameters.setSignatureProfileId(defaultProfile);
+ CheckHelper.checkSignParameters(signParameters, true);
+
+ if (signParameters.getProfileOverrideProperties() != null) {
+ OverridePropertyHolder.setOverrideProps(signParameters.getProfileOverrideProperties());
+ }
+
+ signParameters.setDocument(PdfAS.applyStrictMode(signParameters.getDocument()));
+
+ SignaturePlaceholderData spd = null;
+ SignaturePlaceholderContext.setSignaturePlaceholderData(null);
+ if (signParameters.isCheckForPlaceholder()) {
+ spd = SignaturePlaceholderExtractor.extract(signParameters.getDocument().createInputStream(), signParameters.getPlaceholderId(), signParameters.getPlaceholderMatchMode());
+ if (spd != null){
+ if (spd.getProfile() != null)
+ signParameters.setSignatureProfileId(spd.getProfile());
+ if (spd.getType() != null)
+ signParameters.setSignatureType(spd.getType());
+ if (spd.getKey() != null)
+ signParameters.setSignatureKeyIdentifier(spd.getKey());
}
-
- TablePos pos = null;
- if (spd != null && spd.getTablePos() != null)
- pos = spd.getTablePos();
- else
- pos = PosHelper.formTablePos(signParameters.getSignaturePositioning());
-
- Signator signator = createSignator(signParameters.getSignatureType());
-
- SignatorInformation signatorInfo = signator.prepareSign(
- new PdfDataSourceAdapter(signParameters.getDocument()),
- signParameters.getSignatureProfileId(),
- pos,
- signParameters.getTimeStamperImpl());
-
- SignatureDetailInformationImpl ret = new SignatureDetailInformationImpl();
- ret.setSignatorInformation(signatorInfo);
- return ret;
- } finally {
- OverridePropertyHolder.removeProperties();
- DynamicSignatureProfileImpl.disposeLocalProfile();
}
+ CheckHelper.checkSignParameters(signParameters, true);
+
+ if (signParameters.getSignatureProfileId() == null)
+ {
+ SettingsReader settings = SettingsReader.getInstance();
+ String defaultProfile = settings.getValueFromKey(SignatureTypes.DEFAULT_TYPE);
+ signParameters.setSignatureProfileId(defaultProfile);
+ }
+
+ TablePos pos = null;
+ if (spd != null && spd.getTablePos() != null)
+ pos = spd.getTablePos();
+ else
+ pos = PosHelper.formTablePos(signParameters.getSignaturePositioning());
+
+ Signator signator = createSignator(signParameters.getSignatureType());
+
+ SignatorInformation signatorInfo = signator.prepareSign(
+ new PdfDataSourceAdapter(signParameters.getDocument()),
+ signParameters.getSignatureProfileId(),
+ pos,
+ signParameters.getTimeStamperImpl());
+
+ SignatureDetailInformationImpl ret = new SignatureDetailInformationImpl();
+ ret.setSignatorInformation(signatorInfo);
+ return ret;
}
@@ -700,29 +695,24 @@ public class PdfAsObject implements PdfAs
public SignResult sign(SignParameters signParameters, SignatureDetailInformation signatorInfo)
throws PdfAsException {
- try {
- CheckHelper.checkSignParametersForSignAfterPrepare(signParameters, false);
-
- if (signParameters.getProfileOverrideProperties() != null) {
- OverridePropertyHolder.setOverrideProps(signParameters.getProfileOverrideProperties());
- }
+ CheckHelper.checkSignParametersForSignAfterPrepare(signParameters, false);
+
+ if (signParameters.getProfileOverrideProperties() != null) {
+ OverridePropertyHolder.setOverrideProps(signParameters.getProfileOverrideProperties());
+ }
- String connectorId = CommandlineConnectorChooser.chooseCommandlineConnectorForSign(signParameters.getSignatureDevice());
+ String connectorId = CommandlineConnectorChooser.chooseCommandlineConnectorForSign(signParameters.getSignatureDevice());
- ConnectorParameters cp = new ConnectorParameters();
- cp.setProfileId(signParameters.getSignatureProfileId());
- cp.setSignatureKeyIdentifier(signParameters.getSignatureKeyIdentifier());
- Connector c = at.gv.egiz.pdfas.framework.ConnectorFactory.createConnector(connectorId, cp);
+ ConnectorParameters cp = new ConnectorParameters();
+ cp.setProfileId(signParameters.getSignatureProfileId());
+ cp.setSignatureKeyIdentifier(signParameters.getSignatureKeyIdentifier());
+ Connector c = at.gv.egiz.pdfas.framework.ConnectorFactory.createConnector(connectorId, cp);
- SignatureData sd = new SignatureDataImpl(new PdfDataSourceAdapter(signatorInfo.getSignatureData()), signatorInfo.getSignatureData().getMimeType());
- SignSignatureObject sso = PdfAS.sign(sd, c, signParameters.getTimeStamperImpl());
- ((SignatureDetailInformationImpl)signatorInfo).setSignSignatureObject(sso);
-
- return finishSign(signParameters, signatorInfo);
- } finally {
- OverridePropertyHolder.removeProperties();
- DynamicSignatureProfileImpl.disposeLocalProfile();
- }
+ SignatureData sd = new SignatureDataImpl(new PdfDataSourceAdapter(signatorInfo.getSignatureData()), signatorInfo.getSignatureData().getMimeType());
+ SignSignatureObject sso = PdfAS.sign(sd, c, signParameters.getTimeStamperImpl());
+ ((SignatureDetailInformationImpl)signatorInfo).setSignSignatureObject(sso);
+
+ return finishSign(signParameters, signatorInfo);
}
public SignResult finishSign(SignParameters signParameters, SignatureDetailInformation signatureDetailInformation)