mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 17:11:39 +03:00
[FEATURE] Предварительная имплементация UserHWID
This commit is contained in:
parent
91b7b2cd06
commit
765d47deec
4 changed files with 38 additions and 6 deletions
|
@ -3,6 +3,7 @@
|
||||||
import pro.gravit.launchserver.LaunchServer;
|
import pro.gravit.launchserver.LaunchServer;
|
||||||
import pro.gravit.launchserver.command.Command;
|
import pro.gravit.launchserver.command.Command;
|
||||||
import pro.gravit.launchserver.dao.User;
|
import pro.gravit.launchserver.dao.User;
|
||||||
|
import pro.gravit.launchserver.dao.UserHWID;
|
||||||
import pro.gravit.utils.helper.LogHelper;
|
import pro.gravit.utils.helper.LogHelper;
|
||||||
|
|
||||||
public class GetUserCommand extends Command {
|
public class GetUserCommand extends Command {
|
||||||
|
@ -30,5 +31,9 @@ public void invoke(String... args) throws Exception {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LogHelper.info("[%s] UUID: %s", user.username, user.uuid.toString());
|
LogHelper.info("[%s] UUID: %s", user.username, user.uuid.toString());
|
||||||
|
for(UserHWID hwid : user.hwids)
|
||||||
|
{
|
||||||
|
LogHelper.info("[%s] HWID: memory: %d | serial %s | hwdiskserial: %s | processorID %s | macAddr %s", user.username, hwid.totalMemory, hwid.serialNumber, hwid.HWDiskSerial, hwid.processorID, hwid.macAddr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
import pro.gravit.launchserver.LaunchServer;
|
import pro.gravit.launchserver.LaunchServer;
|
||||||
import pro.gravit.launchserver.dao.LaunchServerDaoFactory;
|
import pro.gravit.launchserver.dao.LaunchServerDaoFactory;
|
||||||
import pro.gravit.launchserver.dao.User;
|
import pro.gravit.launchserver.dao.User;
|
||||||
|
import pro.gravit.launchserver.dao.UserHWID;
|
||||||
import pro.gravit.launchserver.dao.impl.HibernateUserDAOImpl;
|
import pro.gravit.launchserver.dao.impl.HibernateUserDAOImpl;
|
||||||
import pro.gravit.launchserver.hibernate.SessionFactoryManager;
|
import pro.gravit.launchserver.hibernate.SessionFactoryManager;
|
||||||
import pro.gravit.utils.helper.CommonHelper;
|
import pro.gravit.utils.helper.CommonHelper;
|
||||||
|
@ -25,6 +26,7 @@ public void preInit(LaunchServer launchServer) {
|
||||||
Runnable init = () -> {
|
Runnable init = () -> {
|
||||||
Configuration cfg = new Configuration()
|
Configuration cfg = new Configuration()
|
||||||
.addAnnotatedClass(User.class)
|
.addAnnotatedClass(User.class)
|
||||||
|
.addAnnotatedClass(UserHWID.class)
|
||||||
.setProperty("hibernate.connection.driver_class", driver)
|
.setProperty("hibernate.connection.driver_class", driver)
|
||||||
.setProperty("hibernate.connection.url", url)
|
.setProperty("hibernate.connection.url", url)
|
||||||
.setProperty("hibernate.connection.username", username)
|
.setProperty("hibernate.connection.username", username)
|
||||||
|
|
|
@ -4,14 +4,10 @@
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.*;
|
||||||
import javax.persistence.Entity;
|
|
||||||
import javax.persistence.GeneratedValue;
|
|
||||||
import javax.persistence.GenerationType;
|
|
||||||
import javax.persistence.Id;
|
|
||||||
import javax.persistence.Table;
|
|
||||||
|
|
||||||
import pro.gravit.launcher.ClientPermissions;
|
import pro.gravit.launcher.ClientPermissions;
|
||||||
import pro.gravit.utils.helper.LogHelper;
|
import pro.gravit.utils.helper.LogHelper;
|
||||||
|
@ -33,6 +29,12 @@ public class User {
|
||||||
public String serverID;
|
public String serverID;
|
||||||
private String password_salt;
|
private String password_salt;
|
||||||
public long permissions;
|
public long permissions;
|
||||||
|
//TODO: заменить EAGER на LASY и придумать способ сохранить сессию
|
||||||
|
// [ERROR] org.hibernate.LazyInitializationException:
|
||||||
|
// failed to lazily initialize a collection of role: pro.gravit.launchserver.dao.User.hwids, could not initialize proxy - no Session
|
||||||
|
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||||
|
@JoinColumn(name = "user_id")
|
||||||
|
public Collection<UserHWID> hwids;
|
||||||
public void setPassword(String password)
|
public void setPassword(String password)
|
||||||
{
|
{
|
||||||
password_salt = SecurityHelper.randomStringAESKey();
|
password_salt = SecurityHelper.randomStringAESKey();
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
package pro.gravit.launchserver.dao;
|
||||||
|
|
||||||
|
import pro.gravit.launcher.LauncherAPI;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "users_hwids")
|
||||||
|
public class UserHWID {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private long id;
|
||||||
|
@LauncherAPI
|
||||||
|
public long totalMemory = 0;
|
||||||
|
@LauncherAPI
|
||||||
|
public String serialNumber;
|
||||||
|
@LauncherAPI
|
||||||
|
public String HWDiskSerial;
|
||||||
|
@LauncherAPI
|
||||||
|
public String processorID;
|
||||||
|
@LauncherAPI
|
||||||
|
public String macAddr;
|
||||||
|
}
|
Loading…
Reference in a new issue