aboutsummaryrefslogtreecommitdiff
path: root/signature-standards/sigs-pkcs7detached/src/main/java/at/gv/egiz
diff options
context:
space:
mode:
Diffstat (limited to 'signature-standards/sigs-pkcs7detached/src/main/java/at/gv/egiz')
-rw-r--r--signature-standards/sigs-pkcs7detached/src/main/java/at/gv/egiz/pdfas/sigs/pkcs7detached/PKCS7DetachedSigner.java14
-rw-r--r--signature-standards/sigs-pkcs7detached/src/main/java/at/gv/egiz/pdfas/sigs/pkcs7detached/PKCS7DetachedVerifier.java11
2 files changed, 9 insertions, 16 deletions
diff --git a/signature-standards/sigs-pkcs7detached/src/main/java/at/gv/egiz/pdfas/sigs/pkcs7detached/PKCS7DetachedSigner.java b/signature-standards/sigs-pkcs7detached/src/main/java/at/gv/egiz/pdfas/sigs/pkcs7detached/PKCS7DetachedSigner.java
index 6411fe67..df792256 100644
--- a/signature-standards/sigs-pkcs7detached/src/main/java/at/gv/egiz/pdfas/sigs/pkcs7detached/PKCS7DetachedSigner.java
+++ b/signature-standards/sigs-pkcs7detached/src/main/java/at/gv/egiz/pdfas/sigs/pkcs7detached/PKCS7DetachedSigner.java
@@ -14,7 +14,6 @@ import iaik.x509.X509Certificate;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.OutputStream;
import java.security.KeyStore;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
@@ -22,8 +21,6 @@ import java.security.cert.Certificate;
import java.util.Date;
import org.apache.pdfbox.pdmodel.interactive.digitalsignature.PDSignature;
-import org.bouncycastle.cms.CMSException;
-import org.bouncycastle.cms.CMSProcessable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -51,7 +48,7 @@ public class PKCS7DetachedSigner implements IPlainSigner {
privKey = (PrivateKey) ks.getKey(alias, keypassword.toCharArray());
cert = new X509Certificate(ks.getCertificate(alias).getEncoded());
} catch (Throwable e) {
- throw new PdfAsException("Failed to get KeyStore", e);
+ throw new PdfAsException("error.pdf.sig.02", e);
}
}
@@ -61,6 +58,7 @@ public class PKCS7DetachedSigner implements IPlainSigner {
public byte[] sign(byte[] input, int[] byteRange) throws PdfAsException {
try {
+ logger.info("Creating PKCS7 signature.");
IssuerAndSerialNumber issuer = new IssuerAndSerialNumber(cert);
SignerInfo signer1 = new SignerInfo(issuer, AlgorithmID.sha256,
AlgorithmID.ecdsa_With_SHA256,
@@ -84,14 +82,14 @@ public class PKCS7DetachedSigner implements IPlainSigner {
while ((r = dataIs.read(buf)) > 0)
; // skip data
ContentInfo ci = new ContentInfo(si);
-
+ logger.info("PKCS7 signature done.");
return ci.getEncoded();
} catch (NoSuchAlgorithmException e) {
- throw new PdfAsSignatureException("", e);
+ throw new PdfAsSignatureException("error.pdf.sig.01", e);
} catch (iaik.cms.CMSException e) {
- throw new PdfAsSignatureException("", e);
+ throw new PdfAsSignatureException("error.pdf.sig.01", e);
} catch (IOException e) {
- throw new PdfAsSignatureException("", e);
+ throw new PdfAsSignatureException("error.pdf.sig.01", e);
}
}
diff --git a/signature-standards/sigs-pkcs7detached/src/main/java/at/gv/egiz/pdfas/sigs/pkcs7detached/PKCS7DetachedVerifier.java b/signature-standards/sigs-pkcs7detached/src/main/java/at/gv/egiz/pdfas/sigs/pkcs7detached/PKCS7DetachedVerifier.java
index 3d0aed42..7d5c029a 100644
--- a/signature-standards/sigs-pkcs7detached/src/main/java/at/gv/egiz/pdfas/sigs/pkcs7detached/PKCS7DetachedVerifier.java
+++ b/signature-standards/sigs-pkcs7detached/src/main/java/at/gv/egiz/pdfas/sigs/pkcs7detached/PKCS7DetachedVerifier.java
@@ -40,16 +40,11 @@ public class PKCS7DetachedVerifier implements IVerifyFilter {
SignedData signedData = new SignedData(contentData, new AlgorithmID[] {
AlgorithmID.sha256
- });
-
- FileOutputStream fos = new FileOutputStream("/tmp/verify.bin");
- fos.write(signatureContent);
- fos.close();
-
+ });
ContentInfo ci = new ContentInfo(new ByteArrayInputStream(
signatureContent));
if (!ci.getContentType().equals(ObjectID.cms_signedData)) {
- throw new PdfAsException("No Signed DATA");
+ throw new PdfAsException("error.pdf.verify.01");
}
//SignedData signedData = (SignedData)ci.getContent();
//signedData.setContent(contentData);
@@ -98,7 +93,7 @@ public class PKCS7DetachedVerifier implements IVerifyFilter {
return result;
} catch (Throwable e) {
- throw new PdfAsException("Verify failed", e);
+ throw new PdfAsException("error.pdf.verify.02", e);
}
}