mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUACAMOLE-728: Properly expose JDBC driver values from enums.
This commit is contained in:
@@ -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)
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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();
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user