Example #1
0
        public static ICollection <string> GetMemoryProtection(MemoryProtectionConfig protect)
        {
            var result = new List <string>();

            if (protect.ProtectNotes)
            {
                result.Add(PwDefs.NotesField);
            }
            if (protect.ProtectPassword)
            {
                result.Add(PwDefs.PasswordField);
            }
            if (protect.ProtectTitle)
            {
                result.Add(PwDefs.TitleField);
            }
            if (protect.ProtectUrl)
            {
                result.Add(PwDefs.UrlField);
            }
            if (protect.ProtectUserName)
            {
                result.Add(PwDefs.UserNameField);
            }

            return(result);
        }
Example #2
0
        public static void AppendToField(PwEntry pe, string strName, string strValue,
                                         PwDatabase pdContext, string strSeparator, bool bOnlyIfNotDup)
        {
            if (pe == null)
            {
                Debug.Assert(false); return;
            }
            if (string.IsNullOrEmpty(strName))
            {
                Debug.Assert(false); return;
            }

            if (strValue == null)
            {
                Debug.Assert(false); strValue = string.Empty;
            }

            if (strSeparator == null)
            {
                if (PwDefs.IsStandardField(strName) && (strName != PwDefs.NotesField))
                {
                    strSeparator = ", ";
                }
                else
                {
                    strSeparator = MessageService.NewLine;
                }
            }

            ProtectedString psPrev = pe.Strings.Get(strName);

            if ((psPrev == null) || psPrev.IsEmpty)
            {
                MemoryProtectionConfig mpc = ((pdContext != null) ?
                                              pdContext.MemoryProtection : new MemoryProtectionConfig());
                bool bProtect = mpc.GetProtection(strName);

                pe.Strings.Set(strName, new ProtectedString(bProtect, strValue));
            }
            else if (strValue.Length != 0)
            {
                bool bAppend = true;
                if (bOnlyIfNotDup)
                {
                    ProtectedString psValue = new ProtectedString(false, strValue);
                    bAppend = !psPrev.Equals(psValue, false);
                }

                if (bAppend)
                {
                    pe.Strings.Set(strName, psPrev + (strSeparator + strValue));
                }
            }
        }
Example #3
0
        public void TestGetMemoryProtection()
        {
            var protect = new MemoryProtectionConfig();

            protect.ProtectUserName = true;
            var result = Util.GetMemoryProtection(protect);

            CollectionAssert.Contains(result, PwDefs.PasswordField);
            CollectionAssert.Contains(result, PwDefs.UserNameField);
            CollectionAssert.DoesNotContain(result, PwDefs.NotesField);
            CollectionAssert.DoesNotContain(result, PwDefs.TitleField);
            CollectionAssert.DoesNotContain(result, PwDefs.UrlField);
        }
        private void WriteList(string name, MemoryProtectionConfig value)
        {
            Debug.Assert(name != null);
            Debug.Assert(value != null);

            m_xmlWriter.WriteStartElement(name);

            WriteObject(ElemProtTitle, value.ProtectTitle);
            WriteObject(ElemProtUserName, value.ProtectUserName);
            WriteObject(ElemProtPassword, value.ProtectPassword);
            WriteObject(ElemProtUrl, value.ProtectUrl);
            WriteObject(ElemProtNotes, value.ProtectNotes);
            // WriteObject(ElemProtAutoHide, value.AutoEnableVisualHiding);

            m_xmlWriter.WriteEndElement();
        }
Example #5
0
        private void Clear()
        {
            m_pgRootGroup = null;
            m_vDeletedObjects = new PwObjectList<PwDeletedObject>();

            m_uuidDataCipher = StandardAesEngine.AesUuid;
            m_caCompression = PwCompressionAlgorithm.GZip;

            m_uKeyEncryptionRounds = PwDefs.DefaultKeyEncryptionRounds;

            m_pwUserKey = null;
            m_memProtConfig = new MemoryProtectionConfig();

            m_vCustomIcons = new List<PwCustomIcon>();

            m_strName = string.Empty;
            m_strDesc = string.Empty;
            m_strDefaultUserName = string.Empty;

            m_bUINeedsIconUpdate = true;

            m_ioSource = new IOConnectionInfo();
            m_bDatabaseOpened = false;
            m_bModified = false;

            m_pwLastSelectedGroup = PwUuid.Zero;
            m_pwLastTopVisibleGroup = PwUuid.Zero;

            m_pbHashOfFileOnDisk = null;
            m_pbHashOfLastIO = null;
        }
Example #6
0
 public MemoryProtectionConfigBuffer()
 {
     mMemoryProtectionConfig = new MemoryProtectionConfig();
 }
Example #7
0
 public MemoryProtectionConfigBuffer(MemoryProtectionConfig memoryProtectionConfig)
 {
     mMemoryProtectionConfig = memoryProtectionConfig;
 }
Example #8
0
        void col_field_box_SelectedIndexChanged(object sender, EventArgs e)
        {
            DataGridViewCell       cell      = dataGridView.CurrentCell;
            DataGridViewRow        row       = cell.OwningRow;
            String                 field     = cell.EditedFormattedValue.ToString();
            bool                   read_only = true;
            string                 type      = "Inline";
            string                 fieldName = "";
            MemoryProtectionConfig conf      = m_host.Database.MemoryProtection;

            switch (field)
            {
            case "Title":
                fieldName = PwDefs.TitleField;
                type      = conf.ProtectTitle ? "Protected Inline" : "Inline";
                break;

            case "Username":
                fieldName = PwDefs.UserNameField;
                type      = conf.ProtectUserName ? "Protected Inline" : "Inline";
                break;

            case "Password":
                fieldName = PwDefs.PasswordField;
                type      = conf.ProtectPassword ? "Protected Inline" : "Inline";
                break;

            case "Password Confirmation":
                fieldName = "@confirm";
                type      = conf.ProtectPassword ? "Protected Inline" : "Inline";
                break;

            case "URL":
                fieldName = PwDefs.UrlField;
                type      = conf.ProtectUrl ? "Protected Inline" : "Inline URL";
                break;

            case "Override URL":
                fieldName = "@override";
                break;

            case "Expiry Date":
                fieldName = "@exp_date";
                type      = "Date Time";
                break;

            case "Notes":
                fieldName = PwDefs.NotesField;
                type      = conf.ProtectNotes ? "Protected Inline" : "RichTextbox";
                break;

            default:
                type      = "";
                read_only = false;
                break;
            }
            if (field != "Custom" && !field_is_unique(row, fieldName))
            {
                MessageBox.Show("Another entry in the template is already using that field, cannot change");
                cell.Value = "Custom";
                dataGridView.RefreshEdit();
                return;
            }
            row.Cells["colType"].ReadOnly = row.Cells["colFieldName"].ReadOnly = read_only;
            if (type != "")
            {
                row.Cells["colType"].Value = type;
                SetRowOptionEnabled(row, type);
            }
            if (fieldName != "")
            {
                row.Cells["colFieldName"].Value = fieldName;
            }
        }
Example #9
0
        private void WriteList(string name, MemoryProtectionConfig value)
        {
            Debug.Assert(name != null);
            Debug.Assert(value != null);

            m_xmlWriter.WriteStartElement(name);

            WriteObject(ElemProtTitle, value.ProtectTitle);
            WriteObject(ElemProtUserName, value.ProtectUserName);
            WriteObject(ElemProtPassword, value.ProtectPassword);
            WriteObject(ElemProtUrl, value.ProtectUrl);
            WriteObject(ElemProtNotes, value.ProtectNotes);
            // WriteObject(ElemProtAutoHide, value.AutoEnableVisualHiding);

            m_xmlWriter.WriteEndElement();
        }