mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 05:07:41 +00:00
GUACAMOLE-760: Add support for configuring server timezone.
This commit is contained in:
@@ -24,6 +24,7 @@ import com.google.inject.Module;
|
||||
import com.google.inject.name.Names;
|
||||
import java.io.File;
|
||||
import java.util.Properties;
|
||||
import java.util.TimeZone;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.auth.mysql.conf.MySQLDriver;
|
||||
import org.apache.guacamole.auth.mysql.conf.MySQLEnvironment;
|
||||
@@ -115,6 +116,11 @@ public class MySQLAuthenticationProviderModule implements Module {
|
||||
// Get the MySQL-compatible driver to use.
|
||||
mysqlDriver = environment.getMySQLDriver();
|
||||
|
||||
// If timezone is present, set it.
|
||||
TimeZone serverTz = environment.getServerTimeZone();
|
||||
if (serverTz != null)
|
||||
driverProperties.setProperty("serverTimezone", serverTz.getID());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -23,6 +23,7 @@ import java.io.File;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.sql.SQLException;
|
||||
import java.util.TimeZone;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.auth.jdbc.JDBCEnvironment;
|
||||
import org.slf4j.Logger;
|
||||
@@ -393,4 +394,18 @@ public class MySQLEnvironment extends JDBCEnvironment {
|
||||
false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the server timezone if configured in guacamole.properties, or
|
||||
* null if the configuration option is not present.
|
||||
*
|
||||
* @return
|
||||
* The server timezone as configured in guacamole.properties.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs retrieving the configuration value.
|
||||
*/
|
||||
public TimeZone getServerTimeZone() throws GuacamoleException {
|
||||
return getProperty(MySQLGuacamoleProperties.SERVER_TIMEZONE);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -24,6 +24,7 @@ import org.apache.guacamole.properties.EnumGuacamoleProperty;
|
||||
import org.apache.guacamole.properties.FileGuacamoleProperty;
|
||||
import org.apache.guacamole.properties.IntegerGuacamoleProperty;
|
||||
import org.apache.guacamole.properties.StringGuacamoleProperty;
|
||||
import org.apache.guacamole.properties.TimeZoneGuacamoleProperty;
|
||||
|
||||
/**
|
||||
* Properties used by the MySQL Authentication plugin.
|
||||
@@ -251,6 +252,16 @@ public class MySQLGuacamoleProperties {
|
||||
|
||||
@Override
|
||||
public String getName() { return "mysql-auto-create-accounts"; }
|
||||
};
|
||||
|
||||
/**
|
||||
* The time zone of the MySQL database server.
|
||||
*/
|
||||
public static final TimeZoneGuacamoleProperty SERVER_TIMEZONE =
|
||||
new TimeZoneGuacamoleProperty() {
|
||||
|
||||
@Override
|
||||
public String getName() { return "mysql-server-timezone"; }
|
||||
|
||||
};
|
||||
|
||||
|
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.properties;
|
||||
|
||||
import java.util.TimeZone;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
|
||||
/**
|
||||
* A GuacamoleProperty whose value is a TimeZone.
|
||||
*/
|
||||
public abstract class TimeZoneGuacamoleProperty
|
||||
implements GuacamoleProperty<TimeZone> {
|
||||
|
||||
@Override
|
||||
public TimeZone parseValue(String value) throws GuacamoleException {
|
||||
|
||||
// Nothing in, nothing out
|
||||
if (value == null || value.isEmpty())
|
||||
return null;
|
||||
|
||||
// Attempt to return the TimeZone of the provided string value.
|
||||
return TimeZone.getTimeZone(value);
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user