aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpdanner <pdanner@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2010-12-10 13:08:35 +0000
committerpdanner <pdanner@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2010-12-10 13:08:35 +0000
commit1faaccc18a3ccbc7b827da8956fb9783e9713228 (patch)
tree1fe12d1340e681b84d18e1e934e149997de3c904 /src
parent800f1a58123b1f48cc6c6c7c910ae1d137a1790d (diff)
downloadpdf-as-3-1faaccc18a3ccbc7b827da8956fb9783e9713228.tar.gz
pdf-as-3-1faaccc18a3ccbc7b827da8956fb9783e9713228.tar.bz2
pdf-as-3-1faaccc18a3ccbc7b827da8956fb9783e9713228.zip
Removed unnecessary parameters from ReconstructXMLDsigAfterAnalysisParameters; Added getReconstructedXMLDsig() method to VerifyResult
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@700 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/gv/egiz/pdfas/api/verify/VerifyResult.java10
-rw-r--r--src/main/java/at/gv/egiz/pdfas/api/xmldsig/ReconstructXMLDsigAfterAnalysisParameters.java52
-rw-r--r--src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java16
-rw-r--r--src/main/java/at/gv/egiz/pdfas/impl/api/internal/PdfAsInternalObject.java2
-rw-r--r--src/main/java/at/gv/egiz/pdfas/impl/api/verify/VerifyResultAdapter.java14
-rw-r--r--src/main/java/demo/SignatureVerificationDemo.java2
6 files changed, 28 insertions, 68 deletions
diff --git a/src/main/java/at/gv/egiz/pdfas/api/verify/VerifyResult.java b/src/main/java/at/gv/egiz/pdfas/api/verify/VerifyResult.java
index bd62d4a..73b3968 100644
--- a/src/main/java/at/gv/egiz/pdfas/api/verify/VerifyResult.java
+++ b/src/main/java/at/gv/egiz/pdfas/api/verify/VerifyResult.java
@@ -3,9 +3,11 @@ package at.gv.egiz.pdfas.api.verify;
import java.util.Date;
import java.util.List;
+import at.gv.egiz.pdfas.api.PdfAs;
import at.gv.egiz.pdfas.api.analyze.NonTextObjectInfo;
import at.gv.egiz.pdfas.api.commons.SignatureInformation;
import at.gv.egiz.pdfas.api.exceptions.PdfAsException;
+import at.gv.egiz.pdfas.api.xmldsig.XMLDsigData;
/**
* Encapsulates the data of a verification of one signature.
@@ -142,5 +144,13 @@ public interface VerifyResult extends SignatureInformation
*/
public boolean hasNonTextualObjects();
+ /**
+ * Get the reconstructed xmldsig XML data. The reconstruction is done during the verification process.
+ *
+ * @see PdfAs#reconstructXMLDSIG(at.gv.egiz.pdfas.api.xmldsig.ReconstructXMLDsigParameters)
+ * @see PdfAs#reconstructXMLDSIG(at.gv.egiz.pdfas.api.xmldsig.ReconstructXMLDsigAfterAnalysisParameters)
+ * @return
+ */
+ public XMLDsigData getReconstructedXMLDsig();
}
diff --git a/src/main/java/at/gv/egiz/pdfas/api/xmldsig/ReconstructXMLDsigAfterAnalysisParameters.java b/src/main/java/at/gv/egiz/pdfas/api/xmldsig/ReconstructXMLDsigAfterAnalysisParameters.java
index 1f0ecc5..1975a27 100644
--- a/src/main/java/at/gv/egiz/pdfas/api/xmldsig/ReconstructXMLDsigAfterAnalysisParameters.java
+++ b/src/main/java/at/gv/egiz/pdfas/api/xmldsig/ReconstructXMLDsigAfterAnalysisParameters.java
@@ -1,7 +1,5 @@
package at.gv.egiz.pdfas.api.xmldsig;
-import java.util.Date;
-
import at.gv.egiz.pdfas.api.analyze.AnalyzeResult;
import at.gv.egiz.pdfas.api.commons.Constants;
@@ -30,22 +28,6 @@ public class ReconstructXMLDsigAfterAnalysisParameters {
protected String signatureDevice = Constants.SIGNATURE_DEVICE_MOA;
/**
- * Allows to pass a VerificationTime to the signature device.
- */
- protected Date verificationTime = null;
-
- /**
- * Tells the signature device (e.g. MOA) to return the signature hash input
- * data (which is the probably transformed signed data).
- *
- * <p>
- * Note that this forces MOA to return the potentially large signature data to
- * be returned in the result XML, which may result in very bad performance.
- * </p>
- */
- protected boolean returnHashInputData = false;
-
- /**
* @return the analyzeResult
*/
public AnalyzeResult getAnalyzeResult()
@@ -78,38 +60,4 @@ public class ReconstructXMLDsigAfterAnalysisParameters {
{
this.signatureDevice = signatureDevice;
}
-
- /**
- * @return the verificationTime
- */
- public Date getVerificationTime()
- {
- return this.verificationTime;
- }
-
- /**
- * @param verificationTime the verificationTime to set
- */
- public void setVerificationTime(Date verificationTime)
- {
- this.verificationTime = verificationTime;
- }
-
- /**
- * @return the returnHashInputData
- */
- public boolean isReturnHashInputData()
- {
- return this.returnHashInputData;
- }
-
- /**
- * @param returnHashInputData
- * the returnHashInputData to set
- */
- public void setReturnHashInputData(boolean returnHashInputData)
- {
- this.returnHashInputData = returnHashInputData;
- }
-
}
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 dc6e106..1cb158e 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
@@ -370,9 +370,7 @@ public class PdfAsObject implements PdfAs
ReconstructXMLDsigAfterAnalysisParameters reconstructParams,
VerifyAfterAnalysisParameters verifyAfterAnalysisParameters) {
reconstructParams.setAnalyzeResult(verifyAfterAnalysisParameters.getAnalyzeResult());
- reconstructParams.setReturnHashInputData(verifyAfterAnalysisParameters.isReturnHashInputData());
reconstructParams.setSignatureDevice(verifyAfterAnalysisParameters.getSignatureDevice());
- reconstructParams.setVerificationTime(verifyAfterAnalysisParameters.getVerificationTime());
}
/**
@@ -515,20 +513,12 @@ public class PdfAsObject implements PdfAs
AnalyzeResult ar = analyze(analyzeParameters);
ReconstructXMLDsigAfterAnalysisParameters rxaap = new ReconstructXMLDsigAfterAnalysisParameters();
- fillReconstructXMLDsigAfterAnalysisParametersWithReconstructXMLDsigParameters(rxaap, reconstructXMLDsigParameters);
+ rxaap.setSignatureDevice(reconstructXMLDsigParameters.getSignatureDevice());
rxaap.setAnalyzeResult(ar);
return reconstructXMLDSIG(rxaap);
}
- protected void fillReconstructXMLDsigAfterAnalysisParametersWithReconstructXMLDsigParameters(
- ReconstructXMLDsigAfterAnalysisParameters rxaap,
- ReconstructXMLDsigParameters reconstructXMLDsigParameters) {
- rxaap.setReturnHashInputData(reconstructXMLDsigParameters.isReturnHashInputData());
- rxaap.setSignatureDevice(reconstructXMLDsigParameters.getSignatureDevice());
- rxaap.setVerificationTime(reconstructXMLDsigParameters.getVerificationTime());
- }
-
/**
* @see PdfAs#reconstructXMLDSIG(ReconstructXMLDsigAfterAnalysisParameters)
*/
@@ -579,7 +569,7 @@ public class PdfAsObject implements PdfAs
ExtendedSignatureInformation extSigInfo = (ExtendedSignatureInformation)extSignatures.get(i);
SignatureHolder holder = (SignatureHolder) extSigInfo.getSignatureInformation().getInternalSignatureInformation();
- VerifyResult vr = new VerifyResultAdapter(response, holder, verifyAfterReconstructXMLDsigParameters.getVerificationTime());
+ VerifyResult vr = new VerifyResultAdapter(response, holder, verifyAfterReconstructXMLDsigParameters.getVerificationTime(), extSigInfo.getXmlDsigData());
vr.setNonTextualObjects( extSigInfo.getSignatureInformation().getNonTextualObjects());
vrs.add(vr);
@@ -589,7 +579,7 @@ public class PdfAsObject implements PdfAs
ExtendedSignatureInformation extSigInfo = (ExtendedSignatureInformation)extSignatures.get(verifySignatureIndex);
SignatureHolder holder = (SignatureHolder) extSigInfo.getSignatureInformation().getInternalSignatureInformation();
- VerifyResult vr = new VerifyResultAdapter(response, holder, verifyAfterReconstructXMLDsigParameters.getVerificationTime());
+ VerifyResult vr = new VerifyResultAdapter(response, holder, verifyAfterReconstructXMLDsigParameters.getVerificationTime(), extSigInfo.getXmlDsigData());
vr.setNonTextualObjects( extSigInfo.getSignatureInformation().getNonTextualObjects());
vrs.add(vr);
diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/internal/PdfAsInternalObject.java b/src/main/java/at/gv/egiz/pdfas/impl/api/internal/PdfAsInternalObject.java
index 4e36c24..747f6b0 100644
--- a/src/main/java/at/gv/egiz/pdfas/impl/api/internal/PdfAsInternalObject.java
+++ b/src/main/java/at/gv/egiz/pdfas/impl/api/internal/PdfAsInternalObject.java
@@ -272,7 +272,7 @@ public class PdfAsInternalObject implements PdfAsInternal {
Properties props = new Properties();
props.setProperty(BKUPostConnection.RESPONSE_STRING_KEY, xmlResponse);
SignatureResponse sigResponse = local_conn.analyzeVerifyResponse(props);
- return new VerifyResultAdapter(sigResponse, holder, null);
+ return new VerifyResultAdapter(sigResponse, holder, null, null); // timestamp and xmldsig not needed here
}
/**
diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/verify/VerifyResultAdapter.java b/src/main/java/at/gv/egiz/pdfas/impl/api/verify/VerifyResultAdapter.java
index b640bc7..265c916 100644
--- a/src/main/java/at/gv/egiz/pdfas/impl/api/verify/VerifyResultAdapter.java
+++ b/src/main/java/at/gv/egiz/pdfas/impl/api/verify/VerifyResultAdapter.java
@@ -14,6 +14,7 @@ import org.apache.commons.logging.LogFactory;
import at.gv.egiz.pdfas.api.exceptions.PdfAsException;
import at.gv.egiz.pdfas.api.verify.SignatureCheck;
import at.gv.egiz.pdfas.api.verify.VerifyResult;
+import at.gv.egiz.pdfas.api.xmldsig.XMLDsigData;
import at.gv.egiz.pdfas.impl.api.commons.SignatureInformationAdapter;
import at.knowcenter.wag.egov.egiz.exceptions.SettingNotFoundException;
import at.knowcenter.wag.egov.egiz.pdf.BinarySignatureHolder;
@@ -38,6 +39,8 @@ public class VerifyResultAdapter extends SignatureInformationAdapter implements
protected Date vTime = null;
private String timestamp;
+
+ private XMLDsigData xmlDsigData;
/**
@@ -49,12 +52,14 @@ public class VerifyResultAdapter extends SignatureInformationAdapter implements
* The SignatureHolder.
* @param verificationTime
* The time of verification. This is directly returned by {@link #getVerificationTime()}
+ * @param xmlDsigData
*/
- public VerifyResultAdapter(SignatureResponse sigRes, SignatureHolder sh, Date verificationTime)
+ public VerifyResultAdapter(SignatureResponse sigRes, SignatureHolder sh, Date verificationTime, XMLDsigData xmlDsigData)
{
super(sh);
this.sigRes = sigRes;
this.vTime = verificationTime;
+ this.xmlDsigData = xmlDsigData;
if (sh instanceof BinarySignatureHolder) {
this.timestamp = ((BinarySignatureHolder)sh).getSignatureObject().getTimeStamp();
}
@@ -169,5 +174,12 @@ public class VerifyResultAdapter extends SignatureInformationAdapter implements
public boolean isVerificationDone() {
return this.sigRes.getVerificationImpossibleEx() == null;
}
+
+ /**
+ * @see VerifyResult#getReconstructedXMLDsig()
+ */
+ public XMLDsigData getReconstructedXMLDsig() {
+ return this.xmlDsigData;
+ }
}
diff --git a/src/main/java/demo/SignatureVerificationDemo.java b/src/main/java/demo/SignatureVerificationDemo.java
index b1c11c7..6abb37e 100644
--- a/src/main/java/demo/SignatureVerificationDemo.java
+++ b/src/main/java/demo/SignatureVerificationDemo.java
@@ -3,7 +3,6 @@ package demo;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
-import java.util.Date;
import java.util.Iterator;
import java.util.List;
@@ -114,6 +113,7 @@ public class SignatureVerificationDemo {
// retrieve reconstructed signature
ReconstructXMLDsigAfterAnalysisParameters recstrParams = new ReconstructXMLDsigAfterAnalysisParameters();
+ recstrParams.setSignatureDevice(Constants.SIGNATURE_DEVICE_BKU);
recstrParams.setAnalyzeResult(analyzeResult);
ReconstructXMLDsigResult recstrResult = pdfasAPI.reconstructXMLDSIG(recstrParams);