aboutsummaryrefslogtreecommitdiff
path: root/signature-standards/sigs-pades/src/main/java/at/gv/egiz
diff options
context:
space:
mode:
authorAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2014-10-23 09:29:16 +0200
committerAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2014-10-23 09:29:16 +0200
commit5501deb7a20fc61901ecd629ae15337e497bb4fd (patch)
tree3310e0bcc9c5cb10b2e32076caee086b5a1863f2 /signature-standards/sigs-pades/src/main/java/at/gv/egiz
parent295078772e6786b5ba1a6933133f977e2e93d3b5 (diff)
downloadpdf-as-4-5501deb7a20fc61901ecd629ae15337e497bb4fd.tar.gz
pdf-as-4-5501deb7a20fc61901ecd629ae15337e497bb4fd.tar.bz2
pdf-as-4-5501deb7a20fc61901ecd629ae15337e497bb4fd.zip
Close Keystore File handle
Diffstat (limited to 'signature-standards/sigs-pades/src/main/java/at/gv/egiz')
-rw-r--r--signature-standards/sigs-pades/src/main/java/at/gv/egiz/pdfas/sigs/pades/PAdESSignerKeystore.java17
1 files changed, 13 insertions, 4 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 220cf6e2..a3240450 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
@@ -82,20 +82,28 @@ public class PAdESSignerKeystore implements IPlainSigner, PAdESConstants {
+ "]");
KeyStore ks = null;
- if(provider == null) {
+ if (provider == null) {
ks = KeyStore.getInstance(type);
} else {
ks = KeyStore.getInstance(type, provider);
}
-
+
if (ks == null) {
throw new PdfAsException("error.pdf.sig.14");
}
if (kspassword == null) {
throw new PdfAsException("error.pdf.sig.15");
}
+ FileInputStream is = null;
+ try {
+ is = new FileInputStream(file);
+ ks.load(is, kspassword.toCharArray());
+ } finally {
+ if (is != null) {
+ is.close();
+ }
+ }
- ks.load(new FileInputStream(file), kspassword.toCharArray());
if (keypassword == null) {
throw new PdfAsException("error.pdf.sig.16");
}
@@ -148,7 +156,8 @@ public class PAdESSignerKeystore implements IPlainSigner, PAdESConstants {
logger.warn("Failed to open Keystore with IAIK provider!");
} catch (Throwable e1) {
logger.error("Keystore IAIK provider error: ", e);
- logger.error("Keystore " + fallBackProvider + " provider error: ", e1);
+ logger.error("Keystore " + fallBackProvider
+ + " provider error: ", e1);
throw new PdfAsException("error.pdf.sig.02", e1);
}
}