diff --git a/SHiNE-server/shine-server-db/src/main/java/shine/db/dao/ConnectionsStateDAO.java b/SHiNE-server/shine-server-db/src/main/java/shine/db/dao/ConnectionsStateDAO.java index ca0c66d3..e01fdf52 100644 --- a/SHiNE-server/shine-server-db/src/main/java/shine/db/dao/ConnectionsStateDAO.java +++ b/SHiNE-server/shine-server-db/src/main/java/shine/db/dao/ConnectionsStateDAO.java @@ -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 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 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 out = new ArrayList<>(); try (PreparedStatement ps = c.prepareStatement(sql)) { diff --git a/SHiNE-server/shine-server-db/src/main/java/shine/db/dao/SolanaUsersDAO.java b/SHiNE-server/shine-server-db/src/main/java/shine/db/dao/CurrentUsersDAO.java similarity index 79% rename from SHiNE-server/shine-server-db/src/main/java/shine/db/dao/SolanaUsersDAO.java rename to SHiNE-server/shine-server-db/src/main/java/shine/db/dao/CurrentUsersDAO.java index 5a4e4026..c68d6aae 100644 --- a/SHiNE-server/shine-server-db/src/main/java/shine/db/dao/SolanaUsersDAO.java +++ b/SHiNE-server/shine-server-db/src/main/java/shine/db/dao/CurrentUsersDAO.java @@ -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 searchByLoginPrefix(Connection c, String prefix) throws SQLException { + public List 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 result = new ArrayList<>(); + List result = new ArrayList<>(); try (PreparedStatement ps = c.prepareStatement(sql)) { ps.setString(1, prefix.toLowerCase() + "%"); @@ -180,7 +180,7 @@ public final class SolanaUsersDAO { } /** Поиск по префиксу без внешнего соединения. Сам открывает/закрывает. */ - public List searchByLoginPrefix(String prefix) throws SQLException { + public List 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")); diff --git a/SHiNE-server/shine-server-db/src/main/java/shine/db/entities/SolanaUserEntry.java b/SHiNE-server/shine-server-db/src/main/java/shine/db/entities/CurrentUserEntry.java similarity index 90% rename from SHiNE-server/shine-server-db/src/main/java/shine/db/entities/SolanaUserEntry.java rename to SHiNE-server/shine-server-db/src/main/java/shine/db/entities/CurrentUserEntry.java index ee0e7a20..8a14051b 100644 --- a/SHiNE-server/shine-server-db/src/main/java/shine/db/entities/SolanaUserEntry.java +++ b/SHiNE-server/shine-server-db/src/main/java/shine/db/entities/CurrentUserEntry.java @@ -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, diff --git a/SHiNE-server/shine-server-db/src/main/java/shine/db/sql/SolanaUsersSql.java b/SHiNE-server/shine-server-db/src/main/java/shine/db/sql/CurrentUsersSql.java similarity index 90% rename from SHiNE-server/shine-server-db/src/main/java/shine/db/sql/SolanaUsersSql.java rename to SHiNE-server/shine-server-db/src/main/java/shine/db/sql/CurrentUsersSql.java index 968cf0b2..6dad44b3 100644 --- a/SHiNE-server/shine-server-db/src/main/java/shine/db/sql/SolanaUsersSql.java +++ b/SHiNE-server/shine-server-db/src/main/java/shine/db/sql/CurrentUsersSql.java @@ -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()) { diff --git a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/ConnectionContext.java b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/ConnectionContext.java index 742c851e..4b91345c 100644 --- a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/ConnectionContext.java +++ b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/ConnectionContext.java @@ -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; } diff --git a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/auth/Net_AuthChallenge_Handler.java b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/auth/Net_AuthChallenge_Handler.java index 8481ad9b..1ea04e3f 100644 --- a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/auth/Net_AuthChallenge_Handler.java +++ b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/auth/Net_AuthChallenge_Handler.java @@ -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, diff --git a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/auth/Net_CloseActiveSession_Handler.java b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/auth/Net_CloseActiveSession_Handler.java index e5ceb22c..11cdacbe 100644 --- a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/auth/Net_CloseActiveSession_Handler.java +++ b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/auth/Net_CloseActiveSession_Handler.java @@ -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(); diff --git a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/auth/Net_CreateAuthSession__Handler.java b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/auth/Net_CreateAuthSession__Handler.java index cebbfbde..bd103779 100644 --- a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/auth/Net_CreateAuthSession__Handler.java +++ b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/auth/Net_CreateAuthSession__Handler.java @@ -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, diff --git a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/auth/Net_ListSessions_Handler.java b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/auth/Net_ListSessions_Handler.java index e53a24db..bfe2c720 100644 --- a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/auth/Net_ListSessions_Handler.java +++ b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/auth/Net_ListSessions_Handler.java @@ -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 sessions; diff --git a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/auth/Net_SessionLogin_Handler.java b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/auth/Net_SessionLogin_Handler.java index 6a4f51a1..4c2d65c5 100644 --- a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/auth/Net_SessionLogin_Handler.java +++ b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/auth/Net_SessionLogin_Handler.java @@ -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, diff --git a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/auth/Net_StartEspPairing_Handler.java b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/auth/Net_StartEspPairing_Handler.java index bf08799a..ed6254e8 100644 --- a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/auth/Net_StartEspPairing_Handler.java +++ b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/auth/Net_StartEspPairing_Handler.java @@ -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 недоступен"); } diff --git a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/channels/ChannelsReadSupport.java b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/channels/ChannelsReadSupport.java index 6daf45c7..1b7ca2df 100644 --- a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/channels/ChannelsReadSupport.java +++ b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/channels/ChannelsReadSupport.java @@ -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); diff --git a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/connections/Net_AddCloseFriend_Handler.java b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/connections/Net_AddCloseFriend_Handler.java index ef0cc877..bbb03fc4 100644 --- a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/connections/Net_AddCloseFriend_Handler.java +++ b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/connections/Net_AddCloseFriend_Handler.java @@ -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); diff --git a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/connections/Net_GetFriendsLists_Handler.java b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/connections/Net_GetFriendsLists_Handler.java index 42330be7..d4f63047 100644 --- a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/connections/Net_GetFriendsLists_Handler.java +++ b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/connections/Net_GetFriendsLists_Handler.java @@ -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()) { diff --git a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/connections/Net_GetUserConnectionsGraph_Handler.java b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/connections/Net_GetUserConnectionsGraph_Handler.java index 90da70e2..ea83a791 100644 --- a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/connections/Net_GetUserConnectionsGraph_Handler.java +++ b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/connections/Net_GetUserConnectionsGraph_Handler.java @@ -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; diff --git a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/system/Net_GetSyncUserProfile_Handler.java b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/system/Net_GetSyncUserProfile_Handler.java index 9bf9c582..24dff5b5 100644 --- a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/system/Net_GetSyncUserProfile_Handler.java +++ b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/system/Net_GetSyncUserProfile_Handler.java @@ -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()); diff --git a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/tempToTest/Net_GetUser_Handler.java b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/tempToTest/Net_GetUser_Handler.java index 9e282951..961faa65 100644 --- a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/tempToTest/Net_GetUser_Handler.java +++ b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/tempToTest/Net_GetUser_Handler.java @@ -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()); diff --git a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/tempToTest/Net_SearchUsers_Handler.java b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/tempToTest/Net_SearchUsers_Handler.java index 6647fea2..ebc86f24 100644 --- a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/tempToTest/Net_SearchUsers_Handler.java +++ b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/tempToTest/Net_SearchUsers_Handler.java @@ -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 users = dao.searchByLoginPrefix(prefix); // case-insensitive + LIMIT 5 + CurrentUsersDAO dao = CurrentUsersDAO.getInstance(); + List users = dao.searchByLoginPrefix(prefix); // case-insensitive + LIMIT 5 List logins = new ArrayList<>(); - for (SolanaUserEntry u : users) { + for (CurrentUserEntry u : users) { if (u != null && u.getLogin() != null) { logins.add(u.getLogin()); // регистр как в БД } diff --git a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/userParams/Net_ListUserParams_Handler.java b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/userParams/Net_ListUserParams_Handler.java index e2561cd4..d6460161 100644 --- a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/userParams/Net_ListUserParams_Handler.java +++ b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/userParams/Net_ListUserParams_Handler.java @@ -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 items = new ArrayList<>(); diff --git a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/userParams/Net_UpsertUserParam_Handler.java b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/userParams/Net_UpsertUserParam_Handler.java index dac10f7f..5fa03b14 100644 --- a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/userParams/Net_UpsertUserParam_Handler.java +++ b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/handlers/userParams/Net_UpsertUserParam_Handler.java @@ -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, diff --git a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/messages/Net_CallInviteBroadcast_Handler.java b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/messages/Net_CallInviteBroadcast_Handler.java index a1023a2b..359529e0 100644 --- a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/messages/Net_CallInviteBroadcast_Handler.java +++ b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/messages/Net_CallInviteBroadcast_Handler.java @@ -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", "Пользователь не найден"); } diff --git a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/messages/Net_CallSignalToSession_Handler.java b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/messages/Net_CallSignalToSession_Handler.java index 60ec4df3..b81bd0c5 100644 --- a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/messages/Net_CallSignalToSession_Handler.java +++ b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/messages/Net_CallSignalToSession_Handler.java @@ -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", "Пользователь не найден"); } diff --git a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/messages/Net_SendDirectMessage_Handler.java b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/messages/Net_SendDirectMessage_Handler.java index 353f335d..32b80d64 100644 --- a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/messages/Net_SendDirectMessage_Handler.java +++ b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/messages/Net_SendDirectMessage_Handler.java @@ -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 пользователь не найден"); } diff --git a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/messages/Net_SendSignal_Handler.java b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/messages/Net_SendSignal_Handler.java index 6a751cd8..760402ab 100644 --- a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/messages/Net_SendSignal_Handler.java +++ b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/messages/Net_SendSignal_Handler.java @@ -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", "Пользователь не найден"); } diff --git a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/messages/SignedMessagesCore.java b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/messages/SignedMessagesCore.java index 7f5ffa3a..f6783dd9 100644 --- a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/messages/SignedMessagesCore.java +++ b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/messages/SignedMessagesCore.java @@ -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) { diff --git a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/utils/AuthSignatures.java b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/utils/AuthSignatures.java index 539ab1e2..93702ef9 100644 --- a/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/utils/AuthSignatures.java +++ b/SHiNE-server/shine-server-net-protocol/src/main/java/server/logic/ws_protocol/JSON/utils/AuthSignatures.java @@ -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, diff --git a/SHiNE-server/shine-server-net-protocol/src/main/java/server/ws/WsConnectionUtils.java b/SHiNE-server/shine-server-net-protocol/src/main/java/server/ws/WsConnectionUtils.java index 0a8ec176..3db46942 100644 --- a/SHiNE-server/shine-server-net-protocol/src/main/java/server/ws/WsConnectionUtils.java +++ b/SHiNE-server/shine-server-net-protocol/src/main/java/server/ws/WsConnectionUtils.java @@ -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 = diff --git a/SHiNE-server/src/test/java/test/it/cases/IT_07_EspPairing.java b/SHiNE-server/src/test/java/test/it/cases/IT_07_EspPairing.java index 0ac2f49f..381e3d1c 100644 --- a/SHiNE-server/src/test/java/test/it/cases/IT_07_EspPairing.java +++ b/SHiNE-server/src/test/java/test/it/cases/IT_07_EspPairing.java @@ -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); diff --git a/VERSION.properties b/VERSION.properties index 9bac0fee..ea93735c 100644 --- a/VERSION.properties +++ b/VERSION.properties @@ -1,2 +1,2 @@ client.version=1.2.354 -server.version=1.2.334 +server.version=1.2.335 diff --git a/docs/libs/shine-server-bd/DOC.md b/docs/libs/shine-server-bd/DOC.md index 0c7fcffe..b08de246 100644 --- a/docs/libs/shine-server-bd/DOC.md +++ b/docs/libs/shine-server-bd/DOC.md @@ -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-решение, позволяющее регистрировать новых пользователей