mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUACAMOLE-363: Update so that any of the available TDS-compatible drivers can be used.
This commit is contained in:
@@ -44,7 +44,7 @@ public class SQLServerAuthenticationProviderModule implements Module {
|
||||
/**
|
||||
* Whether or not to use JTDS Driver
|
||||
*/
|
||||
private Boolean useJTDSDriver = false;
|
||||
private String sqlServerDriver;
|
||||
|
||||
/**
|
||||
* Creates a new SQLServer authentication provider module that configures
|
||||
@@ -75,8 +75,8 @@ public class SQLServerAuthenticationProviderModule implements Module {
|
||||
// Use UTF-8 in database
|
||||
driverProperties.setProperty("characterEncoding", "UTF-8");
|
||||
|
||||
// Capture whether or not to use the JTDS driver.
|
||||
this.useJTDSDriver = environment.getSQLServerJTDSDriver();
|
||||
// Capture which driver to use for the connection.
|
||||
this.sqlServerDriver = environment.getSQLServerDriver();
|
||||
|
||||
}
|
||||
|
||||
@@ -84,8 +84,13 @@ public class SQLServerAuthenticationProviderModule implements Module {
|
||||
public void configure(Binder binder) {
|
||||
|
||||
// Bind SQLServer-specific properties
|
||||
if (this.useJTDSDriver)
|
||||
// Look at the property to choose the correct driver.
|
||||
if (sqlServerDriver.equals(SQLServerEnvironment.SQLSERVER_DRIVER_JTDS))
|
||||
JdbcHelper.SQL_Server_jTDS.configure(binder);
|
||||
else if(sqlServerDriver.equals(SQLServerEnvironment.SQLSERVER_DRIVER_DATADIRECT))
|
||||
JdbcHelper.SQL_Server_DataDirect.configure(binder);
|
||||
else if(sqlServerDriver.equals(SQLServerEnvironment.SQLSERVER_DRIVER_MS))
|
||||
JdbcHelper.SQL_Server_MS_Driver.configure(binder);
|
||||
else
|
||||
JdbcHelper.SQL_Server_2005_MS_Driver.configure(binder);
|
||||
|
||||
|
@@ -96,6 +96,30 @@ public class SQLServerEnvironment extends JDBCEnvironment {
|
||||
*/
|
||||
private int DEFAULT_MAX_GROUP_CONNECTIONS = 0;
|
||||
|
||||
/**
|
||||
* The value for the sqlserver-driver property that triggers the use of
|
||||
* the open source JTDS driver.
|
||||
*/
|
||||
public final static String SQLSERVER_DRIVER_JTDS = "jtds";
|
||||
|
||||
/**
|
||||
* The value for the sqlserver-driver property that triggers the use of
|
||||
* the DataDirect JDBC driver.
|
||||
*/
|
||||
public final static String SQLSERVER_DRIVER_DATADIRECT = "datadirect";
|
||||
|
||||
/**
|
||||
* The value for the sqlserver-driver property that triggers the use of
|
||||
* the older Microsoft JDBC driver.
|
||||
*/
|
||||
public final static String SQLSERVER_DRIVER_MS = "microsoft";
|
||||
|
||||
/**
|
||||
* The value for the sqlserver-driver property that triggers the use of
|
||||
* the Microsoft JDBC driver. This is the default.
|
||||
*/
|
||||
public final static String SQLSERVER_DRIVER_MS_2005 = "microsoft2005";
|
||||
|
||||
/**
|
||||
* Constructs a new SQLServerEnvironment, providing access to SQLServer-specific
|
||||
* configuration options.
|
||||
@@ -169,6 +193,15 @@ public class SQLServerEnvironment extends JDBCEnvironment {
|
||||
|
||||
}
|
||||
|
||||
// Check driver property is one of the acceptable values.
|
||||
String driver = getProperty(SQLServerGuacamoleProperties.SQLSERVER_DRIVER);
|
||||
if (!(driver.equals(SQLSERVER_DRIVER_JTDS) ||
|
||||
driver.equals(SQLSERVER_DRIVER_DATADIRECT) ||
|
||||
driver.equals(SQLSERVER_DRIVER_MS) ||
|
||||
driver.equals(SQLSERVER_DRIVER_MS_2005)))
|
||||
logger.warn("{} property has been set to an invalid value. The default Microsoft 2005 driver will be used.",
|
||||
SQLServerGuacamoleProperties.SQLSERVER_DRIVER.getName());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -314,10 +347,10 @@ public class SQLServerEnvironment extends JDBCEnvironment {
|
||||
* 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 {
|
||||
public String getSQLServerDriver() throws GuacamoleException {
|
||||
return getProperty(
|
||||
SQLServerGuacamoleProperties.SQLSERVER_JTDS_DRIVER,
|
||||
false
|
||||
SQLServerGuacamoleProperties.SQLSERVER_DRIVER,
|
||||
SQLSERVER_DRIVER_MS_2005
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -200,11 +200,11 @@ public class SQLServerGuacamoleProperties {
|
||||
/**
|
||||
* Whether or not to use the JTDS driver for SQL Server connections.
|
||||
*/
|
||||
public static final BooleanGuacamoleProperty
|
||||
SQLSERVER_JTDS_DRIVER = new BooleanGuacamoleProperty() {
|
||||
public static final StringGuacamoleProperty
|
||||
SQLSERVER_DRIVER = new StringGuacamoleProperty() {
|
||||
|
||||
@Override
|
||||
public String getName() { return "sqlserver-use-jtds-driver"; }
|
||||
public String getName() { return "sqlserver-driver"; }
|
||||
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user