public ShareCommon(IResolver resolver) { this.pbData = resolver.GetInstanceOf <IPBData>(); this.pbWebApi = resolver.GetInstanceOf <IPBWebAPI>(); inAppAnalyitics = resolver.GetInstanceOf <IInAppAnalytics>(); this.resolver = resolver; }
public List<SecureItemViewModel> GetViewItems( bool recommendedsiteFlag) { Stopwatch watch = new Stopwatch(); watch.Start(); IPBData pbData = resolver.GetInstanceOf<IPBData>(); IPBWebAPI pbWebApi = resolver.GetInstanceOf<IPBWebAPI>(); List<SecureItem> sites; List<SecureItemViewModel> passVaultItems = new List<SecureItemViewModel>(); try { <<<<<<< HEAD //if (recommendedsiteFlag) //{ // var recommendedSites = pbData.GetRecommendedSites(); // if(recommendedSites != null) // { // foreach (var site in recommendedSites) // { // passVaultItems.Add(new DefaultView() { Id = site.Id, Image = _common.GetImagePathForSite(site.UUID), Name = site.FriendlyName, Category = site.Folder != null ? site.Folder : "Other", Favorite = false, Username = null, LastAccess = null }); ======= if (recommendedsiteFlag) { var recommendedSites = pbData.GetRecommendedSites(); if(recommendedSites != null) { foreach (var site in recommendedSites) { passVaultItems.Add(new DefaultView() { Id = site.Id, Image = Common.GetImagePathForSite(site.UUID), Name = site.FriendlyName, Category = site.Folder != null ? site.Folder.Name : "Other", Favorite = false, Username = null, LastAccess = null });
public SecureBrowserContentPanel(IResolver resolver) { InitializeComponent(); this.DataContext = new SecureBrowserViewModel(resolver); this.resolver = resolver; webApi = resolver.GetInstanceOf <IPBWebAPI>(); }
/// <summary> /// Initialize command with function /// </summary> public LoginViewModel(IResolver resolver, Grid advertisingGrid) { //generateKeysStep.ExecuteAsync(); this.resolver = resolver; this.pbData = resolver.GetInstanceOf <IPBData>(); this.webApi = resolver.GetInstanceOf <IPBWebAPI>(); SubmitCommand = new AsyncRelayCommand <LoadingWindow>(Submit); SubmitCodeVerificationCommand = new RelayCommand(SubmitCodeVerification); CloseCommand = new RelayCommand(CloseWindow); CancelCommand = new RelayCommand(CancelVerification); ElementTextChangedCommand = new RelayCommand(ElementTextChanged); CodeTextChangedCommand = new RelayCommand(CodeTextChanged); //PasswordGotFocusCommand = new RelayCommand(PasswordGotFocus); CodeVerificationGotFocusCommand = new RelayCommand(CodeVerificationGotFocus); ForgotLinkCommand = new RelayCommand(ForgotLinkClick); LostPhoneLinkCommand = new RelayCommand(LostPhoneLinkClick); CloseForgotMasterPasswordDialogCommand = new RelayCommand(CloseForgotMasterPasswordDialogClick); //PasswordChanged = new RelayCommand(PasswordChangedEvent); PasswordFieldGotFocusCommand = new RelayCommand(UserPasswordGotFocus); PasswordFieldLostFocusCommand = new RelayCommand(UserPasswordLostFocus); //ApplyDefaultStyle(passwordBox, DefaultProperties.MasterPasswordStyle, DefaultProperties.ToggleEyeBigIconStyle); this.pbData.OnUserLoggedIn += pbData_OnUserLoggedIn; this.advertisingGrid = advertisingGrid; PrefillUserEmail(); ForgotMasterPasswordModel = new ForgotMasterPasswordViewModel(resolver, this); PlaceHolderText = (string)System.Windows.Application.Current.FindResource("MasterPassword"); OpenMainUI = true; }
public EnterPromoCodeControlDialogViewModel(IResolver resolver) { this.resolver = resolver; pbData = resolver.GetInstanceOf <IPBData>(); webAPI = resolver.GetInstanceOf <IPBWebAPI>(); EnterPromoCodeScreenVisibility = true; InitializeCommands(); }
public LoginLanguage([Import(typeof(IResolver))] IResolver resolver) { this.resolver = resolver; this.pbData = resolver.GetInstanceOf <IPBData>(); this.webAPI = resolver.GetInstanceOf <IPBWebAPI>(); InitializeComponent(); DataContext = new LoginLanguageViewModel(SelectLanguageComboBox, this.resolver); }
public LicenseActivationBusinessLayer(IResolver resolver) { if (resolver != null) { webAPI = resolver.GetInstanceOf <IPBWebAPI>(); pbData = resolver.GetInstanceOf <IPBData>(); } }
// private string email = null; public SetupCompleteViewModel(IResolver resolver) { this.resolver = resolver; this.pbData = resolver.GetInstanceOf <IPBData>(); this.webApi = resolver.GetInstanceOf <IPBWebAPI>(); SetPinButtonCommand = new AsyncRelayCommand <LoadingWindow>(SetPinButtonClick, completed: (obj) => SubmitCompleted(obj)); CloseCommand = new RelayCommand(CloseWindow); successVerification = false; CreateWindows(); }
public CreateAccountLayer(IResolver resolver, Action <MarketingActionType> logStep) { this.resolver = resolver; this.logStep = logStep; this.pbData = resolver.GetInstanceOf <IPBData>(); this.webApi = resolver.GetInstanceOf <IPBWebAPI>(); inAppAnalyitics = resolver.GetInstanceOf <IInAppAnalytics>(); generateKeysStep = new GenerateKeysStep().Execute(); }
public PersonalInfoSetupViewModel(IResolver resolver) { this.resolver = resolver; this.pbData = resolver.GetInstanceOf <IPBData>(); this.api = resolver.GetInstanceOf <IPBWebAPI>(); this.mixpanelLogger = new PersonalInfoSetupAnalyticsLogger(resolver.GetInstanceOf <IInAppAnalytics>()); this.CloseCommand = new RelayCommand(CloseCommandExecute); this.ContinueCommand = new RelayCommand(ContinueCommandExecute); email = pbData.ActiveUser; }
public PBApp(IResolver moduleLoader, string[] args) { this.args = args == null ? new string[0] : args; clipboardTimer.Elapsed += clipboardTimer_Elapsed; this.moduleLoader = moduleLoader; pbData = moduleLoader.GetInstanceOf <IPBData>(); // pbData.OnProfileUnlock += pbData_OnProfileUnlock; pbData.OnUserLoggedIn += pbData_OnUserLoggedIn; pbData.OnCloseProfile += pbData_OnCloseProfile; currentLanguage = pbData.GetConfigurationValueByAccountAndKey(DefaultProperties.Configuration_DefaultAccount, "last_selected_lang"); if (string.IsNullOrWhiteSpace(currentLanguage)) { currentLanguage = "en"; } sync = moduleLoader.GetInstanceOf <IPBSync>(); sync.OnGetMergePassword(GetMergePassword); webAPI = moduleLoader.GetInstanceOf <IPBWebAPI>(); BrowserMonitor = moduleLoader.GetInstanceOf <IBrowserMonitor>(); updater = moduleLoader.GetInstanceOf <IAppUpdater>(); updater.UpdatedVersionDetected += UpdatedVersionDetected; categories = new Dictionary <string, string>(); resourcePaths = new Dictionary <string, Uri>(); resourcePaths.Add("Fonts", new Uri("/font;component/FontProperty.xaml", UriKind.RelativeOrAbsolute)); resourcePaths.Add("Themes", new Uri("/theme;component/Theme.xaml", UriKind.RelativeOrAbsolute)); resourcePaths.Add("Images", new Uri("/image;component/ImageResource.xaml", UriKind.RelativeOrAbsolute)); resourcePaths.Add("LocalStyles1", new Uri("pack://application:,,,/PBAppUI;component/resources/dictionary/styles/passwordbossresource.xaml", UriKind.RelativeOrAbsolute)); resourcePaths.Add("LocalStyles2", new Uri("pack://application:,,,/PBAppUI;component/resources/dictionary/styles/primarydashboardresource.xaml", UriKind.RelativeOrAbsolute)); resourcePaths.Add("LocalStyles3", new Uri("pack://application:,,,/PBAppUI;component/resources/dictionary/styles/AddControlStyles.xaml", UriKind.RelativeOrAbsolute)); foreach (var uri in resourcePaths.Values) { LoadAndMerge(uri); } SetLanguage(currentLanguage); SystemTray.SetResolver(moduleLoader); sysTray = new SystemTray(); sysTray.InitializeTrayProperties(); SystemTray.OnBeforeShutDownHandler += SystemTray_OnBeforeShutDownHandler; LoginWindow loginWindow = new LoginWindow(moduleLoader); Navigator.NavigationService = loginWindow.MainFrame.NavigationService; if (!pbData.ControllerIsUpToDate()) { pbData_OnInvalidVersion(DBFileType.Controller); } else { pbData.OnInvalidVersion += pbData_OnInvalidVersion; } Application.Current.Dispatcher.UnhandledException += onDispatcherUnhandledException; systemIdlePoller = new SystemIdlePoller(); }
public void ShowTwoStepBackupSecurityCodeScreen(object obj) { HideAllStepScreens(); TwoStepBackupSecurityCodeScreenVisibility = true; if (!string.IsNullOrWhiteSpace(MobilePhone)) { IPBWebAPI api = this.AccountSettingsViewModel.resolver.GetInstanceOf <IPBWebAPI>(); var pbData = this.AccountSettingsViewModel.resolver.GetInstanceOf <IPBData>(); var resp = api.UpdateAccount(pbData.ActiveUser + "|" + pbData.DeviceUUID, new PasswordBoss.WEBApiJSON.AccountRequest { backup_phone = MobilePhone }); } }
public ForgotMasterPasswordViewModel(IResolver resolver, LoginViewModel loginViewModel) { _resolver = resolver; pbData = resolver.GetInstanceOf <IPBData>(); webAPI = resolver.GetInstanceOf <IPBWebAPI>(); _loginViewModel = loginViewModel; OpenSupportPageCommand = new RelayCommand(OpenSupport); OpenGetCodeCommand = new RelayCommand(OpenGetCode); ShowInitialScreenCommand = new RelayCommand(ShowFirstScreenClick); ShowSecondScreenCommand = new RelayCommand(ShowSecondScreenClick); ShowInitialScreenSecondPartCommand = new RelayCommand(ShowInitialScreenSecondPartClick); ShowThirdScreenCommand = new AsyncRelayCommand <LoadingWindow>(ShowThirdScreenClick); }
public bool ConfirmCode() { bool isConfirmed = false; var pbData = this.AccountSettingsViewModel.resolver.GetInstanceOf <IPBData>(); IPBWebAPI api = this.AccountSettingsViewModel.resolver.GetInstanceOf <IPBWebAPI>(); var twoStepResp = api.ConfirmAccount2StepSecretKeyCode(pbData.ActiveUser + "|" + pbData.DeviceUUID, new PasswordBoss.WEBApiJSON.SecretKeyConfirmationRequest { code = ConfirmationCode }); string twoStepAuthResp = twoStepResp.auth; bool.TryParse(twoStepAuthResp, out isConfirmed); return(isConfirmed); }
public CreateAccountViewModel(IResolver resolver, string email) : base(resolver) { this.UserEmailId = email; this.resolver = resolver; this.pbData = resolver.GetInstanceOf <IPBData>(); this.webApi = resolver.GetInstanceOf <IPBWebAPI>(); Task.Factory.StartNew(() => { this.webApi.GetEndpoints(); }); // logic for account creation with provided callbacks for GUI calls this.createAccountLayer = new CreateAccountLayer(resolver, LogStep); this.createAccountLayer.BackToLoginScreenRequired += (o, e) => OnBackToLoginScreen(); this.createAccountLayer.MessageRaised += (o, e) => OnMessageRaised(e.Message); this.createAccountLayer.VerificationRequired += (o, e) => OnVerificationRequired(); this.createAccountLayer.SetupCompleteRequired += (o, e) => OnSetupCompleteViewRequired(); this._userPasswordWrapper = new PasswordBoxViewModel(this, "UserPasswordWrapper"); this._userConfirmPasswordWrapper = new PasswordBoxViewModel(this, "UserConfirmPasswordWrapper"); this.CloseCommand = new RelayCommand(CloseCommandExecute); this.EmailTextChangedCommand = new RelayCommand(EmailTextChangedExecute); this.PrivacyPolicyCommand = new RelayCommand((x) => OpenUri(PrivacyPolicyLink)); this.TermsOfServiceCommand = new RelayCommand((x) => OpenUri(TermsOfUseLink)); this.PasswordFieldGotFocusCommand = new RelayCommand(UserPasswordGotFocus); this.LoginExistingButtonCommand = new RelayCommand(LoginExistingCommand); this.CreateNewButtonCommand = new RelayCommand(CreateNewButtonCommandExecute); // validator helper for validation properties this.validator = new Validator <CreateAccountViewModel>(this); this.validator.AddProperty(ValidationProperties.IsValidEmail, (v) => _commonObj.IsEmailValid(v.UserEmailId)); this.validator.AddProperty(ValidationProperties.IsPasswordsEqual, (v) => { return(v.UserPasswordWrapper.Password == v.UserConfirmPasswordWrapper.Password); }); this.validator.AddProperty(ValidationProperties.IsValidMasterPassword, (v) => v.UserPasswordWrapper.IsPasswordValid); this.validator.AddProperty(ValidationProperties.IsValidConfirmPassword, (v) => v.UserConfirmPasswordWrapper.IsPasswordValid); this.validator.AddProperty(ValidationProperties.IsEmailHasValue, (v) => !string.IsNullOrEmpty(v.UserEmailId)); this.validator.AddProperty(ValidationProperties.IsMasterPasswordHasValue, (v) => !string.IsNullOrEmpty(v.UserPasswordWrapper.Password)); this.validator.AddProperty(ValidationProperties.IsConfirmPasswordHasValue, (v) => !string.IsNullOrEmpty(v.UserConfirmPasswordWrapper.Password)); this.validator.SetProperty(ValidationProperties.IsValidEmail, true); this.validator.SetProperty(ValidationProperties.IsPasswordsEqual, true); }
public VerificationRequiredViewModel(IResolver resolver, string email, string password) { this.email = email; this.mastePassword = password; this.resolver = resolver; this.pbData = resolver.GetInstanceOf <IPBData>(); this.webAPI = resolver.GetInstanceOf <IPBWebAPI>(); SubmitButtonCommand = new AsyncRelayCommand <LoadingWindow>(SubmitButtonClick, completed: (obj) => SubmitCompleted(obj)); ElementTextChangedCommand = new RelayCommand(ElementTextChanged); CloseCommand = new RelayCommand(CloseWindow); TryAgainButtonCommand = new RelayCommand(TryAgainCommand); ResendButtonCommand = new RelayCommand(ResendCommand); CancelButtonCommand = new RelayCommand(CancelCommand); MessageBoxInfoConfirmButtonCommand = new RelayCommand(MessageBoxInfoConfirmCommand); successVerification = false; }
private bool TryToRegisterDevice(string email, out string uuid) { IPBWebAPI webAPI = resolver.GetInstanceOf <IPBWebAPI>(); uuid = ""; //try to register device logger.Debug("register device request"); dynamic deviceRegistrationResponse = webAPI.RegisterDevice(new WEBApiJSON.DeviceRegistrationRequest() { installation = pbData.InstallationUUID, nickname = Environment.MachineName, software_version = Assembly.GetExecutingAssembly().GetName().Version.ToString() }, email); if (deviceRegistrationResponse == null) { OnMessageRaised("Error in device registration"); return(false); } else { try { uuid = deviceRegistrationResponse.devices[0].uuid.ToString(); } catch { uuid = ""; } // if api returned verification request for this device - if (IsError(deviceRegistrationResponse, deviceRegistrationResponse_UnverifiedDevice)) { //send verification code for new device dynamic verificationRequestResponse = webAPI.RequestVerificationCode(email); if (VerificationRequired != null) { VerificationRequired(this, EventArgs.Empty); } return(false); } } return(true); }
public dynamic LoadSecretKey() { dynamic twoStepResp = null; lock (SecretKeyLoadedLock) { //if(!SecretKeyLoaded) //{ var pbData = this.AccountSettingsViewModel.resolver.GetInstanceOf <IPBData>(); IPBWebAPI api = this.AccountSettingsViewModel.resolver.GetInstanceOf <IPBWebAPI>(); twoStepResp = api.GetAccount2StepInfo(pbData.ActiveUser + "|" + pbData.DeviceUUID, new PasswordBoss.WEBApiJSON.AccountRequest { storage_region = this.AccountSettingsViewModel.CurrentStorageRegionUUID, email = pbData.ActiveUser, installation = pbData.InstallationUUID, synchronize = this.AccountSettingsViewModel.EnableStorageCloudBackup }); //} } return(twoStepResp); }
public ConfirmMasterPasswordViewModel(string email, string password, IResolver resolver) { this.email = email; this.masterPassword = password; this.resolver = resolver; this.pbData = resolver.GetInstanceOf <IPBData>(); this.webApi = resolver.GetInstanceOf <IPBWebAPI>(); inAppAnalyitics = resolver.GetInstanceOf <IInAppAnalytics>(); //PasswordChangedCommand = new RelayCommand(PasswordChanged); NextButtonCommand = new AsyncRelayCommand <LoadingWindow>(NextButtonClick); CloseCommand = new RelayCommand(CloseWindow); PasswordFieldGotFocusCommand = new RelayCommand(UserPasswordGotFocus); PasswordFieldLostFocusCommand = new RelayCommand(UserPasswordLostFocus); GoBackCommand = new RelayCommand(GoBackClick); PlaceHolderText = (string)System.Windows.Application.Current.FindResource("ReEnterMassterPass"); //PasswordGotFocusCommand = new RelayCommand(PasswordGotFocus); //ApplyDefaultStyle(passwordBox, DefaultProperties.ConfirmMasterPasswordStyle, DefaultProperties.ToggleEyeBigIconStyle); }
/// <summary> /// Fill combobox item /// </summary> /// <param name="loginCombobox"></param> private void FillComboboxItem(ComboBox loginCombobox) { IPBWebAPI pbWebAPI = resolver.GetInstanceOf <IPBWebAPI>(); var langs = pbData.GetLanguages(); if (langs != null && langs.Count > 0) { Languages = new Dictionary <string, string>(); foreach (var lan in langs) { Languages.Add(lan.Code, lan.TranslationName); } } else { try { dynamic languageList = pbWebAPI.GetLanguages(); Languages = new Dictionary <string, string>(); foreach (var lan in languageList.languages) { Languages.Add(lan.code.ToString(), lan.translated_name.ToString()); } } catch { } } string localUserLanguage = Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName; if (localUserLanguage != null) { SelectedLanguage = Languages.FirstOrDefault(x => x.Key.ToLower() == localUserLanguage.ToLower()); } if (SelectedLanguage.Key == null || SelectedLanguage.Value == null) { SelectedLanguage = Languages.FirstOrDefault(x => x.Key.ToLower() == "en"); } }
public List <SecureItemViewModel> GetViewItems(bool recommendedsiteFlag) { Stopwatch watch = new Stopwatch(); watch.Start(); IPBData pbData = resolver.GetInstanceOf <IPBData>(); IPBWebAPI pbWebApi = resolver.GetInstanceOf <IPBWebAPI>(); List <SecureItem> sites; List <SecureItemViewModel> passVaultItems = new List <SecureItemViewModel>(); try { if ((sites = pbData.GetSecureItemsByItemType(SecureItemType)) != null) { foreach (var site in sites) { if (site.Data == null) { logger.Error("GetSortedViewItems: site data is null"); continue; } var item = SubItemsComponentTree.FirstOrDefault(x => x.ItemType == site.Type); if (item != null) { var secureItemVM = Activator.CreateInstance(item.CreateItemType, site, item.BackgoundColor, item.Icon) as SecureItemViewModel; passVaultItems.Add(secureItemVM); } } } } catch (Exception ex) { MessageBox.Show((string)System.Windows.Application.Current.FindResource("GeneralErrorText")); logger.Error(ex.Message); } watch.Stop(); logger.Info("SecureItemsHolderViewModel.GetViewItems> items got: {0}, executed in: {1} ms", passVaultItems.Count, watch.ElapsedMilliseconds); return(passVaultItems); }
public EnterLicenseKeyViewModel(IResolver resolver, LicenseActivationTypeBase licenseMessages, LicenseActivationBusinessLayer licenseActivationBusinessLayer) : base(resolver) { if (resolver == null) { throw new ArgumentException("resolver"); } this.InstallType = licenseMessages.InstallType; this.resolver = resolver; this.webAPI = resolver.GetInstanceOf <IPBWebAPI>(); this.data = resolver.GetInstanceOf <IPBData>(); this.owner = ((PBApp)Application.Current).FindWindow <LoginWindow>(); this.LicenseMessages = licenseMessages; this.ActivateCommand = CreateActivateCommand(); this.BuyNowCommand = new RelayCommand(BuyNowCommandExecute); this.ContinueCommand = new RelayCommand(ContinueCommandExecute); this.ActivationSuccessDialogOk = new RelayCommand(ActivationSuccessDialogOkExecute); this.fadeTimerHelper = new ViewFadeTimerHelper(() => IsModalViewShown = true, () => IsModalViewShown = false, 3000); this.licenseActivationBusinessLayer = licenseActivationBusinessLayer; this.owner.Topmost = false; }
public void CloseTwoStepVerificationDialog(object obj) { if (!TwoStepCompletedScreenVisibility) { AccountSettingsViewModel.TwoStepVerification = false; } else { AccountSettingsViewModel.TwoStepVerification = true; } if (AccountSettingsViewModel.TwoStepVerification) { var pbData = this.AccountSettingsViewModel.resolver.GetInstanceOf <IPBData>(); IPBWebAPI api = this.AccountSettingsViewModel.resolver.GetInstanceOf <IPBWebAPI>(); var resp = api.UpdateAccount(pbData.ActiveUser + "|" + pbData.DeviceUUID, new PasswordBoss.WEBApiJSON.AccountRequest { multi_factor_authentication = AccountSettingsViewModel.TwoStepVerification }); if (resp == null) { throw new Exception("API call failed"); } pbData.UpdateMultiFactorAuthentication(AccountSettingsViewModel.TwoStepVerification); var inAppAnalyitics = this.AccountSettingsViewModel.resolver.GetInstanceOf <IInAppAnalytics>(); if (inAppAnalyitics != null) { inAppAnalyitics.Get <Events.TwoFactorVerificationEvent, AOItemType>().Log(AOItemType.Enabled); } } HideAllStepScreens(); TwoStepVerificationUserControlVisibility = false; AccountSettingsViewModel.Content.Close(); }
private bool TryToGetDeviceID(string userEmailId, string masterPassword, bool profileExists, bool hasDeviceID) { logger.Debug("TryToGetDeviceId started. profileExists - {0}, hasDeviceId - {1}", profileExists, hasDeviceID); var canProceed = !profileExists || !hasDeviceID; if (!canProceed) { return(false); // refactoring complexity of conditions. } if (!webApi.HasInetConn) { logger.Error("TryToGetDeviceID - No internet connection - exit"); return(false); } IPBWebAPI webAPI = resolver.GetInstanceOf <IPBWebAPI>(); // try to register device dynamic deviceRegistrationResponse = webAPI.RegisterDevice( new WEBApiJSON.DeviceRegistrationRequest() { installation = pbData.InstallationUUID, nickname = System.Windows.Forms.SystemInformation.ComputerName, software_version = Assembly.GetAssembly(typeof(PasswordBoss.PBApp)).GetName().Version.ToString() }, userEmailId); if (deviceRegistrationResponse == null) { logger.Error("deviceRegistrationResponse is empty"); //MessageBox.Show("Error in device registration"); Application.Current.Dispatcher.Invoke((Action) delegate { string _message = System.Windows.Application.Current.FindResource("ErrorInDeviceRegistrationLoginMessage") as string; CustomInformationMessageBoxWindow c = new CustomInformationMessageBoxWindow(_message); c.ShowDialog(); }); //return false; return(true); } else { if (deviceRegistrationResponse.error != null) { logger.Debug("DeviceRegistrationResponse.error = {0}", deviceRegistrationResponse.error); //MessageBox.Show(deviceRegistrationResponse.error.message.ToString()); if (deviceRegistrationResponse.error.code.ToString() == "412") { //Before information label on login //var createAccountScreen = new CreateAccount(resolver, userEmailId); //Navigator.NavigationService.Navigate(createAccountScreen); Application.Current.Dispatcher.Invoke((Action) delegate { ErrorMessage = (string)System.Windows.Application.Current.FindResource("AccountDoesNotExists"); }); // createAccountScreen.EmailTextBox.Text = UserEmail; // resolver.GetInstanceOf<CreateAccount>(); } else if (deviceRegistrationResponse.error.code.ToString() == "403") { logger.Debug("Calling requestVerificationCode"); webAPI.RequestVerificationCode(userEmailId); logger.Debug("Called requestVerificationCode"); Application.Current.Dispatcher.Invoke((Action) delegate { var verificationScreen = new VerificationRequired(resolver, userEmailId, masterPassword); // resolver.GetInstanceOf<VerificationRequired>(); Navigator.NavigationService.Navigate(verificationScreen); }); } return(true); } else { logger.Error("deviceRegistrationResponse didnt return error code"); Application.Current.Dispatcher.Invoke((Action) delegate { string _message = System.Windows.Application.Current.FindResource("ServerErrorLoginMessage") as string; CustomInformationMessageBoxWindow c = new CustomInformationMessageBoxWindow(_message); c.ShowDialog(); }); } return(true); } //pbData.DeviceUUID = deviceRegistrationResponse.devices[0].uuid.ToString(); //todo write device uuid into device table //ServerErrorLoginMessage //MessageBox.Show("Local profile does not exist. Create new account or register device with existing account!"); return(true); }
internal static void CheckRSA(GenerateKeysStepResult generateKeysStepResult, IPBData db, IPBWebAPI web) { // RIO - Hot path if (db == null || web == null) { return; } UserInfo ui = db.GetUserInfo(db.ActiveUser); if (ui == null) { return; } bool createKeys = true; if (ui.RSAPrivateKey != null) { using (var rsa = RSAKeyManagement.ImportPEMToRSACSP(ui.RSAPrivateKey)) { createKeys = !(rsa != null && rsa.KeySize == 2048); } } if (createKeys) { Func <dynamic, string> extractPublicKeyFromAccountJSON = (dynamic json) => { if (json == null) { logger.Error("CheckRSA: json is null"); } else if (json.error != null) { logger.Error("CheckRSA: {0}", json.error); } else if (json.ToString().Contains("\"public_key\"")) { return((string)json.account.public_key); } return(null); }; //generateKeysStep.Wait(); byte[] publicKeyPem = generateKeysStepResult.PublicKey; ProtectedDataBlock privateKeyPem = generateKeysStepResult.PrivateKey; string public_keyB64 = Convert.ToBase64String(publicKeyPem); string pub_key = extractPublicKeyFromAccountJSON(web.GetAccount(db.ActiveUser + "|" + db.DeviceUUID, new PasswordBoss.WEBApiJSON.AccountRequest { })); if (!string.IsNullOrWhiteSpace(pub_key)) { using (RSACryptoServiceProvider rsaPub = RSAKeyManagement.ImportPEMToRSACSP(Encoding.UTF8.GetString(Convert.FromBase64String(pub_key)))) { if (rsaPub != null && rsaPub.KeySize == 2048) { return; } } } dynamic accountResponse = web.UpdateAccount(db.ActiveUser + "|" + db.DeviceUUID, new PasswordBoss.WEBApiJSON.AccountRequest { public_key = public_keyB64 }); if (accountResponse == null) { logger.Error("CheckRSA: UpdateAccount failed"); } else if (accountResponse.error != null) { logger.Error("CheckRSA: UpdateAccount - {0}", accountResponse.error); } else { pub_key = extractPublicKeyFromAccountJSON(accountResponse); if (pub_key != null && Encoding.UTF8.GetString(Convert.FromBase64String(pub_key)) == Encoding.UTF8.GetString(publicKeyPem)) { ui.RSAPrivateKey = privateKeyPem; ui.PublicKey = publicKeyPem; if (!db.UpdateUserKeys(ui)) { logger.Error("CheckRSA: UpdateUserKeys failed"); } } } } }
private bool TryToShowMainWindow(bool isAuthenticated) { logger.Debug("TryToShowMainWindow called; isAuthenticated - {0}", isAuthenticated); if (!isAuthenticated) { logger.Error("Cant show main window - not authenticated"); return(false); } logger.Debug("Getting device"); Device device = pbData.GetDevice(pbData.InstallationUUID); if (device != null) { pbData.DeviceUUID = device.UUID; logger.Debug("found device - {0}", pbData.DeviceUUID); } else { logger.Error("Cant find device"); Application.Current.Dispatcher.Invoke((Action) delegate { string _message = System.Windows.Application.Current.FindResource("ProblemReadingDeviceIdLoginMessage") as string; CustomInformationMessageBoxWindow c = new CustomInformationMessageBoxWindow(_message); c.ShowDialog(); }); return(true); } IPBWebAPI pbWebAPI = resolver.GetInstanceOf <IPBWebAPI>(); logger.Debug("Get countries"); if (pbData.GetCountries().Count == 0) { logger.Debug("Get countries - request from web API"); dynamic countries = pbWebAPI.RequestCountry(String.Format("{0}|{1}", pbData.ActiveUser, pbData.DeviceUUID)); pbData.AddCounties(countries); } logger.Debug("GetConfigurationByAccountAndKey {0} < {1}", UserEmail, DefaultProperties.Configuration_Key_RememberEmail); var rememberLoginEmail = pbData.GetConfigurationByAccountAndKey(UserEmail, DefaultProperties.Configuration_Key_RememberEmail); if (rememberLoginEmail == null) { logger.Debug("GetConfigurationByAccountAndKey failed, adding configuration"); rememberLoginEmail = new Configuration() { AccountEmail = UserEmail, Key = DefaultProperties.Configuration_Key_RememberEmail, Value = true.ToString() }; pbData.AddOrUpdateConfiguration(rememberLoginEmail); logger.Debug("Condifuration added"); } bool isEnabledRememberLoginEmail = false; logger.Debug("TRying to parse rememberLoginEmail"); if (bool.TryParse(rememberLoginEmail.Value, out isEnabledRememberLoginEmail)) { logger.Debug("rememberLoginEmail parsed - {0}", isEnabledRememberLoginEmail); if (isEnabledRememberLoginEmail) { var lastLogin = new Configuration() { AccountEmail = DefaultProperties.Configuration_DefaultAccount, Key = DefaultProperties.Configuration_Key_LastLoginEmail, Value = UserEmail }; pbData.AddOrUpdateConfiguration(lastLogin); logger.Debug("Configuration updated"); } } bool isDeviceTrusted = false; var isDeviceTrustedStr = pbData.GetPrivateSetting(DefaultProperties.Settings_Device_IsDeviceTrusted); if (!string.IsNullOrWhiteSpace(isDeviceTrustedStr)) { bool.TryParse(isDeviceTrustedStr, out isDeviceTrusted); } logger.Debug("IsDeviceTrusted - {0}", isDeviceTrusted); if (isDeviceTrusted) { DateTimeOffset lastCheckedDateTimeOffset = new DateTimeOffset(); DateTime lastCheckedDate = new DateTime(); var isDeviceTrustedLastCheckedStr = pbData.GetPrivateSetting(DefaultProperties.Settings_Device_IsDeviceTrustedLastChecked); bool isParsed = DateTimeOffset.TryParse(isDeviceTrustedLastCheckedStr, out lastCheckedDateTimeOffset); if (isParsed) { lastCheckedDate = lastCheckedDateTimeOffset.UtcDateTime; var totalDaysCount = (DateTime.UtcNow - lastCheckedDate).TotalDays; if (totalDaysCount > DefaultProperties.Settings_Device_IsDeviceTrustedLastCheckedMinDays) { logger.Debug("device not trusted - totalDaysCount > DefaultProperties.Settings_Device_IsDeviceTrustedLastCheckedMinDays"); isDeviceTrusted = false; //notify we need to enter this info } } else { isDeviceTrusted = false; } } logger.Debug("IsTurningPassSavingExecuted - {0}", IsTurningPassSavingExecuted); if (!IsTurningPassSavingExecuted) { IsTurningPassSavingExecuted = true; bool turnOffPassSaving = false; Boolean.TryParse(pbData.GetPrivateSetting(DefaultProperties.Settings_Advanced_TurnOffPassSaving), out turnOffPassSaving); logger.Debug("TurnOffPassSaving - {0}", turnOffPassSaving); if (turnOffPassSaving) { pbData.DisableStoringPasswordInBrowsers(); } else { pbData.EnableStoringPasswordInBrowsers(); } } //Task.Factory.StartNew(() => CheckRSA(generateKeysStep, pbData, webApi)); logger.Debug("CheckRsa Calling generateKeysStep - {0}", generateKeysStep); CheckRSA(generateKeysStep, pbData, webApi); //pbData.TryToClearMessageHistory(); logger.Debug("OpenMainUI - {0}", OpenMainUI); if (OpenMainUI) { ShowMainWindowIfNeeded(isDeviceTrusted); } else { Application.Current.Dispatcher.BeginInvoke((Action)(() => { CloseLoginWindow(); MainWindow mainWindow = ((PBApp)Application.Current).FindWindow <MainWindow>(); if (mainWindow == null) { mainWindow = new MainWindow(resolver); } })); } return(true); }
public SyncImagesHelper(IPBData pbData, IPBWebAPI webApi) { this.pbData = pbData; this.webApi = webApi; }
public List <DefaultView> GetSortedViewItems(int sortIndex, bool recommendedsiteFlag) { Stopwatch watch = new Stopwatch(); watch.Start(); IPBData pbData = resolver.GetInstanceOf <IPBData>(); IPBWebAPI pbWebApi = resolver.GetInstanceOf <IPBWebAPI>(); List <SecureItem> secureItems; List <DefaultView> passVaultItems = new List <DefaultView>(); try { if (recommendedsiteFlag) { passVaultItems.Add(new DefaultView() { Id = "1", Image = System.Windows.Application.Current.FindResource("1").ToString(), Name = System.Windows.Application.Current.FindResource("Names").ToString(), Category = System.Windows.Application.Current.FindResource("Names").ToString(), Favorite = false, Username = null, LastAccess = null, RecommendedHoverText = System.Windows.Application.Current.FindResource("AddName").ToString() }); passVaultItems.Add(new DefaultView() { Id = "2", Image = System.Windows.Application.Current.FindResource("2").ToString(), Name = System.Windows.Application.Current.FindResource("Address").ToString(), Category = System.Windows.Application.Current.FindResource("Address").ToString(), Favorite = false, Username = null, LastAccess = null, RecommendedHoverText = System.Windows.Application.Current.FindResource("AddAddress").ToString() }); passVaultItems.Add(new DefaultView() { Id = "3", Image = System.Windows.Application.Current.FindResource("3").ToString(), Name = System.Windows.Application.Current.FindResource("PhoneNumbers").ToString(), Category = System.Windows.Application.Current.FindResource("PhoneNumbers").ToString(), Favorite = false, Username = null, LastAccess = null, RecommendedHoverText = System.Windows.Application.Current.FindResource("AddPhoneNumber").ToString() }); passVaultItems.Add(new DefaultView() { Id = "4", Image = System.Windows.Application.Current.FindResource("4").ToString(), Name = System.Windows.Application.Current.FindResource("Company").ToString(), Category = System.Windows.Application.Current.FindResource("Company").ToString(), Favorite = false, Username = null, LastAccess = null, RecommendedHoverText = System.Windows.Application.Current.FindResource("AddCompany").ToString() }); passVaultItems.Add(new DefaultView() { Id = "5", Image = System.Windows.Application.Current.FindResource("5").ToString(), Name = System.Windows.Application.Current.FindResource("Email").ToString(), Category = System.Windows.Application.Current.FindResource("Email").ToString(), Favorite = false, Username = null, LastAccess = null, RecommendedHoverText = System.Windows.Application.Current.FindResource("AddEmail").ToString() }); passVaultItems.Add(new DefaultView() { Id = "6", Image = System.Windows.Application.Current.FindResource("6").ToString(), Name = System.Windows.Application.Current.FindResource("DriverLicense").ToString(), Category = System.Windows.Application.Current.FindResource("DriverLicense").ToString(), Favorite = false, Username = null, LastAccess = null, RecommendedHoverText = System.Windows.Application.Current.FindResource("AddDriverLicense").ToString() }); passVaultItems.Add(new DefaultView() { Id = "7", Image = System.Windows.Application.Current.FindResource("7").ToString(), Name = System.Windows.Application.Current.FindResource("Passport").ToString(), Category = System.Windows.Application.Current.FindResource("Passport").ToString(), Favorite = false, Username = null, LastAccess = null, RecommendedHoverText = System.Windows.Application.Current.FindResource("AddPassport").ToString() }); passVaultItems.Add(new DefaultView() { Id = "8", Image = System.Windows.Application.Current.FindResource("8").ToString(), Name = System.Windows.Application.Current.FindResource("MemberIDs").ToString(), Category = System.Windows.Application.Current.FindResource("MemberIDs").ToString(), Favorite = false, Username = null, LastAccess = null, RecommendedHoverText = System.Windows.Application.Current.FindResource("AddMemberID").ToString() }); passVaultItems.Add(new DefaultView() { Id = "9", Image = System.Windows.Application.Current.FindResource("9").ToString(), Name = System.Windows.Application.Current.FindResource("SocialSecurity").ToString(), Category = System.Windows.Application.Current.FindResource("SocialSecurity").ToString(), Favorite = false, Username = null, LastAccess = null, RecommendedHoverText = System.Windows.Application.Current.FindResource("AddSocialSecurity").ToString() }); passVaultItems.Add(new DefaultView() { Id = "10", Image = System.Windows.Application.Current.FindResource("10").ToString(), Name = System.Windows.Application.Current.FindResource("SecureNotes").ToString(), Category = System.Windows.Application.Current.FindResource("SecureNotes").ToString(), Favorite = false, Username = null, LastAccess = null, RecommendedHoverText = System.Windows.Application.Current.FindResource("AddSecureNotes").ToString() }); } else { if ((secureItems = pbData.GetSecureItemsByItemType(DefaultProperties.SecurityItemType_PersonalInfo)) != null) { string text2 = String.Empty; string text1 = String.Empty; foreach (var item in secureItems) { text2 = String.Empty; text1 = item.Name; string image = String.Empty; text2 = String.Empty; text1 = item.Name; switch (item.Type) { case DefaultProperties.SecurityItemSubType_PI_Address: text2 = item.Data.address1; break; case DefaultProperties.SecurityItemSubType_PI_Company: text2 = String.Empty; break; case DefaultProperties.SecurityItemSubType_SN_DriverLicense: text2 = item.Data.driverLicenceNumber; break; case DefaultProperties.SecurityItemSubType_PI_Email: text2 = item.Data.email; break; case DefaultProperties.SecurityItemSubType_SN_MemberIDs: text2 = item.Data.memberID; break; case DefaultProperties.SecurityItemSubType_PI_Names: text2 = String.Empty; break; case DefaultProperties.SecurityItemSubType_SN_Passport: text2 = item.Data.passportNumber; break; case DefaultProperties.SecurityItemSubType_PI_PhoneNumber: text2 = item.Data.phoneNumber; break; case DefaultProperties.SecurityItemSubType_PI_SecureNotes: text2 = String.Empty; break; case DefaultProperties.SecurityItemSubType_SN_SocialSecurity: text2 = String.Empty; break; default: text2 = String.Empty; break; } passVaultItems.Add(new DefaultView() { Id = item.Id, Name = text1, Image = GetItemImage(item.Type), Category = item.Folder != null ? item.Folder.Name : "Other", Favorite = item.Favorite, Username = text2, LastAccess = item.LastAccess, shared = item.Share }); } } } passVaultItems = SortViewItems(sortIndex, passVaultItems); } catch (Exception ex) { MessageBox.Show((string)System.Windows.Application.Current.FindResource("GeneralErrorText")); logger.Error(ex.Message); } watch.Stop(); logger.Info("executed in: {0} ms", watch.ElapsedMilliseconds); return(passVaultItems); }
private void NextButtonClick(object element) { try { logger.Debug("Started account request and creating rsaKeys"); if (String.IsNullOrEmpty(email) || String.IsNullOrEmpty(masterPassword)) { // To - Do Change style of Dialog MessageBox.Show("Error retreiving account information"); return; } if (this.masterPassword != UserPassword) { // To - Do Change style of Dialog MessageBox.Show("Master password not matching"); return; } UserPassword = string.Empty; //Generate a public/private key pair /*RSA rsaBase = new RSA(); * rsaBase.GenerateKeys(1024, 65537, null, null); * string privateKeyPem = rsaBase.PrivateKeyAsPEM; * string publicKeyPem = rsaBase.PublicKeyAsPEM; * * logger.Debug("Call webAPI.RequestAccount"); * string publicKeyPem = rsaBase.PublicKeyAsPEM;*/ byte[] publicKeyPem = null; ProtectedDataBlock privateKeyPem = null; using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(2048)) { privateKeyPem = new ProtectedDataBlock(Encoding.UTF8.GetBytes(RSAKeyManagement.ExportPrivateKeyToPEM(rsa))); publicKeyPem = Encoding.UTF8.GetBytes(RSAKeyManagement.ExportPublicKeyToPEM(rsa)); } IPBWebAPI webAPI = resolver.GetInstanceOf <IPBWebAPI>(); dynamic accountResponse = webAPI.RequestAccount(new WEBApiJSON.AccountRequest() { email = email, language = "English", installation = pbData.InstallationUUID, public_key = Convert.ToBase64String(publicKeyPem) }); if (accountResponse == null) { // To - Do Change style of Dialog MessageBox.Show("Error in account registration"); return; } else { if (accountResponse.error != null) { //MessageBox.Show(accountResponse.error.details[0].ToString()); if (accountResponse.error.code == "400") { //try to register device dynamic deviceRegistrationResponse = webAPI.RegisterDevice(new WEBApiJSON.DeviceRegistrationRequest() { installation = pbData.InstallationUUID, nickname = Environment.MachineName, software_version = Assembly.GetExecutingAssembly().GetName().Version.ToString() }, email); if (deviceRegistrationResponse == null) { // To - Do Change style of Dialog MessageBox.Show("Error in device registration"); return; } else { if (deviceRegistrationResponse.error != null) { //MessageBox.Show(deviceRegistrationResponse.error.message.ToString()); if (deviceRegistrationResponse.error.code.ToString() == "403") { //send verification code for new device dynamic verificationRequestResponse = webAPI.RequestVerificationCode(email); Application.Current.Dispatcher.Invoke((Action) delegate { var verificationScreen = new VerificationRequired(resolver, email, masterPassword);// resolver.GetInstanceOf<VerificationRequired>(); Navigator.NavigationService.Navigate(verificationScreen); }); } return; } Application.Current.Dispatcher.Invoke((Action) delegate { Login login = resolver.GetInstanceOf <Login>(); login.EmailTextBox.Text = email; Navigator.NavigationService.Navigate(login); }); } } } } logger.Debug("Creating profile"); if (!pbData.CreateProfile(email, masterPassword)) { // To - Do Change style of Dialog MessageBox.Show("Error while creating secure database"); } pbData.AddUserInfo(new DTO.UserInfo() { Email = email, RSAPrivateKey = privateKeyPem, PublicKey = publicKeyPem }); logger.Debug("Performing initial sync"); PerformInitialSync(); SetDefaultSettings(pbData); inAppAnalyitics.Get <Events.AccountCreationFlow, AccountCreationFlowItem>().Log(new AccountCreationFlowItem(3, AccountCreationFlowSteps.ConfirmMP, string.Empty, MarketingActionType.Continue)); // Added dispatcher because background worker can't create new UI elements Application.Current.Dispatcher.Invoke((Action) delegate { var nextScreen = new SetupComplete(resolver);// resolver.GetInstanceOf<SetupComplete>(); Navigator.NavigationService.Navigate(nextScreen); }); } catch (Exception ex) { logger.Error(ex.Message); } }
public MainWindow([Import(typeof(IResolver))] IResolver resolver)//[ImportMany] IEnumerable<IUIComponent> components, [Import(typeof(IPBData))]IPBData pbData) { Application.Current.MainWindow = this; application = (PBApp)Application.Current; //masterDialog = new MasterPwdBox(); this.resolver = resolver; this.components = resolver.GetAllInstancesOf <IUIComponent>(); if (this.components == null) { this.components = new List <IUIComponent>(); } this.subComponents = resolver.GetAllInstancesOf <IUISubComponent>(); if (this.subComponents == null) { this.subComponents = new List <IUISubComponent>(); } this.dialogs = resolver.GetAllInstancesOf <IDialog>(); if (this.dialogs == null) { this.dialogs = new List <IDialog>(); } this.pbData = resolver.GetInstanceOf <IPBData>(); ServiceLocator.Register <IFolderService>(new FolderService(pbData)); this.webApi = resolver.GetInstanceOf <IPBWebAPI>(); this.accountSettingsUserControl = new AccountSettings.AccountSettings(resolver) { Visibility = System.Windows.Visibility.Collapsed }; this.accountSettingsUserControl.Loaded += accountSettingsUserControl_Loaded; this.searchViewModel = new SearchViewModel(resolver, SecureHolderCollection); searchViewModel.ChangeVisibility += (o, e) => { topGrid.Visibility = searchViewModel.IsOpen ? Visibility.Collapsed : Visibility.Visible; var component = components.FirstOrDefault(x => x.ID == selectedUIComponentID); if (component != null) { component.Selected = !searchViewModel.IsOpen; } }; folderTreeViewModel = new FoldersTreeViewModel(resolver); folderTreeViewModel.SelectedFolder_Changed += (o, e) => { if (selectedUIComponentID != null) { var component = components.FirstOrDefault(x => x.ID == selectedUIComponentID); if (component != null && component.ViewModel is ISecureHolder) { ((ISecureHolder)component.ViewModel).UpdateTreeView(); } } }; folderTreeViewModel.FolderList_Changed += (o, e) => { Reload(); }; folderTreeViewModel.ItemsToFolder_Moved += (o, e) => { if (selectedUIComponentID != null) { foreach (var item in e.Items.GroupBy(x => (x as ISecureItemVM).Type)) { var holder = SecureHolderCollection.FirstOrDefault(x => x.SecureItemType == item.Key); if (holder != null) { holder.MoveSecureItemToFolder(item, e.FolderId); } } } }; foreach (var holder in SecureHolderCollection) { holder.FolderListUpdated += (o, e) => { folderTreeViewModel.UpdateFolderTree(); }; holder.DataUpdated += (o, e) => { searchViewModel.Update(); }; holder.AddSecureItem += (o, e) => { addBtn_Click(null, null); }; } syncImagesHelper = new SyncImagesHelper(pbData, webApi); //this.pbData.OnLoginToProfile(pbData_LoginToProfile); this.pbData.OnProfileLock += ProfileLock; this.pbData.OnUserLoggedIn += pbData_OnUserLoggedIn; Title = this.pbData.ActiveUser; resizer = new WindowResizer(this); InitializeComponent(); LoadMenu(); //LoadDialog(dialogOrder); Closing += OnMainClosing; sync = resolver.GetInstanceOf <IPBSync>(); if (sync != null) { sync.OnSyncFinished += sync_OnSyncFinished; sync.OnSyncDeviceDeleted += sync_OnSyncDeviceDeleted; //sync.OnSyncSuccess += sync_OnSyncSuccess; } var advertControl = new MainWindowAdvertising(resolver); inAppAdvertisingGrid.Children.Add(advertControl); Grid.SetColumn(advertControl, 1); ucMainSearchBox.DataContext = searchViewModel; mainSearchResultPanel.DataContext = searchViewModel; selectFolderControl.DataContext = folderTreeViewModel; this.ResizeMode = System.Windows.ResizeMode.CanMinimize; this.ShowInTaskbar = true; LoadForShowOnStartup(); if (_pbExtSecureBrowserBridge == null) { _pbExtSecureBrowserBridge = resolver.GetInstanceOf <IPBExtSecureBrowserBridge>(); } this.Activated += MainWindow_Activated; SyncAsync(); var test = this.FindName("menuUserControl") as MenuUserControl; this.DataContext = new MainWindowViewModel(); }