GUACAMOLE-363: Allow use of alternate JTDS driver.

Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/commit/d6d7c376
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/d6d7c376
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/d6d7c376

Branch: refs/heads/master
Commit: d6d7c3768fb5945033627907c691c896c915bc51
Parents: 2eb4889
Author: Nick Couchman <vn...@apache.org>
Authored: Tue Aug 29 21:41:00 2017 -0400
Committer: Nick Couchman <vn...@apache.org>
Committed: Thu Sep 28 07:00:52 2017 -0400

----------------------------------------------------------------------
 .../SQLServerAuthenticationProviderModule.java  | 13 ++++++++++++-
 .../auth/sqlserver/SQLServerEnvironment.java    | 20 +++++++++++++++++++-
 .../sqlserver/SQLServerGuacamoleProperties.java | 11 +++++++++++
 3 files changed, 42 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/d6d7c376/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-sqlserver/src/main/java/org/apache/guacamole/auth/sqlserver/SQLServerAuthenticationProviderModule.java
----------------------------------------------------------------------
diff --git 
a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-sqlserver/src/main/java/org/apache/guacamole/auth/sqlserver/SQLServerAuthenticationProviderModule.java
 
b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-sqlserver/src/main/java/org/apache/guacamole/auth/sqlserver/SQLServerAuthenticationProviderModule.java
index ebb1a06..d936f14 100644
--- 
a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-sqlserver/src/main/java/org/apache/guacamole/auth/sqlserver/SQLServerAuthenticationProviderModule.java
+++ 
b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-sqlserver/src/main/java/org/apache/guacamole/auth/sqlserver/SQLServerAuthenticationProviderModule.java
@@ -40,6 +40,11 @@ public class SQLServerAuthenticationProviderModule 
implements Module {
      * SQLServer-specific driver configuration 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
@@ -70,13 +75,19 @@ 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();
+
     }
 
     @Override
     public void configure(Binder binder) {
 
         // 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
         Names.bindProperties(binder, myBatisProperties);

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/d6d7c376/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-sqlserver/src/main/java/org/apache/guacamole/auth/sqlserver/SQLServerEnvironment.java
----------------------------------------------------------------------
diff --git 
a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-sqlserver/src/main/java/org/apache/guacamole/auth/sqlserver/SQLServerEnvironment.java
 
b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-sqlserver/src/main/java/org/apache/guacamole/auth/sqlserver/SQLServerEnvironment.java
index 67d8827..4d24dd3 100644
--- 
a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-sqlserver/src/main/java/org/apache/guacamole/auth/sqlserver/SQLServerEnvironment.java
+++ 
b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-sqlserver/src/main/java/org/apache/guacamole/auth/sqlserver/SQLServerEnvironment.java
@@ -272,7 +272,7 @@ public class SQLServerEnvironment extends JDBCEnvironment {
     public String getSQLServerDatabase() throws GuacamoleException {
         return 
getRequiredProperty(SQLServerGuacamoleProperties.SQLSERVER_DATABASE);
     }
-    
+
     /**
      * Returns the username that should be used when authenticating with the
      * SQLServer database containing the Guacamole authentication tables.
@@ -302,5 +302,23 @@ public class SQLServerEnvironment extends JDBCEnvironment {
     public String getSQLServerPassword() throws GuacamoleException {
         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
+        );
+    }
     
 }

http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/d6d7c376/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-sqlserver/src/main/java/org/apache/guacamole/auth/sqlserver/SQLServerGuacamoleProperties.java
----------------------------------------------------------------------
diff --git 
a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-sqlserver/src/main/java/org/apache/guacamole/auth/sqlserver/SQLServerGuacamoleProperties.java
 
b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-sqlserver/src/main/java/org/apache/guacamole/auth/sqlserver/SQLServerGuacamoleProperties.java
index e45f502..d04d9a1 100644
--- 
a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-sqlserver/src/main/java/org/apache/guacamole/auth/sqlserver/SQLServerGuacamoleProperties.java
+++ 
b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-sqlserver/src/main/java/org/apache/guacamole/auth/sqlserver/SQLServerGuacamoleProperties.java
@@ -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"; }
+
+    };
+
 }

Reply via email to