svn commit: r966797 - /ofbiz/branches/release4.0/framework/base/src/base/org/ofbiz/base/util/KeyStoreUtil.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r966797 - /ofbiz/branches/release4.0/framework/base/src/base/org/ofbiz/base/util/KeyStoreUtil.java

doogie-3
Author: doogie
Date: Thu Jul 22 18:46:13 2010
New Revision: 966797

URL: http://svn.apache.org/viewvc?rev=966797&view=rev
Log:
Manually applied fix from trunk for revision: 966785.

Modified:
    ofbiz/branches/release4.0/framework/base/src/base/org/ofbiz/base/util/KeyStoreUtil.java

Modified: ofbiz/branches/release4.0/framework/base/src/base/org/ofbiz/base/util/KeyStoreUtil.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release4.0/framework/base/src/base/org/ofbiz/base/util/KeyStoreUtil.java?rev=966797&r1=966796&r2=966797&view=diff
==============================================================================
--- ofbiz/branches/release4.0/framework/base/src/base/org/ofbiz/base/util/KeyStoreUtil.java (original)
+++ ofbiz/branches/release4.0/framework/base/src/base/org/ofbiz/base/util/KeyStoreUtil.java Thu Jul 22 18:46:13 2010
@@ -50,7 +50,11 @@ public class KeyStoreUtil {
         ComponentConfig.KeystoreInfo ks = ComponentConfig.getKeystoreInfo(componentName, keyStoreName);
         File file = new File(ks.createResourceHandler().getFullLocation());
         FileOutputStream out = new FileOutputStream(file);
-        store.store(out, ks.getPassword().toCharArray());
+        try {
+            store.store(out, ks.getPassword().toCharArray());
+        } finally {
+            out.close();
+        }
     }
 
     public static KeyStore getComponentKeyStore(String componentName, String keyStoreName) throws IOException, GeneralSecurityException, GenericConfigException {
@@ -67,7 +71,12 @@ public class KeyStoreUtil {
             throw new IOException("Invalid keystore type; null");
         }
         KeyStore ks = KeyStore.getInstance(type);
-        ks.load(url.openStream(), password.toCharArray());
+        InputStream in = url.openStream();
+        try {
+            ks.load(in, password.toCharArray());
+        } finally {
+            in.close();
+        }
         return ks;
     }
 
@@ -78,7 +87,12 @@ public class KeyStoreUtil {
             File file = new File(fileName);
             if (file.exists() && file.canRead()) {
                 KeyStore ks = KeyStore.getInstance("jks");
-                ks.load(new FileInputStream(file), password.toCharArray());
+                InputStream in = new FileInputStream(keyFile);
+                try {
+                    ks.load(in, password.toCharArray());
+                } finally {
+                    in.close();
+                }
                 return ks;
             }
         }