Фикс инициализации MySQLAuthHandler

This commit is contained in:
Gravit 2018-12-26 18:35:28 +07:00
parent 84a6784d26
commit 05bad22ede
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
2 changed files with 31 additions and 5 deletions

View file

@ -118,6 +118,18 @@ public String getBindAddress() {
return bindAddress; return bindAddress;
} }
public void setProjectName(String projectName) {
this.projectName = projectName;
}
public void setBinaryName(String binaryName) {
this.binaryName = binaryName;
}
public void setEnv(LauncherConfig.LauncherEnvironment env) {
this.env = env;
}
public SocketAddress getSocketAddress() { public SocketAddress getSocketAddress() {
return new InetSocketAddress(bindAddress, port); return new InetSocketAddress(bindAddress, port);
@ -478,6 +490,8 @@ private void generateConfigIfNotExists() throws IOException {
// Set server address // Set server address
LogHelper.println("LaunchServer address: "); LogHelper.println("LaunchServer address: ");
newConfig.setAddress(commandHandler.readLine()); newConfig.setAddress(commandHandler.readLine());
LogHelper.println("LaunchServer projectName: ");
newConfig.setProjectName(commandHandler.readLine());
// Write LaunchServer config // Write LaunchServer config
LogHelper.info("Writing LaunchServer config file"); LogHelper.info("Writing LaunchServer config file");

View file

@ -15,13 +15,25 @@ public final class MySQLAuthHandler extends CachedAuthHandler {
private String usernameColumn; private String usernameColumn;
private String accessTokenColumn; private String accessTokenColumn;
private String serverIDColumn; private String serverIDColumn;
private String table;
// Prepared SQL queries // Prepared SQL queries
private String queryByUUIDSQL; private transient String queryByUUIDSQL;
private String queryByUsernameSQL; private transient String queryByUsernameSQL;
private String updateAuthSQL; private transient String updateAuthSQL;
private String updateServerIDSQL; private transient String updateServerIDSQL;
public MySQLAuthHandler()
{
// Prepare SQL queries
queryByUUIDSQL = String.format("SELECT %s, %s, %s, %s FROM %s WHERE %s=? LIMIT 1",
uuidColumn, usernameColumn, accessTokenColumn, serverIDColumn, table, uuidColumn);
queryByUsernameSQL = String.format("SELECT %s, %s, %s, %s FROM %s WHERE %s=? LIMIT 1",
uuidColumn, usernameColumn, accessTokenColumn, serverIDColumn, table, usernameColumn);
updateAuthSQL = String.format("UPDATE %s SET %s=?, %s=?, %s=NULL WHERE %s=? LIMIT 1",
table, usernameColumn, accessTokenColumn, serverIDColumn, uuidColumn);
updateServerIDSQL = String.format("UPDATE %s SET %s=? WHERE %s=? LIMIT 1",
table, serverIDColumn, uuidColumn);
}
@Override @Override
public void close() { public void close() {
mySQLHolder.close(); mySQLHolder.close();