aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib
diff options
context:
space:
mode:
authorAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2014-10-30 17:15:54 +0100
committerAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2014-10-30 17:15:54 +0100
commitfb3344c1e4d4ac8e8a6aa5605d052cee8cd4c3b1 (patch)
tree01e04f2f9e9286c02bbc55699d027150180bbe01 /pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib
parente123b037e65b336c677c0a66125ae85f5827417a (diff)
downloadpdf-as-4-fb3344c1e4d4ac8e8a6aa5605d052cee8cd4c3b1.tar.gz
pdf-as-4-fb3344c1e4d4ac8e8a6aa5605d052cee8cd4c3b1.tar.bz2
pdf-as-4-fb3344c1e4d4ac8e8a6aa5605d052cee8cd4c3b1.zip
Introduced Process Information Map in PDFASError and SignResult
Diffstat (limited to 'pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib')
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/sign/SignResult.java3
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/ErrorExtractor.java21
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsImpl.java20
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/SignResultImpl.java8
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/status/OperationStatus.java5
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/status/RequestedSignature.java7
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/util/SignatureUtils.java4
7 files changed, 51 insertions, 17 deletions
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/sign/SignResult.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/sign/SignResult.java
index 8084f8f1..d2dc896e 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/sign/SignResult.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/sign/SignResult.java
@@ -24,6 +24,7 @@
package at.gv.egiz.pdfas.lib.api.sign;
import java.security.cert.X509Certificate;
+import java.util.Map;
import at.gv.egiz.pdfas.lib.api.SignaturePosition;
@@ -52,4 +53,6 @@ public interface SignResult {
* return null if no position information is available.
*/
public SignaturePosition getSignaturePosition();
+
+ public Map<String, String> getProcessInformations();
}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/ErrorExtractor.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/ErrorExtractor.java
index 6708fc5b..9b2a8d79 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/ErrorExtractor.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/ErrorExtractor.java
@@ -7,6 +7,7 @@ import at.gv.egiz.pdfas.common.exceptions.ErrorConstants;
import at.gv.egiz.pdfas.common.exceptions.PDFASError;
import at.gv.egiz.pdfas.common.exceptions.PdfAsMOAException;
import at.gv.egiz.pdfas.common.exceptions.SLPdfAsException;
+import at.gv.egiz.pdfas.lib.impl.status.OperationStatus;
public class ErrorExtractor implements ErrorConstants {
@@ -48,7 +49,7 @@ public class ErrorExtractor implements ErrorConstants {
return null;
}
- public static PDFASError searchPdfAsError(Throwable e) {
+ public static PDFASError searchPdfAsError(Throwable e, OperationStatus status) {
Throwable cur = e;
PDFASError err = null;
@@ -68,6 +69,11 @@ public class ErrorExtractor implements ErrorConstants {
}
if(err != null) {
+
+ if(status != null) {
+ err.getProcessInformations().putAll(status.getMetaInformations());
+ }
+
return err;
}
@@ -89,11 +95,22 @@ public class ErrorExtractor implements ErrorConstants {
}
if (err != null) {
+
+ if(status != null) {
+ err.getProcessInformations().putAll(status.getMetaInformations());
+ }
+
return err;
}
logger.info("Cannot extract correct failure code from: ", e);
- return new PDFASError(ERROR_GENERIC, e);
+ err = new PDFASError(ERROR_GENERIC, e);
+
+ if(status != null) {
+ err.getProcessInformations().putAll(status.getMetaInformations());
+ }
+
+ return err;
}
}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsImpl.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsImpl.java
index 4828bae3..aa524cc9 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsImpl.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/PdfAsImpl.java
@@ -190,7 +190,7 @@ public class PdfAsImpl implements PdfAs, IConfigurationConstants,
} catch (Throwable e) {
logger.error("Failed to create signature [" + e.getMessage() + "]",
e);
- throw ErrorExtractor.searchPdfAsError(e);
+ throw ErrorExtractor.searchPdfAsError(e, status);
} finally {
if (status != null) {
status.clear();
@@ -217,7 +217,7 @@ public class PdfAsImpl implements PdfAs, IConfigurationConstants,
try {
return backend.getVerifier().verify(parameter);
} catch (Throwable e) {
- throw ErrorExtractor.searchPdfAsError(e);
+ throw ErrorExtractor.searchPdfAsError(e, null);
}
}
@@ -230,7 +230,7 @@ public class PdfAsImpl implements PdfAs, IConfigurationConstants,
verifySignParameter(parameter);
StatusRequestImpl request = new StatusRequestImpl();
-
+ OperationStatus status = null;
try {
// Status initialization
if (!(parameter.getConfiguration() instanceof ISettings)) {
@@ -248,7 +248,7 @@ public class PdfAsImpl implements PdfAs, IConfigurationConstants,
}
ISettings settings = (ISettings) parameter.getConfiguration();
- OperationStatus status = new OperationStatus(settings, parameter,
+ status = new OperationStatus(settings, parameter,
backend);
IPdfSigner signer = backend.getPdfSigner();
@@ -267,7 +267,7 @@ public class PdfAsImpl implements PdfAs, IConfigurationConstants,
return request;
} catch (Throwable e) {
logger.error("startSign", e);
- throw ErrorExtractor.searchPdfAsError(e);
+ throw ErrorExtractor.searchPdfAsError(e, status);
}
}
@@ -329,7 +329,7 @@ public class PdfAsImpl implements PdfAs, IConfigurationConstants,
} catch (Throwable e) {
logger.error("process", e);
- throw ErrorExtractor.searchPdfAsError(e);
+ throw ErrorExtractor.searchPdfAsError(e, status);
}
} else if (request.needSignature()) {
request.setNeedSignature(false);
@@ -379,7 +379,7 @@ public class PdfAsImpl implements PdfAs, IConfigurationConstants,
return createSignResult(status);
} catch (IOException e) {
// new PdfAsException("error.pdf.sig.06", e);
- throw ErrorExtractor.searchPdfAsError(e);
+ throw ErrorExtractor.searchPdfAsError(e, status);
} finally {
if (status != null) {
status.clear();
@@ -456,7 +456,7 @@ public class PdfAsImpl implements PdfAs, IConfigurationConstants,
.getCertificate());
result.setSignaturePosition(status.getRequestedSignature()
.getSignaturePosition());
-
+ result.getProcessInformations().putAll(status.getMetaInformations());
return result;
}
@@ -499,10 +499,10 @@ public class PdfAsImpl implements PdfAs, IConfigurationConstants,
resolution, status, requestedSignature);
} catch (PdfAsException e) {
logger.error("PDF-AS Exception", e);
- throw ErrorExtractor.searchPdfAsError(e);
+ throw ErrorExtractor.searchPdfAsError(e, status);
} catch (Throwable e) {
logger.error("Throwable Exception", e);
- throw ErrorExtractor.searchPdfAsError(e);
+ throw ErrorExtractor.searchPdfAsError(e, status);
}
}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/SignResultImpl.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/SignResultImpl.java
index f713eb6a..44992c2b 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/SignResultImpl.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/SignResultImpl.java
@@ -24,6 +24,8 @@
package at.gv.egiz.pdfas.lib.impl;
import java.security.cert.X509Certificate;
+import java.util.HashMap;
+import java.util.Map;
import at.gv.egiz.pdfas.lib.api.SignaturePosition;
import at.gv.egiz.pdfas.lib.api.sign.SignResult;
@@ -32,6 +34,7 @@ public class SignResultImpl implements SignResult {
protected X509Certificate certificate;
protected SignaturePosition position;
+ protected Map<String, String> processInfo = new HashMap<String, String>();
public SignResultImpl() {
}
@@ -52,4 +55,9 @@ public class SignResultImpl implements SignResult {
this.position = position;
}
+ @Override
+ public Map<String, String> getProcessInformations() {
+ return processInfo;
+ }
+
}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/status/OperationStatus.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/status/OperationStatus.java
index 7b2ce69c..ecdddfa1 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/status/OperationStatus.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/status/OperationStatus.java
@@ -54,6 +54,7 @@ public class OperationStatus implements Serializable {
private RequestedSignature requestedSignature;
private Calendar signingDate;
private PDFASBackend backend;
+ private Map<String, String> metaInformations = new HashMap<String, String>();
public OperationStatus(ISettings configuration, SignParameter signParameter, PDFASBackend backend) {
this.configuration = configuration;
@@ -169,4 +170,8 @@ public class OperationStatus implements Serializable {
}
return null;
}
+
+ public Map<String, String> getMetaInformations() {
+ return metaInformations;
+ }
}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/status/RequestedSignature.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/status/RequestedSignature.java
index c9cab906..8226d7e9 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/status/RequestedSignature.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/impl/status/RequestedSignature.java
@@ -92,7 +92,8 @@ public class RequestedSignature implements ICertificateProvider {
public void setSignaturePosition(SignaturePosition signaturePosition) {
this.signaturePosition = signaturePosition;
}
-
-
-
+
+ public OperationStatus getStatus() {
+ return status;
+ }
}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/util/SignatureUtils.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/util/SignatureUtils.java
index cdc7f11e..14dbdd16 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/util/SignatureUtils.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/util/SignatureUtils.java
@@ -46,14 +46,14 @@ public class SignatureUtils implements ErrorConstants {
VerifyResultImpl verifyResult = new VerifyResultImpl();
//results.add(verifyResult);
try {
- logger.info("Signature Algo: {}, Digest {}", signedData
+ logger.debug("Signature Algo: {}, Digest {}", signedData
.getSignerInfos()[0].getSignatureAlgorithm(),
signedData.getSignerInfos()[0].getDigestAlgorithm());
// verify the signature for SignerInfo at index i
X509Certificate signer_cert = signedData.verify(0);
// if the signature is OK the certificate of the
// signer is returned
- logger.info("Signature OK from signer: "
+ logger.debug("Signature OK from signer: "
+ signer_cert.getSubjectDN());
verifyResult.setSignerCertificate(signer_cert);