diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/MySQLAuthenticationProviderModule.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/MySQLAuthenticationProviderModule.java index f2908ee66..5dead1545 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/MySQLAuthenticationProviderModule.java +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/MySQLAuthenticationProviderModule.java @@ -86,7 +86,7 @@ public class MySQLAuthenticationProviderModule implements Module { // Set the SSL mode to use when conncting MySQLSSLMode sslMode = environment.getMySQLSSLMode(); - driverProperties.setProperty("sslMode", sslMode.toString()); + driverProperties.setProperty("sslMode", sslMode.getDriverValue()); // Set legacy properties if (sslMode == MySQLSSLMode.DISABLED) diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/conf/MySQLSSLMode.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/conf/MySQLSSLMode.java index a95bb556d..0820150c6 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/conf/MySQLSSLMode.java +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/java/org/apache/guacamole/auth/mysql/conf/MySQLSSLMode.java @@ -30,31 +30,60 @@ public enum MySQLSSLMode { * Do not use SSL at all. */ @PropertyValue("disabled") - DISABLED, + DISABLED("disabled"), /** * Prefer SSL, but fall back to unencrypted. */ @PropertyValue("preferred") - PREFERRED, + PREFERRED("preferred"), /** * Require SSL, but perform no certificate validation. */ @PropertyValue("required") - REQUIRED, + REQUIRED("required"), /** * Require SSL, and validate server certificate issuer. */ @PropertyValue("verify-ca") - VERIFY_CA, + VERIFY_CA("verify-ca"), /** * Require SSL and validate both server certificate issuer and server * identity. */ @PropertyValue("verify-identity") - VERIFY_IDENTITY; + VERIFY_IDENTITY("verify-identity"); + + /** + * The value expected by and passed on to the JDBC driver for the given + * SSL operation mode. + */ + private final String driverValue; + + /** + * Create a new instance of this enum with the given driverValue as the + * value that will be used when configuring the JDBC driver. + * + * @param driverValue + * The value to use when configuring the JDBC driver. + */ + MySQLSSLMode(String driverValue) { + this.driverValue = driverValue; + } + + /** + * Returns the String value for a given Enum that properly configures the + * JDBC driver for the desired mode of SSL operation. + * + * @return + * The String value for the current Enum that configures the JDBC driver + * for the desired mode of SSL operation. + */ + public String getDriverValue() { + return driverValue; + } } diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/PostgreSQLAuthenticationProviderModule.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/PostgreSQLAuthenticationProviderModule.java index e65abb82f..67fafe452 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/PostgreSQLAuthenticationProviderModule.java +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/PostgreSQLAuthenticationProviderModule.java @@ -75,10 +75,12 @@ public class PostgreSQLAuthenticationProviderModule implements Module { // Check the SSL mode and set if configured. PostgreSQLSSLMode sslMode = environment.getPostgreSQLSSLMode(); - driverProperties.setProperty("sslmode", sslMode.toString()); + driverProperties.setProperty("sslmode", sslMode.getDriverValue()); // If SSL is enabled, check for and set other SSL properties. if (sslMode != PostgreSQLSSLMode.DISABLE) { + + // Sets the legacy SSL configuration mode required by older servers. driverProperties.setProperty("ssl", "true"); File sslClientCert = environment.getPostgreSQLSSLClientCertFile(); diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/conf/PostgreSQLSSLMode.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/conf/PostgreSQLSSLMode.java index 709308ef8..7a467f4c4 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/conf/PostgreSQLSSLMode.java +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/java/org/apache/guacamole/auth/postgresql/conf/PostgreSQLSSLMode.java @@ -63,42 +63,32 @@ public enum PostgreSQLSSLMode { VERIFY_FULL("verify-full"); /** - * The value actually passed on to the JDBC driver. + * The value expected by and passed on to the JDBC driver for the given + * SSL operation mode. */ - private final String configValue; + private final String driverValue; /** - * Create a new instance of this enum with the given configValue as the + * Create a new instance of this enum with the given driverValue as the * value that will be used when configuring the JDBC driver. * - * @param configValue + * @param driverValue * The value to use when configuring the JDBC driver. */ - PostgreSQLSSLMode(String configValue) { - this.configValue = configValue; - } - - @Override - public String toString() { - return configValue; + PostgreSQLSSLMode(String driverValue) { + this.driverValue = driverValue; } /** - * Given the String value, determine the correct enum value that matches - * the string, or null if there is no match. - * - * @param value - * The String value to test to find a match. + * Returns the String value for a given Enum that properly configures the + * JDBC driver for the desired mode of SSL operation. * * @return - * The enum value matching the given String. + * The String value for the current Enum that configures the JDBC driver + * for the desired mode of SSL operation. */ - public static PostgreSQLSSLMode getValue(String value) { - for (PostgreSQLSSLMode mode : PostgreSQLSSLMode.values()) { - if (mode.toString().equals(value)) - return mode; - } - return null; + public String getDriverValue() { + return driverValue; } }