Добавление учетных записей администратором
This commit is contained in:
11
.idea/workspace.xml
generated
11
.idea/workspace.xml
generated
@@ -6,7 +6,16 @@
|
|||||||
</artifacts-to-build>
|
</artifacts-to-build>
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="" />
|
<list default="true" id="e42177c3-2328-4b27-8a01-35779b2beb99" name="Default Changelist" comment="">
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/_VisualDVM/Passes/All/PublishUserAccount.java" 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/UserAccount/UI/UserAccountsForm.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/ComponentsServer/UserAccount/UI/UserAccountsForm.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/Passes/PassCode.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Passes/PassCode.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/_VisualDVM/Passes/Server/PublishServerObject.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/_VisualDVM/Passes/Server/PublishServerObject.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" />
|
||||||
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import org.apache.commons.lang.RandomStringUtils;
|
|||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
|
import java.io.Serializable;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
@@ -337,7 +338,7 @@ public class ComponentsServer extends RepositoryServer<BugReportsDatabase> {
|
|||||||
account = new UserAccount(account_info);
|
account = new UserAccount(account_info);
|
||||||
account.role = Constants.admins_mails.contains(account.email) ? AccountRole.Admin : AccountRole.User;
|
account.role = Constants.admins_mails.contains(account.email) ? AccountRole.Admin : AccountRole.User;
|
||||||
credentials_db.Insert(account);
|
credentials_db.Insert(account);
|
||||||
FileUtils.writeStringToFile(account.getServerKeyFile(), RandomStringUtils.random(100, true, true));
|
account.generateKey();
|
||||||
}
|
}
|
||||||
response.object = account;
|
response.object = account;
|
||||||
response.arg = FileUtils.readFileToString(account.getServerKeyFile());
|
response.arg = FileUtils.readFileToString(account.getServerKeyFile());
|
||||||
@@ -345,9 +346,18 @@ public class ComponentsServer extends RepositoryServer<BugReportsDatabase> {
|
|||||||
void ReceiveCredentialsDatabase() throws Exception {
|
void ReceiveCredentialsDatabase() throws Exception {
|
||||||
response.object = Utils_.fileToBytes(credentials_db.getFile());
|
response.object = Utils_.fileToBytes(credentials_db.getFile());
|
||||||
}
|
}
|
||||||
|
void PublishUserAccount() throws Exception {
|
||||||
|
DBObject dbObject = (DBObject) request.object;
|
||||||
|
response.object = (Serializable) credentials_db.InsertS(dbObject).getPK();
|
||||||
|
//--
|
||||||
|
credentials_db.userAccounts.get(response.object).generateKey();
|
||||||
|
}
|
||||||
void EditUserAccount() throws Exception {
|
void EditUserAccount() throws Exception {
|
||||||
UserAccount new_object = (UserAccount) request.object;
|
UserAccount new_object = (UserAccount) request.object;
|
||||||
credentials_db.UpdateWithCheck(new_object);
|
credentials_db.UpdateWithCheck(new_object);
|
||||||
|
}
|
||||||
|
void DeleteUserAccount() throws Exception {
|
||||||
|
|
||||||
}
|
}
|
||||||
//--
|
//--
|
||||||
@Override
|
@Override
|
||||||
@@ -385,6 +395,9 @@ public class ComponentsServer extends RepositoryServer<BugReportsDatabase> {
|
|||||||
@Override
|
@Override
|
||||||
protected void Session() throws Exception {
|
protected void Session() throws Exception {
|
||||||
switch (code) {
|
switch (code) {
|
||||||
|
case PublishUserAccount:
|
||||||
|
PublishUserAccount();
|
||||||
|
break;
|
||||||
case EditUserAccount:
|
case EditUserAccount:
|
||||||
EditUserAccount();
|
EditUserAccount();
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import Common.Visual.DataSetControlForm;
|
|||||||
import Common.Visual.Menus.DataMenuBar;
|
import Common.Visual.Menus.DataMenuBar;
|
||||||
import Common.Visual.Tables.ColumnInfo;
|
import Common.Visual.Tables.ColumnInfo;
|
||||||
import Common.Visual.Windows.Dialog.DBObjectDialog;
|
import Common.Visual.Windows.Dialog.DBObjectDialog;
|
||||||
import _VisualDVM.ComponentsServer.Subscribes.Subscriber;
|
|
||||||
import _VisualDVM.ComponentsServer.UserAccount.AccountRole;
|
import _VisualDVM.ComponentsServer.UserAccount.AccountRole;
|
||||||
import _VisualDVM.ComponentsServer.UserAccount.UserAccount;
|
import _VisualDVM.ComponentsServer.UserAccount.UserAccount;
|
||||||
import _VisualDVM.Global;
|
import _VisualDVM.Global;
|
||||||
@@ -50,7 +49,9 @@ public class UserAccountsForm extends DataSetControlForm<UserAccount> {
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected DataMenuBar createMenuBar() {
|
protected DataMenuBar createMenuBar() {
|
||||||
return new DataMenuBar(dataSource.getPluralDescription(), PassCode.SynchronizeCredentials, PassCode.EditUserAccount);
|
return new DataMenuBar(dataSource.getPluralDescription(), PassCode.SynchronizeCredentials,
|
||||||
|
PassCode.PublishUserAccount,
|
||||||
|
PassCode.EditUserAccount);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
protected DBObjectDialog getDialog() {
|
protected DBObjectDialog getDialog() {
|
||||||
|
|||||||
@@ -47,6 +47,9 @@ public class UserAccount extends iDBObject {
|
|||||||
public String getKey() throws Exception{
|
public String getKey() throws Exception{
|
||||||
return FileUtils.readFileToString(getServerKeyFile());
|
return FileUtils.readFileToString(getServerKeyFile());
|
||||||
}
|
}
|
||||||
|
public void generateKey() throws Exception {
|
||||||
|
FileUtils.writeStringToFile(getServerKeyFile(), RandomStringUtils.random(100, true, true));
|
||||||
|
}
|
||||||
//todo часть устарело.разобрать.
|
//todo часть устарело.разобрать.
|
||||||
public boolean CheckRegistered(TextLog Log) {
|
public boolean CheckRegistered(TextLog Log) {
|
||||||
if (role.equals(AccountRole.Undefined)) {
|
if (role.equals(AccountRole.Undefined)) {
|
||||||
|
|||||||
22
src/_VisualDVM/Passes/All/PublishUserAccount.java
Normal file
22
src/_VisualDVM/Passes/All/PublishUserAccount.java
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
package _VisualDVM.Passes.All;
|
||||||
|
import Common.Database.Database;
|
||||||
|
import _VisualDVM.ComponentsServer.ComponentsServer;
|
||||||
|
import _VisualDVM.ComponentsServer.UserAccount.UserAccount;
|
||||||
|
import _VisualDVM.Global;
|
||||||
|
import _VisualDVM.Passes.Server.PublishServerObject;
|
||||||
|
import _VisualDVM.Repository.Server.SafeServerExchangeUnit;
|
||||||
|
import _VisualDVM.Repository.Server.ServerCode;
|
||||||
|
public class PublishUserAccount extends PublishServerObject<ComponentsServer, UserAccount> {
|
||||||
|
public PublishUserAccount() {
|
||||||
|
super(Global.componentsServer, UserAccount.class);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected Database getDb() {
|
||||||
|
return server.credentials_db;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void ServerAction() throws Exception {
|
||||||
|
Command(new SafeServerExchangeUnit(ServerCode.PublishUserAccount, "", target));
|
||||||
|
pk = server_response.object;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -356,12 +356,15 @@ public enum PassCode implements PassCode_ {
|
|||||||
DetectSelectedTestsMinMaDim,
|
DetectSelectedTestsMinMaDim,
|
||||||
ConfirmEmail,
|
ConfirmEmail,
|
||||||
SynchronizeCredentials,
|
SynchronizeCredentials,
|
||||||
|
PublishUserAccount,
|
||||||
EditUserAccount
|
EditUserAccount
|
||||||
;
|
;
|
||||||
//--
|
//--
|
||||||
@Override
|
@Override
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
switch (this) {
|
switch (this) {
|
||||||
|
case PublishUserAccount:
|
||||||
|
return "Добавление учётной записи";
|
||||||
case EditUserAccount:
|
case EditUserAccount:
|
||||||
return "Редактирование учётной записи";
|
return "Редактирование учётной записи";
|
||||||
case SynchronizeCredentials:
|
case SynchronizeCredentials:
|
||||||
|
|||||||
@@ -32,13 +32,10 @@ public class PublishServerObject<S extends RepositoryServer, D extends DBObject>
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
protected String getEmail() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
//--
|
//--
|
||||||
@Override
|
@Override
|
||||||
protected void ServerAction() throws Exception {
|
protected void ServerAction() throws Exception {
|
||||||
Command(new SafeServerExchangeUnit(ServerCode.PublishObject, getEmail(), target));
|
Command(new SafeServerExchangeUnit(ServerCode.PublishObject, "", target));
|
||||||
pk = server_response.object;
|
pk = server_response.object;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -65,9 +65,12 @@ public enum ServerCode {
|
|||||||
DetectTestsMinMaxDim,
|
DetectTestsMinMaxDim,
|
||||||
GetUserAccountByKey,
|
GetUserAccountByKey,
|
||||||
GetUserAccountByEmail,
|
GetUserAccountByEmail,
|
||||||
EditUserAccount;
|
EditUserAccount,
|
||||||
|
PublishUserAccount;
|
||||||
public String getDescription(){
|
public String getDescription(){
|
||||||
switch (this){
|
switch (this){
|
||||||
|
case PublishUserAccount:
|
||||||
|
return "Создание учётной записи на сервере";
|
||||||
case EditUserAccount:
|
case EditUserAccount:
|
||||||
return "Редактирование учётной записи на сервере";
|
return "Редактирование учётной записи на сервере";
|
||||||
case ReceiveCredentialsDatabase:
|
case ReceiveCredentialsDatabase:
|
||||||
|
|||||||
Reference in New Issue
Block a user