This commit is contained in:
James Muehlner
2013-07-09 11:14:41 -07:00
parent b44faacbae
commit d0ae81fa0c
6 changed files with 27 additions and 0 deletions

View File

@@ -117,6 +117,7 @@ public class MySQLAuthenticationProvider implements AuthenticationProvider {
public MySQLAuthenticationProvider() throws GuacamoleException { public MySQLAuthenticationProvider() throws GuacamoleException {
final Properties myBatisProperties = new Properties(); final Properties myBatisProperties = new Properties();
final Properties driverProperties = new Properties();
// Set the mysql properties for MyBatis. // Set the mysql properties for MyBatis.
myBatisProperties.setProperty("mybatis.environment.id", "guacamole"); myBatisProperties.setProperty("mybatis.environment.id", "guacamole");
@@ -126,6 +127,7 @@ public class MySQLAuthenticationProvider implements AuthenticationProvider {
myBatisProperties.setProperty("JDBC.username", GuacamoleProperties.getRequiredProperty(MySQLGuacamoleProperties.MYSQL_USERNAME)); myBatisProperties.setProperty("JDBC.username", GuacamoleProperties.getRequiredProperty(MySQLGuacamoleProperties.MYSQL_USERNAME));
myBatisProperties.setProperty("JDBC.password", GuacamoleProperties.getRequiredProperty(MySQLGuacamoleProperties.MYSQL_PASSWORD)); myBatisProperties.setProperty("JDBC.password", GuacamoleProperties.getRequiredProperty(MySQLGuacamoleProperties.MYSQL_PASSWORD));
myBatisProperties.setProperty("JDBC.autoCommit", "false"); myBatisProperties.setProperty("JDBC.autoCommit", "false");
driverProperties.setProperty("characterEncoding","UTF-8");
// Set up Guice injector. // Set up Guice injector.
injector = Guice.createInjector( injector = Guice.createInjector(
@@ -135,6 +137,9 @@ public class MySQLAuthenticationProvider implements AuthenticationProvider {
@Override @Override
public void configure(Binder binder) { public void configure(Binder binder) {
Names.bindProperties(binder, myBatisProperties); Names.bindProperties(binder, myBatisProperties);
binder.bind(Properties.class)
.annotatedWith(Names.named("JDBC.driverProperties"))
.toInstance(driverProperties);
} }
}, },

View File

@@ -20,6 +20,7 @@ package net.sourceforge.guacamole.net.basic;
*/ */
import java.io.IOException; import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Collection; import java.util.Collection;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServlet;
@@ -227,6 +228,15 @@ public abstract class AuthenticatingHttpServlet extends HttpServlet {
protected void service(HttpServletRequest request, HttpServletResponse response) protected void service(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException { throws IOException, ServletException {
// Set character encoding to UTF-8 if it's not already set
if(request.getCharacterEncoding() == null) {
try {
request.setCharacterEncoding("UTF-8");
} catch (UnsupportedEncodingException exception) {
throw new ServletException(exception);
}
}
HttpSession httpSession = request.getSession(true); HttpSession httpSession = request.getSession(true);
// Try to get user context from session // Try to get user context from session

View File

@@ -93,6 +93,9 @@ public class List extends AuthenticatingHttpServlet {
// Write XML content type // Write XML content type
response.setHeader("Content-Type", "text/xml"); response.setHeader("Content-Type", "text/xml");
// Set encoding
response.setCharacterEncoding("UTF-8");
// Get connection directory // Get connection directory
Directory<String, Connection> directory = context.getConnectionDirectory(); Directory<String, Connection> directory = context.getConnectionDirectory();

View File

@@ -102,6 +102,9 @@ public class List extends AuthenticatingHttpServlet {
// Do not cache // Do not cache
response.setHeader("Cache-Control", "no-cache"); response.setHeader("Cache-Control", "no-cache");
// Set encoding
response.setCharacterEncoding("UTF-8");
// Write actual XML // Write actual XML
try { try {

View File

@@ -200,6 +200,9 @@ public class List extends AuthenticatingHttpServlet {
// Do not cache // Do not cache
response.setHeader("Cache-Control", "no-cache"); response.setHeader("Cache-Control", "no-cache");
// Set encoding
response.setCharacterEncoding("UTF-8");
// Map of all available protocols // Map of all available protocols
Map<String, ProtocolInfo> protocols = new HashMap<String, ProtocolInfo>(); Map<String, ProtocolInfo> protocols = new HashMap<String, ProtocolInfo>();

View File

@@ -51,6 +51,9 @@ public class List extends AuthenticatingHttpServlet {
// Write XML content type // Write XML content type
response.setHeader("Content-Type", "text/xml"); response.setHeader("Content-Type", "text/xml");
// Set encoding
response.setCharacterEncoding("UTF-8");
// Write actual XML // Write actual XML
try { try {