You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by mj...@apache.org on 2017/10/29 05:22:30 UTC

[1/4] incubator-guacamole-client git commit: GUACAMOLE-362: Fix resource leak in FileInputStream when reading private key.

Repository: incubator-guacamole-client
Updated Branches:
  refs/heads/staging/0.9.14-incubating 1a7f85ae5 -> 393c70f23


GUACAMOLE-362: Fix resource leak in FileInputStream when reading private key.


Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/commit/5c0c8239
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/5c0c8239
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/5c0c8239

Branch: refs/heads/staging/0.9.14-incubating
Commit: 5c0c823913a1d77e4f72bf3212f0f7a1032cf1e1
Parents: 1a7f85a
Author: Nick Couchman <vn...@apache.org>
Authored: Sat Oct 28 09:15:58 2017 -0400
Committer: Nick Couchman <vn...@apache.org>
Committed: Sat Oct 28 09:15:58 2017 -0400

----------------------------------------------------------------------
 .../apache/guacamole/auth/cas/conf/PrivateKeyGuacamoleProperty.java | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/5c0c8239/extensions/guacamole-auth-cas/src/main/java/org/apache/guacamole/auth/cas/conf/PrivateKeyGuacamoleProperty.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-cas/src/main/java/org/apache/guacamole/auth/cas/conf/PrivateKeyGuacamoleProperty.java b/extensions/guacamole-auth-cas/src/main/java/org/apache/guacamole/auth/cas/conf/PrivateKeyGuacamoleProperty.java
index bd0bd69..78da89e 100644
--- a/extensions/guacamole-auth-cas/src/main/java/org/apache/guacamole/auth/cas/conf/PrivateKeyGuacamoleProperty.java
+++ b/extensions/guacamole-auth-cas/src/main/java/org/apache/guacamole/auth/cas/conf/PrivateKeyGuacamoleProperty.java
@@ -60,6 +60,7 @@ public abstract class PrivateKeyGuacamoleProperty implements GuacamoleProperty<P
             for (int readBytes; (readBytes = keyStreamIn.read(keyBuffer)) != -1;)
                 keyStreamOut.write(keyBuffer, 0, readBytes);
 
+            keyStreamIn.close();
             final byte[] keyBytes = keyStreamOut.toByteArray();
 
             // Set up decryption infrastructure


[2/4] incubator-guacamole-client git commit: GUACAMOLE-362: Move close to finally block.

Posted by mj...@apache.org.
GUACAMOLE-362: Move close to finally block.


Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/commit/91e57027
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/91e57027
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/91e57027

Branch: refs/heads/staging/0.9.14-incubating
Commit: 91e570276889bd3b83e8420be7604ee7817a3965
Parents: 5c0c823
Author: Nick Couchman <vn...@apache.org>
Authored: Sat Oct 28 14:04:13 2017 -0400
Committer: Nick Couchman <vn...@apache.org>
Committed: Sat Oct 28 14:04:13 2017 -0400

----------------------------------------------------------------------
 .../cas/conf/PrivateKeyGuacamoleProperty.java   | 51 +++++++++++---------
 1 file changed, 28 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/91e57027/extensions/guacamole-auth-cas/src/main/java/org/apache/guacamole/auth/cas/conf/PrivateKeyGuacamoleProperty.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-cas/src/main/java/org/apache/guacamole/auth/cas/conf/PrivateKeyGuacamoleProperty.java b/extensions/guacamole-auth-cas/src/main/java/org/apache/guacamole/auth/cas/conf/PrivateKeyGuacamoleProperty.java
index 78da89e..d71ae1a 100644
--- a/extensions/guacamole-auth-cas/src/main/java/org/apache/guacamole/auth/cas/conf/PrivateKeyGuacamoleProperty.java
+++ b/extensions/guacamole-auth-cas/src/main/java/org/apache/guacamole/auth/cas/conf/PrivateKeyGuacamoleProperty.java
@@ -49,39 +49,44 @@ public abstract class PrivateKeyGuacamoleProperty implements GuacamoleProperty<P
         if (value == null || value.isEmpty())
             return null;
 
+        FileInputStream keyStreamIn = null;
+
         try {
+            try {
 
-            // Open and read the file specified in the configuration.
-            File keyFile = new File(value);
-            FileInputStream keyStreamIn = new FileInputStream(keyFile);
-            ByteArrayOutputStream keyStreamOut = new ByteArrayOutputStream();
-            byte[] keyBuffer = new byte[1024];
+                // Open and read the file specified in the configuration.
+                File keyFile = new File(value);
+                keyStreamIn = new FileInputStream(keyFile);
+                ByteArrayOutputStream keyStreamOut = new ByteArrayOutputStream();
+                byte[] keyBuffer = new byte[1024];
 
-            for (int readBytes; (readBytes = keyStreamIn.read(keyBuffer)) != -1;)
-                keyStreamOut.write(keyBuffer, 0, readBytes);
+                for (int readBytes; (readBytes = keyStreamIn.read(keyBuffer)) != -1;)
+                    keyStreamOut.write(keyBuffer, 0, readBytes);
 
-            keyStreamIn.close();
-            final byte[] keyBytes = keyStreamOut.toByteArray();
+                final byte[] keyBytes = keyStreamOut.toByteArray();
 
-            // Set up decryption infrastructure
-            KeyFactory keyFactory = KeyFactory.getInstance("RSA");
-            KeySpec keySpec = new PKCS8EncodedKeySpec(keyBytes);
-            return keyFactory.generatePrivate(keySpec);
+                // Set up decryption infrastructure
+                KeyFactory keyFactory = KeyFactory.getInstance("RSA");
+                KeySpec keySpec = new PKCS8EncodedKeySpec(keyBytes);
+                return keyFactory.generatePrivate(keySpec);
 
-        }
-        catch (FileNotFoundException e) {
-            throw new GuacamoleServerException("Could not find the specified key file.", e);
+            }
+            catch (FileNotFoundException e) {
+                throw new GuacamoleServerException("Could not find the specified key file.", e);
+            }
+            catch (NoSuchAlgorithmException e) {
+                throw new GuacamoleServerException("RSA algorithm is not available.", e);
+            }
+            catch (InvalidKeySpecException e) {
+                throw new GuacamoleServerException("Key is not in expected PKCS8 encoding.", e);
+            }
+            finally {
+                keyStreamIn.close();
+            }
         }
         catch (IOException e) {
             throw new GuacamoleServerException("Could not read in the specified key file.", e);
         }
-        catch (NoSuchAlgorithmException e) {
-            throw new GuacamoleServerException("RSA algorithm is not available.", e);
-        }
-        catch (InvalidKeySpecException e) {
-            throw new GuacamoleServerException("Key is not in expected PKCS8 encoding.", e);
-        }
-
     }
 
 }


[3/4] incubator-guacamole-client git commit: GUACAMOLE-362: Avoid NullPointerException when closing input stream.

Posted by mj...@apache.org.
GUACAMOLE-362: Avoid NullPointerException when closing input stream.


Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/commit/32ccde08
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/32ccde08
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/32ccde08

Branch: refs/heads/staging/0.9.14-incubating
Commit: 32ccde08d242f4ca3257d6bb800153b36d1e9325
Parents: 91e5702
Author: Nick Couchman <vn...@apache.org>
Authored: Sat Oct 28 14:19:37 2017 -0400
Committer: Nick Couchman <vn...@apache.org>
Committed: Sat Oct 28 14:19:37 2017 -0400

----------------------------------------------------------------------
 .../guacamole/auth/cas/conf/PrivateKeyGuacamoleProperty.java      | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/32ccde08/extensions/guacamole-auth-cas/src/main/java/org/apache/guacamole/auth/cas/conf/PrivateKeyGuacamoleProperty.java
----------------------------------------------------------------------
diff --git a/extensions/guacamole-auth-cas/src/main/java/org/apache/guacamole/auth/cas/conf/PrivateKeyGuacamoleProperty.java b/extensions/guacamole-auth-cas/src/main/java/org/apache/guacamole/auth/cas/conf/PrivateKeyGuacamoleProperty.java
index d71ae1a..455f177 100644
--- a/extensions/guacamole-auth-cas/src/main/java/org/apache/guacamole/auth/cas/conf/PrivateKeyGuacamoleProperty.java
+++ b/extensions/guacamole-auth-cas/src/main/java/org/apache/guacamole/auth/cas/conf/PrivateKeyGuacamoleProperty.java
@@ -81,7 +81,8 @@ public abstract class PrivateKeyGuacamoleProperty implements GuacamoleProperty<P
                 throw new GuacamoleServerException("Key is not in expected PKCS8 encoding.", e);
             }
             finally {
-                keyStreamIn.close();
+                if (keyStreamIn != null)
+                    keyStreamIn.close();
             }
         }
         catch (IOException e) {


[4/4] incubator-guacamole-client git commit: GUACAMOLE-362: Merge changes addressing InputStream leak when reading CAS ClearPass private key.

Posted by mj...@apache.org.
GUACAMOLE-362: Merge changes addressing InputStream leak when reading CAS ClearPass private key.


Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/commit/393c70f2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/393c70f2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/393c70f2

Branch: refs/heads/staging/0.9.14-incubating
Commit: 393c70f236ce31546de74884cddec36291da7b1e
Parents: 1a7f85a 32ccde0
Author: Michael Jumper <mj...@apache.org>
Authored: Sat Oct 28 22:20:53 2017 -0700
Committer: Michael Jumper <mj...@apache.org>
Committed: Sat Oct 28 22:20:53 2017 -0700

----------------------------------------------------------------------
 .../cas/conf/PrivateKeyGuacamoleProperty.java   | 51 +++++++++++---------
 1 file changed, 29 insertions(+), 22 deletions(-)
----------------------------------------------------------------------