mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-10 19:43:10 +00:00
Fix various problems with resources potentially not being freed, and other minor fixes suggested by FindBugs
git-svn-id: http://scm.dspace.org/svn/repo/branches/dspace-1_5_x@3036 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
@@ -140,12 +140,13 @@ public class X509Authentication
|
||||
// First look for keystore full of trusted certs.
|
||||
if (keystorePath != null)
|
||||
{
|
||||
FileInputStream fis = null;
|
||||
if (keystorePassword == null)
|
||||
keystorePassword = "";
|
||||
try {
|
||||
KeyStore ks = KeyStore.getInstance("JKS");
|
||||
ks.load(new FileInputStream(keystorePath),
|
||||
keystorePassword.toCharArray());
|
||||
fis = new FileInputStream(keystorePath);
|
||||
ks.load(fis, keystorePassword.toCharArray());
|
||||
caCertKeyStore = ks;
|
||||
}
|
||||
catch (IOException e)
|
||||
@@ -158,14 +159,22 @@ public class X509Authentication
|
||||
log.error("X509Authentication: Failed to extract CA keystore, file="+
|
||||
keystorePath+", error="+e.toString());
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (fis != null)
|
||||
try { fis.close(); } catch (IOException ioe) { }
|
||||
}
|
||||
}
|
||||
|
||||
// Second, try getting public key out of CA cert, if that's configured.
|
||||
if (caCertPath != null)
|
||||
{
|
||||
InputStream is = null;
|
||||
FileInputStream fis = null;
|
||||
try
|
||||
{
|
||||
InputStream is = new BufferedInputStream(new FileInputStream(caCertPath));
|
||||
fis = new FileInputStream(caCertPath);
|
||||
is = new BufferedInputStream(fis);
|
||||
X509Certificate cert = (X509Certificate) CertificateFactory
|
||||
.getInstance("X.509").generateCertificate(is);
|
||||
if (cert != null)
|
||||
@@ -181,6 +190,14 @@ public class X509Authentication
|
||||
log.error("X509Authentication: Failed to extract CA cert, file="+
|
||||
caCertPath+", error="+e.toString());
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (is != null)
|
||||
try { is.close(); } catch (IOException ioe) { }
|
||||
|
||||
if (fis != null)
|
||||
try { fis.close(); } catch (IOException ioe) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user