void PasswordManagement_PasswordManagementEvent(object sender, RoutedPropertyChangedEventArgs <UMPEventArgs> e) { try { var args = e.NewValue; if (args == null) { return; } switch (args.Code) { case PasswordManagerEventCode.PASS_SETTED: RecordEncryptInfo info = args.Data as RecordEncryptInfo; if (info == null) { return; } GetRealPassword(info); break; } } catch (Exception ex) { ShowException(ex.Message); } }
public static EncryptInfoConfig CreateItem(RecordEncryptInfo info) { EncryptInfoConfig item = new EncryptInfoConfig(); item.UserID = info.UserID; item.IsRemember = info.IsRemember; item.StartTime = S3102App.EncryptString(info.StartTime.ToString("yyyy-MM-dd HH:mm:ss")); item.EndTime = S3102App.EncryptString(info.EndTime.ToString("yyyy-MM-dd HH:mm:ss")); item.Password = S3102App.EncryptString(info.Password); return(item); }
void BtnConfirm_Click(object sender, RoutedEventArgs e) { try { if (!CheckInput()) { return; } string strAddress = TxtServerAddress.Text; DateTime expireTime = DateTime.Now.AddDays(1).ToUniversalTime(); //默认有效期一天 if (TxtExpireTime.Value != null) { expireTime = ((DateTime)TxtExpireTime.Value).ToUniversalTime(); } bool isRemember = true;//CbRemember.IsChecked == string strPassword = TxtPassword.Password; if (ListRecordEncryptInfos != null) { bool isAdd = false; var temp = ListRecordEncryptInfos.FirstOrDefault(s => s.ServerAddress == strAddress); if (temp == null) { temp = new RecordEncryptInfo(); isAdd = true; } temp.UserID = CurrentApp.Session.UserID; temp.ServerAddress = strAddress; temp.StartTime = DateTime.Now.ToUniversalTime(); temp.EndTime = expireTime; temp.Password = strPassword; temp.IsRemember = isRemember; if (isRemember) { if (isAdd) { ListRecordEncryptInfos.Add(temp); } SaveRecordEncryptConfig(); } OnPasswordManagerEventEvent(PasswordManagerEventCode.PASS_SETTED, temp); var parent = Parent as PopupPanel; if (parent != null) { parent.IsOpen = false; } } } catch (Exception ex) { ShowException(ex.Message); } }
private void SetDecryptPassword() { try { if (RecordInfoItem == null) { return; } if (RecordInfoItem.EncryptFlag != "2") { return; } if (ListEncryptInfo == null) { return; } string strServerAddress = RecordInfoItem.VoiceIP; var encryptInfo = ListEncryptInfo.FirstOrDefault(s => s.UserID == CurrentApp.Session.UserID && s.ServerAddress == strServerAddress); if (encryptInfo == null) { encryptInfo = new RecordEncryptInfo(); encryptInfo.UserID = CurrentApp.Session.UserID; encryptInfo.ServerAddress = strServerAddress; encryptInfo.StartTime = DateTime.Now.ToUniversalTime(); encryptInfo.EndTime = DateTime.Now.AddDays(1).ToUniversalTime(); encryptInfo.IsRemember = false; ListEncryptInfo.Add(encryptInfo); } UCPasswordManagement uc = new UCPasswordManagement(); uc.PasswordManagerEvent += PasswordManagement_PasswordManagementEvent; uc.CurrentApp = CurrentApp; uc.ParentPage = ParentPage; uc.ListUserSettingInfos = ListUserSettingInfos; uc.RecordInfoItem = RecordInfoItem; uc.ListRecordEncryptInfos = ListEncryptInfo; if (ParentPage != null) { ParentPage.OpenPasswordPanel(uc); } } catch (Exception ex) { ShowException(ex.Message); } }
public OperationReturn GetRealPassword(RecordEncryptInfo encryptInfo) { OperationReturn optReturn = new OperationReturn(); optReturn.Result = true; optReturn.Code = 0; try { if (Session == null) { optReturn.Result = false; optReturn.Code = RET_NO_SESSION; optReturn.Message = string.Format("SessionInfo is null"); return(optReturn); } if (mRecordInfo == null) { optReturn.Result = false; optReturn.Code = RET_NO_RECORDINFO; optReturn.Message = string.Format("RecordInfo is null"); return(optReturn); } if (encryptInfo == null) { optReturn.Result = false; optReturn.Code = Defines.RET_OBJECT_NULL; optReturn.Message = string.Format("EncryptInfo is null"); return(optReturn); } //新密钥解老密钥 List <string> listArgs = new List <string>(); listArgs.Add("1"); //对象类型:1 listArgs.Add(encryptInfo.ServerAddress); //加密对象:录音服务器的IP地址或机器名 listArgs.Add(mRecordInfo.SerialID.ToString()); //录音流水号:C002 listArgs.Add(mRecordInfo.StartRecordTime.ToString("yyyy-MM-dd HH:mm:ss")); //录音开始时间 listArgs.Add(encryptInfo.EndTime.ToString("yyyy-MM-dd HH:mm:ss")); //密钥截至时间 listArgs.Add(encryptInfo.Password); //新密钥 listArgs.Add(string.Empty); //无 Service06ServerInfo server = new Service06ServerInfo(); server.Host = Session.AppServerInfo.Address; server.Port = Session.AppServerInfo.SupportHttps ? Session.AppServerInfo.Port - 7 : Session.AppServerInfo.Port - 6; OnDebug("GetRealPass", string.Format("Getting real password.\t{0}", encryptInfo.ServerAddress)); optReturn = Service06Helper.DoOperation(server, Service06Command.GET_PASS, listArgs); if (!optReturn.Result) { return(optReturn); } string strReturn = optReturn.Data.ToString(); string[] listReturn = strReturn.Split(new[] { ConstValue.SPLITER_CHAR }, StringSplitOptions.None); if (listReturn.Length <= 0) { optReturn.Result = false; optReturn.Code = Defines.RET_PARAM_INVALID; optReturn.Message = string.Format("Return value length invalid"); return(optReturn); } string strError = listReturn[0]; strError = ((S3106App)CurrentApp).DecryptString(strError); if (strError.StartsWith("ERROR")) { optReturn.Result = false; optReturn.Code = RET_GET_REAL_PASSWORD_FAIL; optReturn.Message = string.Format("Get real password fail.\t{0}", strError); return(optReturn); } string strKey1B = string.Empty; if (listReturn.Length > 2) { strKey1B = listReturn[2]; } strKey1B = ((S3106App)CurrentApp).DecryptString(strKey1B); encryptInfo.RealPassword = strKey1B; OnDebug("GetRealPass", string.Format("Get real password end.\t{0}", ((S3106App)CurrentApp).EncryptString(strKey1B))); } catch (Exception ex) { optReturn.Result = false; optReturn.Code = Defines.RET_FAIL; optReturn.Message = ex.Message; optReturn.Exception = ex; } return(optReturn); }
private void GetRealPassword(RecordEncryptInfo info) { try { if (RecordInfoItem == null) { return; } RecordInfo recordInfo = RecordInfoItem.RecordInfo; if (recordInfo == null) { return; } recordInfo.RecordReference = GetRecordInfoByRef(recordInfo.SerialID.ToString()); if (string.IsNullOrWhiteSpace(recordInfo.RecordReference)) { return; } if (ParentPage1 != null) { ParentPage1.SetBusy(true); } if (ParentPage2 != null) { ParentPage2.SetBusy(true); } bool isSuccess = false; mWorker = new BackgroundWorker(); mWorker.WorkerReportsProgress = true; mWorker.WorkerSupportsCancellation = true; mWorker.DoWork += (s, de) => { try { OperationReturn optReturn; RecordOperator recordOperator = new RecordOperator(recordInfo); recordOperator.Debug += (cat, msg) => CurrentApp.WriteLog(cat, msg); recordOperator.Session = CurrentApp.Session; recordOperator.ListSftpServers = ListSftpServers; recordOperator.ListDownloadParams = ListDownloadParams; recordOperator.ListEncryptInfo = ListEncryptInfo; recordOperator.Service03Helper = Service03Helper; optReturn = recordOperator.GetRealPassword(info); if (!optReturn.Result) { workMsg = optReturn.Code; CurrentApp.WriteLog("GetRealPass", string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message)); mWorker.ReportProgress(0); mWorker.Dispose(); return; } isSuccess = true; } catch (Exception ex) { CurrentApp.WriteLog("GetRealPass", string.Format("Fail.\t{0}", ex.Message)); } }; mWorker.ProgressChanged += (s, pe) => { ShowRecordOperatorMessage(workMsg); }; mWorker.RunWorkerCompleted += (s, re) => { mWorker.Dispose(); if (ParentPage1 != null) { ParentPage1.SetBusy(false); } if (ParentPage2 != null) { ParentPage2.SetBusy(false); } if (!isSuccess) { CurrentApp.WriteLog("GetRealPass", string.Format("Get real password fail.")); return; } PlayRecord(); }; mWorker.RunWorkerAsync(); } catch (Exception ex) { ShowException(ex.Message); } }
private void GetRealPassword(RecordEncryptInfo info) { try { if (RecordInfoItem == null) { return; } RecordInfo recordInfo = RecordInfoItem.RecordInfo; if (recordInfo == null) { return; } if (ParentPage != null) { ParentPage.SetBusy(true, string.Empty); } bool isSuccess = false; mWorker = new BackgroundWorker(); mWorker.DoWork += (s, de) => { try { OperationReturn optReturn; RecordOperator recordOperator = new RecordOperator(recordInfo); recordOperator.Debug += (cat, msg) => CurrentApp.WriteLog(cat, msg); recordOperator.Session = CurrentApp.Session; recordOperator.ListSftpServers = ListSftpServers; recordOperator.ListDownloadParams = ListDownloadParams; recordOperator.ListEncryptInfo = ListEncryptInfo; recordOperator.Service03Helper = Service03Helper; optReturn = recordOperator.GetRealPassword(info); if (!optReturn.Result) { ShowRecordOperatorMessage(optReturn); CurrentApp.WriteLog("GetRealPass", string.Format("Fail.\t{0}\t{1}", optReturn.Code, optReturn.Message)); return; } isSuccess = true; } catch (Exception ex) { CurrentApp.WriteLog("GetRealPass", string.Format("Fail.\t{0}", ex.Message)); } }; mWorker.RunWorkerCompleted += (s, re) => { mWorker.Dispose(); if (ParentPage != null) { ParentPage.SetBusy(false, string.Empty); } if (!isSuccess) { CurrentApp.WriteLog("GetRealPass", string.Format("Get real password fail.")); return; } PlayRecord(); }; mWorker.RunWorkerAsync(); } catch (Exception ex) { ShowException(ex.Message); } }