Example #1
0
    public EditViewLoginViewModel(LoginSimplified current, List <string> keyIds, Action positiveAction, Action negativeAction, Action <LoginSimplified, bool /* Was Security Modified */, string /* Key identifier */> edit, PasswordBox pwBox)
    {
        this.KeyIdentifiers = new ObservableCollection <string>();
        foreach (string keyIdentifier in keyIds)
        {
            this.KeyIdentifiers.Add(keyIdentifier);
        }

        if (keyIds.Count > 0)
        {
            this.SelectedKeyIdentifier = keyIds[0];
        }

        this.onPositiveClose              = positiveAction;
        this.onNegativeClose              = negativeAction;
        this.editLogin                    = edit;
        this.passwordBox                  = pwBox;
        this.passwordBox.PasswordChanged += this.passwordBoxContentChanged;

        this.zeroBasedIndexNumber = current.zeroBasedIndexNumber;
        this.wasOriginallySecret  = current.IsSecure;
        this.IsSecret             = current.IsSecure;
        this.Title                = current.Title;
        this.URL                  = current.URL;
        this.Email                = current.Email;
        this.Username             = current.Username;
        this.Password             = current.Password;
        this.passwordBox.Password = current.Password;
        this.Notes                = current.Notes;
        // TODO: Icon here once it is supported
        this.Category = current.Category;
        this.Tags     = current.Tags;
    }
Example #2
0
    private void GenerateLoginSimplifiedsFromCommonSecrets()
    {
        this.logins.Clear();
        List <LoginSimplified> newLogins = LoginSimplified.TurnIntoUICompatible(this.csc.loginInformations, this.csc.loginInformationSecrets, this.derivedPasswords, this.settingsData);

        foreach (LoginSimplified login in newLogins)
        {
            this.logins.Add(login);
        }
    }
Example #3
0
    private void AddLoginToCollection(LoginSimplified newLogin, string keyIdentifier)
    {
        LoginInformation loginToAdd = new LoginInformation(newLogin.Title, newLogin.URL, newLogin.Email, newLogin.Username, newLogin.Password,
                                                           newLogin.Notes, newLogin.Icon, newLogin.Category, newLogin.Tags);

        if (newLogin.IsSecure)
        {
            this.csc.AddLoginInformationSecret(this.derivedPasswords[keyIdentifier], loginToAdd, keyIdentifier);
        }
        else
        {
            this.csc.loginInformations.Add(loginToAdd);
        }

        // Adding a login information modifies the structure
        this.isModified = true;
        this.UpdateMainTitle(this.filePath != null ? this.filePath : untitledTempName);

        this.GenerateLoginSimplifiedsFromCommonSecrets();
    }
Example #4
0
    private void EditLoginInCollection(LoginSimplified editedLogin, bool wasSecurityModified, string keyIdentifier)
    {
        LoginInformation loginToAdd = new LoginInformation(editedLogin.Title, editedLogin.URL, editedLogin.Email, editedLogin.Username, editedLogin.Password,
                                                           editedLogin.Notes, editedLogin.Icon, editedLogin.Category, editedLogin.Tags);

        if (wasSecurityModified)
        {
            // If logininformation jumps from secure <-> unsecure
            if (editedLogin.IsSecure)
            {
                this.csc.loginInformations.RemoveAt(editedLogin.zeroBasedIndexNumber);
                this.csc.AddLoginInformationSecret(this.derivedPasswords[keyIdentifier], loginToAdd, keyIdentifier);
            }
            else
            {
                this.csc.loginInformationSecrets.RemoveAt(editedLogin.zeroBasedIndexNumber);
                this.csc.loginInformations.Add(loginToAdd);
            }
        }
        else
        {
            if (editedLogin.IsSecure)
            {
                this.csc.ReplaceLoginInformationSecret(editedLogin.zeroBasedIndexNumber, this.derivedPasswords[keyIdentifier], loginToAdd, keyIdentifier);
            }
            else
            {
                this.csc.loginInformations[editedLogin.zeroBasedIndexNumber] = loginToAdd;
            }
        }

        // Editing a login information modifies the structure
        this.isModified = true;
        this.UpdateMainTitle(this.filePath != null ? this.filePath : untitledTempName);

        this.GenerateLoginSimplifiedsFromCommonSecrets();
    }