From dc09d0ef2ae0b6a6424ee1561aa1edf63f33899b Mon Sep 17 00:00:00 2001 From: Virtually Nick Date: Thu, 26 Dec 2019 16:00:21 -0500 Subject: [PATCH] GUACAMOLE-583: Add ability to configure SQL Server instance name. --- .../SQLServerAuthenticationProviderModule.java | 5 +++++ .../auth/sqlserver/SQLServerEnvironment.java | 17 +++++++++++++++++ .../sqlserver/SQLServerGuacamoleProperties.java | 11 +++++++++++ 3 files changed, 33 insertions(+) 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 22cb47461..ce18ce145 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 @@ -69,6 +69,11 @@ public class SQLServerAuthenticationProviderModule implements Module { myBatisProperties.setProperty("JDBC.schema", environment.getSQLServerDatabase()); myBatisProperties.setProperty("JDBC.username", environment.getSQLServerUsername()); myBatisProperties.setProperty("JDBC.password", environment.getSQLServerPassword()); + + String instance = environment.getSQLServerInstance(); + if (instance != null) + myBatisProperties.setProperty("JDBC.instanceName", instance); + myBatisProperties.setProperty("JDBC.autoCommit", "false"); myBatisProperties.setProperty("mybatis.pooled.pingEnabled", "true"); myBatisProperties.setProperty("mybatis.pooled.pingQuery", "SELECT 1"); 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 db068b9b8..9b61be0d2 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 @@ -172,6 +172,23 @@ public class SQLServerEnvironment extends JDBCEnvironment { ); } + /** + * Returns the instance name of the SQL Server installation hosting the + * Guacamole database, if any. If unspecified it will be null. + * + * @return + * The instance name of the SQL Server install hosting the Guacamole + * database, or null if undefined. + * + * @throws GuacamoleException + * If an error occurs reading guacamole.properties. + */ + public String getSQLServerInstance() throws GuacamoleException { + return getProperty( + SQLServerGuacamoleProperties.SQLSERVER_INSTANCE + ); + } + /** * Returns the port number of the SQLServer server hosting the Guacamole * authentication tables. If unspecified, this will be the default 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 45635996f..af2a2a161 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 @@ -43,6 +43,17 @@ public class SQLServerGuacamoleProperties { public String getName() { return "sqlserver-hostname"; } }; + + /** + * The instance name of the SQL Server where the Guacamole database is running. + */ + public static final StringGuacamoleProperty SQLSERVER_INSTANCE = + new StringGuacamoleProperty() { + + @Override + public String getName() { return "sqlserver-instance"; } + + }; /** * The port of the SQLServer server hosting the Guacamole authentication