Завершение обновления безопасности.

v++
This commit is contained in:
2025-02-21 01:57:15 +03:00
parent 49f0a56c4f
commit 8701c8ba36
23 changed files with 230 additions and 41 deletions

View File

@@ -30,6 +30,7 @@ import _VisualDVM.TestingSystem.DVM.DVMConfiguration.DVMConfiguration;
import _VisualDVM.TestingSystem.DVM.DVMPackage.DVMPackage;
import _VisualDVM.TestingSystem.DVM.DVMSettings.DVMSettings;
import _VisualDVM.TestingSystem.DVM.DVMTestingChecker;
import _VisualDVM.TestingSystem.DVM.PackageCredentials.DVMPackageCredentials;
import _VisualDVM.TestingSystem.SAPFOR.Json.SapforPackage_json;
import _VisualDVM.TestingSystem.SAPFOR.Json.SapforVersion_json;
import _VisualDVM.TestingSystem.SAPFOR.SapforConfiguration.SapforConfiguration;
@@ -58,7 +59,9 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
public String name = "?";
DVMTestingChecker dvmTestingChecker = new DVMTestingChecker();
SapforTestingPlanner sapforTestingPlanner = new SapforTestingPlanner();
//--
//-->
MachinesDatabase machines_db;
//-->
protected Thread testingThread = new Thread(() -> {
while (true) {
dvmTestingChecker.Perform();
@@ -70,6 +73,15 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
super(TestsDatabase.class);
name = Utils_.getDateName("testingServer");
}
@Override
public void StartAction() throws Exception {
try {
machines_db = new MachinesDatabase();
machines_db.Activate();
} catch (Exception ex) {
ex.printStackTrace();
}
}
public static void TimerOn() {
checkTimer = new Timer(Global.normalProperties.CheckTestingIntervalSeconds * 1000, e -> {
Global.mainModule.getPass(PassCode.ActualizePackages).Do();
@@ -103,6 +115,10 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
dvmPackage.saveJson();
dvmPackage.package_json = null; // объект больше не нужен.
//--
//Занести учетные данные пакета в базу о машинах. это основной поток, нить не нужна. арг это пароль
DVMPackageCredentials credentials = new DVMPackageCredentials(dvmPackage, request.arg);
machines_db.Insert(credentials);
//--
} else if (object instanceof SapforPackage) {
((SapforPackage) object).init();
}
@@ -205,6 +221,11 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
DVMPackage dvmPackage = (DVMPackage) object;
File workspace = dvmPackage.getLocalWorkspace();
Utils_.forceDeleteWithCheck(workspace);
//--
DVMPackageCredentials credentials = machines_db.dvmPackagesCredentials.getForPackageId(dvmPackage.id);
if (credentials != null)
machines_db.Delete(credentials);
//--
} else if (object instanceof SapforPackage) {
SapforPackage sapforPackage = (SapforPackage) object;
//--
@@ -495,8 +516,12 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
if (dvmPackage.state.isActive()) {
//-
if (!machinesProcesses.hasProcessForPackage(dvmPackage)) {
MachineProcess new_process = new MachineProcess(dvmPackage);
processes_to_start.put(new_process.getUniqueKey(), new_process);
DVMPackageCredentials credentials = machines_db.dvmPackagesCredentials.getForPackageId(dvmPackage.id);
if (credentials != null) {
MachineProcess new_process = new MachineProcess(dvmPackage, credentials);
//получить пароль.
processes_to_start.put(new_process.getUniqueKey(), new_process);
}
}
}
}
@@ -569,7 +594,7 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
UserAccount account = new UserAccount();
account.name = "server";
account.email = Constants.MailAddress;
account.role= AccountRole.Admin;
account.role = AccountRole.Admin;
//-
int sapforId = Integer.parseInt(request.arg);
if (!db.serverSapfors.containsKey(sapforId)) {
@@ -758,10 +783,22 @@ public class TestingServer extends RepositoryServer<TestsDatabase> {
}
}
}
void GetDVMPackageCredentials() throws Exception {
int package_id = (int) request.object;
if (!db.dvmPackages.containsKey(package_id))
throw new RepositoryRefuseException("Не найден пакет с ключом " + Utils_.Brackets(package_id));
DVMPackageCredentials res = machines_db.dvmPackagesCredentials.getForPackageId(package_id);
if (res == null)
throw new RepositoryRefuseException("Не найдено учетных данных для пакета " + Utils_.Brackets(package_id));
response.object = res;
}
//--
@Override
protected void Session() throws Exception {
switch (code) {
case GetDVMPackageCredentials:
GetDVMPackageCredentials();
break;
case PerformAutoSapforTesting:
PerformAutoSapforTesting();
break;