mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-04-03 15:01:56 +03:00
[REFACTOR] Removed commented code
This commit is contained in:
parent
4deffc9a8e
commit
1a3daa1954
1 changed files with 0 additions and 75 deletions
|
@ -51,8 +51,6 @@ public abstract class AbstractSQLCoreProvider extends AuthCoreProvider {
|
||||||
public String customQueryByUsernameSQL;
|
public String customQueryByUsernameSQL;
|
||||||
public String customQueryByLoginSQL;
|
public String customQueryByLoginSQL;
|
||||||
public String customQueryPermissionsByUUIDSQL;
|
public String customQueryPermissionsByUUIDSQL;
|
||||||
//public String customQueryRoleByUUIDSQL;
|
|
||||||
//public String customQueryRoleByNameSQL;
|
|
||||||
public String customQueryRolesByUserUUID;
|
public String customQueryRolesByUserUUID;
|
||||||
public String customUpdateAuthSQL;
|
public String customUpdateAuthSQL;
|
||||||
public String customUpdateServerIdSQL;
|
public String customUpdateServerIdSQL;
|
||||||
|
@ -61,8 +59,6 @@ public abstract class AbstractSQLCoreProvider extends AuthCoreProvider {
|
||||||
public transient String queryByUsernameSQL;
|
public transient String queryByUsernameSQL;
|
||||||
public transient String queryByLoginSQL;
|
public transient String queryByLoginSQL;
|
||||||
public transient String queryPermissionsByUUIDSQL;
|
public transient String queryPermissionsByUUIDSQL;
|
||||||
//public transient String queryRoleByUUIDSQL;
|
|
||||||
//public transient String queryRoleByNameSQL;
|
|
||||||
public transient String queryRolesByUserUUID;
|
public transient String queryRolesByUserUUID;
|
||||||
|
|
||||||
public transient String updateAuthSQL;
|
public transient String updateAuthSQL;
|
||||||
|
@ -179,10 +175,6 @@ public void init(LaunchServer server) {
|
||||||
queryByUsernameSQL = customQueryByUsernameSQL != null ? customQueryByUsernameSQL : String.format("SELECT %s FROM %s WHERE %s=? LIMIT 1",
|
queryByUsernameSQL = customQueryByUsernameSQL != null ? customQueryByUsernameSQL : String.format("SELECT %s FROM %s WHERE %s=? LIMIT 1",
|
||||||
userInfoCols, table, usernameColumn);
|
userInfoCols, table, usernameColumn);
|
||||||
queryByLoginSQL = customQueryByLoginSQL != null ? customQueryByLoginSQL : queryByUsernameSQL;
|
queryByLoginSQL = customQueryByLoginSQL != null ? customQueryByLoginSQL : queryByUsernameSQL;
|
||||||
/*
|
|
||||||
queryPermissionsByUUIDSQL = customQueryPermissionsByUUIDSQL != null ? customQueryPermissionsByUUIDSQL : String.format("SELECT (%s) FROM %s WHERE %s=?",
|
|
||||||
permissionsPermissionColumn, permissionsTable, permissionsUUIDColumn);
|
|
||||||
*/
|
|
||||||
|
|
||||||
queryPermissionsByUUIDSQL = customQueryPermissionsByUUIDSQL != null ? customQueryPermissionsByUUIDSQL :
|
queryPermissionsByUUIDSQL = customQueryPermissionsByUUIDSQL != null ? customQueryPermissionsByUUIDSQL :
|
||||||
"WITH RECURSIVE req AS (\n" +
|
"WITH RECURSIVE req AS (\n" +
|
||||||
|
@ -196,13 +188,7 @@ public void init(LaunchServer server) {
|
||||||
queryRolesByUserUUID = customQueryRolesByUserUUID != null ? customQueryRolesByUserUUID : String.format("SELECT r.%s FROM %s r\n" +
|
queryRolesByUserUUID = customQueryRolesByUserUUID != null ? customQueryRolesByUserUUID : String.format("SELECT r.%s FROM %s r\n" +
|
||||||
"INNER JOIN %s pr ON r.%s=substring(pr.%s from 6) or r.%s=substring(pr.%s from 6)\n" +
|
"INNER JOIN %s pr ON r.%s=substring(pr.%s from 6) or r.%s=substring(pr.%s from 6)\n" +
|
||||||
"WHERE pr.%s = ?",rolesNameColumn,rolesTable,permissionsTable,rolesUUIDColumn,permissionsPermissionColumn,rolesNameColumn,permissionsPermissionColumn,permissionsUUIDColumn);
|
"WHERE pr.%s = ?",rolesNameColumn,rolesTable,permissionsTable,rolesUUIDColumn,permissionsPermissionColumn,rolesNameColumn,permissionsPermissionColumn,permissionsUUIDColumn);
|
||||||
/*
|
|
||||||
queryRoleByUUIDSQL = customQueryRoleByUUIDSQL != null ? customQueryRoleByUUIDSQL : String.format("SELECT %s, %s FROM %s WHERE %s=? LIMIT 1",
|
|
||||||
rolesUUIDColumn, rolesNameColumn,rolesTable,rolesUUIDColumn);
|
|
||||||
|
|
||||||
queryRoleByNameSQL = customQueryRoleByNameSQL != null ? customQueryRoleByNameSQL : String.format("SELECT %s, %s FROM %s WHERE %s=? LIMIT 1",
|
|
||||||
rolesUUIDColumn, rolesNameColumn,rolesTable,rolesNameColumn);
|
|
||||||
*/
|
|
||||||
updateAuthSQL = customUpdateAuthSQL != null ? customUpdateAuthSQL : String.format("UPDATE %s SET %s=?, %s=NULL WHERE %s=?",
|
updateAuthSQL = customUpdateAuthSQL != null ? customUpdateAuthSQL : String.format("UPDATE %s SET %s=?, %s=NULL WHERE %s=?",
|
||||||
table, accessTokenColumn, serverIDColumn, uuidColumn);
|
table, accessTokenColumn, serverIDColumn, uuidColumn);
|
||||||
updateServerIDSQL = customUpdateServerIdSQL != null ? customUpdateServerIdSQL : String.format("UPDATE %s SET %s=? WHERE %s=?",
|
updateServerIDSQL = customUpdateServerIdSQL != null ? customUpdateServerIdSQL : String.format("UPDATE %s SET %s=? WHERE %s=?",
|
||||||
|
@ -245,7 +231,6 @@ public void close() throws IOException {
|
||||||
|
|
||||||
private SQLUser constructUser(ResultSet set) throws SQLException {
|
private SQLUser constructUser(ResultSet set) throws SQLException {
|
||||||
return set.next() ? new SQLUser(UUID.fromString(set.getString(uuidColumn)), set.getString(usernameColumn),
|
return set.next() ? new SQLUser(UUID.fromString(set.getString(uuidColumn)), set.getString(usernameColumn),
|
||||||
//set.getString(accessTokenColumn), set.getString(serverIDColumn), set.getString(passwordColumn), requestPermissions(set.getString(uuidColumn))) : null;
|
|
||||||
set.getString(accessTokenColumn), set.getString(serverIDColumn), set.getString(passwordColumn), requestPermissions(set.getString(uuidColumn))) : null;
|
set.getString(accessTokenColumn), set.getString(serverIDColumn), set.getString(passwordColumn), requestPermissions(set.getString(uuidColumn))) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,40 +238,7 @@ public ClientPermissions requestPermissions (String uuid) throws SQLException
|
||||||
{
|
{
|
||||||
return new ClientPermissions(queryRolesNames(queryRolesByUserUUID,uuid),queryPermissions(queryPermissionsByUUIDSQL,uuid));
|
return new ClientPermissions(queryRolesNames(queryRolesByUserUUID,uuid),queryPermissions(queryPermissionsByUUIDSQL,uuid));
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
public ClientPermissions requestPermissions (String uuid) throws SQLException
|
|
||||||
{
|
|
||||||
try{
|
|
||||||
ClientPermissions perms = new ClientPermissions();
|
|
||||||
|
|
||||||
for(String perm : queryPermissions(queryPermissionsByUUIDSQL,uuid))
|
|
||||||
perms.addPerm(perm);
|
|
||||||
|
|
||||||
List<String> groupPerms = new ArrayList<>(perms.getPerms());
|
|
||||||
groupPerms.removeIf(s->!s.startsWith("role."));
|
|
||||||
|
|
||||||
for(String groupPerm : groupPerms)
|
|
||||||
{
|
|
||||||
String role = groupPerm.substring(5);
|
|
||||||
if(processRole(queryRole(queryRoleByUUIDSQL,role),perms)) continue;
|
|
||||||
if(processRole(queryRole(queryRoleByNameSQL,role),perms)) continue;
|
|
||||||
logger.warn(String.format( "Role not found: %s",role));
|
|
||||||
}
|
|
||||||
|
|
||||||
return perms;
|
|
||||||
} catch (SQLException e) {
|
|
||||||
throw new SQLException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean processRole(SQLRole role, ClientPermissions perms) throws SQLException {
|
|
||||||
if(role == null) return false;
|
|
||||||
perms.addRole(role.name);
|
|
||||||
for(String perm : queryPermissions(queryPermissionsByUUIDSQL,role.uuid))
|
|
||||||
perms.addPerm(perm);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
private SQLUser queryUser(String sql, String value) throws SQLException {
|
private SQLUser queryUser(String sql, String value) throws SQLException {
|
||||||
try (Connection c = getSQLConfig().getConnection()) {
|
try (Connection c = getSQLConfig().getConnection()) {
|
||||||
PreparedStatement s = c.prepareStatement(sql);
|
PreparedStatement s = c.prepareStatement(sql);
|
||||||
|
@ -330,33 +282,6 @@ private List<String> queryRolesNames(String sql, String value) throws SQLExcepti
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
private SQLRole queryRole(String sql, String value) throws SQLException {
|
|
||||||
try (Connection c = getSQLConfig().getConnection()) {
|
|
||||||
PreparedStatement s = c.prepareStatement(sql);
|
|
||||||
s.setString(1, value);
|
|
||||||
s.setQueryTimeout(MySQLSourceConfig.TIMEOUT);
|
|
||||||
ResultSet set = s.executeQuery();
|
|
||||||
if(!set.next()) return null;
|
|
||||||
return new SQLRole(set.getString(rolesNameColumn), set.getString(rolesUUIDColumn));
|
|
||||||
} catch (SQLException e) {
|
|
||||||
throw new SQLException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class SQLRole
|
|
||||||
{
|
|
||||||
public String name;
|
|
||||||
public String uuid;
|
|
||||||
|
|
||||||
SQLRole(String name, String uuid)
|
|
||||||
{
|
|
||||||
this.name = name;
|
|
||||||
this.uuid = uuid;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
public static class SQLUser implements User {
|
public static class SQLUser implements User {
|
||||||
protected UUID uuid;
|
protected UUID uuid;
|
||||||
protected String username;
|
protected String username;
|
||||||
|
|
Loading…
Reference in a new issue