From ae88f0d77b27ee5483ee30c8ae6a8ca38d4dc38c Mon Sep 17 00:00:00 2001 From: Jeff Gran Date: Tue, 17 Feb 2015 14:39:36 -0700 Subject: [PATCH] use SafePropertyAccessor to access properties instead of directly --- src/main/java/org/jruby/ext/openssl/OpenSSL.java | 7 ++++--- src/main/java/org/jruby/ext/openssl/x509store/Lookup.java | 5 +++-- .../java/org/jruby/ext/openssl/x509store/X509Utils.java | 8 +++++--- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/jruby/ext/openssl/OpenSSL.java b/src/main/java/org/jruby/ext/openssl/OpenSSL.java index 8e92868c..3a616cde 100644 --- a/src/main/java/org/jruby/ext/openssl/OpenSSL.java +++ b/src/main/java/org/jruby/ext/openssl/OpenSSL.java @@ -37,6 +37,7 @@ import org.jruby.runtime.ThreadContext; import org.jruby.runtime.builtin.IRubyObject; import org.jruby.util.ByteList; +import org.jruby.util.SafePropertyAccessor; /** * OpenSSL (methods as well as an entry point) @@ -55,7 +56,7 @@ public static boolean isProviderAvailable() { } public static void createOpenSSL(final Ruby runtime) { - boolean registerProvider = Boolean.getBoolean("jruby.openssl.provider.register"); + boolean registerProvider = SafePropertyAccessor.getBoolean("jruby.openssl.provider.register"); SecurityHelper.setRegisterProvider( registerProvider ); final RubyModule _OpenSSL = runtime.getOrCreateModule("OpenSSL"); @@ -109,9 +110,9 @@ public static void createOpenSSL(final Ruby runtime) { _OpenSSL.setConstant("OPENSSL_VERSION", runtime.newString(OPENSSL_VERSION)); _OpenSSL.setConstant("OPENSSL_VERSION_NUMBER", runtime.newFixnum(OPENSSL_VERSION_NUMBER)); - setDebug(_OpenSSL, runtime.newBoolean( Boolean.getBoolean("jruby.openssl.debug") ) ); + setDebug(_OpenSSL, runtime.newBoolean( SafePropertyAccessor.getBoolean("jruby.openssl.debug") ) ); - final String warn = System.getProperty("jruby.openssl.warn"); + final String warn = SafePropertyAccessor.getProperty("jruby.openssl.warn"); if ( warn != null ) OpenSSL.warn = Boolean.parseBoolean(warn); } diff --git a/src/main/java/org/jruby/ext/openssl/x509store/Lookup.java b/src/main/java/org/jruby/ext/openssl/x509store/Lookup.java index cd12b830..f9a1d6ed 100644 --- a/src/main/java/org/jruby/ext/openssl/x509store/Lookup.java +++ b/src/main/java/org/jruby/ext/openssl/x509store/Lookup.java @@ -66,6 +66,7 @@ import org.jruby.RubyHash; import org.jruby.ext.openssl.SecurityHelper; import org.jruby.util.JRubyFile; +import org.jruby.util.SafePropertyAccessor; import org.jruby.util.io.ChannelDescriptor; import org.jruby.util.io.ChannelStream; import org.jruby.util.io.FileExistsException; @@ -277,7 +278,7 @@ else if ( v instanceof CRL ) { } public int loadDefaultJavaCACertsFile() throws Exception { - final String certsFile = System.getProperty("java.home") + + final String certsFile = SafePropertyAccessor.getProperty("java.home") + "/lib/security/cacerts".replace('/', File.separatorChar); final FileInputStream fin = new FileInputStream(certsFile); int count = 0; @@ -543,7 +544,7 @@ private int addCertificateDirectory(final LookupDir ctx, final String dir, final return 0; } - String[] dirs = dir.split(System.getProperty("path.separator")); + String[] dirs = dir.split(SafePropertyAccessor.getProperty("path.separator")); for ( int i=0; i