fix merge errors (i hope)

This commit is contained in:
darkk1138
2013-11-24 11:24:12 +01:00
parent d3ff1188d8
commit b178a96dfc
2 changed files with 4 additions and 165 deletions
+3 -163
View File
@@ -67,6 +67,7 @@ public class LoginService implements INetworkDispatch{
private DatabaseConnection databaseConnection1;
private DatabaseConnection databaseConnection2;
private Random random;
private ILoginProvider LoginProvider;
public LoginService(NGECore core) {
this.core = core;
@@ -96,7 +97,6 @@ public class LoginService implements INetworkDispatch{
data.position(0);
clientID.deserialize(data);
String err = "";
String user = clientID.getAccountName();
String pass = clientID.getPassword();
int id = LoginProvider.getAccountId(user, pass, session.getRemoteAddress().toString());
@@ -307,111 +307,6 @@ public class LoginService implements INetworkDispatch{
return clusterStatus;
}
/**
* Checks if account ID exists in game DB.
* @param id Account ID.
*/
private boolean checkIfAccountExistInGameDB(int id) {
try {
PreparedStatement preparedStatement = databaseConnection.preparedStatement("SELECT * FROM accounts WHERE id=?");
preparedStatement.setInt(1, id);
ResultSet resultSet = preparedStatement.executeQuery();
if (resultSet.next()) {
return true;
}
} catch (SQLException e) {
e.printStackTrace();
}
return false;
}
/**
* Saves forum account to game DB if the account does not exist in the game DB already.
* @param id Account ID.
* @param user Username
* @param email User's email
* @param pass Hashed password
*/
private void createAccountForGameDB(int id, String user, String email, String pass) {
try {
PreparedStatement ps = databaseConnection.preparedStatement("INSERT INTO accounts (id, \"user\", \"pass\", \"email\") VALUES (?, ?, ?, ?)");
ps.setInt(1, id);
ps.setString(2, user);
ps.setString(3, pass);
ps.setString(4, email);
ps.executeUpdate();
ps.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
/**
* Checks if user is allowed to login.
* @param id Account ID.
* @param user Username
* @param email User's email
* @param pass User password
* @param encryptPass encrypted password
* @param ip Users IP address
*/
private String canUserLogin(String user, String email, String pass, String encryptPass, int id, String ip) {
/*if ((new PHPBB3Auth()).phpbb_check_hash(pass, encryptPass)) {
if(checkBanlistforUserAndIP(id, ip)) {
return "You cannot login to the ProjectSWG server while being banned from ProjectSWG services";
}
return "";
} else {
return "Invalid Password";
}*/
try {
PreparedStatement ps = databaseConnection.preparedStatement("SELECT * FROM accounts WHERE id=" + id + " AND \"pass\"='" + pass + "'");
ResultSet resultSet = ps.executeQuery();
if (resultSet.next()) {
return "";
}
} catch (SQLException e) {
e.printStackTrace();
}
return "Invalid Password";
}
/**
* Checks if User has a forum account or IP ban.
* @param id Account ID.
* @param ip User's IP address.
*/
private boolean checkBanlistforUserAndIP(int id, String ip) {
if (!ip.contains("/"))
return false;
String IP = ((ip.split("/", 2)[1]).split(", ", 2)[0]).split(":", 2)[0];
try {
PreparedStatement preparedStatement = databaseConnection2.preparedStatement("SELECT ban_id FROM phpbb_banlist WHERE ban_ip=?");
preparedStatement.setString(1, IP);
ResultSet resultSet = preparedStatement.executeQuery();
if (resultSet.next()) {
return true;
} else {
preparedStatement.close();
preparedStatement = databaseConnection2.preparedStatement("SELECT ban_id FROM phpbb_banlist WHERE ban_userid=?");
preparedStatement.setInt(1, id);
resultSet = preparedStatement.executeQuery();
if (resultSet.next()) {
return true;
}
}
} catch (SQLException e) {
e.printStackTrace();
}
return false;
}
/**
* Checks if User has correct client version.
* @param version Client Version String
@@ -420,61 +315,6 @@ public class LoginService implements INetworkDispatch{
System.out.println("Version Received: " + version);
return true;
}
/**
* Gets Account ID from forum DB by username.
* @param user Username.
*/
private int getAccountID(String user) {
try {
PreparedStatement pStatement = databaseConnection.preparedStatement("SELECT id FROM accounts WHERE \"user\"='" + user + "'");
ResultSet resultSet = pStatement.executeQuery();
if (resultSet.next()) {
return resultSet.getInt("id");
}
} catch (SQLException e) {
e.printStackTrace();
};
return -1;
}
/**
* Gets Account Email from forum DB by username.
* @param user Username.
*/
private String getAccountEmail(String user) {
try {
PreparedStatement pStatement = databaseConnection2.preparedStatement("SELECT user_email FROM phpbb_users WHERE username=?");
pStatement.setString(1, user);
ResultSet resultSet = pStatement.executeQuery();
if (resultSet.next()) {
return resultSet.getString("user_email");
}
} catch (SQLException e) {
e.printStackTrace();
};
return "";
}
/**
* Gets hashed Account Password from forum DB by username.
* @param user Username.
*/
private String getAccountPassword(String user) {
try {
PreparedStatement pStatement = databaseConnection2.preparedStatement("SELECT user_password FROM phpbb_users WHERE username=?");
pStatement.setString(1, user);
ResultSet resultSet = pStatement.executeQuery();
if (resultSet.next()) {
return resultSet.getString("user_password");
}
pStatement.close();
} catch (SQLException e) {
e.printStackTrace();
};
return "";
}
}