ключ теперь не поле бд а отдельный файл на сервере.
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -49,5 +49,5 @@ Makefiles/*
|
||||
Repo/*
|
||||
Sts/*
|
||||
Tests/*
|
||||
Key/*
|
||||
Keys/*
|
||||
debug.log
|
||||
10
.idea/workspace.xml
generated
10
.idea/workspace.xml
generated
@@ -7,13 +7,13 @@
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
|
||||
<change afterPath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/EditUserAccount.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/ComponentsServer/ComponentsServer.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/ComponentsServer/ComponentsServer.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/ComponentsServer/CredentialsDatabase.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/ComponentsServer/CredentialsDatabase.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/ComponentsServer/UserAccount/UI/UserAccountsForm.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/ComponentsServer/UserAccount/UI/UserAccountsForm.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Passes/PassCode.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Passes/PassCode.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Repository/Server/ServerCode.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Repository/Server/ServerCode.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/ComponentsServer/UserAccount/UserAccount.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/ComponentsServer/UserAccount/UserAccount.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Constants.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Constants.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Global.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Global.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/CheckAccount.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/CheckAccount.java" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
|
||||
@@ -7,11 +7,10 @@ import _VisualDVM.ComponentsServer.BugReport.Json.BugReportAdditionJson;
|
||||
import _VisualDVM.ComponentsServer.Component.ComponentType;
|
||||
import _VisualDVM.ComponentsServer.Component.Json.ComponentPublicationInfoJson;
|
||||
import _VisualDVM.ComponentsServer.Component.Json.ComponentVersionsInfoJson;
|
||||
import _VisualDVM.ComponentsServer.Subscribes.Subscriber;
|
||||
import _VisualDVM.ComponentsServer.UserAccount.AccountRole;
|
||||
import _VisualDVM.ComponentsServer.UserAccount.UserAccount;
|
||||
import _VisualDVM.Constants;
|
||||
import _VisualDVM.Global;
|
||||
import _VisualDVM.ComponentsServer.UserAccount.AccountRole;
|
||||
import _VisualDVM.GlobalData.Machine.Machine;
|
||||
import _VisualDVM.GlobalData.Machine.MachineType;
|
||||
import _VisualDVM.GlobalData.RemoteFile.RemoteFile;
|
||||
@@ -221,7 +220,7 @@ public class ComponentsServer extends RepositoryServer<BugReportsDatabase> {
|
||||
response.object = Utils_.fileToBytes(archives);
|
||||
} else throw new RepositoryRefuseException("Не удалось запаковать архивы");
|
||||
}
|
||||
void ReceiveBugReportsDatabase() throws Exception{
|
||||
void ReceiveBugReportsDatabase() throws Exception {
|
||||
response.object = Utils_.fileToBytes(db.getFile());
|
||||
}
|
||||
void ReceiveBugReport() throws Exception {
|
||||
@@ -329,23 +328,24 @@ public class ComponentsServer extends RepositoryServer<BugReportsDatabase> {
|
||||
}
|
||||
void GetUserAccountByKey() throws Exception {
|
||||
UserAccount account = credentials_db.userAccounts.getByKey(request.arg);
|
||||
response.object = account==null? null: account;
|
||||
response.object = account == null ? null : account;
|
||||
}
|
||||
void GetUserAccountByEmail() throws Exception {
|
||||
UserAccount account_info = (UserAccount) request.object;
|
||||
UserAccount account = credentials_db.userAccounts.getByEmail(account_info.email);
|
||||
if (account==null){
|
||||
if (account == null) {
|
||||
account = new UserAccount(account_info);
|
||||
account.role = Constants.admins_mails.contains(account.email)? AccountRole.Admin: AccountRole.User;
|
||||
account.security_key = RandomStringUtils.random(100, true, true);
|
||||
account.role = Constants.admins_mails.contains(account.email) ? AccountRole.Admin : AccountRole.User;
|
||||
credentials_db.Insert(account);
|
||||
FileUtils.writeStringToFile(account.getServerKeyFile(), RandomStringUtils.random(100, true, true));
|
||||
}
|
||||
response.object = account;
|
||||
response.arg = FileUtils.readFileToString(account.getServerKeyFile());
|
||||
}
|
||||
void ReceiveCredentialsDatabase() throws Exception{
|
||||
void ReceiveCredentialsDatabase() throws Exception {
|
||||
response.object = Utils_.fileToBytes(credentials_db.getFile());
|
||||
}
|
||||
void EditUserAccount() throws Exception{
|
||||
void EditUserAccount() throws Exception {
|
||||
UserAccount new_object = (UserAccount) request.object;
|
||||
credentials_db.UpdateWithCheck(new_object);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,10 @@ import Common.Utils.TextLog;
|
||||
import _VisualDVM.ComponentsServer.BugReport.BugReport;
|
||||
import _VisualDVM.Global;
|
||||
import com.sun.org.glassfish.gmbal.Description;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.lang.RandomStringUtils;
|
||||
|
||||
import java.io.File;
|
||||
public class UserAccount extends iDBObject {
|
||||
public String name = "";
|
||||
public String email = "";
|
||||
@@ -12,7 +16,6 @@ public class UserAccount extends iDBObject {
|
||||
public String telegram_name="";
|
||||
@Description("DEFAULT 1")
|
||||
public int subscribe_active = 1;
|
||||
public String security_key = "";
|
||||
@Description("DEFAULT 'Undefined'")
|
||||
public AccountRole role = AccountRole.Undefined; //права доступа
|
||||
public UserAccount(){
|
||||
@@ -29,13 +32,21 @@ public class UserAccount extends iDBObject {
|
||||
email = src_.email;
|
||||
telegram_name=src_.telegram_name;
|
||||
subscribe_active=src_.subscribe_active;
|
||||
security_key = src_.security_key;
|
||||
role = src_.role;
|
||||
}
|
||||
public UserAccount(String name_in, String email_in){
|
||||
name = name_in;
|
||||
email=email_in;
|
||||
}
|
||||
public File getClientKeyFile(){
|
||||
return new File(Global.KeysDirectory,"key");
|
||||
}
|
||||
public File getServerKeyFile(){
|
||||
return new File(Global.KeysDirectory,String.valueOf(id));
|
||||
}
|
||||
public String getKey() throws Exception{
|
||||
return FileUtils.readFileToString(getServerKeyFile());
|
||||
}
|
||||
//todo часть устарело.разобрать.
|
||||
public boolean CheckRegistered(TextLog Log) {
|
||||
if (role.equals(AccountRole.Undefined)) {
|
||||
|
||||
@@ -8,9 +8,9 @@ public class UserAccountsDBTable extends iDBTable<UserAccount> {
|
||||
public UserAccountsDBTable() {
|
||||
super(UserAccount.class);
|
||||
}
|
||||
public UserAccount getByKey(String key_in){
|
||||
public UserAccount getByKey(String key_in) throws Exception{
|
||||
for (UserAccount userAccount: Data.values()){
|
||||
if (userAccount.security_key.equals(key_in))
|
||||
if (userAccount.getKey().equals(key_in))
|
||||
return userAccount;
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -22,7 +22,7 @@ public class Constants {
|
||||
public static final String TestsDirectoryName = "Tests";
|
||||
public static final String DVMPackagesDirectoryName = "DVMPackages";
|
||||
public static final String PerformanceAnalyzerDirectoryName = "PerformanceAnalyzer";
|
||||
public static final String KeyDirectoryName = "Key";
|
||||
public static final String KeyDirectoryName = "Keys";
|
||||
//--
|
||||
//SVN vmk-post@yandex.ru
|
||||
public static final String REPOSITORY_AUTHENTICATION = "--username dvmhuser --password dvmh2013 --non-interactive";
|
||||
|
||||
@@ -35,7 +35,7 @@ public class Global {
|
||||
public static ComponentsSet components = null;
|
||||
public static MessagesServer messagesServer = null;
|
||||
public static File ComponentsDirectory;
|
||||
public static File KeyDirectory;
|
||||
public static File KeysDirectory;
|
||||
public static File DataDirectory;
|
||||
public static File BugReportsDirectory;
|
||||
public static File BackUpsDirectory;
|
||||
@@ -75,7 +75,7 @@ public class Global {
|
||||
Utils_.CheckDirectory(PerformanceAnalyzerDirectory = new File(Utils_.getHomeDirectory(), Constants.PerformanceAnalyzerDirectoryName));
|
||||
Utils_.CheckDirectory(DVMPackagesDirectory = new File(Utils_.getHomeDirectory(), Constants.DVMPackagesDirectoryName));
|
||||
Utils_.CheckDirectory(SapforPackagesDirectory = new File(Utils_.getHomeDirectory(), "SapforPackages"));
|
||||
Utils_.CheckDirectory(KeyDirectory = new File(Utils_.getHomeDirectory(), Constants.KeyDirectoryName));
|
||||
Utils_.CheckDirectory(KeysDirectory = new File(Utils_.getHomeDirectory(), Constants.KeyDirectoryName));
|
||||
}
|
||||
public static void CheckServerDirectories() {
|
||||
Utils_.CheckDirectory(ComponentsDirectory = new File(Utils_.getHomeDirectory(), Constants.ComponentsDirectoryName));
|
||||
@@ -84,6 +84,7 @@ public class Global {
|
||||
//-
|
||||
Utils_.CheckDirectory(BugReportsDirectory = new File(Utils_.getHomeDirectory(), Constants.BugsDirectoryName));
|
||||
Utils_.CheckDirectory(DataBackUpsDirectory = new File(Utils_.getHomeDirectory(), Constants.DataBackUpsDirectoryName));
|
||||
Utils_.CheckDirectory(KeysDirectory = new File(Utils_.getHomeDirectory(), Constants.KeyDirectoryName));
|
||||
}
|
||||
public static void CheckTestingSystemDirectories() {
|
||||
Utils_.CheckDirectory(ComponentsDirectory = new File(Utils_.getHomeDirectory(), Constants.ComponentsDirectoryName));
|
||||
@@ -95,7 +96,6 @@ public class Global {
|
||||
Utils_.CheckDirectory(DVMPackagesDirectory = new File(Utils_.getHomeDirectory(), Constants.DVMPackagesDirectoryName));
|
||||
Utils_.CheckDirectory(SapforsDirectory = new File(Utils_.getHomeDirectory(), "Sapfors"));
|
||||
Utils_.CheckDirectory(SapforPackagesDirectory = new File(Utils_.getHomeDirectory(), "SapforPackages"));
|
||||
//CheclAndClean через неделю
|
||||
Utils_.CheckDirectory(MachinesDirectory = new File(Utils_.getHomeDirectory(), "Machines"));
|
||||
}
|
||||
public static void CreateLogAtComponentsPath() {
|
||||
|
||||
@@ -26,7 +26,7 @@ public class CheckAccount extends ComponentsServerPass {
|
||||
//подтвердили почту. теперь проверяем ее роль на сервере. если на сервере нет акка будет создан
|
||||
if (SendRequest(ServerCode.GetUserAccountByEmail, "",Global.mainModule.getAccount())){
|
||||
Global.mainModule.setAccount((UserAccount) request.server_response.object);
|
||||
FileUtils.writeStringToFile(keyFile, Global.mainModule.getAccount().security_key);
|
||||
FileUtils.writeStringToFile(keyFile, request.server_response.arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,7 @@ public class CheckAccount extends ComponentsServerPass {
|
||||
protected boolean canStart(Object... args) throws Exception {
|
||||
Global.mainModule.getAccount().role = AccountRole.Undefined;
|
||||
Global.normalProperties.Update();
|
||||
keyFile = new File(Global.KeyDirectory, "key");
|
||||
keyFile = new File(Global.KeysDirectory, "key");
|
||||
//--
|
||||
//1. Ищем ключ.
|
||||
if (keyFile.exists()) {
|
||||
|
||||
Reference in New Issue
Block a user