Завершение обновления безопасности.
v++
This commit is contained in:
@@ -4,6 +4,7 @@ import Common.Database.Objects.DBObject;
|
||||
import Common.Utils.Utils_;
|
||||
import _VisualDVM.*;
|
||||
import _VisualDVM.TestingSystem.DVM.DVMPackage.DVMPackage;
|
||||
import _VisualDVM.TestingSystem.DVM.PackageCredentials.DVMPackageCredentials;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
@@ -23,14 +24,16 @@ public class MachineProcess extends DBObject {
|
||||
public MachineProcess(MachineProcess p) {
|
||||
SynchronizeFields(p);
|
||||
}
|
||||
public MachineProcess(DVMPackage p) {
|
||||
public MachineProcess(DVMPackage p, DVMPackageCredentials credentials) {
|
||||
machineAddress = p.machine_address;
|
||||
machinePort = p.machine_port;
|
||||
userName = p.user_name;
|
||||
userPassword = p.user_password;
|
||||
userWorkspace = p.user_workspace;
|
||||
testingSystemRoot = Utils_.getHomePath();
|
||||
serverName = Global.testingServer.name;
|
||||
//-->>
|
||||
userPassword = credentials.userPassword;
|
||||
//-->>
|
||||
id = Utils_.getDateName(machineAddress + "_" + machinePort + "_" + userName);
|
||||
}
|
||||
@Override
|
||||
@@ -94,7 +97,7 @@ public class MachineProcess extends DBObject {
|
||||
//копирование визуализатора
|
||||
File src = new File(Utils_.getHomeDirectory(), "TestingSystem.jar");
|
||||
File supervisor = new File(workspace, "VisualSapfor.jar");
|
||||
FileUtils.copyFile(src, supervisor);
|
||||
FileUtils.copyFile(src, supervisor); //? можно ли символическую ссылку?
|
||||
//создание настроек
|
||||
VisualDVMProperties properties = new VisualDVMProperties();
|
||||
properties.Mode = Mode.MachineQueue;
|
||||
|
||||
23
src/_VisualDVM/TestingSystem/Common/MachinesDatabase.java
Normal file
23
src/_VisualDVM/TestingSystem/Common/MachinesDatabase.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package _VisualDVM.TestingSystem.Common;
|
||||
import Common.Database.SQLITE.SQLiteDatabase;
|
||||
import Common.Passes.PassCode_;
|
||||
import _VisualDVM.GlobalData.Machine.MachinesDBTable;
|
||||
import _VisualDVM.GlobalData.User.UsersDBTable;
|
||||
import _VisualDVM.TestingSystem.DVM.PackageCredentials.DVMPackageCredentials;
|
||||
import _VisualDVM.TestingSystem.DVM.PackageCredentials.DVMPackagesCredentialsDBTable;
|
||||
|
||||
import java.nio.file.Paths;
|
||||
public class MachinesDatabase extends SQLiteDatabase {
|
||||
DVMPackagesCredentialsDBTable dvmPackagesCredentials;
|
||||
public MachinesDatabase() {
|
||||
super(Paths.get(System.getProperty("user.dir"), "Data", "machines.sqlite").toFile());
|
||||
}
|
||||
@Override
|
||||
protected void initAllTables() throws Exception {
|
||||
addTable(dvmPackagesCredentials = new DVMPackagesCredentialsDBTable());
|
||||
}
|
||||
@Override
|
||||
public PassCode_ getSynchronizePassCode() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -258,7 +258,7 @@ public class TestsDatabase extends SQLiteDatabase {
|
||||
case ConnectionError:
|
||||
break;
|
||||
default:
|
||||
if (dvmPackage.getMachine().getURL().equals(arg))
|
||||
if (dvmPackage.getMachineURL().equals(arg))
|
||||
machinePackages.add(dvmPackage);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import _VisualDVM.TestingSystem.Common.TestingPackage.TestingPackage;
|
||||
import _VisualDVM.TestingSystem.DVM.DVMConfiguration.DVMConfiguration;
|
||||
import _VisualDVM.TestingSystem.DVM.DVMSettings.DVMSettings;
|
||||
import _VisualDVM.TestingSystem.DVM.DVMTasks.DVMCompilationTask;
|
||||
import com.sun.org.glassfish.gmbal.Description;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Vector;
|
||||
@@ -26,7 +27,6 @@ public class DVMPackage extends TestingPackage<DVMPackage_json> {
|
||||
public int machine_port = 22;
|
||||
//---
|
||||
public String user_name = "";
|
||||
public String user_password;
|
||||
public String user_workspace;
|
||||
//---
|
||||
public DVMPackage() {
|
||||
@@ -47,7 +47,6 @@ public class DVMPackage extends TestingPackage<DVMPackage_json> {
|
||||
machine_port = machine.port;
|
||||
//-
|
||||
user_name = user.login;
|
||||
user_password = user.password;
|
||||
user_workspace = user.workspace;
|
||||
//-
|
||||
drv = compiler.call_command;
|
||||
@@ -99,16 +98,18 @@ public class DVMPackage extends TestingPackage<DVMPackage_json> {
|
||||
machine_port = tasksPackage.machine_port;
|
||||
user_name = tasksPackage.user_name;
|
||||
user_workspace = tasksPackage.user_workspace;
|
||||
user_password = tasksPackage.user_password;
|
||||
}
|
||||
public Machine getMachine() {
|
||||
return new Machine(machine_name, machine_address, machine_port, MachineType.Server);
|
||||
}
|
||||
public User getUser() {
|
||||
return new User(user_name, user_password, user_workspace);
|
||||
return new User(user_name, "", user_workspace);
|
||||
}
|
||||
@Override
|
||||
public void checkFinishState() throws Exception {
|
||||
}
|
||||
public String getMachineURL(){
|
||||
return machine_address + ":" + machine_port;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package _VisualDVM.TestingSystem.DVM.PackageCredentials;
|
||||
import Common.CommonConstants;
|
||||
import Common.Database.Objects.iDBObject;
|
||||
import _VisualDVM.GlobalData.Machine.Machine;
|
||||
import _VisualDVM.GlobalData.Machine.MachineType;
|
||||
import _VisualDVM.GlobalData.User.User;
|
||||
import _VisualDVM.TestingSystem.DVM.DVMPackage.DVMPackage;
|
||||
public class DVMPackageCredentials extends iDBObject {
|
||||
public int dvmpackage_id = CommonConstants.Nan;
|
||||
public String userPassword = "";
|
||||
//---->>
|
||||
public DVMPackageCredentials() {
|
||||
}
|
||||
public DVMPackageCredentials(DVMPackage dvmPackage, String password_in) {
|
||||
dvmpackage_id = dvmPackage.id;
|
||||
userPassword = password_in;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package _VisualDVM.TestingSystem.DVM.PackageCredentials;
|
||||
import Common.Database.Tables.iDBTable;
|
||||
import _VisualDVM.TestingSystem.DVM.DVMPackage.DVMPackage;
|
||||
public class DVMPackagesCredentialsDBTable extends iDBTable<DVMPackageCredentials> {
|
||||
public DVMPackagesCredentialsDBTable() {
|
||||
super(DVMPackageCredentials.class);
|
||||
}
|
||||
public DVMPackageCredentials getForPackageId(int dvmPackage_id){
|
||||
for (DVMPackageCredentials dvmPackageCredentials: Data.values()){
|
||||
if (dvmPackageCredentials.dvmpackage_id==dvmPackage_id)
|
||||
return dvmPackageCredentials;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user