mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-10-31 16:01:00 +01:00
Removed SecurityTable.Col
This commit is contained in:
parent
21b1489d69
commit
84dc8e4c3b
@ -22,7 +22,10 @@ import com.djrapitops.plan.db.DBType;
|
|||||||
import com.djrapitops.plan.db.SQLDB;
|
import com.djrapitops.plan.db.SQLDB;
|
||||||
import com.djrapitops.plan.db.access.ExecStatement;
|
import com.djrapitops.plan.db.access.ExecStatement;
|
||||||
import com.djrapitops.plan.db.access.QueryStatement;
|
import com.djrapitops.plan.db.access.QueryStatement;
|
||||||
import com.djrapitops.plan.db.sql.parsing.*;
|
import com.djrapitops.plan.db.sql.parsing.CreateTableParser;
|
||||||
|
import com.djrapitops.plan.db.sql.parsing.Insert;
|
||||||
|
import com.djrapitops.plan.db.sql.parsing.Select;
|
||||||
|
import com.djrapitops.plan.db.sql.parsing.Sql;
|
||||||
import com.djrapitops.plugin.utilities.Verify;
|
import com.djrapitops.plugin.utilities.Verify;
|
||||||
|
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
@ -34,8 +37,6 @@ import java.util.List;
|
|||||||
* Table that is in charge of storing WebUser data.
|
* Table that is in charge of storing WebUser data.
|
||||||
* <p>
|
* <p>
|
||||||
* Table Name: plan_security
|
* Table Name: plan_security
|
||||||
* <p>
|
|
||||||
* For contained columns {@link Col}
|
|
||||||
*
|
*
|
||||||
* @author Rsl1122
|
* @author Rsl1122
|
||||||
* @see WebUser
|
* @see WebUser
|
||||||
@ -51,9 +52,9 @@ public class SecurityTable extends Table {
|
|||||||
public SecurityTable(SQLDB db) {
|
public SecurityTable(SQLDB db) {
|
||||||
super(TABLE_NAME, db);
|
super(TABLE_NAME, db);
|
||||||
insertStatement = Insert.values(tableName,
|
insertStatement = Insert.values(tableName,
|
||||||
Col.USERNAME,
|
USERNAME,
|
||||||
Col.SALT_PASSWORD_HASH,
|
SALT_PASSWORD_HASH,
|
||||||
Col.PERMISSION_LEVEL);
|
PERMISSION_LEVEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String insertStatement;
|
private String insertStatement;
|
||||||
@ -72,7 +73,7 @@ public class SecurityTable extends Table {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void removeUser(String user) {
|
public void removeUser(String user) {
|
||||||
String sql = "DELETE FROM " + tableName + " WHERE (" + Col.USERNAME + "=?)";
|
String sql = "DELETE FROM " + tableName + " WHERE (" + USERNAME + "=?)";
|
||||||
|
|
||||||
execute(new ExecStatement(sql) {
|
execute(new ExecStatement(sql) {
|
||||||
@Override
|
@Override
|
||||||
@ -83,7 +84,7 @@ public class SecurityTable extends Table {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public WebUser getWebUser(String user) {
|
public WebUser getWebUser(String user) {
|
||||||
String sql = Select.all(tableName).where(Col.USERNAME + "=?").toString();
|
String sql = Select.all(tableName).where(USERNAME + "=?").toString();
|
||||||
|
|
||||||
return query(new QueryStatement<WebUser>(sql) {
|
return query(new QueryStatement<WebUser>(sql) {
|
||||||
@Override
|
@Override
|
||||||
@ -94,8 +95,8 @@ public class SecurityTable extends Table {
|
|||||||
@Override
|
@Override
|
||||||
public WebUser processResults(ResultSet set) throws SQLException {
|
public WebUser processResults(ResultSet set) throws SQLException {
|
||||||
if (set.next()) {
|
if (set.next()) {
|
||||||
String saltedPassHash = set.getString(Col.SALT_PASSWORD_HASH.get());
|
String saltedPassHash = set.getString(SALT_PASSWORD_HASH);
|
||||||
int permissionLevel = set.getInt(Col.PERMISSION_LEVEL.get());
|
int permissionLevel = set.getInt(PERMISSION_LEVEL);
|
||||||
return new WebUser(user, saltedPassHash, permissionLevel);
|
return new WebUser(user, saltedPassHash, permissionLevel);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -122,29 +123,6 @@ public class SecurityTable extends Table {
|
|||||||
return getWebUser(user) != null;
|
return getWebUser(user) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public enum Col implements Column {
|
|
||||||
@Deprecated USERNAME("username"),
|
|
||||||
@Deprecated SALT_PASSWORD_HASH("salted_pass_hash"),
|
|
||||||
@Deprecated PERMISSION_LEVEL("permission_level");
|
|
||||||
|
|
||||||
private final String column;
|
|
||||||
|
|
||||||
Col(String column) {
|
|
||||||
this.column = column;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String get() {
|
|
||||||
return toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return column;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addUsers(List<WebUser> users) {
|
public void addUsers(List<WebUser> users) {
|
||||||
if (Verify.isEmpty(users)) {
|
if (Verify.isEmpty(users)) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user