From 5501deb7a20fc61901ecd629ae15337e497bb4fd Mon Sep 17 00:00:00 2001 From: Andreas Fitzek Date: Thu, 23 Oct 2014 09:29:16 +0200 Subject: Close Keystore File handle --- .../gv/egiz/pdfas/sigs/pades/PAdESSignerKeystore.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'signature-standards/sigs-pades/src') 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); } } -- cgit v1.2.3