Сервер: переименовать слой current users

This commit is contained in:
AidarKC
2026-07-27 19:16:04 +04:00
parent 23748504e6
commit 0db3c3af5a
30 changed files with 118 additions and 117 deletions
@@ -1,7 +1,7 @@
package shine.db.dao;
import shine.db.DbController;
import shine.db.sql.SolanaUsersSql;
import shine.db.sql.CurrentUsersSql;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -49,8 +49,8 @@ public final class ConnectionsStateDAO {
AND cs.rel_type = ?
ORDER BY friend_login
""".formatted(
SolanaUsersSql.usersSubquery("u_login"),
SolanaUsersSql.usersSubquery("u_bch")
CurrentUsersSql.usersSubquery("u_login"),
CurrentUsersSql.usersSubquery("u_bch")
);
List<String> out = new ArrayList<>();
@@ -85,8 +85,8 @@ public final class ConnectionsStateDAO {
AND cs.rel_type = ?
ORDER BY friend_login
""".formatted(
SolanaUsersSql.usersSubquery("u_actor"),
SolanaUsersSql.usersSubquery("u_target")
CurrentUsersSql.usersSubquery("u_actor"),
CurrentUsersSql.usersSubquery("u_target")
);
List<String> out = new ArrayList<>();
@@ -123,7 +123,7 @@ public final class ConnectionsStateDAO {
AND b.rel_type = a.rel_type
)
ORDER BY u.login
""".formatted(SolanaUsersSql.usersSubquery("u"));
""".formatted(CurrentUsersSql.usersSubquery("u"));
List<String> out = new ArrayList<>();
try (PreparedStatement ps = c.prepareStatement(sql)) {
@@ -2,15 +2,15 @@ package shine.db.dao;
import shine.db.DbController;
import shine.db.KeyEncodingUtil;
import shine.db.entities.SolanaUserEntry;
import shine.db.sql.SolanaUsersSql;
import shine.db.entities.CurrentUserEntry;
import shine.db.sql.CurrentUsersSql;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
/**
* SolanaUsersDAO совместимый runtime-доступ к текущему срезу пользователей.
* CurrentUsersDAO совместимый runtime-доступ к текущему срезу пользователей.
*
* Источник:
* - solana_user_pda_current
@@ -26,17 +26,17 @@ import java.util.List;
* - методы с 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 SolanaUsersDAO() {}
private CurrentUsersDAO() {}
public static SolanaUsersDAO getInstance() {
public static CurrentUsersDAO getInstance() {
if (instance == null) {
synchronized (SolanaUsersDAO.class) {
if (instance == null) instance = new SolanaUsersDAO();
synchronized (CurrentUsersDAO.class) {
if (instance == null) instance = new CurrentUsersDAO();
}
}
return instance;
@@ -51,7 +51,7 @@ public final class SolanaUsersDAO {
FROM %s
WHERE LOWER(login) = LOWER(?)
LIMIT 1
""".formatted(SolanaUsersSql.usersSubquery("su"));
""".formatted(CurrentUsersSql.usersSubquery("su"));
try (PreparedStatement ps = c.prepareStatement(sql)) {
ps.setString(1, login);
@@ -75,7 +75,7 @@ public final class SolanaUsersDAO {
FROM %s
WHERE blockchain_name = ?
LIMIT 1
""".formatted(SolanaUsersSql.usersSubquery("su"));
""".formatted(CurrentUsersSql.usersSubquery("su"));
try (PreparedStatement ps = c.prepareStatement(sql)) {
ps.setString(1, blockchainName);
@@ -95,7 +95,7 @@ public final class SolanaUsersDAO {
// -------------------- SELECT --------------------
/** Получить по login (case-insensitive) с внешним соединением. Соединение НЕ закрывает. */
public SolanaUserEntry getByLogin(Connection c, String login) throws SQLException {
public CurrentUserEntry getByLogin(Connection c, String login) throws SQLException {
String sql = """
SELECT
login,
@@ -105,7 +105,7 @@ public final class SolanaUsersDAO {
client_key
FROM %s
WHERE LOWER(login) = LOWER(?)
""".formatted(SolanaUsersSql.usersSubquery("su"));
""".formatted(CurrentUsersSql.usersSubquery("su"));
try (PreparedStatement ps = c.prepareStatement(sql)) {
ps.setString(1, login);
@@ -117,14 +117,14 @@ public final class SolanaUsersDAO {
}
/** Получить по login (case-insensitive) без внешнего соединения. Сам открывает/закрывает. */
public SolanaUserEntry getByLogin(String login) throws SQLException {
public CurrentUserEntry getByLogin(String login) throws SQLException {
try (Connection c = db.getConnection()) {
return getByLogin(c, login);
}
}
/** Получить по blockchain_name (case-sensitive) с внешним соединением. Соединение НЕ закрывает. */
public SolanaUserEntry getByBlockchainName(Connection c, String blockchainName) throws SQLException {
public CurrentUserEntry getByBlockchainName(Connection c, String blockchainName) throws SQLException {
String sql = """
SELECT
login,
@@ -134,7 +134,7 @@ public final class SolanaUsersDAO {
client_key
FROM %s
WHERE blockchain_name = ?
""".formatted(SolanaUsersSql.usersSubquery("su"));
""".formatted(CurrentUsersSql.usersSubquery("su"));
try (PreparedStatement ps = c.prepareStatement(sql)) {
ps.setString(1, blockchainName);
@@ -146,14 +146,14 @@ public final class SolanaUsersDAO {
}
/** Получить по blockchain_name без внешнего соединения. */
public SolanaUserEntry getByBlockchainName(String blockchainName) throws SQLException {
public CurrentUserEntry getByBlockchainName(String blockchainName) throws SQLException {
try (Connection c = db.getConnection()) {
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 = """
SELECT
login,
@@ -165,9 +165,9 @@ public final class SolanaUsersDAO {
WHERE LOWER(login) LIKE ?
ORDER BY login
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)) {
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()) {
return searchByLoginPrefix(c, prefix);
}
@@ -188,8 +188,8 @@ public final class SolanaUsersDAO {
// -------------------- MAPPER --------------------
private SolanaUserEntry mapRow(ResultSet rs) throws SQLException {
SolanaUserEntry e = new SolanaUserEntry();
private CurrentUserEntry mapRow(ResultSet rs) throws SQLException {
CurrentUserEntry e = new CurrentUserEntry();
e.setLogin(rs.getString("login"));
e.setBlockchainName(rs.getString("blockchain_name"));
@@ -3,9 +3,10 @@ package shine.db.entities;
import java.util.Base64;
/**
* SolanaUserEntry локальная запись пользователя из Solana.
* CurrentUserEntry локальная runtime-проекция текущего состояния пользователя.
*
* Таблица: solana_users
* Источник:
* - solana_user_pda_current
*
* Поля:
* - login PRIMARY KEY (TEXT)
@@ -14,7 +15,7 @@ import java.util.Base64;
* - blockchain_key TEXT NOT NULL
* - client_key TEXT NOT NULL
*/
public class SolanaUserEntry {
public class CurrentUserEntry {
private String login;
@@ -29,9 +30,9 @@ public class SolanaUserEntry {
/** Ключ устройства (публичный ключ устройства) */
private String clientKey;
public SolanaUserEntry() {}
public CurrentUserEntry() {}
public SolanaUserEntry(String login,
public CurrentUserEntry(String login,
String blockchainName,
String solanaKey,
String blockchainKey,
@@ -1,8 +1,8 @@
package shine.db.sql;
public final class SolanaUsersSql {
public final class CurrentUsersSql {
private SolanaUsersSql() {}
private CurrentUsersSql() {}
public static String usersSubquery(String alias) {
if (alias == null || alias.isBlank()) {
@@ -1,7 +1,7 @@
package server.logic.ws_protocol.JSON;
import org.eclipse.jetty.websocket.api.Session;
import shine.db.entities.SolanaUserEntry;
import shine.db.entities.CurrentUserEntry;
import shine.db.entities.ActiveSessionEntry;
/**
@@ -26,7 +26,7 @@ public class ConnectionContext {
public static final int AUTH_STATUS_USER = 2; // авторизованный пользователь
// Полный пользователь из БД (solana_users)
private SolanaUserEntry solanaUserEntry;
private CurrentUserEntry solanaUserEntry;
// Активная сессия из БД (active_sessions)
private ActiveSessionEntry activeSessionEntry;
@@ -89,11 +89,11 @@ public class ConnectionContext {
// --- SolanaUser / ActiveSession ---
public SolanaUserEntry getSolanaUser() {
public CurrentUserEntry getSolanaUser() {
return solanaUserEntry;
}
public void setSolanaUser(SolanaUserEntry solanaUserEntry) {
public void setSolanaUser(CurrentUserEntry solanaUserEntry) {
this.solanaUserEntry = solanaUserEntry;
}
@@ -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.utils.NetExceptionResponseFactory;
import server.logic.ws_protocol.WireCodes;
import shine.db.dao.SolanaUsersDAO;
import shine.db.entities.SolanaUserEntry;
import shine.db.dao.CurrentUsersDAO;
import shine.db.entities.CurrentUserEntry;
import org.slf4j.Logger;
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) {
return NetExceptionResponseFactory.error(
req,
@@ -18,7 +18,7 @@ import server.logic.ws_protocol.WireCodes;
import server.ws.WsConnectionUtils;
import shine.db.dao.ActiveSessionsDAO;
import shine.db.entities.ActiveSessionEntry;
import shine.db.entities.SolanaUserEntry;
import shine.db.entities.CurrentUserEntry;
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 targetSessionId = req.getSessionId();
@@ -15,9 +15,9 @@ import server.logic.ws_protocol.JSON.utils.NetExceptionResponseFactory;
import server.logic.ws_protocol.WireCodes;
import server.ws.WsConnectionUtils;
import shine.db.dao.ActiveSessionsDAO;
import shine.db.dao.SolanaUsersDAO;
import shine.db.dao.CurrentUsersDAO;
import shine.db.entities.ActiveSessionEntry;
import shine.db.entities.SolanaUserEntry;
import shine.db.entities.CurrentUserEntry;
import shine.geo.ClientInfoService;
import shine.geo.GeoLookupService;
import utils.crypto.Ed25519Util;
@@ -72,7 +72,7 @@ public class Net_CreateAuthSession__Handler implements JsonMessageHandler {
return err;
}
SolanaUserEntry userFromContext = ctx.getSolanaUser();
CurrentUserEntry userFromContext = ctx.getSolanaUser();
String loginFromContext = userFromContext.getLogin();
String loginFromReq = req.getLogin();
if (loginFromReq == null || loginFromReq.isBlank()) {
@@ -97,9 +97,9 @@ public class Net_CreateAuthSession__Handler implements JsonMessageHandler {
return err;
}
SolanaUserEntry user;
CurrentUserEntry user;
try {
user = SolanaUsersDAO.getInstance().getByLogin(loginFromContext);
user = CurrentUsersDAO.getInstance().getByLogin(loginFromContext);
} catch (SQLException e) {
Net_Response err = NetExceptionResponseFactory.error(
req,
@@ -14,7 +14,7 @@ import server.logic.ws_protocol.JSON.utils.NetExceptionResponseFactory;
import server.logic.ws_protocol.WireCodes;
import shine.db.dao.ActiveSessionsDAO;
import shine.db.entities.ActiveSessionEntry;
import shine.db.entities.SolanaUserEntry;
import shine.db.entities.CurrentUserEntry;
import shine.geo.GeoLookupService;
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();
List<ActiveSessionEntry> sessions;
@@ -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.WireCodes;
import shine.db.dao.ActiveSessionsDAO;
import shine.db.dao.SolanaUsersDAO;
import shine.db.dao.CurrentUsersDAO;
import shine.db.entities.ActiveSessionEntry;
import shine.db.entities.SolanaUserEntry;
import shine.db.entities.CurrentUserEntry;
import shine.geo.ClientInfoService;
import shine.geo.GeoLookupService;
import utils.crypto.Ed25519Util;
@@ -188,9 +188,9 @@ public class Net_SessionLogin_Handler implements JsonMessageHandler {
ctx.setSessionLoginNonceExpiresAtMs(0);
// подтягиваем пользователя
SolanaUserEntry user;
CurrentUserEntry user;
try {
user = SolanaUsersDAO.getInstance().getByLogin(session.getLogin());
user = CurrentUsersDAO.getInstance().getByLogin(session.getLogin());
} catch (SQLException e) {
return NetExceptionResponseFactory.error(
req,
@@ -15,10 +15,10 @@ import server.logic.ws_protocol.JSON.utils.NetIdGenerator;
import server.logic.ws_protocol.WireCodes;
import shine.db.dao.EspPairingRequestsDAO;
import shine.db.dao.EspPairingSettingsDAO;
import shine.db.dao.SolanaUsersDAO;
import shine.db.dao.CurrentUsersDAO;
import shine.db.entities.EspPairingRequestEntry;
import shine.db.entities.EspPairingSettingsEntry;
import shine.db.entities.SolanaUserEntry;
import shine.db.entities.CurrentUserEntry;
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>");
}
SolanaUserEntry user = SolanaUsersDAO.getInstance().getByLogin(login);
CurrentUserEntry user = CurrentUsersDAO.getInstance().getByLogin(login);
if (user == null) {
return NetExceptionResponseFactory.error(req, 422, "PAIRING_NOT_AVAILABLE", "Для этого login pairing недоступен");
}
@@ -8,7 +8,7 @@ import blockchain.body.TextLineBody;
import blockchain.body.TextReplyBody;
import shine.db.channels.ChannelNameRules;
import shine.db.MsgSubType;
import shine.db.sql.SolanaUsersSql;
import shine.db.sql.CurrentUsersSql;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -31,7 +31,7 @@ final class ChannelsReadSupport {
private ChannelsReadSupport() {}
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");
try (PreparedStatement ps = c.prepareStatement(sql)) {
ps.setString(1, anyCaseLogin);
@@ -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.WireCodes;
import shine.db.MsgSubType;
import shine.db.sql.SolanaUsersSql;
import shine.db.sql.CurrentUsersSql;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -58,7 +58,7 @@ public class Net_AddCloseFriend_Handler implements JsonMessageHandler {
}
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";
try (PreparedStatement ps = c.prepareStatement(sql)) {
ps.setString(1, login);
@@ -13,7 +13,7 @@ import server.logic.ws_protocol.WireCodes;
import shine.db.MsgSubType;
import shine.db.DbController;
import shine.db.dao.ConnectionsStateDAO;
import shine.db.sql.SolanaUsersSql;
import shine.db.sql.CurrentUsersSql;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -100,7 +100,7 @@ public class Net_GetFriendsLists_Handler implements JsonMessageHandler {
FROM %s
WHERE LOWER(login) = LOWER(?)
LIMIT 1
""".formatted(SolanaUsersSql.usersSubquery("su"));
""".formatted(CurrentUsersSql.usersSubquery("su"));
try (PreparedStatement ps = c.prepareStatement(sql)) {
ps.setString(1, loginAnyCase);
try (ResultSet rs = ps.executeQuery()) {
@@ -10,7 +10,7 @@ import server.logic.ws_protocol.JSON.utils.NetExceptionResponseFactory;
import server.logic.ws_protocol.WireCodes;
import shine.db.MsgSubType;
import shine.db.dao.ConnectionsStateDAO;
import shine.db.sql.SolanaUsersSql;
import shine.db.sql.CurrentUsersSql;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -114,7 +114,7 @@ public class Net_GetUserConnectionsGraph_Handler implements JsonMessageHandler {
}
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";
try (PreparedStatement ps = c.prepareStatement(sql)) {
ps.setString(1, loginAnyCase);
@@ -177,7 +177,7 @@ public class Net_GetUserConnectionsGraph_Handler implements JsonMessageHandler {
WHERE LOWER(su.login) IN (%s)
GROUP 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)) {
int i = 1;
@@ -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.WireCodes;
import shine.db.dao.BlockchainStateDAO;
import shine.db.dao.SolanaUsersDAO;
import shine.db.dao.CurrentUsersDAO;
import shine.db.entities.BlockchainStateEntry;
import shine.db.entities.SolanaUserEntry;
import shine.db.entities.CurrentUserEntry;
/**
* GetSyncUserProfile server-to-server профиль пользователя для межсерверной синхронизации.
@@ -23,7 +23,7 @@ import shine.db.entities.SolanaUserEntry;
public final class Net_GetSyncUserProfile_Handler implements JsonMessageHandler {
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();
@Override
@@ -41,7 +41,7 @@ public final class Net_GetSyncUserProfile_Handler implements JsonMessageHandler
}
try {
SolanaUserEntry user = usersDAO.getByLogin(login);
CurrentUserEntry user = usersDAO.getByLogin(login);
Net_GetSyncUserProfile_Response resp = new Net_GetSyncUserProfile_Response();
resp.setOp(req.getOp());
@@ -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.WireCodes;
import shine.db.dao.BlockchainStateDAO;
import shine.db.dao.SolanaUsersDAO;
import shine.db.dao.CurrentUsersDAO;
import shine.db.entities.BlockchainStateEntry;
import shine.db.entities.SolanaUserEntry;
import shine.db.entities.CurrentUserEntry;
import java.sql.SQLException;
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();
try {
SolanaUserEntry u = usersDAO.getByLogin(req.getLogin());
CurrentUserEntry u = usersDAO.getByLogin(req.getLogin());
Net_GetUser_Response resp = new Net_GetUser_Response();
resp.setOp(req.getOp());
@@ -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.utils.NetExceptionResponseFactory;
import server.logic.ws_protocol.WireCodes;
import shine.db.dao.SolanaUsersDAO;
import shine.db.entities.SolanaUserEntry;
import shine.db.dao.CurrentUsersDAO;
import shine.db.entities.CurrentUserEntry;
import java.sql.SQLException;
import java.util.ArrayList;
@@ -37,11 +37,11 @@ public class Net_SearchUsers_Handler implements JsonMessageHandler {
String prefix = req.getPrefix().trim();
try {
SolanaUsersDAO dao = SolanaUsersDAO.getInstance();
List<SolanaUserEntry> users = dao.searchByLoginPrefix(prefix); // case-insensitive + LIMIT 5
CurrentUsersDAO dao = CurrentUsersDAO.getInstance();
List<CurrentUserEntry> users = dao.searchByLoginPrefix(prefix); // case-insensitive + LIMIT 5
List<String> logins = new ArrayList<>();
for (SolanaUserEntry u : users) {
for (CurrentUserEntry u : users) {
if (u != null && u.getLogin() != null) {
logins.add(u.getLogin()); // регистр как в БД
}
@@ -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.WireCodes;
import shine.db.DbController;
import shine.db.dao.SolanaUsersDAO;
import shine.db.dao.CurrentUsersDAO;
import shine.db.dao.UserParamsDAO;
import shine.db.entities.SolanaUserEntry;
import shine.db.entities.CurrentUserEntry;
import shine.db.entities.UserParamEntry;
import java.sql.Connection;
@@ -63,7 +63,7 @@ public class Net_ListUserParams_Handler implements JsonMessageHandler {
resp.setRequestId(req.getRequestId());
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);
List<Net_ListUserParams_Response.Item> items = new ArrayList<>();
@@ -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.WireCodes;
import shine.db.DbController;
import shine.db.dao.SolanaUsersDAO;
import shine.db.dao.CurrentUsersDAO;
import shine.db.dao.UserParamsDAO;
import shine.db.entities.SolanaUserEntry;
import shine.db.entities.CurrentUserEntry;
import shine.db.entities.UserParamEntry;
import utils.config.ShineSignatureConstants;
import utils.crypto.Ed25519Util;
@@ -105,12 +105,12 @@ public class Net_UpsertUserParam_Handler implements JsonMessageHandler {
// ---------------- DB checks + upsert ----------------
DbController db = DbController.getInstance();
SolanaUsersDAO usersDAO = SolanaUsersDAO.getInstance();
CurrentUsersDAO usersDAO = CurrentUsersDAO.getInstance();
UserParamsDAO paramsDAO = UserParamsDAO.getInstance();
try (Connection c = db.getConnection()) {
// 1) user exists
SolanaUserEntry user = usersDAO.getByLogin(c, login);
CurrentUserEntry user = usersDAO.getByLogin(c, login);
if (user == null) {
return NetExceptionResponseFactory.error(
req,
@@ -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.WireCodes;
import shine.db.dao.ActiveSessionsDAO;
import shine.db.dao.SolanaUsersDAO;
import shine.db.dao.CurrentUsersDAO;
import shine.db.entities.ActiveSessionEntry;
import shine.db.entities.SolanaUserEntry;
import shine.db.entities.CurrentUserEntry;
import java.util.HashSet;
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 обязательны");
}
SolanaUserEntry targetUser = SolanaUsersDAO.getInstance().getByLogin(toRequest);
CurrentUserEntry targetUser = CurrentUsersDAO.getInstance().getByLogin(toRequest);
if (targetUser == null) {
return NetExceptionResponseFactory.error(req, 404, "USER_NOT_FOUND", "Пользователь не найден");
}
@@ -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.WireCodes;
import shine.db.dao.ActiveSessionsDAO;
import shine.db.dao.SolanaUsersDAO;
import shine.db.dao.CurrentUsersDAO;
import shine.db.entities.ActiveSessionEntry;
import shine.db.entities.SolanaUserEntry;
import shine.db.entities.CurrentUserEntry;
import java.util.HashSet;
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 обязательны");
}
SolanaUserEntry targetUser = SolanaUsersDAO.getInstance().getByLogin(toRequest);
CurrentUserEntry targetUser = CurrentUsersDAO.getInstance().getByLogin(toRequest);
if (targetUser == null) {
return NetExceptionResponseFactory.error(req, 404, "USER_NOT_FOUND", "Пользователь не найден");
}
@@ -18,11 +18,11 @@ import shine.db.dao.ActiveSessionsDAO;
import shine.db.dao.DirectMessagesDAO;
import shine.db.dao.SignedDirectMessagesHistoryDAO;
import shine.db.dao.SignedDmReplayDAO;
import shine.db.dao.SolanaUsersDAO;
import shine.db.dao.CurrentUsersDAO;
import shine.db.entities.ActiveSessionEntry;
import shine.db.entities.DirectMessageEntry;
import shine.db.entities.SignedDirectMessageHistoryEntry;
import shine.db.entities.SolanaUserEntry;
import shine.db.entities.CurrentUserEntry;
import utils.crypto.Ed25519Util;
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(), "Некорректный формат пакета");
}
SolanaUserEntry fromUser = SolanaUsersDAO.getInstance().getByLogin(packet.fromLogin);
SolanaUserEntry toUser = SolanaUsersDAO.getInstance().getByLogin(packet.toLogin);
CurrentUserEntry fromUser = CurrentUsersDAO.getInstance().getByLogin(packet.fromLogin);
CurrentUserEntry toUser = CurrentUsersDAO.getInstance().getByLogin(packet.toLogin);
if (fromUser == null || toUser == null) {
return NetExceptionResponseFactory.error(req, 404, "USER_NOT_FOUND", "from/to пользователь не найден");
}
@@ -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.NetExceptionResponseFactory;
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.SolanaUserEntry;
import shine.db.entities.CurrentUserEntry;
import utils.crypto.Ed25519Util;
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 секунд");
}
SolanaUserEntry senderUser = ctx.getSolanaUser();
CurrentUserEntry senderUser = ctx.getSolanaUser();
if (senderUser == null || senderUser.getClientKey() == null || senderUser.getClientKey().isBlank()) {
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) {
return NetExceptionResponseFactory.error(req, 404, "USER_NOT_FOUND", "Пользователь не найден");
}
@@ -1,8 +1,8 @@
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.SolanaUserEntry;
import shine.db.entities.CurrentUserEntry;
import utils.crypto.Ed25519Util;
import java.util.Base64;
@@ -46,22 +46,22 @@ final class SignedMessagesCore {
}
static void verifyUsersAndSignature(SignedMessageBlock block) throws Exception {
SolanaUserEntry from = resolveUser(block.fromLogin);
SolanaUserEntry to = resolveUser(block.toLogin);
CurrentUserEntry from = resolveUser(block.fromLogin);
CurrentUserEntry to = resolveUser(block.toLogin);
if (from == null || to == null) {
throw new IllegalArgumentException("USER_NOT_FOUND");
}
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());
if (!Ed25519Util.verify(block.signedBody, block.signature64, pubKey32)) {
throw new IllegalArgumentException("BAD_SIGNATURE");
}
}
private static SolanaUserEntry resolveUser(String login) throws Exception {
return SolanaUsersDAO.getInstance().getByLogin(login);
private static CurrentUserEntry resolveUser(String login) throws Exception {
return CurrentUsersDAO.getInstance().getByLogin(login);
}
static void validatePair(SignedMessageBlock incoming, SignedMessageBlock outgoing) {
@@ -1,6 +1,6 @@
////package server.logic.ws_protocol.JSON.utils;
//
//import shine.db.entities.SolanaUserEntry;
//import shine.db.entities.CurrentUserEntry;
//import utils.crypto.Ed25519Util;
//
//import java.nio.charset.StandardCharsets;
@@ -35,7 +35,7 @@
// * Подпись проверяется над preimageCreateAuthSession(...).
// */
// public static boolean verifyCreateAuthSessionSignature(
// SolanaUserEntry user,
// CurrentUserEntry user,
// String login,
// String authNonce,
// long timeMs,
@@ -5,7 +5,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import server.logic.ws_protocol.JSON.ActiveConnectionsRegistry;
import server.logic.ws_protocol.JSON.ConnectionContext;
import shine.db.entities.SolanaUserEntry;
import shine.db.entities.CurrentUserEntry;
import java.net.SocketAddress;
import java.util.concurrent.atomic.AtomicLong;
@@ -57,7 +57,7 @@ public final class WsConnectionUtils {
final String sessionId = safeString(ctx.getSessionId());
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 activeSessionId =
@@ -7,7 +7,7 @@ import test.it.utils.log.TestLog;
import test.it.utils.log.TestResult;
import test.it.utils.ws.WsSession;
import utils.crypto.Ed25519Util;
import shine.db.dao.SolanaUsersDAO;
import shine.db.dao.CurrentUsersDAO;
import utils.crypto.HashSHA256Util;
import java.time.Duration;
@@ -207,7 +207,7 @@ public class IT_07_EspPairing {
}
private static void ensureUserSeeded() throws Exception {
if (SolanaUsersDAO.getInstance().existsByLogin(LOGIN)) {
if (CurrentUsersDAO.getInstance().existsByLogin(LOGIN)) {
return;
}
throw new IllegalStateException("Тестовый пользователь отсутствует в актуальном PDA snapshot: " + LOGIN);
+1 -1
View File
@@ -1,2 +1,2 @@
client.version=1.2.354
server.version=1.2.334
server.version=1.2.335
+1 -1
View File
@@ -9,7 +9,7 @@ shine.db.DatabaseInitializer — проверяет наличие `db_schema_ve
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).
// Временное runtime-решение, позволяющее регистрировать новых пользователей