From 863607c9a401cd424f3210ec1b7ceb399ba4684e Mon Sep 17 00:00:00 2001 From: games647 Date: Thu, 23 Feb 2017 09:16:11 +0100 Subject: [PATCH] Add optional useSSL config option --- LICENSE | 2 +- .../com/github/games647/fastlogin/core/AuthStorage.java | 3 ++- .../games647/fastlogin/core/shared/FastLoginCore.java | 4 +++- core/src/main/resources/config.yml | 8 ++++++-- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/LICENSE b/LICENSE index 20efd1b3..a3852d9e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2015 +Copyright (c) 2015-17 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/core/src/main/java/com/github/games647/fastlogin/core/AuthStorage.java b/core/src/main/java/com/github/games647/fastlogin/core/AuthStorage.java index 80480381..e256350e 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/AuthStorage.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/AuthStorage.java @@ -23,7 +23,7 @@ public class AuthStorage { private final HikariDataSource dataSource; public AuthStorage(FastLoginCore core, String driver, String host, int port, String databasePath - , String user, String pass) { + , String user, String pass, boolean useSSL) { this.core = core; HikariConfig databaseConfig = new HikariConfig(); @@ -34,6 +34,7 @@ public class AuthStorage { //a try to fix https://www.spigotmc.org/threads/fastlogin.101192/page-26#post-1874647 Properties properties = new Properties(); properties.setProperty("date_string_format", "yyyy-MM-dd HH:mm:ss"); + properties.setProperty("useSSL", String.valueOf(useSSL)); databaseConfig.setDataSourceProperties(properties); ThreadFactoryBuilder threadFactoryBuilder = new ThreadFactoryBuilder() diff --git a/core/src/main/java/com/github/games647/fastlogin/core/shared/FastLoginCore.java b/core/src/main/java/com/github/games647/fastlogin/core/shared/FastLoginCore.java index ea84ac14..af8a5247 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/shared/FastLoginCore.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/shared/FastLoginCore.java @@ -162,7 +162,9 @@ public class FastLoginCore

> { String user = sharedConfig.get("username", ""); String password = sharedConfig.get("password", ""); - storage = new AuthStorage(this, driver, host, port, database, user, password); + boolean useSSL = sharedConfig.get("useSSL", false); + + storage = new AuthStorage(this, driver, host, port, database, user, password, useSSL); try { storage.createTables(); return true; diff --git a/core/src/main/resources/config.yml b/core/src/main/resources/config.yml index de043749..eb7d87f4 100644 --- a/core/src/main/resources/config.yml +++ b/core/src/main/resources/config.yml @@ -164,10 +164,14 @@ driver: org.sqlite.JDBC # File location database: '{pluginDir}/FastLogin.db' -# MySQL +# MySQL/MariaDB #driver: com.mysql.jdbc.Driver #host: localhost #port: 3306 #database: fastlogin #username: myUser -#password: myPassword \ No newline at end of file +#password: myPassword + +# It's strongly recommended to enable SSL and setup a SSL certificate if the MySQL server isn't running on the same +# machine +#useSSL: false