GUACAMOLE-728: Properly expose JDBC driver values from enums.

This commit is contained in:
Virtually Nick
2020-06-16 11:44:07 -04:00
parent 31288fc4d0
commit 986d5a1225
4 changed files with 51 additions and 30 deletions

View File

@@ -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)

View File

@@ -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;
}
}