GUACAMOLE-363: Allow use of alternate JTDS driver.

This commit is contained in:
Nick Couchman
2017-08-29 21:41:00 -04:00
parent 2eb48895bf
commit d6d7c3768f
3 changed files with 42 additions and 2 deletions

View File

@@ -40,6 +40,11 @@ public class SQLServerAuthenticationProviderModule implements Module {
* SQLServer-specific driver configuration properties. * SQLServer-specific driver configuration properties.
*/ */
private final Properties driverProperties = new Properties(); private final Properties driverProperties = new Properties();
/**
* Whether or not to use JTDS Driver
*/
private Boolean useJTDSDriver = false;
/** /**
* Creates a new SQLServer authentication provider module that configures * Creates a new SQLServer authentication provider module that configures
@@ -70,13 +75,19 @@ public class SQLServerAuthenticationProviderModule implements Module {
// Use UTF-8 in database // Use UTF-8 in database
driverProperties.setProperty("characterEncoding", "UTF-8"); driverProperties.setProperty("characterEncoding", "UTF-8");
// Capture whether or not to use the JTDS driver.
this.useJTDSDriver = environment.getSQLServerJTDSDriver();
} }
@Override @Override
public void configure(Binder binder) { public void configure(Binder binder) {
// Bind SQLServer-specific properties // Bind SQLServer-specific properties
JdbcHelper.SQL_Server_2005_MS_Driver.configure(binder); if (this.useJTDSDriver)
JdbcHelper.SQL_Server_jTDS.configure(binder);
else
JdbcHelper.SQL_Server_2005_MS_Driver.configure(binder);
// Bind MyBatis properties // Bind MyBatis properties
Names.bindProperties(binder, myBatisProperties); Names.bindProperties(binder, myBatisProperties);

View File

@@ -272,7 +272,7 @@ public class SQLServerEnvironment extends JDBCEnvironment {
public String getSQLServerDatabase() throws GuacamoleException { public String getSQLServerDatabase() throws GuacamoleException {
return getRequiredProperty(SQLServerGuacamoleProperties.SQLSERVER_DATABASE); return getRequiredProperty(SQLServerGuacamoleProperties.SQLSERVER_DATABASE);
} }
/** /**
* Returns the username that should be used when authenticating with the * Returns the username that should be used when authenticating with the
* SQLServer database containing the Guacamole authentication tables. * SQLServer database containing the Guacamole authentication tables.
@@ -302,5 +302,23 @@ public class SQLServerEnvironment extends JDBCEnvironment {
public String getSQLServerPassword() throws GuacamoleException { public String getSQLServerPassword() throws GuacamoleException {
return getRequiredProperty(SQLServerGuacamoleProperties.SQLSERVER_PASSWORD); return getRequiredProperty(SQLServerGuacamoleProperties.SQLSERVER_PASSWORD);
} }
/**
* Returns whether or not to use the SourceForge JTDS driver for more
* generic JTDS connections instead of the Microsoft-provided JDBC driver.
*
* @return
* True if the JTDS driver should be used; false by default.
*
* @throws GuacamoleException
* If an error occurs while retrieving the property value, or if the
* value was not set, as this property is required.
*/
public Boolean getSQLServerJTDSDriver() throws GuacamoleException {
return getProperty(
SQLServerGuacamoleProperties.SQLSERVER_JTDS_DRIVER,
false
);
}
} }

View File

@@ -197,4 +197,15 @@ public class SQLServerGuacamoleProperties {
}; };
/**
* Whether or not to use the JTDS driver for SQL Server connections.
*/
public static final BooleanGuacamoleProperty
SQLSERVER_JTDS_DRIVER = new BooleanGuacamoleProperty() {
@Override
public String getName() { return "sqlserver-use-jtds-driver"; }
};
} }