SHA256
Сервер: переименовать слой current users
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
package shine.db.dao;
|
package shine.db.dao;
|
||||||
|
|
||||||
import shine.db.DbController;
|
import shine.db.DbController;
|
||||||
import shine.db.sql.SolanaUsersSql;
|
import shine.db.sql.CurrentUsersSql;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
@@ -49,8 +49,8 @@ public final class ConnectionsStateDAO {
|
|||||||
AND cs.rel_type = ?
|
AND cs.rel_type = ?
|
||||||
ORDER BY friend_login
|
ORDER BY friend_login
|
||||||
""".formatted(
|
""".formatted(
|
||||||
SolanaUsersSql.usersSubquery("u_login"),
|
CurrentUsersSql.usersSubquery("u_login"),
|
||||||
SolanaUsersSql.usersSubquery("u_bch")
|
CurrentUsersSql.usersSubquery("u_bch")
|
||||||
);
|
);
|
||||||
|
|
||||||
List<String> out = new ArrayList<>();
|
List<String> out = new ArrayList<>();
|
||||||
@@ -85,8 +85,8 @@ public final class ConnectionsStateDAO {
|
|||||||
AND cs.rel_type = ?
|
AND cs.rel_type = ?
|
||||||
ORDER BY friend_login
|
ORDER BY friend_login
|
||||||
""".formatted(
|
""".formatted(
|
||||||
SolanaUsersSql.usersSubquery("u_actor"),
|
CurrentUsersSql.usersSubquery("u_actor"),
|
||||||
SolanaUsersSql.usersSubquery("u_target")
|
CurrentUsersSql.usersSubquery("u_target")
|
||||||
);
|
);
|
||||||
|
|
||||||
List<String> out = new ArrayList<>();
|
List<String> out = new ArrayList<>();
|
||||||
@@ -123,7 +123,7 @@ public final class ConnectionsStateDAO {
|
|||||||
AND b.rel_type = a.rel_type
|
AND b.rel_type = a.rel_type
|
||||||
)
|
)
|
||||||
ORDER BY u.login
|
ORDER BY u.login
|
||||||
""".formatted(SolanaUsersSql.usersSubquery("u"));
|
""".formatted(CurrentUsersSql.usersSubquery("u"));
|
||||||
|
|
||||||
List<String> out = new ArrayList<>();
|
List<String> out = new ArrayList<>();
|
||||||
try (PreparedStatement ps = c.prepareStatement(sql)) {
|
try (PreparedStatement ps = c.prepareStatement(sql)) {
|
||||||
|
|||||||
+23
-23
@@ -2,15 +2,15 @@ package shine.db.dao;
|
|||||||
|
|
||||||
import shine.db.DbController;
|
import shine.db.DbController;
|
||||||
import shine.db.KeyEncodingUtil;
|
import shine.db.KeyEncodingUtil;
|
||||||
import shine.db.entities.SolanaUserEntry;
|
import shine.db.entities.CurrentUserEntry;
|
||||||
import shine.db.sql.SolanaUsersSql;
|
import shine.db.sql.CurrentUsersSql;
|
||||||
|
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SolanaUsersDAO — совместимый runtime-доступ к текущему срезу пользователей.
|
* CurrentUsersDAO — совместимый runtime-доступ к текущему срезу пользователей.
|
||||||
*
|
*
|
||||||
* Источник:
|
* Источник:
|
||||||
* - solana_user_pda_current
|
* - solana_user_pda_current
|
||||||
@@ -26,17 +26,17 @@ import java.util.List;
|
|||||||
* - методы с Connection НЕ закрывают соединение
|
* - методы с Connection НЕ закрывают соединение
|
||||||
* - методы без Connection сами открывают и закрывают соединение
|
* - методы без Connection сами открывают и закрывают соединение
|
||||||
*/
|
*/
|
||||||
public final class SolanaUsersDAO {
|
public final class CurrentUsersDAO {
|
||||||
|
|
||||||
private static volatile SolanaUsersDAO instance;
|
private static volatile CurrentUsersDAO instance;
|
||||||
private final DbController db = DbController.getInstance();
|
private final DbController db = DbController.getInstance();
|
||||||
|
|
||||||
private SolanaUsersDAO() {}
|
private CurrentUsersDAO() {}
|
||||||
|
|
||||||
public static SolanaUsersDAO getInstance() {
|
public static CurrentUsersDAO getInstance() {
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
synchronized (SolanaUsersDAO.class) {
|
synchronized (CurrentUsersDAO.class) {
|
||||||
if (instance == null) instance = new SolanaUsersDAO();
|
if (instance == null) instance = new CurrentUsersDAO();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return instance;
|
return instance;
|
||||||
@@ -51,7 +51,7 @@ public final class SolanaUsersDAO {
|
|||||||
FROM %s
|
FROM %s
|
||||||
WHERE LOWER(login) = LOWER(?)
|
WHERE LOWER(login) = LOWER(?)
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
""".formatted(SolanaUsersSql.usersSubquery("su"));
|
""".formatted(CurrentUsersSql.usersSubquery("su"));
|
||||||
|
|
||||||
try (PreparedStatement ps = c.prepareStatement(sql)) {
|
try (PreparedStatement ps = c.prepareStatement(sql)) {
|
||||||
ps.setString(1, login);
|
ps.setString(1, login);
|
||||||
@@ -75,7 +75,7 @@ public final class SolanaUsersDAO {
|
|||||||
FROM %s
|
FROM %s
|
||||||
WHERE blockchain_name = ?
|
WHERE blockchain_name = ?
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
""".formatted(SolanaUsersSql.usersSubquery("su"));
|
""".formatted(CurrentUsersSql.usersSubquery("su"));
|
||||||
|
|
||||||
try (PreparedStatement ps = c.prepareStatement(sql)) {
|
try (PreparedStatement ps = c.prepareStatement(sql)) {
|
||||||
ps.setString(1, blockchainName);
|
ps.setString(1, blockchainName);
|
||||||
@@ -95,7 +95,7 @@ public final class SolanaUsersDAO {
|
|||||||
// -------------------- SELECT --------------------
|
// -------------------- SELECT --------------------
|
||||||
|
|
||||||
/** Получить по login (case-insensitive) с внешним соединением. Соединение НЕ закрывает. */
|
/** Получить по login (case-insensitive) с внешним соединением. Соединение НЕ закрывает. */
|
||||||
public SolanaUserEntry getByLogin(Connection c, String login) throws SQLException {
|
public CurrentUserEntry getByLogin(Connection c, String login) throws SQLException {
|
||||||
String sql = """
|
String sql = """
|
||||||
SELECT
|
SELECT
|
||||||
login,
|
login,
|
||||||
@@ -105,7 +105,7 @@ public final class SolanaUsersDAO {
|
|||||||
client_key
|
client_key
|
||||||
FROM %s
|
FROM %s
|
||||||
WHERE LOWER(login) = LOWER(?)
|
WHERE LOWER(login) = LOWER(?)
|
||||||
""".formatted(SolanaUsersSql.usersSubquery("su"));
|
""".formatted(CurrentUsersSql.usersSubquery("su"));
|
||||||
|
|
||||||
try (PreparedStatement ps = c.prepareStatement(sql)) {
|
try (PreparedStatement ps = c.prepareStatement(sql)) {
|
||||||
ps.setString(1, login);
|
ps.setString(1, login);
|
||||||
@@ -117,14 +117,14 @@ public final class SolanaUsersDAO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Получить по login (case-insensitive) без внешнего соединения. Сам открывает/закрывает. */
|
/** Получить по login (case-insensitive) без внешнего соединения. Сам открывает/закрывает. */
|
||||||
public SolanaUserEntry getByLogin(String login) throws SQLException {
|
public CurrentUserEntry getByLogin(String login) throws SQLException {
|
||||||
try (Connection c = db.getConnection()) {
|
try (Connection c = db.getConnection()) {
|
||||||
return getByLogin(c, login);
|
return getByLogin(c, login);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Получить по blockchain_name (case-sensitive) с внешним соединением. Соединение НЕ закрывает. */
|
/** Получить по blockchain_name (case-sensitive) с внешним соединением. Соединение НЕ закрывает. */
|
||||||
public SolanaUserEntry getByBlockchainName(Connection c, String blockchainName) throws SQLException {
|
public CurrentUserEntry getByBlockchainName(Connection c, String blockchainName) throws SQLException {
|
||||||
String sql = """
|
String sql = """
|
||||||
SELECT
|
SELECT
|
||||||
login,
|
login,
|
||||||
@@ -134,7 +134,7 @@ public final class SolanaUsersDAO {
|
|||||||
client_key
|
client_key
|
||||||
FROM %s
|
FROM %s
|
||||||
WHERE blockchain_name = ?
|
WHERE blockchain_name = ?
|
||||||
""".formatted(SolanaUsersSql.usersSubquery("su"));
|
""".formatted(CurrentUsersSql.usersSubquery("su"));
|
||||||
|
|
||||||
try (PreparedStatement ps = c.prepareStatement(sql)) {
|
try (PreparedStatement ps = c.prepareStatement(sql)) {
|
||||||
ps.setString(1, blockchainName);
|
ps.setString(1, blockchainName);
|
||||||
@@ -146,14 +146,14 @@ public final class SolanaUsersDAO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Получить по blockchain_name без внешнего соединения. */
|
/** Получить по blockchain_name без внешнего соединения. */
|
||||||
public SolanaUserEntry getByBlockchainName(String blockchainName) throws SQLException {
|
public CurrentUserEntry getByBlockchainName(String blockchainName) throws SQLException {
|
||||||
try (Connection c = db.getConnection()) {
|
try (Connection c = db.getConnection()) {
|
||||||
return getByBlockchainName(c, blockchainName);
|
return getByBlockchainName(c, blockchainName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Поиск по префиксу с внешним соединением. Соединение НЕ закрывает. */
|
/** Поиск по префиксу с внешним соединением. Соединение НЕ закрывает. */
|
||||||
public List<SolanaUserEntry> searchByLoginPrefix(Connection c, String prefix) throws SQLException {
|
public List<CurrentUserEntry> searchByLoginPrefix(Connection c, String prefix) throws SQLException {
|
||||||
String sql = """
|
String sql = """
|
||||||
SELECT
|
SELECT
|
||||||
login,
|
login,
|
||||||
@@ -165,9 +165,9 @@ public final class SolanaUsersDAO {
|
|||||||
WHERE LOWER(login) LIKE ?
|
WHERE LOWER(login) LIKE ?
|
||||||
ORDER BY login
|
ORDER BY login
|
||||||
LIMIT 5
|
LIMIT 5
|
||||||
""".formatted(SolanaUsersSql.usersSubquery("su"));
|
""".formatted(CurrentUsersSql.usersSubquery("su"));
|
||||||
|
|
||||||
List<SolanaUserEntry> result = new ArrayList<>();
|
List<CurrentUserEntry> result = new ArrayList<>();
|
||||||
|
|
||||||
try (PreparedStatement ps = c.prepareStatement(sql)) {
|
try (PreparedStatement ps = c.prepareStatement(sql)) {
|
||||||
ps.setString(1, prefix.toLowerCase() + "%");
|
ps.setString(1, prefix.toLowerCase() + "%");
|
||||||
@@ -180,7 +180,7 @@ public final class SolanaUsersDAO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Поиск по префиксу без внешнего соединения. Сам открывает/закрывает. */
|
/** Поиск по префиксу без внешнего соединения. Сам открывает/закрывает. */
|
||||||
public List<SolanaUserEntry> searchByLoginPrefix(String prefix) throws SQLException {
|
public List<CurrentUserEntry> searchByLoginPrefix(String prefix) throws SQLException {
|
||||||
try (Connection c = db.getConnection()) {
|
try (Connection c = db.getConnection()) {
|
||||||
return searchByLoginPrefix(c, prefix);
|
return searchByLoginPrefix(c, prefix);
|
||||||
}
|
}
|
||||||
@@ -188,8 +188,8 @@ public final class SolanaUsersDAO {
|
|||||||
|
|
||||||
// -------------------- MAPPER --------------------
|
// -------------------- MAPPER --------------------
|
||||||
|
|
||||||
private SolanaUserEntry mapRow(ResultSet rs) throws SQLException {
|
private CurrentUserEntry mapRow(ResultSet rs) throws SQLException {
|
||||||
SolanaUserEntry e = new SolanaUserEntry();
|
CurrentUserEntry e = new CurrentUserEntry();
|
||||||
|
|
||||||
e.setLogin(rs.getString("login"));
|
e.setLogin(rs.getString("login"));
|
||||||
e.setBlockchainName(rs.getString("blockchain_name"));
|
e.setBlockchainName(rs.getString("blockchain_name"));
|
||||||
+6
-5
@@ -3,9 +3,10 @@ package shine.db.entities;
|
|||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SolanaUserEntry — локальная запись пользователя из Solana.
|
* CurrentUserEntry — локальная runtime-проекция текущего состояния пользователя.
|
||||||
*
|
*
|
||||||
* Таблица: solana_users
|
* Источник:
|
||||||
|
* - solana_user_pda_current
|
||||||
*
|
*
|
||||||
* Поля:
|
* Поля:
|
||||||
* - login — PRIMARY KEY (TEXT)
|
* - login — PRIMARY KEY (TEXT)
|
||||||
@@ -14,7 +15,7 @@ import java.util.Base64;
|
|||||||
* - blockchain_key — TEXT NOT NULL
|
* - blockchain_key — TEXT NOT NULL
|
||||||
* - client_key — TEXT NOT NULL
|
* - client_key — TEXT NOT NULL
|
||||||
*/
|
*/
|
||||||
public class SolanaUserEntry {
|
public class CurrentUserEntry {
|
||||||
|
|
||||||
private String login;
|
private String login;
|
||||||
|
|
||||||
@@ -29,9 +30,9 @@ public class SolanaUserEntry {
|
|||||||
/** Ключ устройства (публичный ключ устройства) */
|
/** Ключ устройства (публичный ключ устройства) */
|
||||||
private String clientKey;
|
private String clientKey;
|
||||||
|
|
||||||
public SolanaUserEntry() {}
|
public CurrentUserEntry() {}
|
||||||
|
|
||||||
public SolanaUserEntry(String login,
|
public CurrentUserEntry(String login,
|
||||||
String blockchainName,
|
String blockchainName,
|
||||||
String solanaKey,
|
String solanaKey,
|
||||||
String blockchainKey,
|
String blockchainKey,
|
||||||
+2
-2
@@ -1,8 +1,8 @@
|
|||||||
package shine.db.sql;
|
package shine.db.sql;
|
||||||
|
|
||||||
public final class SolanaUsersSql {
|
public final class CurrentUsersSql {
|
||||||
|
|
||||||
private SolanaUsersSql() {}
|
private CurrentUsersSql() {}
|
||||||
|
|
||||||
public static String usersSubquery(String alias) {
|
public static String usersSubquery(String alias) {
|
||||||
if (alias == null || alias.isBlank()) {
|
if (alias == null || alias.isBlank()) {
|
||||||
+4
-4
@@ -1,7 +1,7 @@
|
|||||||
package server.logic.ws_protocol.JSON;
|
package server.logic.ws_protocol.JSON;
|
||||||
|
|
||||||
import org.eclipse.jetty.websocket.api.Session;
|
import org.eclipse.jetty.websocket.api.Session;
|
||||||
import shine.db.entities.SolanaUserEntry;
|
import shine.db.entities.CurrentUserEntry;
|
||||||
import shine.db.entities.ActiveSessionEntry;
|
import shine.db.entities.ActiveSessionEntry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,7 +26,7 @@ public class ConnectionContext {
|
|||||||
public static final int AUTH_STATUS_USER = 2; // авторизованный пользователь
|
public static final int AUTH_STATUS_USER = 2; // авторизованный пользователь
|
||||||
|
|
||||||
// Полный пользователь из БД (solana_users)
|
// Полный пользователь из БД (solana_users)
|
||||||
private SolanaUserEntry solanaUserEntry;
|
private CurrentUserEntry solanaUserEntry;
|
||||||
|
|
||||||
// Активная сессия из БД (active_sessions)
|
// Активная сессия из БД (active_sessions)
|
||||||
private ActiveSessionEntry activeSessionEntry;
|
private ActiveSessionEntry activeSessionEntry;
|
||||||
@@ -89,11 +89,11 @@ public class ConnectionContext {
|
|||||||
|
|
||||||
// --- SolanaUser / ActiveSession ---
|
// --- SolanaUser / ActiveSession ---
|
||||||
|
|
||||||
public SolanaUserEntry getSolanaUser() {
|
public CurrentUserEntry getSolanaUser() {
|
||||||
return solanaUserEntry;
|
return solanaUserEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSolanaUser(SolanaUserEntry solanaUserEntry) {
|
public void setSolanaUser(CurrentUserEntry solanaUserEntry) {
|
||||||
this.solanaUserEntry = solanaUserEntry;
|
this.solanaUserEntry = solanaUserEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -9,8 +9,8 @@ import server.logic.ws_protocol.JSON.handlers.auth.entyties.Net_AuthChallenge_Re
|
|||||||
import server.logic.ws_protocol.JSON.handlers.auth.entyties.Net_AuthChallenge_Response;
|
import server.logic.ws_protocol.JSON.handlers.auth.entyties.Net_AuthChallenge_Response;
|
||||||
import server.logic.ws_protocol.JSON.utils.NetExceptionResponseFactory;
|
import server.logic.ws_protocol.JSON.utils.NetExceptionResponseFactory;
|
||||||
import server.logic.ws_protocol.WireCodes;
|
import server.logic.ws_protocol.WireCodes;
|
||||||
import shine.db.dao.SolanaUsersDAO;
|
import shine.db.dao.CurrentUsersDAO;
|
||||||
import shine.db.entities.SolanaUserEntry;
|
import shine.db.entities.CurrentUserEntry;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ public class Net_AuthChallenge_Handler implements JsonMessageHandler {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SolanaUserEntry solanaUserEntry = SolanaUsersDAO.getInstance().getByLogin(login);
|
CurrentUserEntry solanaUserEntry = CurrentUsersDAO.getInstance().getByLogin(login);
|
||||||
if (solanaUserEntry == null) {
|
if (solanaUserEntry == null) {
|
||||||
return NetExceptionResponseFactory.error(
|
return NetExceptionResponseFactory.error(
|
||||||
req,
|
req,
|
||||||
|
|||||||
+2
-2
@@ -18,7 +18,7 @@ import server.logic.ws_protocol.WireCodes;
|
|||||||
import server.ws.WsConnectionUtils;
|
import server.ws.WsConnectionUtils;
|
||||||
import shine.db.dao.ActiveSessionsDAO;
|
import shine.db.dao.ActiveSessionsDAO;
|
||||||
import shine.db.entities.ActiveSessionEntry;
|
import shine.db.entities.ActiveSessionEntry;
|
||||||
import shine.db.entities.SolanaUserEntry;
|
import shine.db.entities.CurrentUserEntry;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ public class Net_CloseActiveSession_Handler implements JsonMessageHandler {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SolanaUserEntry user = ctx.getSolanaUser();
|
CurrentUserEntry user = ctx.getSolanaUser();
|
||||||
String currentLogin = user.getLogin();
|
String currentLogin = user.getLogin();
|
||||||
|
|
||||||
String targetSessionId = req.getSessionId();
|
String targetSessionId = req.getSessionId();
|
||||||
|
|||||||
+5
-5
@@ -15,9 +15,9 @@ import server.logic.ws_protocol.JSON.utils.NetExceptionResponseFactory;
|
|||||||
import server.logic.ws_protocol.WireCodes;
|
import server.logic.ws_protocol.WireCodes;
|
||||||
import server.ws.WsConnectionUtils;
|
import server.ws.WsConnectionUtils;
|
||||||
import shine.db.dao.ActiveSessionsDAO;
|
import shine.db.dao.ActiveSessionsDAO;
|
||||||
import shine.db.dao.SolanaUsersDAO;
|
import shine.db.dao.CurrentUsersDAO;
|
||||||
import shine.db.entities.ActiveSessionEntry;
|
import shine.db.entities.ActiveSessionEntry;
|
||||||
import shine.db.entities.SolanaUserEntry;
|
import shine.db.entities.CurrentUserEntry;
|
||||||
import shine.geo.ClientInfoService;
|
import shine.geo.ClientInfoService;
|
||||||
import shine.geo.GeoLookupService;
|
import shine.geo.GeoLookupService;
|
||||||
import utils.crypto.Ed25519Util;
|
import utils.crypto.Ed25519Util;
|
||||||
@@ -72,7 +72,7 @@ public class Net_CreateAuthSession__Handler implements JsonMessageHandler {
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
SolanaUserEntry userFromContext = ctx.getSolanaUser();
|
CurrentUserEntry userFromContext = ctx.getSolanaUser();
|
||||||
String loginFromContext = userFromContext.getLogin();
|
String loginFromContext = userFromContext.getLogin();
|
||||||
String loginFromReq = req.getLogin();
|
String loginFromReq = req.getLogin();
|
||||||
if (loginFromReq == null || loginFromReq.isBlank()) {
|
if (loginFromReq == null || loginFromReq.isBlank()) {
|
||||||
@@ -97,9 +97,9 @@ public class Net_CreateAuthSession__Handler implements JsonMessageHandler {
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
SolanaUserEntry user;
|
CurrentUserEntry user;
|
||||||
try {
|
try {
|
||||||
user = SolanaUsersDAO.getInstance().getByLogin(loginFromContext);
|
user = CurrentUsersDAO.getInstance().getByLogin(loginFromContext);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
Net_Response err = NetExceptionResponseFactory.error(
|
Net_Response err = NetExceptionResponseFactory.error(
|
||||||
req,
|
req,
|
||||||
|
|||||||
+2
-2
@@ -14,7 +14,7 @@ import server.logic.ws_protocol.JSON.utils.NetExceptionResponseFactory;
|
|||||||
import server.logic.ws_protocol.WireCodes;
|
import server.logic.ws_protocol.WireCodes;
|
||||||
import shine.db.dao.ActiveSessionsDAO;
|
import shine.db.dao.ActiveSessionsDAO;
|
||||||
import shine.db.entities.ActiveSessionEntry;
|
import shine.db.entities.ActiveSessionEntry;
|
||||||
import shine.db.entities.SolanaUserEntry;
|
import shine.db.entities.CurrentUserEntry;
|
||||||
import shine.geo.GeoLookupService;
|
import shine.geo.GeoLookupService;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@@ -45,7 +45,7 @@ public class Net_ListSessions_Handler implements JsonMessageHandler {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SolanaUserEntry user = ctx.getSolanaUser();
|
CurrentUserEntry user = ctx.getSolanaUser();
|
||||||
String currentLogin = user.getLogin();
|
String currentLogin = user.getLogin();
|
||||||
|
|
||||||
List<ActiveSessionEntry> sessions;
|
List<ActiveSessionEntry> sessions;
|
||||||
|
|||||||
+4
-4
@@ -14,9 +14,9 @@ import server.logic.ws_protocol.JSON.utils.AuthKeyUtils;
|
|||||||
import server.logic.ws_protocol.JSON.utils.NetExceptionResponseFactory;
|
import server.logic.ws_protocol.JSON.utils.NetExceptionResponseFactory;
|
||||||
import server.logic.ws_protocol.WireCodes;
|
import server.logic.ws_protocol.WireCodes;
|
||||||
import shine.db.dao.ActiveSessionsDAO;
|
import shine.db.dao.ActiveSessionsDAO;
|
||||||
import shine.db.dao.SolanaUsersDAO;
|
import shine.db.dao.CurrentUsersDAO;
|
||||||
import shine.db.entities.ActiveSessionEntry;
|
import shine.db.entities.ActiveSessionEntry;
|
||||||
import shine.db.entities.SolanaUserEntry;
|
import shine.db.entities.CurrentUserEntry;
|
||||||
import shine.geo.ClientInfoService;
|
import shine.geo.ClientInfoService;
|
||||||
import shine.geo.GeoLookupService;
|
import shine.geo.GeoLookupService;
|
||||||
import utils.crypto.Ed25519Util;
|
import utils.crypto.Ed25519Util;
|
||||||
@@ -188,9 +188,9 @@ public class Net_SessionLogin_Handler implements JsonMessageHandler {
|
|||||||
ctx.setSessionLoginNonceExpiresAtMs(0);
|
ctx.setSessionLoginNonceExpiresAtMs(0);
|
||||||
|
|
||||||
// подтягиваем пользователя
|
// подтягиваем пользователя
|
||||||
SolanaUserEntry user;
|
CurrentUserEntry user;
|
||||||
try {
|
try {
|
||||||
user = SolanaUsersDAO.getInstance().getByLogin(session.getLogin());
|
user = CurrentUsersDAO.getInstance().getByLogin(session.getLogin());
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
return NetExceptionResponseFactory.error(
|
return NetExceptionResponseFactory.error(
|
||||||
req,
|
req,
|
||||||
|
|||||||
+3
-3
@@ -15,10 +15,10 @@ import server.logic.ws_protocol.JSON.utils.NetIdGenerator;
|
|||||||
import server.logic.ws_protocol.WireCodes;
|
import server.logic.ws_protocol.WireCodes;
|
||||||
import shine.db.dao.EspPairingRequestsDAO;
|
import shine.db.dao.EspPairingRequestsDAO;
|
||||||
import shine.db.dao.EspPairingSettingsDAO;
|
import shine.db.dao.EspPairingSettingsDAO;
|
||||||
import shine.db.dao.SolanaUsersDAO;
|
import shine.db.dao.CurrentUsersDAO;
|
||||||
import shine.db.entities.EspPairingRequestEntry;
|
import shine.db.entities.EspPairingRequestEntry;
|
||||||
import shine.db.entities.EspPairingSettingsEntry;
|
import shine.db.entities.EspPairingSettingsEntry;
|
||||||
import shine.db.entities.SolanaUserEntry;
|
import shine.db.entities.CurrentUserEntry;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ public class Net_StartEspPairing_Handler implements JsonMessageHandler {
|
|||||||
return NetExceptionResponseFactory.error(req, WireCodes.Status.BAD_REQUEST, "BAD_PASSWORD_HASH_FORMAT", "passwordHash должен быть пустым или иметь формат sha256$<64 hex>");
|
return NetExceptionResponseFactory.error(req, WireCodes.Status.BAD_REQUEST, "BAD_PASSWORD_HASH_FORMAT", "passwordHash должен быть пустым или иметь формат sha256$<64 hex>");
|
||||||
}
|
}
|
||||||
|
|
||||||
SolanaUserEntry user = SolanaUsersDAO.getInstance().getByLogin(login);
|
CurrentUserEntry user = CurrentUsersDAO.getInstance().getByLogin(login);
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
return NetExceptionResponseFactory.error(req, 422, "PAIRING_NOT_AVAILABLE", "Для этого login pairing недоступен");
|
return NetExceptionResponseFactory.error(req, 422, "PAIRING_NOT_AVAILABLE", "Для этого login pairing недоступен");
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -8,7 +8,7 @@ import blockchain.body.TextLineBody;
|
|||||||
import blockchain.body.TextReplyBody;
|
import blockchain.body.TextReplyBody;
|
||||||
import shine.db.channels.ChannelNameRules;
|
import shine.db.channels.ChannelNameRules;
|
||||||
import shine.db.MsgSubType;
|
import shine.db.MsgSubType;
|
||||||
import shine.db.sql.SolanaUsersSql;
|
import shine.db.sql.CurrentUsersSql;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
@@ -31,7 +31,7 @@ final class ChannelsReadSupport {
|
|||||||
private ChannelsReadSupport() {}
|
private ChannelsReadSupport() {}
|
||||||
|
|
||||||
static String canonicalLogin(Connection c, String anyCaseLogin) throws SQLException {
|
static String canonicalLogin(Connection c, String anyCaseLogin) throws SQLException {
|
||||||
String sql = ("SELECT login FROM " + SolanaUsersSql.usersSubquery("su")
|
String sql = ("SELECT login FROM " + CurrentUsersSql.usersSubquery("su")
|
||||||
+ " WHERE LOWER(login) = LOWER(?) LIMIT 1");
|
+ " WHERE LOWER(login) = LOWER(?) LIMIT 1");
|
||||||
try (PreparedStatement ps = c.prepareStatement(sql)) {
|
try (PreparedStatement ps = c.prepareStatement(sql)) {
|
||||||
ps.setString(1, anyCaseLogin);
|
ps.setString(1, anyCaseLogin);
|
||||||
|
|||||||
+2
-2
@@ -9,7 +9,7 @@ import server.logic.ws_protocol.JSON.handlers.connections.entyties.Net_AddCloseF
|
|||||||
import server.logic.ws_protocol.JSON.utils.NetExceptionResponseFactory;
|
import server.logic.ws_protocol.JSON.utils.NetExceptionResponseFactory;
|
||||||
import server.logic.ws_protocol.WireCodes;
|
import server.logic.ws_protocol.WireCodes;
|
||||||
import shine.db.MsgSubType;
|
import shine.db.MsgSubType;
|
||||||
import shine.db.sql.SolanaUsersSql;
|
import shine.db.sql.CurrentUsersSql;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
@@ -58,7 +58,7 @@ public class Net_AddCloseFriend_Handler implements JsonMessageHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String findCanonicalLogin(Connection c, String login) throws Exception {
|
private String findCanonicalLogin(Connection c, String login) throws Exception {
|
||||||
String sql = "SELECT login FROM " + SolanaUsersSql.usersSubquery("su")
|
String sql = "SELECT login FROM " + CurrentUsersSql.usersSubquery("su")
|
||||||
+ " WHERE LOWER(login) = LOWER(?) LIMIT 1";
|
+ " WHERE LOWER(login) = LOWER(?) LIMIT 1";
|
||||||
try (PreparedStatement ps = c.prepareStatement(sql)) {
|
try (PreparedStatement ps = c.prepareStatement(sql)) {
|
||||||
ps.setString(1, login);
|
ps.setString(1, login);
|
||||||
|
|||||||
+2
-2
@@ -13,7 +13,7 @@ import server.logic.ws_protocol.WireCodes;
|
|||||||
import shine.db.MsgSubType;
|
import shine.db.MsgSubType;
|
||||||
import shine.db.DbController;
|
import shine.db.DbController;
|
||||||
import shine.db.dao.ConnectionsStateDAO;
|
import shine.db.dao.ConnectionsStateDAO;
|
||||||
import shine.db.sql.SolanaUsersSql;
|
import shine.db.sql.CurrentUsersSql;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
@@ -100,7 +100,7 @@ public class Net_GetFriendsLists_Handler implements JsonMessageHandler {
|
|||||||
FROM %s
|
FROM %s
|
||||||
WHERE LOWER(login) = LOWER(?)
|
WHERE LOWER(login) = LOWER(?)
|
||||||
LIMIT 1
|
LIMIT 1
|
||||||
""".formatted(SolanaUsersSql.usersSubquery("su"));
|
""".formatted(CurrentUsersSql.usersSubquery("su"));
|
||||||
try (PreparedStatement ps = c.prepareStatement(sql)) {
|
try (PreparedStatement ps = c.prepareStatement(sql)) {
|
||||||
ps.setString(1, loginAnyCase);
|
ps.setString(1, loginAnyCase);
|
||||||
try (ResultSet rs = ps.executeQuery()) {
|
try (ResultSet rs = ps.executeQuery()) {
|
||||||
|
|||||||
+3
-3
@@ -10,7 +10,7 @@ import server.logic.ws_protocol.JSON.utils.NetExceptionResponseFactory;
|
|||||||
import server.logic.ws_protocol.WireCodes;
|
import server.logic.ws_protocol.WireCodes;
|
||||||
import shine.db.MsgSubType;
|
import shine.db.MsgSubType;
|
||||||
import shine.db.dao.ConnectionsStateDAO;
|
import shine.db.dao.ConnectionsStateDAO;
|
||||||
import shine.db.sql.SolanaUsersSql;
|
import shine.db.sql.CurrentUsersSql;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
@@ -114,7 +114,7 @@ public class Net_GetUserConnectionsGraph_Handler implements JsonMessageHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String findCanonicalLogin(Connection c, String loginAnyCase) throws Exception {
|
private String findCanonicalLogin(Connection c, String loginAnyCase) throws Exception {
|
||||||
String sql = "SELECT login FROM " + SolanaUsersSql.usersSubquery("su")
|
String sql = "SELECT login FROM " + CurrentUsersSql.usersSubquery("su")
|
||||||
+ " WHERE LOWER(login) = LOWER(?) LIMIT 1";
|
+ " WHERE LOWER(login) = LOWER(?) LIMIT 1";
|
||||||
try (PreparedStatement ps = c.prepareStatement(sql)) {
|
try (PreparedStatement ps = c.prepareStatement(sql)) {
|
||||||
ps.setString(1, loginAnyCase);
|
ps.setString(1, loginAnyCase);
|
||||||
@@ -177,7 +177,7 @@ public class Net_GetUserConnectionsGraph_Handler implements JsonMessageHandler {
|
|||||||
WHERE LOWER(su.login) IN (%s)
|
WHERE LOWER(su.login) IN (%s)
|
||||||
GROUP BY su.login
|
GROUP BY su.login
|
||||||
ORDER BY su.login
|
ORDER BY su.login
|
||||||
""".formatted(SolanaUsersSql.usersSubquery("su"), String.join(", ", placeholders));
|
""".formatted(CurrentUsersSql.usersSubquery("su"), String.join(", ", placeholders));
|
||||||
|
|
||||||
try (PreparedStatement ps = c.prepareStatement(sql)) {
|
try (PreparedStatement ps = c.prepareStatement(sql)) {
|
||||||
int i = 1;
|
int i = 1;
|
||||||
|
|||||||
+4
-4
@@ -11,9 +11,9 @@ import server.logic.ws_protocol.JSON.handlers.system.entyties.Net_GetSyncUserPro
|
|||||||
import server.logic.ws_protocol.JSON.utils.NetExceptionResponseFactory;
|
import server.logic.ws_protocol.JSON.utils.NetExceptionResponseFactory;
|
||||||
import server.logic.ws_protocol.WireCodes;
|
import server.logic.ws_protocol.WireCodes;
|
||||||
import shine.db.dao.BlockchainStateDAO;
|
import shine.db.dao.BlockchainStateDAO;
|
||||||
import shine.db.dao.SolanaUsersDAO;
|
import shine.db.dao.CurrentUsersDAO;
|
||||||
import shine.db.entities.BlockchainStateEntry;
|
import shine.db.entities.BlockchainStateEntry;
|
||||||
import shine.db.entities.SolanaUserEntry;
|
import shine.db.entities.CurrentUserEntry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GetSyncUserProfile — server-to-server профиль пользователя для межсерверной синхронизации.
|
* GetSyncUserProfile — server-to-server профиль пользователя для межсерверной синхронизации.
|
||||||
@@ -23,7 +23,7 @@ import shine.db.entities.SolanaUserEntry;
|
|||||||
public final class Net_GetSyncUserProfile_Handler implements JsonMessageHandler {
|
public final class Net_GetSyncUserProfile_Handler implements JsonMessageHandler {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(Net_GetSyncUserProfile_Handler.class);
|
private static final Logger log = LoggerFactory.getLogger(Net_GetSyncUserProfile_Handler.class);
|
||||||
private final SolanaUsersDAO usersDAO = SolanaUsersDAO.getInstance();
|
private final CurrentUsersDAO usersDAO = CurrentUsersDAO.getInstance();
|
||||||
private final BlockchainStateDAO stateDAO = BlockchainStateDAO.getInstance();
|
private final BlockchainStateDAO stateDAO = BlockchainStateDAO.getInstance();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -41,7 +41,7 @@ public final class Net_GetSyncUserProfile_Handler implements JsonMessageHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
SolanaUserEntry user = usersDAO.getByLogin(login);
|
CurrentUserEntry user = usersDAO.getByLogin(login);
|
||||||
|
|
||||||
Net_GetSyncUserProfile_Response resp = new Net_GetSyncUserProfile_Response();
|
Net_GetSyncUserProfile_Response resp = new Net_GetSyncUserProfile_Response();
|
||||||
resp.setOp(req.getOp());
|
resp.setOp(req.getOp());
|
||||||
|
|||||||
+4
-4
@@ -11,9 +11,9 @@ import server.logic.ws_protocol.JSON.handlers.tempToTest.entyties.Net_GetUser_Re
|
|||||||
import server.logic.ws_protocol.JSON.utils.NetExceptionResponseFactory;
|
import server.logic.ws_protocol.JSON.utils.NetExceptionResponseFactory;
|
||||||
import server.logic.ws_protocol.WireCodes;
|
import server.logic.ws_protocol.WireCodes;
|
||||||
import shine.db.dao.BlockchainStateDAO;
|
import shine.db.dao.BlockchainStateDAO;
|
||||||
import shine.db.dao.SolanaUsersDAO;
|
import shine.db.dao.CurrentUsersDAO;
|
||||||
import shine.db.entities.BlockchainStateEntry;
|
import shine.db.entities.BlockchainStateEntry;
|
||||||
import shine.db.entities.SolanaUserEntry;
|
import shine.db.entities.CurrentUserEntry;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -37,11 +37,11 @@ public class Net_GetUser_Handler implements JsonMessageHandler {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
SolanaUsersDAO usersDAO = SolanaUsersDAO.getInstance();
|
CurrentUsersDAO usersDAO = CurrentUsersDAO.getInstance();
|
||||||
BlockchainStateDAO stateDAO = BlockchainStateDAO.getInstance();
|
BlockchainStateDAO stateDAO = BlockchainStateDAO.getInstance();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
SolanaUserEntry u = usersDAO.getByLogin(req.getLogin());
|
CurrentUserEntry u = usersDAO.getByLogin(req.getLogin());
|
||||||
|
|
||||||
Net_GetUser_Response resp = new Net_GetUser_Response();
|
Net_GetUser_Response resp = new Net_GetUser_Response();
|
||||||
resp.setOp(req.getOp());
|
resp.setOp(req.getOp());
|
||||||
|
|||||||
+5
-5
@@ -10,8 +10,8 @@ import server.logic.ws_protocol.JSON.handlers.tempToTest.entyties.Net_SearchUser
|
|||||||
import server.logic.ws_protocol.JSON.handlers.tempToTest.entyties.Net_SearchUsers_Response;
|
import server.logic.ws_protocol.JSON.handlers.tempToTest.entyties.Net_SearchUsers_Response;
|
||||||
import server.logic.ws_protocol.JSON.utils.NetExceptionResponseFactory;
|
import server.logic.ws_protocol.JSON.utils.NetExceptionResponseFactory;
|
||||||
import server.logic.ws_protocol.WireCodes;
|
import server.logic.ws_protocol.WireCodes;
|
||||||
import shine.db.dao.SolanaUsersDAO;
|
import shine.db.dao.CurrentUsersDAO;
|
||||||
import shine.db.entities.SolanaUserEntry;
|
import shine.db.entities.CurrentUserEntry;
|
||||||
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -37,11 +37,11 @@ public class Net_SearchUsers_Handler implements JsonMessageHandler {
|
|||||||
String prefix = req.getPrefix().trim();
|
String prefix = req.getPrefix().trim();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
SolanaUsersDAO dao = SolanaUsersDAO.getInstance();
|
CurrentUsersDAO dao = CurrentUsersDAO.getInstance();
|
||||||
List<SolanaUserEntry> users = dao.searchByLoginPrefix(prefix); // case-insensitive + LIMIT 5
|
List<CurrentUserEntry> users = dao.searchByLoginPrefix(prefix); // case-insensitive + LIMIT 5
|
||||||
|
|
||||||
List<String> logins = new ArrayList<>();
|
List<String> logins = new ArrayList<>();
|
||||||
for (SolanaUserEntry u : users) {
|
for (CurrentUserEntry u : users) {
|
||||||
if (u != null && u.getLogin() != null) {
|
if (u != null && u.getLogin() != null) {
|
||||||
logins.add(u.getLogin()); // регистр как в БД
|
logins.add(u.getLogin()); // регистр как в БД
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -11,9 +11,9 @@ import server.logic.ws_protocol.JSON.handlers.userParams.entyties.Net_ListUserPa
|
|||||||
import server.logic.ws_protocol.JSON.utils.NetExceptionResponseFactory;
|
import server.logic.ws_protocol.JSON.utils.NetExceptionResponseFactory;
|
||||||
import server.logic.ws_protocol.WireCodes;
|
import server.logic.ws_protocol.WireCodes;
|
||||||
import shine.db.DbController;
|
import shine.db.DbController;
|
||||||
import shine.db.dao.SolanaUsersDAO;
|
import shine.db.dao.CurrentUsersDAO;
|
||||||
import shine.db.dao.UserParamsDAO;
|
import shine.db.dao.UserParamsDAO;
|
||||||
import shine.db.entities.SolanaUserEntry;
|
import shine.db.entities.CurrentUserEntry;
|
||||||
import shine.db.entities.UserParamEntry;
|
import shine.db.entities.UserParamEntry;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
@@ -63,7 +63,7 @@ public class Net_ListUserParams_Handler implements JsonMessageHandler {
|
|||||||
resp.setRequestId(req.getRequestId());
|
resp.setRequestId(req.getRequestId());
|
||||||
resp.setStatus(WireCodes.Status.OK);
|
resp.setStatus(WireCodes.Status.OK);
|
||||||
|
|
||||||
SolanaUserEntry user = SolanaUsersDAO.getInstance().getByLogin(login);
|
CurrentUserEntry user = CurrentUsersDAO.getInstance().getByLogin(login);
|
||||||
resp.setLogin(user != null && user.getLogin() != null ? user.getLogin() : login);
|
resp.setLogin(user != null && user.getLogin() != null ? user.getLogin() : login);
|
||||||
|
|
||||||
List<Net_ListUserParams_Response.Item> items = new ArrayList<>();
|
List<Net_ListUserParams_Response.Item> items = new ArrayList<>();
|
||||||
|
|||||||
+4
-4
@@ -12,9 +12,9 @@ import server.logic.ws_protocol.JSON.handlers.userParams.entyties.Net_UpsertUser
|
|||||||
import server.logic.ws_protocol.JSON.utils.NetExceptionResponseFactory;
|
import server.logic.ws_protocol.JSON.utils.NetExceptionResponseFactory;
|
||||||
import server.logic.ws_protocol.WireCodes;
|
import server.logic.ws_protocol.WireCodes;
|
||||||
import shine.db.DbController;
|
import shine.db.DbController;
|
||||||
import shine.db.dao.SolanaUsersDAO;
|
import shine.db.dao.CurrentUsersDAO;
|
||||||
import shine.db.dao.UserParamsDAO;
|
import shine.db.dao.UserParamsDAO;
|
||||||
import shine.db.entities.SolanaUserEntry;
|
import shine.db.entities.CurrentUserEntry;
|
||||||
import shine.db.entities.UserParamEntry;
|
import shine.db.entities.UserParamEntry;
|
||||||
import utils.config.ShineSignatureConstants;
|
import utils.config.ShineSignatureConstants;
|
||||||
import utils.crypto.Ed25519Util;
|
import utils.crypto.Ed25519Util;
|
||||||
@@ -105,12 +105,12 @@ public class Net_UpsertUserParam_Handler implements JsonMessageHandler {
|
|||||||
|
|
||||||
// ---------------- DB checks + upsert ----------------
|
// ---------------- DB checks + upsert ----------------
|
||||||
DbController db = DbController.getInstance();
|
DbController db = DbController.getInstance();
|
||||||
SolanaUsersDAO usersDAO = SolanaUsersDAO.getInstance();
|
CurrentUsersDAO usersDAO = CurrentUsersDAO.getInstance();
|
||||||
UserParamsDAO paramsDAO = UserParamsDAO.getInstance();
|
UserParamsDAO paramsDAO = UserParamsDAO.getInstance();
|
||||||
|
|
||||||
try (Connection c = db.getConnection()) {
|
try (Connection c = db.getConnection()) {
|
||||||
// 1) user exists
|
// 1) user exists
|
||||||
SolanaUserEntry user = usersDAO.getByLogin(c, login);
|
CurrentUserEntry user = usersDAO.getByLogin(c, login);
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
return NetExceptionResponseFactory.error(
|
return NetExceptionResponseFactory.error(
|
||||||
req,
|
req,
|
||||||
|
|||||||
+3
-3
@@ -15,9 +15,9 @@ import server.logic.ws_protocol.JSON.utils.NetExceptionResponseFactory;
|
|||||||
import server.logic.ws_protocol.JSON.utils.NetIdGenerator;
|
import server.logic.ws_protocol.JSON.utils.NetIdGenerator;
|
||||||
import server.logic.ws_protocol.WireCodes;
|
import server.logic.ws_protocol.WireCodes;
|
||||||
import shine.db.dao.ActiveSessionsDAO;
|
import shine.db.dao.ActiveSessionsDAO;
|
||||||
import shine.db.dao.SolanaUsersDAO;
|
import shine.db.dao.CurrentUsersDAO;
|
||||||
import shine.db.entities.ActiveSessionEntry;
|
import shine.db.entities.ActiveSessionEntry;
|
||||||
import shine.db.entities.SolanaUserEntry;
|
import shine.db.entities.CurrentUserEntry;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -42,7 +42,7 @@ public class Net_CallInviteBroadcast_Handler implements JsonMessageHandler {
|
|||||||
return NetExceptionResponseFactory.error(req, WireCodes.Status.BAD_REQUEST, "BAD_FIELDS", "toLogin/callId/type=100 обязательны");
|
return NetExceptionResponseFactory.error(req, WireCodes.Status.BAD_REQUEST, "BAD_FIELDS", "toLogin/callId/type=100 обязательны");
|
||||||
}
|
}
|
||||||
|
|
||||||
SolanaUserEntry targetUser = SolanaUsersDAO.getInstance().getByLogin(toRequest);
|
CurrentUserEntry targetUser = CurrentUsersDAO.getInstance().getByLogin(toRequest);
|
||||||
if (targetUser == null) {
|
if (targetUser == null) {
|
||||||
return NetExceptionResponseFactory.error(req, 404, "USER_NOT_FOUND", "Пользователь не найден");
|
return NetExceptionResponseFactory.error(req, 404, "USER_NOT_FOUND", "Пользователь не найден");
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -17,9 +17,9 @@ import server.logic.ws_protocol.JSON.utils.NetExceptionResponseFactory;
|
|||||||
import server.logic.ws_protocol.JSON.utils.NetIdGenerator;
|
import server.logic.ws_protocol.JSON.utils.NetIdGenerator;
|
||||||
import server.logic.ws_protocol.WireCodes;
|
import server.logic.ws_protocol.WireCodes;
|
||||||
import shine.db.dao.ActiveSessionsDAO;
|
import shine.db.dao.ActiveSessionsDAO;
|
||||||
import shine.db.dao.SolanaUsersDAO;
|
import shine.db.dao.CurrentUsersDAO;
|
||||||
import shine.db.entities.ActiveSessionEntry;
|
import shine.db.entities.ActiveSessionEntry;
|
||||||
import shine.db.entities.SolanaUserEntry;
|
import shine.db.entities.CurrentUserEntry;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -50,7 +50,7 @@ public class Net_CallSignalToSession_Handler implements JsonMessageHandler {
|
|||||||
return NetExceptionResponseFactory.error(req, WireCodes.Status.BAD_REQUEST, "BAD_FIELDS", "toLogin/targetSessionId/callId/type обязательны");
|
return NetExceptionResponseFactory.error(req, WireCodes.Status.BAD_REQUEST, "BAD_FIELDS", "toLogin/targetSessionId/callId/type обязательны");
|
||||||
}
|
}
|
||||||
|
|
||||||
SolanaUserEntry targetUser = SolanaUsersDAO.getInstance().getByLogin(toRequest);
|
CurrentUserEntry targetUser = CurrentUsersDAO.getInstance().getByLogin(toRequest);
|
||||||
if (targetUser == null) {
|
if (targetUser == null) {
|
||||||
return NetExceptionResponseFactory.error(req, 404, "USER_NOT_FOUND", "Пользователь не найден");
|
return NetExceptionResponseFactory.error(req, 404, "USER_NOT_FOUND", "Пользователь не найден");
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -18,11 +18,11 @@ import shine.db.dao.ActiveSessionsDAO;
|
|||||||
import shine.db.dao.DirectMessagesDAO;
|
import shine.db.dao.DirectMessagesDAO;
|
||||||
import shine.db.dao.SignedDirectMessagesHistoryDAO;
|
import shine.db.dao.SignedDirectMessagesHistoryDAO;
|
||||||
import shine.db.dao.SignedDmReplayDAO;
|
import shine.db.dao.SignedDmReplayDAO;
|
||||||
import shine.db.dao.SolanaUsersDAO;
|
import shine.db.dao.CurrentUsersDAO;
|
||||||
import shine.db.entities.ActiveSessionEntry;
|
import shine.db.entities.ActiveSessionEntry;
|
||||||
import shine.db.entities.DirectMessageEntry;
|
import shine.db.entities.DirectMessageEntry;
|
||||||
import shine.db.entities.SignedDirectMessageHistoryEntry;
|
import shine.db.entities.SignedDirectMessageHistoryEntry;
|
||||||
import shine.db.entities.SolanaUserEntry;
|
import shine.db.entities.CurrentUserEntry;
|
||||||
import utils.crypto.Ed25519Util;
|
import utils.crypto.Ed25519Util;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
@@ -54,8 +54,8 @@ public class Net_SendDirectMessage_Handler implements JsonMessageHandler {
|
|||||||
return NetExceptionResponseFactory.error(req, WireCodes.Status.BAD_REQUEST, ex.getMessage(), "Некорректный формат пакета");
|
return NetExceptionResponseFactory.error(req, WireCodes.Status.BAD_REQUEST, ex.getMessage(), "Некорректный формат пакета");
|
||||||
}
|
}
|
||||||
|
|
||||||
SolanaUserEntry fromUser = SolanaUsersDAO.getInstance().getByLogin(packet.fromLogin);
|
CurrentUserEntry fromUser = CurrentUsersDAO.getInstance().getByLogin(packet.fromLogin);
|
||||||
SolanaUserEntry toUser = SolanaUsersDAO.getInstance().getByLogin(packet.toLogin);
|
CurrentUserEntry toUser = CurrentUsersDAO.getInstance().getByLogin(packet.toLogin);
|
||||||
if (fromUser == null || toUser == null) {
|
if (fromUser == null || toUser == null) {
|
||||||
return NetExceptionResponseFactory.error(req, 404, "USER_NOT_FOUND", "from/to пользователь не найден");
|
return NetExceptionResponseFactory.error(req, 404, "USER_NOT_FOUND", "from/to пользователь не найден");
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -16,9 +16,9 @@ import server.logic.ws_protocol.JSON.push.WsEventSender;
|
|||||||
import server.logic.ws_protocol.JSON.utils.AuthKeyUtils;
|
import server.logic.ws_protocol.JSON.utils.AuthKeyUtils;
|
||||||
import server.logic.ws_protocol.JSON.utils.NetExceptionResponseFactory;
|
import server.logic.ws_protocol.JSON.utils.NetExceptionResponseFactory;
|
||||||
import server.logic.ws_protocol.WireCodes;
|
import server.logic.ws_protocol.WireCodes;
|
||||||
import shine.db.dao.SolanaUsersDAO;
|
import shine.db.dao.CurrentUsersDAO;
|
||||||
import shine.db.entities.ActiveSessionEntry;
|
import shine.db.entities.ActiveSessionEntry;
|
||||||
import shine.db.entities.SolanaUserEntry;
|
import shine.db.entities.CurrentUserEntry;
|
||||||
import utils.crypto.Ed25519Util;
|
import utils.crypto.Ed25519Util;
|
||||||
|
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
@@ -74,12 +74,12 @@ public class Net_SendSignal_Handler implements JsonMessageHandler {
|
|||||||
return NetExceptionResponseFactory.error(req, WireCodes.Status.BAD_REQUEST, "TIME_SKEW", "Время клиента отличается от сервера более чем на 30 секунд");
|
return NetExceptionResponseFactory.error(req, WireCodes.Status.BAD_REQUEST, "TIME_SKEW", "Время клиента отличается от сервера более чем на 30 секунд");
|
||||||
}
|
}
|
||||||
|
|
||||||
SolanaUserEntry senderUser = ctx.getSolanaUser();
|
CurrentUserEntry senderUser = ctx.getSolanaUser();
|
||||||
if (senderUser == null || senderUser.getClientKey() == null || senderUser.getClientKey().isBlank()) {
|
if (senderUser == null || senderUser.getClientKey() == null || senderUser.getClientKey().isBlank()) {
|
||||||
return NetExceptionResponseFactory.error(req, WireCodes.Status.SERVER_DATA_ERROR, "NO_CLIENT_KEY", "Для пользователя не найден client key");
|
return NetExceptionResponseFactory.error(req, WireCodes.Status.SERVER_DATA_ERROR, "NO_CLIENT_KEY", "Для пользователя не найден client key");
|
||||||
}
|
}
|
||||||
|
|
||||||
SolanaUserEntry targetUser = SolanaUsersDAO.getInstance().getByLogin(toRequest);
|
CurrentUserEntry targetUser = CurrentUsersDAO.getInstance().getByLogin(toRequest);
|
||||||
if (targetUser == null) {
|
if (targetUser == null) {
|
||||||
return NetExceptionResponseFactory.error(req, 404, "USER_NOT_FOUND", "Пользователь не найден");
|
return NetExceptionResponseFactory.error(req, 404, "USER_NOT_FOUND", "Пользователь не найден");
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-7
@@ -1,8 +1,8 @@
|
|||||||
package server.logic.ws_protocol.JSON.messages;
|
package server.logic.ws_protocol.JSON.messages;
|
||||||
|
|
||||||
import shine.db.dao.SolanaUsersDAO;
|
import shine.db.dao.CurrentUsersDAO;
|
||||||
import shine.db.entities.SignedMessageV2Entry;
|
import shine.db.entities.SignedMessageV2Entry;
|
||||||
import shine.db.entities.SolanaUserEntry;
|
import shine.db.entities.CurrentUserEntry;
|
||||||
import utils.crypto.Ed25519Util;
|
import utils.crypto.Ed25519Util;
|
||||||
|
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
@@ -46,22 +46,22 @@ final class SignedMessagesCore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void verifyUsersAndSignature(SignedMessageBlock block) throws Exception {
|
static void verifyUsersAndSignature(SignedMessageBlock block) throws Exception {
|
||||||
SolanaUserEntry from = resolveUser(block.fromLogin);
|
CurrentUserEntry from = resolveUser(block.fromLogin);
|
||||||
SolanaUserEntry to = resolveUser(block.toLogin);
|
CurrentUserEntry to = resolveUser(block.toLogin);
|
||||||
if (from == null || to == null) {
|
if (from == null || to == null) {
|
||||||
throw new IllegalArgumentException("USER_NOT_FOUND");
|
throw new IllegalArgumentException("USER_NOT_FOUND");
|
||||||
}
|
}
|
||||||
|
|
||||||
String signerLogin = block.isSignedByRecipient() ? block.toLogin : block.fromLogin;
|
String signerLogin = block.isSignedByRecipient() ? block.toLogin : block.fromLogin;
|
||||||
SolanaUserEntry signer = signerLogin.equalsIgnoreCase(block.fromLogin) ? from : to;
|
CurrentUserEntry signer = signerLogin.equalsIgnoreCase(block.fromLogin) ? from : to;
|
||||||
byte[] pubKey32 = Ed25519Util.keyFromBase64(signer.getClientKey());
|
byte[] pubKey32 = Ed25519Util.keyFromBase64(signer.getClientKey());
|
||||||
if (!Ed25519Util.verify(block.signedBody, block.signature64, pubKey32)) {
|
if (!Ed25519Util.verify(block.signedBody, block.signature64, pubKey32)) {
|
||||||
throw new IllegalArgumentException("BAD_SIGNATURE");
|
throw new IllegalArgumentException("BAD_SIGNATURE");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SolanaUserEntry resolveUser(String login) throws Exception {
|
private static CurrentUserEntry resolveUser(String login) throws Exception {
|
||||||
return SolanaUsersDAO.getInstance().getByLogin(login);
|
return CurrentUsersDAO.getInstance().getByLogin(login);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void validatePair(SignedMessageBlock incoming, SignedMessageBlock outgoing) {
|
static void validatePair(SignedMessageBlock incoming, SignedMessageBlock outgoing) {
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
////package server.logic.ws_protocol.JSON.utils;
|
////package server.logic.ws_protocol.JSON.utils;
|
||||||
//
|
//
|
||||||
//import shine.db.entities.SolanaUserEntry;
|
//import shine.db.entities.CurrentUserEntry;
|
||||||
//import utils.crypto.Ed25519Util;
|
//import utils.crypto.Ed25519Util;
|
||||||
//
|
//
|
||||||
//import java.nio.charset.StandardCharsets;
|
//import java.nio.charset.StandardCharsets;
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
// * Подпись проверяется над preimageCreateAuthSession(...).
|
// * Подпись проверяется над preimageCreateAuthSession(...).
|
||||||
// */
|
// */
|
||||||
// public static boolean verifyCreateAuthSessionSignature(
|
// public static boolean verifyCreateAuthSessionSignature(
|
||||||
// SolanaUserEntry user,
|
// CurrentUserEntry user,
|
||||||
// String login,
|
// String login,
|
||||||
// String authNonce,
|
// String authNonce,
|
||||||
// long timeMs,
|
// long timeMs,
|
||||||
|
|||||||
+2
-2
@@ -5,7 +5,7 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import server.logic.ws_protocol.JSON.ActiveConnectionsRegistry;
|
import server.logic.ws_protocol.JSON.ActiveConnectionsRegistry;
|
||||||
import server.logic.ws_protocol.JSON.ConnectionContext;
|
import server.logic.ws_protocol.JSON.ConnectionContext;
|
||||||
import shine.db.entities.SolanaUserEntry;
|
import shine.db.entities.CurrentUserEntry;
|
||||||
|
|
||||||
import java.net.SocketAddress;
|
import java.net.SocketAddress;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
@@ -57,7 +57,7 @@ public final class WsConnectionUtils {
|
|||||||
final String sessionId = safeString(ctx.getSessionId());
|
final String sessionId = safeString(ctx.getSessionId());
|
||||||
final int authStatus = safeAuthStatus(ctx);
|
final int authStatus = safeAuthStatus(ctx);
|
||||||
|
|
||||||
final SolanaUserEntry user = ctx.getSolanaUser();
|
final CurrentUserEntry user = ctx.getSolanaUser();
|
||||||
final String login = (user != null ? safeString(user.getLogin()) : "");
|
final String login = (user != null ? safeString(user.getLogin()) : "");
|
||||||
|
|
||||||
final String activeSessionId =
|
final String activeSessionId =
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import test.it.utils.log.TestLog;
|
|||||||
import test.it.utils.log.TestResult;
|
import test.it.utils.log.TestResult;
|
||||||
import test.it.utils.ws.WsSession;
|
import test.it.utils.ws.WsSession;
|
||||||
import utils.crypto.Ed25519Util;
|
import utils.crypto.Ed25519Util;
|
||||||
import shine.db.dao.SolanaUsersDAO;
|
import shine.db.dao.CurrentUsersDAO;
|
||||||
import utils.crypto.HashSHA256Util;
|
import utils.crypto.HashSHA256Util;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
@@ -207,7 +207,7 @@ public class IT_07_EspPairing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void ensureUserSeeded() throws Exception {
|
private static void ensureUserSeeded() throws Exception {
|
||||||
if (SolanaUsersDAO.getInstance().existsByLogin(LOGIN)) {
|
if (CurrentUsersDAO.getInstance().existsByLogin(LOGIN)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
throw new IllegalStateException("Тестовый пользователь отсутствует в актуальном PDA snapshot: " + LOGIN);
|
throw new IllegalStateException("Тестовый пользователь отсутствует в актуальном PDA snapshot: " + LOGIN);
|
||||||
|
|||||||
+1
-1
@@ -1,2 +1,2 @@
|
|||||||
client.version=1.2.354
|
client.version=1.2.354
|
||||||
server.version=1.2.334
|
server.version=1.2.335
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ shine.db.DatabaseInitializer — проверяет наличие `db_schema_ve
|
|||||||
|
|
||||||
|
|
||||||
shine.db.entities.* — POJO-модели строк таблиц (без логики, только поля/геттеры/сеттеры + иногда удобные методы вроде getClientKeyByte()).
|
shine.db.entities.* — POJO-модели строк таблиц (без логики, только поля/геттеры/сеттеры + иногда удобные методы вроде getClientKeyByte()).
|
||||||
shine.db.dao.* — DAO по таблицам: ActiveSessionsDAO, SolanaUsersDAO, UserParamsDAO, IpGeoCacheDAO, BlockchainStateDAO, BlocksDAO; плюс “сервисные” DAO:
|
shine.db.dao.* — DAO по таблицам: ActiveSessionsDAO, CurrentUsersDAO, UserParamsDAO, IpGeoCacheDAO, BlockchainStateDAO, BlocksDAO; плюс “сервисные” DAO:
|
||||||
|
|
||||||
UserCreateDAO — атомарная регистрация пользователя в транзакции (BEGIN IMMEDIATE + rollback/commit).
|
UserCreateDAO — атомарная регистрация пользователя в транзакции (BEGIN IMMEDIATE + rollback/commit).
|
||||||
// Временное runtime-решение, позволяющее регистрировать новых пользователей
|
// Временное runtime-решение, позволяющее регистрировать новых пользователей
|
||||||
|
|||||||
Reference in New Issue
Block a user