public void Show(LavaUser user) { this.Title = user.UserName; this.Show(); currentUser = user; LoadingScreen.LoadingScreen loadingScreen = new LoadingScreen.LoadingScreen(); loadingScreen.Show(); // Open document var LoadingThread = new BackgroundWorker(); //Запуск процесса десереализации в фоновом потоке LoadingThread.DoWork += (s, args) => { try { IFileTransfer fileHost = new FileTransferClient(); string[] fileList = fileHost.GetFileList(user.UserName); if (fileList == null) throw new Exception("Error. File list in null"); foreach (var file in fileList) { //Получаем файл. Расшифровываем. Парсим. entrys.Deserialize(file, CryptoLibrary.decrypt28147cfb(user.MasterKey, GetFile(fileHost, file))); } } catch (Exception ex) { args.Result = ex.Message; } }; LoadingThread.RunWorkerCompleted += (s, e) => { if (e.Result != null) MessageBox.Show(loadingScreen, e.Result.ToString(), "Error!", MessageBoxButton.OK, MessageBoxImage.Error); loadingScreen.Close(); }; LoadingThread.RunWorkerAsync(); }
private void btnLogIn_Click(object sender, RoutedEventArgs e) { lblError.Content = ""; byte[] cipheredKeyContainer = new byte[64]; IAuthenticate proxy = new AuthenticateClient(); LavaResult result = proxy.Authenticate(tbUserName.Text, pbPassword.Password); if (result.Result == LAVA_ERROR_CODE.NO_MASTER_KEY) { MasterKeyWindow msKeyWnd = new MasterKeyWindow(); msKeyWnd.ShowDialog(); byte[] masterKey = CryptoLibrary.generateRandom(32); byte[] keyContainer = TLVUtil.StoreTag(0x25, masterKey); cipheredKeyContainer = CryptoLibrary.encrypt28147cfb( CryptoLibrary.computeHash3411(Utility.StringToByteArray(MasterKeyWindow.Password)), keyContainer); result = proxy.StoreKeyContainer(tbUserName.Text, cipheredKeyContainer); if (result.Result != LAVA_ERROR_CODE.OK) { lblError.Content = "Error while putting container: " + result.Result.ToString(); return; } } if (result.Result == LAVA_ERROR_CODE.OK) { EnterMasterKey enterKey = new EnterMasterKey(tbUserName.Text, (AuthenticateClient)proxy); enterKey.ShowDialog(); byte[] key = EnterMasterKey.key; this.Close(); LavaUser user = new LavaUser(tbUserName.Text, pbPassword.Password); user.MasterKey = key; wnd.Show(user); } else lblError.Content = "wrong name or pword"; }