aboutsummaryrefslogtreecommitdiff
path: root/signature-standards
diff options
context:
space:
mode:
Diffstat (limited to 'signature-standards')
-rw-r--r--signature-standards/sigs-pades/src/main/java/at/gv/egiz/pdfas/sigs/pades/PAdESSignerKeystore.java13
-rw-r--r--signature-standards/sigs-pades/src/main/java/at/gv/egiz/pdfas/sigs/pades/PAdESVerifier.java3
-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
4 files changed, 17 insertions, 24 deletions
diff --git a/signature-standards/sigs-pades/src/main/java/at/gv/egiz/pdfas/sigs/pades/PAdESSignerKeystore.java b/signature-standards/sigs-pades/src/main/java/at/gv/egiz/pdfas/sigs/pades/PAdESSignerKeystore.java
index 5ae0ed76..89293fa1 100644
--- a/signature-standards/sigs-pades/src/main/java/at/gv/egiz/pdfas/sigs/pades/PAdESSignerKeystore.java
+++ b/signature-standards/sigs-pades/src/main/java/at/gv/egiz/pdfas/sigs/pades/PAdESSignerKeystore.java
@@ -53,7 +53,7 @@ public class PAdESSignerKeystore 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);
}
}
@@ -124,6 +124,7 @@ public class PAdESSignerKeystore implements IPlainSigner {
si.addSignerInfo(signer1);
InputStream dataIs = si.getInputStream();
byte[] buf = new byte[1024];
+ @SuppressWarnings("unused")
int r;
while ((r = dataIs.read(buf)) > 0)
; // skip data
@@ -131,15 +132,15 @@ public class PAdESSignerKeystore implements IPlainSigner {
return ci.getEncoded();
} catch (NoSuchAlgorithmException e) {
- throw new PdfAsSignatureException("Failed to generate Signature", e);
+ throw new PdfAsSignatureException("error.pdf.sig.01", e);
} catch (iaik.cms.CMSException e) {
- throw new PdfAsSignatureException("Failed to generate Signature", e);
+ throw new PdfAsSignatureException("error.pdf.sig.01", e);
} catch (IOException e) {
- throw new PdfAsSignatureException("Failed to generate Signature", e);
+ throw new PdfAsSignatureException("error.pdf.sig.01", e);
} catch (CertificateException e) {
- throw new PdfAsSignatureException("Failed to generate Signature", e);
+ throw new PdfAsSignatureException("error.pdf.sig.01", e);
} catch (CodingException e) {
- throw new PdfAsSignatureException("Failed to generate Signature", e);
+ throw new PdfAsSignatureException("error.pdf.sig.01", e);
}
}
diff --git a/signature-standards/sigs-pades/src/main/java/at/gv/egiz/pdfas/sigs/pades/PAdESVerifier.java b/signature-standards/sigs-pades/src/main/java/at/gv/egiz/pdfas/sigs/pades/PAdESVerifier.java
index 6e79a1a0..52a58d56 100644
--- a/signature-standards/sigs-pades/src/main/java/at/gv/egiz/pdfas/sigs/pades/PAdESVerifier.java
+++ b/signature-standards/sigs-pades/src/main/java/at/gv/egiz/pdfas/sigs/pades/PAdESVerifier.java
@@ -1,6 +1,5 @@
package at.gv.egiz.pdfas.sigs.pades;
-import iaik.security.provider.IAIK;
import iaik.x509.X509Certificate;
import java.util.ArrayList;
@@ -174,7 +173,7 @@ public class PAdESVerifier implements IVerifyFilter {
resultList.add(result);
}
} catch (Throwable e) {
- e.printStackTrace();
+ throw new PdfAsException("error.pdf.verify.02", e);
}
return resultList;
}
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);
}
}