From b2979482eccddbd64d0c7bc2f7f00f56ad2e4beb Mon Sep 17 00:00:00 2001 From: Sebb Date: Mon, 27 Nov 2023 11:33:19 +0000 Subject: [PATCH] Clarify that constant is a property name --- src/main/java/org/apache/commons/crypto/Crypto.java | 12 ++++++------ .../commons/crypto/jna/LibreSsl20XNativeJna.java | 2 +- .../commons/crypto/jna/OpenSsl11XNativeJna.java | 2 +- .../commons/crypto/jna/OpenSsl30XNativeJna.java | 2 +- .../org/apache/commons/crypto/jna/OpenSslJna.java | 4 ++-- .../apache/commons/crypto/jna/OpenSslNativeJna.java | 8 ++++---- .../java/org/apache/commons/crypto/utils/Utils.java | 4 ++-- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/main/java/org/apache/commons/crypto/Crypto.java b/src/main/java/org/apache/commons/crypto/Crypto.java index 5aca20adf..2facf3f17 100644 --- a/src/main/java/org/apache/commons/crypto/Crypto.java +++ b/src/main/java/org/apache/commons/crypto/Crypto.java @@ -86,23 +86,23 @@ private static Properties getComponentProperties() { * Where to find the SSL crypto library when using JNI * This is used in Utils.libraryPath() */ - public static final String JNI_LIBRARY_PATH = "jni.library.path"; + public static final String JNI_LIBRARY_PATH_PROPERTY = "jni.library.path"; /** * Override property for the default SSL crypto library name when using JNI */ - public static final String JNI_LIBRARY_NAME = "commons.crypto.OpenSslNativeJni"; + public static final String JNI_LIBRARY_NAME_PROPERTY = "commons.crypto.OpenSslNativeJni"; /** * Where to find the SSL crypto library when using JNA * This is used by the JNA library code */ - public static final String JNA_LIBRARY_PATH = "jna.library.path"; + public static final String JNA_LIBRARY_PATH_PROPERTY = "jna.library.path"; /** * Override property for the default SSL crypto library name when using JNA */ - public static final String JNA_LIBRARY_NAME = Crypto.CONF_PREFIX + "OpenSslNativeJna"; + public static final String JNA_LIBRARY_NAME_PROPERTY = Crypto.CONF_PREFIX + "OpenSslNativeJna"; /** Default name for loading SSL crypto library using JNA */ public static final String JNA_LIBRARY_NAME_DEFAULT = "crypto"; @@ -184,8 +184,8 @@ public static boolean isNativeCodeLoaded() { */ public static void main(final String[] args) throws Exception { quiet = args.length == 1 && args[0].equals("-q"); - info("%s=%s", JNI_LIBRARY_PATH, System.getProperty(JNI_LIBRARY_PATH)); - info("%s=%s", JNI_LIBRARY_NAME, System.getProperty(JNI_LIBRARY_NAME)); + info("%s=%s", JNI_LIBRARY_PATH_PROPERTY, System.getProperty(JNI_LIBRARY_PATH_PROPERTY)); + info("%s=%s", JNI_LIBRARY_NAME_PROPERTY, System.getProperty(JNI_LIBRARY_NAME_PROPERTY)); info("%s %s", getComponentName(), getComponentVersion()); if (isNativeCodeLoaded()) { info("Native code loaded OK: %s", OpenSslInfoNative.NativeVersion()); diff --git a/src/main/java/org/apache/commons/crypto/jna/LibreSsl20XNativeJna.java b/src/main/java/org/apache/commons/crypto/jna/LibreSsl20XNativeJna.java index 74aa6f7f0..5deb4c867 100644 --- a/src/main/java/org/apache/commons/crypto/jna/LibreSsl20XNativeJna.java +++ b/src/main/java/org/apache/commons/crypto/jna/LibreSsl20XNativeJna.java @@ -37,7 +37,7 @@ final class LibreSsl20XNativeJna implements OpenSslInterfaceNativeJna { boolean ok = false; Throwable thrown = null; try { - final String libName = System.getProperty(Crypto.JNA_LIBRARY_NAME, Crypto.JNA_LIBRARY_NAME_DEFAULT); + final String libName = System.getProperty(Crypto.JNA_LIBRARY_NAME_PROPERTY, Crypto.JNA_LIBRARY_NAME_DEFAULT); OpenSslJna.debug("Native.register('%s')", libName); Native.register(libName); ok = true; diff --git a/src/main/java/org/apache/commons/crypto/jna/OpenSsl11XNativeJna.java b/src/main/java/org/apache/commons/crypto/jna/OpenSsl11XNativeJna.java index 153c5a178..e70971f52 100644 --- a/src/main/java/org/apache/commons/crypto/jna/OpenSsl11XNativeJna.java +++ b/src/main/java/org/apache/commons/crypto/jna/OpenSsl11XNativeJna.java @@ -36,7 +36,7 @@ final class OpenSsl11XNativeJna implements OpenSslInterfaceNativeJna { boolean ok = false; Throwable thrown = null; try { - final String libName = System.getProperty(Crypto.JNA_LIBRARY_NAME, Crypto.JNA_LIBRARY_NAME_DEFAULT); + final String libName = System.getProperty(Crypto.JNA_LIBRARY_NAME_PROPERTY, Crypto.JNA_LIBRARY_NAME_DEFAULT); OpenSslJna.debug("Native.register('%s')", libName); Native.register(libName); ok = true; diff --git a/src/main/java/org/apache/commons/crypto/jna/OpenSsl30XNativeJna.java b/src/main/java/org/apache/commons/crypto/jna/OpenSsl30XNativeJna.java index 8d8acc804..5db9d4f4b 100644 --- a/src/main/java/org/apache/commons/crypto/jna/OpenSsl30XNativeJna.java +++ b/src/main/java/org/apache/commons/crypto/jna/OpenSsl30XNativeJna.java @@ -38,7 +38,7 @@ final class OpenSsl30XNativeJna implements OpenSslInterfaceNativeJna { boolean ok = false; Throwable thrown = null; try { - final String libName = System.getProperty(Crypto.JNA_LIBRARY_NAME, Crypto.JNA_LIBRARY_NAME_DEFAULT); + final String libName = System.getProperty(Crypto.JNA_LIBRARY_NAME_PROPERTY, Crypto.JNA_LIBRARY_NAME_DEFAULT); OpenSslJna.debug("Native.register('%s')", libName); Native.register(libName); ok = true; diff --git a/src/main/java/org/apache/commons/crypto/jna/OpenSslJna.java b/src/main/java/org/apache/commons/crypto/jna/OpenSslJna.java index 9bb1c934e..4906b117e 100644 --- a/src/main/java/org/apache/commons/crypto/jna/OpenSslJna.java +++ b/src/main/java/org/apache/commons/crypto/jna/OpenSslJna.java @@ -98,9 +98,9 @@ public static boolean isEnabled() { */ public static void main(final String[] args) throws Throwable { // These are used by JNA code if defined: - info("%s=%s", Crypto.JNA_LIBRARY_PATH, System.getProperty(Crypto.JNA_LIBRARY_PATH)); + info("%s=%s", Crypto.JNA_LIBRARY_PATH_PROPERTY, System.getProperty(Crypto.JNA_LIBRARY_PATH_PROPERTY)); info("jna.platform.library.path=%s", System.getProperty("jna.platform.library.path")); - info("%s=%s\n", Crypto.JNA_LIBRARY_NAME, System.getProperty(Crypto.JNA_LIBRARY_NAME)); + info("%s=%s\n", Crypto.JNA_LIBRARY_NAME_PROPERTY, System.getProperty(Crypto.JNA_LIBRARY_NAME_PROPERTY)); // can set jna.debug_load=true for loading info info(Crypto.getComponentName() + " OpenSslJna: enabled = %s, version = 0x%08X", isEnabled(), OpenSslNativeJna.VERSION); final Throwable initialisationError = initialisationError(); diff --git a/src/main/java/org/apache/commons/crypto/jna/OpenSslNativeJna.java b/src/main/java/org/apache/commons/crypto/jna/OpenSslNativeJna.java index 82fc81428..b70715450 100644 --- a/src/main/java/org/apache/commons/crypto/jna/OpenSslNativeJna.java +++ b/src/main/java/org/apache/commons/crypto/jna/OpenSslNativeJna.java @@ -53,18 +53,18 @@ final class OpenSslNativeJna { static { OpenSslJna.debug("OpenSslNativeJna static init start"); - final String libraryName = System.getProperty(Crypto.JNA_LIBRARY_NAME, Crypto.JNA_LIBRARY_NAME_DEFAULT); + final String libraryName = System.getProperty(Crypto.JNA_LIBRARY_NAME_PROPERTY, Crypto.JNA_LIBRARY_NAME_DEFAULT); OpenSslJna.debug("OpenSslNativeJna NativeLibrary.getInstance('%s')", libraryName); // CRYPTO-179 - avoid crash if ("Mac OS X".equals(System.getProperty("os.name")) - && System.getProperty(Crypto.JNA_LIBRARY_NAME, "").isEmpty() - && System.getProperty(Crypto.JNA_LIBRARY_PATH, "").isEmpty() + && System.getProperty(Crypto.JNA_LIBRARY_NAME_PROPERTY, "").isEmpty() + && System.getProperty(Crypto.JNA_LIBRARY_PATH_PROPERTY, "").isEmpty() ) { String ret = OpenSslMacOS.checkLibrary(Crypto.MACOS_LIBRARY_NAME_DEFAULT); if (ret != null) { throw new UnsatisfiedLinkError( String.format("Cannot load default library '%s'; please define %s! (%s)", - Crypto.MACOS_LIBRARY_NAME_DEFAULT, Crypto.JNA_LIBRARY_PATH, ret)); + Crypto.MACOS_LIBRARY_NAME_DEFAULT, Crypto.JNA_LIBRARY_PATH_PROPERTY, ret)); } } @SuppressWarnings("resource") // NativeLibrary.getInstance returns a singleton diff --git a/src/main/java/org/apache/commons/crypto/utils/Utils.java b/src/main/java/org/apache/commons/crypto/utils/Utils.java index 27afb62b8..fbc61ec26 100644 --- a/src/main/java/org/apache/commons/crypto/utils/Utils.java +++ b/src/main/java/org/apache/commons/crypto/utils/Utils.java @@ -212,8 +212,8 @@ public static Properties getProperties(final Properties newProp) { * Do not change the method name or its signature! */ static String libraryPath(final String name) { - final String overridename = System.getProperty(Crypto.JNI_LIBRARY_NAME, name); - final String override = System.getProperty(Crypto.JNI_LIBRARY_PATH); + final String overridename = System.getProperty(Crypto.JNI_LIBRARY_NAME_PROPERTY, name); + final String override = System.getProperty(Crypto.JNI_LIBRARY_PATH_PROPERTY); if (override != null && new File(override).isDirectory()) { return new File(override, overridename).getPath(); }