private void OnExportPublicKeyConfirmMsg(ExportPublicKeyConfirmMsg msg) { _isProcessInProgress = true; UIServices.SetBusyState(); _logger.Info("export public key confirmed --> export key file"); _logger.Info("export path: " + msg.Filename); MasterLogin login = _database.GetAll <MasterLogin>().FirstOrDefault(); if (login != null) { bool success = _cryptographyService.ExportPublicKeyFile(msg.Filename, login.PublicKey); if (success) { _logger.Info("export successful"); _messenger.Send(new ExportPublicKeySuccsessMsg()); } else { _logger.Error("export failed"); _messenger.Send(new ExportPublicKeyFailedMsg()); } } else { _logger.Error("login is null!"); } _isProcessInProgress = false; }
private void ExecuteBackupBindingsCmd(object param) { if (string.IsNullOrEmpty(this.BindingsBackupPath) || !Directory.Exists(this.BindingsBackupPath)) { NotificationHelper.WriteNotification("Chemin de backup invalide."); } else { var appList = this.AllSelected ? this._services.GetAllApplications() : (param as IEnumerable).Cast <Application>(); NotificationHelper.WriteNotification( string.Format("Début du backup de {0} application(s).", appList.Count()) ); UIServices.SetBusyState(); foreach (var app in appList) { NotificationHelper.WriteNotification("Export du binding pour " + app.Name + " dans " + this.BindingsBackupPath + "..."); var trace = this._services.ExportBinding(app.Name, this.BindingsBackupPath); NotificationHelper.WriteNotification(trace); } } }
private void Decrypt(object obj) { _isProcessInProgress = true; UIServices.SetBusyState(); _logger.Info("start decryption"); _logger.Info("source: " + SourceFilepath); _logger.Info("destination: " + TargetFilepath); _logger.Info("sender: " + ContactName); if (CheckSoureAndTargetPath()) { if (IsVaildFile()) { MasterLogin login = _database.GetAll <MasterLogin>().FirstOrDefault(); if (login != null) { bool isDecryped = _cryptographyService.DecryptFile(_sourceFilepath, _targetFilepath, login.PrivateKey); if (isDecryped) { _messenger.Send(new DecryptionSuccsessMsg()); } else { _logger.Error("file can not decrypt!"); _messenger.Send(new DecryptionFailedMsg()); } _logger.Info("check if source file in temp directory and when it is, then delete"); CheckSourceFileInTempDirectory(); //reset inputs SourceFilepath = string.Empty; TargetFilepath = string.Empty; ContactName = string.Empty; } else { _logger.Error("login is null!"); } } else { _logger.Error("file is not vaild for encryption! maybe encrpytion?"); _messenger.Send(new DecryptionFailedMsg()); } } else { _logger.Error("source and/or target path are not vaild!"); _messenger.Send(new SourceTargetInvaildMsg()); } _disableForEncryption = true; _isProcessInProgress = false; }
private void Encrypt(object obj) { _isProcessInProgress = true; UIServices.SetBusyState(); _logger.Info("start encryption"); _logger.Info("source: " + _sourceFilepath); _logger.Info("destination: " + _targetFilepath); _logger.Info("receipient: " + _contactName); if (CheckSoureAndTargetPath()) { if (string.IsNullOrEmpty(ContactName)) { MasterLogin login = _database.GetAll <MasterLogin>().FirstOrDefault(); if (login != null) { _logger.Info("encrpyt file for myself"); _cryptographyService.EncryptFile(_sourceFilepath, _targetFilepath, login.PublicKey); _messenger.Send(new EncryptionSuccsessMsg { TargetPath = _targetFilepath + ".sfs" }); } else { _logger.Error("login is null!"); } } else { _logger.Info("encrpyt file for: " + ContactName); _cryptographyService.EncryptFile(_sourceFilepath, _targetFilepath, PublicKey); _messenger.Send(new EncryptionSuccsessMsg { TargetPath = _targetFilepath }); } _logger.Info("check if source file in temp directory and when it is, then delete"); CheckSourceFileInTempDirectory(); //reset inputs SourceFilepath = string.Empty; TargetFilepath = string.Empty; ContactName = string.Empty; } else { _logger.Error("source and/or target path are not vaild!"); _messenger.Send(new SourceTargetInvaildMsg()); } _disableForEncryption = true; _isProcessInProgress = false; }
public MainVM() { _model.PropertyChanged += (s, e) => { RaisePropertyChanged(e.PropertyName); }; #region Images_LoadCommand Images_LoadCommand = new DelegateCommand <string>(path => { _model.ImageCollection_Load(path); SingleViewMode = false; }); #endregion #region Images_DropCommand Images_DropCommand = new DelegateCommand <DragEventArgs>(dragEventArgs => _model.ImageCollection_Load(dragEventArgs)); #endregion #region SingleViewModeOnCommand SingleViewModeOnCommand = new DelegateCommand <ImageItem>(imageItem => { CurrentImage = imageItem; SingleViewMode = true; }); #endregion #region EscPressedCommand EscPressedCommand = new DelegateCommand(() => SingleViewMode = false, () => SingleViewMode); #endregion #region Image_NextCommand Image_NextCommand = new DelegateCommand( () => CurrentImage = _model.Image_Next(CurrentImage), () => !Image_CommandsBlock); #endregion #region Image_PreviousCommand Image_PreviousCommand = new DelegateCommand( () => CurrentImage = _model.Image_Previous(CurrentImage), () => !Image_CommandsBlock); #endregion #region Image_BlurCommand Image_BlurCommand = new DelegateCommand( () => { UIServices.SetBusyState(); try { _model.Image_Blur(CurrentImage); } catch (Exception ex) { } }, () => !Image_CommandsBlock); #endregion CurrentImage = null; SingleViewMode = false; Image_CommandsBlock = true; }
private void ExecuteBackupMsiCmd(object param) { if (string.IsNullOrEmpty(this.MsiBackupPath) || !Directory.Exists(this.MsiBackupPath)) { NotificationHelper.WriteNotification("Chemin de backup invalide."); } else { var appList = this.AllSelected ? this._services.GetAllApplications() : (param as IEnumerable).Cast <Application>(); NotificationHelper.WriteNotification( string.Format("Début du backup de {0} application(s).", appList.Count()) ); UIServices.SetBusyState(); foreach (var app in appList) { NotificationHelper.WriteNotification("Export de la liste des ressources pour " + app.Name + " dans " + this.MsiBackupPath + "..."); // TODO export MSI avec le resourcespec string resourcesFileName; var trace = this._services.ExportResourceSpecFile(app.Name, this.MsiBackupPath, out resourcesFileName); NotificationHelper.WriteNotification(trace); this._services.ConfigResourcesSpecFile( Path.Combine(this.MsiBackupPath, resourcesFileName), this.ResourcesBindings, this.ResourcesAssemblies, this.ResourcesWebDirectories ); trace = this._services.ExportMsiWithResourcesFilter(app.Name, this.MsiBackupPath, Path.Combine(this.MsiBackupPath, resourcesFileName)); NotificationHelper.WriteNotification(trace); } } }
private void DoLogin(object parameter) { UIServices.SetBusyState(); _logger.Info("reset error msg"); ErrorMsg = string.Empty; _logger.Info("starting with login process"); if (!string.IsNullOrEmpty(_login) && _login.Length >= 6) { var values = (object[])parameter; var passwordBox = values[0] as PasswordBox; if (passwordBox != null) { _logger.Info("password parameter is not null"); string password = passwordBox.Password; if (!string.IsNullOrEmpty(password)) { _logger.Info("password is not null or empty"); _logger.Info("check for exsisting login"); var database = Container.Resolve <IDataAccessLayer>(); List <MasterLogin> logins = database.GetAll <MasterLogin>(); if (logins.Count == 1) { var login = database.GetSingleByName <MasterLogin>(_login); if (login != null) { _logger.Info("login do exsits"); byte[] hashedPassword = _cryptographyService.HashPassword(password, login.Salt); _logger.Info("compare passwords..."); if (_cryptographyService.Compare(hashedPassword, login.Password)) { _logger.Info("...login verified."); OpenMainView(values); } else { _logger.Error("...login failed."); ErrorMsg = "Login failed!"; } } else { _logger.Error("master login already exists"); ErrorMsg = "Master login already exists!"; } } else if (logins.Count == 0) { _logger.Info("login do not exsits"); byte[] salt = _cryptographyService.GenerateSalt(); byte[] hashedPassword = _cryptographyService.HashPassword(password, salt); _cryptographyService.AssignNewKeys(); var masterLogin = new MasterLogin { Name = _login, Password = hashedPassword, Salt = salt, PrivateKey = _cryptographyService.GetPrivateKeyAsXml(), PublicKey = _cryptographyService.GetPublicKey(), }; database.Insert(masterLogin); OpenMainView(values); } } else { _logger.Error("password is null or empty!"); ErrorMsg = "Password is empty!"; } } } else { _logger.Error("login is null, empty or have less then 6 characters!"); ErrorMsg = "Login have less then 6 characters!"; } }
private void Confirm(object obj) { UIServices.SetBusyState(); _logger.Info("password change confirmed"); _logger.Info("parsing parameters"); var parameters = (object[])obj; var oldPasswordBox = parameters[0] as PasswordBox; var newPasswordBox = parameters[1] as PasswordBox; var newPassword2Box = parameters[2] as PasswordBox; if (oldPasswordBox != null && newPasswordBox != null && newPassword2Box != null) { _logger.Info("parameters not null"); _logger.Info("get login data"); MasterLogin login = _database.GetAll <MasterLogin>().First(); _logger.Info("hash entered password"); byte[] hashedPassword = _cryptographyService.HashPassword(oldPasswordBox.Password, login.Salt); _logger.Info("compare entered and stored passwords"); if (_cryptographyService.Compare(hashedPassword, login.Password)) { _logger.Info("password are correct"); string newPassword1 = newPasswordBox.Password; string newPassword2 = newPassword2Box.Password; _logger.Info("compare new passwords"); if (newPassword1 == newPassword2) { _logger.Info("hash new password"); byte[] newSalt = _cryptographyService.GenerateSalt(); byte[] newHashedPassword = _cryptographyService.HashPassword(newPassword1, newSalt); login.Salt = newSalt; login.Password = newHashedPassword; _logger.Info("save changes"); _database.Update(login); _logger.Info("changes are saved"); InformUserAndClose(parameters); } else { _logger.Error("new passwords do not match"); ErrorMsg = "Passwords do not match!"; } } else { _logger.Error("current password is wrong!"); ErrorMsg = "Old Password is wrong!"; } } else { _logger.Error("parameters are null!"); ErrorMsg = "Something went wrong, pleas try again."; } }