PluginEntryFactory(string title, string driveScope, string clientId,
                           ProtectedString clientSecret, string folder, bool useLegacyCreds)
        {
            Entry = new PwEntry(true, true);
            ProtectedStringDictionary strings = Entry.Strings;

            strings.Set(PwDefs.TitleField,
                        new ProtectedString(false, title));
            strings.Set(PwDefs.NotesField,
                        new ProtectedString(false,
                                            Resources.GetFormat("Msg_NewEntryNotesFmt",
                                                                GdsDefs.ProductName)));
            strings.Set(PwDefs.UrlField,
                        new ProtectedString(false, GdsDefs.AccountSearchString));

            StringDictionaryEx data = Entry.CustomData;

            if (useLegacyCreds)
            {
                data.Set(GdsDefs.EntryDriveScope, driveScope);
                data.Set(GdsDefs.EntryClientId, clientId);
                data.Set(GdsDefs.EntryClientSecret, clientSecret.ReadString());
            }
            data.Set(GdsDefs.EntryActiveAppFolder, folder);
            data.Set(GdsDefs.EntryActiveAccount, GdsDefs.EntryActiveAccountTrue);
            data.Set(GdsDefs.EntryUseLegacyCreds, useLegacyCreds ?
                     GdsDefs.ConfigTrue : GdsDefs.ConfigFalse);
            data.Set(GdsDefs.EntryVersion,
                     SyncConfiguration.CurrentVersion.ToString(2));

            Entry.IconId = PwIcon.WorldComputer;
        }
        PluginEntryFactory(string title, string driveScope, string clientId,
                           ProtectedString clientSecret, string folder)
        {
            Entry = new PwEntry(true, true);
            ProtectedStringDictionary strings = Entry.Strings;

            strings.Set(PwDefs.TitleField,
                        new ProtectedString(false, title));
            strings.Set(PwDefs.NotesField,
                        new ProtectedString(false,
                                            Resources.GetFormat("Msg_NewEntryNotesFmt",
                                                                GdsDefs.ProductName)));
            strings.Set(PwDefs.UrlField,
                        new ProtectedString(false, GdsDefs.AccountSearchString));

            StringDictionaryEx data = Entry.CustomData;

            data.Set(GdsDefs.EntryDriveScope, driveScope);
            data.Set(GdsDefs.EntryActiveAppFolder, folder);
            data.Set(GdsDefs.EntryActiveAccount, GdsDefs.EntryActiveAccountTrue);
            data.Set(GdsDefs.EntryClientId, clientId);
            data.Set(GdsDefs.EntryClientSecret, clientSecret.ReadString());

            Entry.IconId = PwIcon.WorldComputer;
        }
Esempio n. 3
0
 public static EntryConfig GetKPRPCConfig(this PwEntry entry, ProtectedStringDictionary strings, ref List<string> configErrors)
 {
     if (strings == null)
         strings = entry.Strings;
     EntryConfig conf = null;
     string json = strings.ReadSafe("KPRPC JSON");
     if (string.IsNullOrEmpty(json))
         conf = new EntryConfig();
     else
     {
         try
         {
             conf = (EntryConfig)Jayrock.Json.Conversion.JsonConvert.Import(typeof(EntryConfig), json);
         }
         catch (Exception)
         {
             var url = strings.ReadSafe("URL");
             if (string.IsNullOrEmpty(url))
                 url = "<unknown>";
             if (configErrors != null)
             {
                 string entryUserName = strings.ReadSafe(PwDefs.UserNameField);
                 //entryUserName = KeePassRPCPlugin.GetPwEntryStringFromDereferencableValue(entry, entryUserName, db);
                 configErrors.Add("Username: "******". URL: " + url);
             }
             else
             {
                 MessageBox.Show("There are configuration errors in this entry. To fix the entry and prevent this warning message appearing, please edit the value of the 'KPRPC JSON' advanced string. Please ask for help on http://keefox.org/help/forum if you're not sure how to fix this. The URL of the entry is: " + url + " and the full configuration data is: " + json, "Warning: Configuration errors", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
             return null;
         }
     }
     return conf;
 }
Esempio n. 4
0
        public KeeFoxEntryUserControl(KeePassRPCExt keePassRPCPlugin, PwEntry entry,
                                      CustomListViewEx advancedListView, PwEntryForm pwEntryForm, ProtectedStringDictionary strings)
        {
            KeePassRPCPlugin = keePassRPCPlugin;
            _entry           = entry;
            InitializeComponent();
            _pwEntryForm = pwEntryForm;
            _strings     = strings;
            string json = strings.ReadSafe("KPRPC JSON");

            if (string.IsNullOrEmpty(json))
            {
                _conf = new EntryConfig();
            }
            else
            {
                try
                {
                    _conf = (EntryConfig)Jayrock.Json.Conversion.JsonConvert.Import(typeof(EntryConfig), json);
                }
                catch (Exception)
                {
                    MessageBox.Show("There are configuration errors in this entry. To fix the entry and prevent this warning message appearing, please edit the value of the 'KeePassRPC JSON config' advanced string. Please ask for help on http://keefox.org/help/forum if you're not sure how to fix this.", "Warning: Configuration errors", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
        private static List <EntryTemplate> parse_entry(ProtectedStringDictionary Strings)
        {
            List <EntryTemplate> ret = new List <EntryTemplate>();

            string[] names = get_protected_dictionary_names(Strings);
            foreach (string name in names)
            {
                if (name.StartsWith("_etm_title_"))
                {
                    String          fieldName = name.Substring("_etm_title_".Length);
                    ProtectedString str       = Strings.Get("_etm_title_" + fieldName);
                    String          title     = str == null ? "" : str.ReadString();
                    str = Strings.Get("_etm_type_" + fieldName);
                    String type = str == null ? "" : str.ReadString();
                    str = Strings.Get("_etm_position_" + fieldName);
                    String position = str == null ? "" : str.ReadString();
                    str = Strings.Get("_etm_options_" + fieldName);
                    String options = str == null ? "" : str.ReadString();
                    ret.Add(new EntryTemplate(title, fieldName, type, position, options));
                }
            }
            ret.Sort((t1, t2) => t1.position.CompareTo(t2.position));

            return(ret);
        }
Esempio n. 6
0
 public KeeFoxEntryUserControl(KeePassRPCExt keePassRPCPlugin, PwEntry entry,
     CustomListViewEx advancedListView, PwEntryForm pwEntryForm, ProtectedStringDictionary strings)
 {
     KeePassRPCPlugin = keePassRPCPlugin;
     _entry = entry;
     InitializeComponent();
     _advancedListView = advancedListView;
     _pwEntryForm = pwEntryForm;
     _strings = strings;
 }
Esempio n. 7
0
 public KeeFoxEntryUserControl(KeePassRPCExt keePassRPCPlugin, PwEntry entry,
                               CustomListViewEx advancedListView, PwEntryForm pwEntryForm, ProtectedStringDictionary strings)
 {
     KeePassRPCPlugin = keePassRPCPlugin;
     _entry           = entry;
     InitializeComponent();
     _pwEntryForm = pwEntryForm;
     _strings     = strings;
     _conf        = entry.GetKPRPCConfig(strings);
 }
		public void InitEx(AutoTypeConfig atConfig, ProtectedStringDictionary vStringDict, string strOriginalName, bool bEditSequenceOnly)
		{
			Debug.Assert(vStringDict != null); if(vStringDict == null) throw new ArgumentNullException("vStringDict");
			Debug.Assert(atConfig != null); if(atConfig == null) throw new ArgumentNullException("atConfig");

			m_atConfig = atConfig;
			m_vStringDict = vStringDict;
			m_strOriginalName = strOriginalName;
			m_bEditSequenceOnly = bEditSequenceOnly;
		}
Esempio n. 9
0
        public static ISshKey GetSshKey(this EntrySettings settings,
                                        ProtectedStringDictionary strings, ProtectedBinaryDictionary binaries,
                                        SprContext sprContext)
        {
            if (!settings.AllowUseOfSshKey)
            {
                return(null);
            }
            KeyFormatter.GetPassphraseCallback getPassphraseCallback =
                delegate(string comment)
            {
                var securePassphrase = new SecureString();
                var passphrase       = SprEngine.Compile(strings.ReadSafe(
                                                             PwDefs.PasswordField), sprContext);
                foreach (var c in passphrase)
                {
                    securePassphrase.AppendChar(c);
                }
                return(securePassphrase);
            };
            Func <Stream> getPrivateKeyStream;
            Func <Stream> getPublicKeyStream = null;

            switch (settings.Location.SelectedType)
            {
            case EntrySettings.LocationType.Attachment:
                if (string.IsNullOrWhiteSpace(settings.Location.AttachmentName))
                {
                    throw new NoAttachmentException();
                }
                var privateKeyData = binaries.Get(settings.Location.AttachmentName);
                var publicKeyData  = binaries.Get(settings.Location.AttachmentName + ".pub");
                getPrivateKeyStream = () => new MemoryStream(privateKeyData.ReadData());
                if (publicKeyData != null)
                {
                    getPublicKeyStream = () => new MemoryStream(publicKeyData.ReadData());
                }
                return(GetSshKey(getPrivateKeyStream, getPublicKeyStream,
                                 settings.Location.AttachmentName, getPassphraseCallback));

            case EntrySettings.LocationType.File:
                var filename = settings.Location.FileName.ExpandEnvironmentVariables();
                getPrivateKeyStream = () => File.OpenRead(filename);
                var publicKeyFile = filename + ".pub";
                if (File.Exists(publicKeyFile))
                {
                    getPublicKeyStream = () => File.OpenRead(publicKeyFile);
                }
                return(GetSshKey(getPrivateKeyStream, getPublicKeyStream,
                                 settings.Location.AttachmentName, getPassphraseCallback));

            default:
                return(null);
            }
        }
        private static string[] get_protected_dictionary_names(ProtectedStringDictionary Strings)
        {
            String[] names = new string[Strings.UCount];
            int      pos   = 0;

            foreach (KeyValuePair <string, ProtectedString> kvpStr in Strings)
            {
                names[pos++] = kvpStr.Key;
            }
            return(names);
        }
 private void erase_entry_template_items(ProtectedStringDictionary Strings)
 {
     string[] names = get_protected_dictionary_names(Strings);
     foreach (string name in names)
     {
         if (name.StartsWith("_etm_"))
         {
             Strings.Remove(name);
         }
     }
 }
        public void InitEx(AutoTypeConfig atConfig, int iAssocIndex, bool bEditSequenceOnly,
            string strDefaultSeq, ProtectedStringDictionary vStringDict)
        {
            Debug.Assert(atConfig != null); if(atConfig == null) throw new ArgumentNullException("atConfig");

            m_atConfig = atConfig;
            m_iAssocIndex = iAssocIndex;
            m_bEditSequenceOnly = bEditSequenceOnly;
            m_strDefaultSeq = (strDefaultSeq ?? string.Empty);
            m_vStringDict = (vStringDict ?? new ProtectedStringDictionary());
        }
Esempio n. 13
0
        /// <summary>
        /// Initialize the dialog. Needs to be called before the dialog is shown.
        /// </summary>
        /// <param name="vStringDict">String container. Must not be <c>null</c>.</param>
        /// <param name="strStringName">Initial name of the string. May be <c>null</c>.</param>
        /// <param name="psStringValue">Initial value. May be <c>null</c>.</param>
        public void InitEx(ProtectedStringDictionary vStringDict, string strStringName,
            ProtectedString psStringValue, PwDatabase pwContext)
        {
            Debug.Assert(vStringDict != null); if(vStringDict == null) throw new ArgumentNullException("vStringDict");
            m_vStringDict = vStringDict;

            m_strStringName = strStringName;
            m_psStringValue = psStringValue;

            m_pwContext = pwContext;
        }
Esempio n. 14
0
 public KeeEntryUserControl(KeePassRPCExt keePassRPCPlugin, PwEntry entry,
                            CustomListViewEx advancedListView, PwEntryForm pwEntryForm, ProtectedStringDictionary strings)
 {
     KeePassRPCPlugin = keePassRPCPlugin;
     _entry           = entry;
     InitializeComponent();
     _pwEntryForm = pwEntryForm;
     _strings     = strings;
     _dbConf      = KeePassRPCPlugin._host.Database.GetKPRPCConfig();
     _conf        = entry.GetKPRPCConfig(strings, _dbConf.DefaultMatchAccuracy);
 }
        public void InitEx(AutoTypeConfig atConfig, int iAssocIndex, bool bEditSequenceOnly,
            string strDefaultSeq, ProtectedStringDictionary vStringDict)
        {
            Debug.Assert(atConfig != null); if(atConfig == null) throw new ArgumentNullException("atConfig");

            m_atConfig = atConfig;
            m_iAssocIndex = iAssocIndex;
            m_bEditSequenceOnly = bEditSequenceOnly;
            m_strDefaultSeq = (strDefaultSeq ?? string.Empty);
            m_vStringDict = (vStringDict ?? new ProtectedStringDictionary());
        }
Esempio n. 16
0
 public override void AttachToEntryDialog(KeePassRPCExt plugin, PwEntry entry, TabControl mainTabControl, PwEntryForm form, CustomListViewEx advancedListView, ProtectedStringDictionary strings)
 {
     KeeFoxEntryUserControl entryControl = new KeeFoxEntryUserControl(plugin, entry, advancedListView, form, strings);
     TabPage keefoxTabPage = new TabPage("KeeFox");
     entryControl.Dock = DockStyle.Fill;
     keefoxTabPage.Controls.Add(entryControl);
     if (mainTabControl.ImageList == null)
         mainTabControl.ImageList = new ImageList();
     int imageIndex = mainTabControl.ImageList.Images.Add(global::KeePassRPC.Properties.Resources.KeeFox16, Color.Transparent);
     keefoxTabPage.ImageIndex = imageIndex;
     mainTabControl.TabPages.Add(keefoxTabPage);
 }
Esempio n. 17
0
        internal static PwEntry CreateVirtual(PwGroup pgParent,
                                              ProtectedStringDictionary dStrings)
        {
            PwEntry pe = new PwEntry(true, true);

            pe.ParentGroup = pgParent;             // Do not add to group
            if (dStrings != null)
            {
                pe.Strings = dStrings;                              // No clone
            }
            return(pe);
        }
Esempio n. 18
0
        /// <summary>
        /// Assign properties to the current entry based on a template entry.
        /// </summary>
        /// <param name="peTemplate">Template entry. Must not be <c>null</c>.</param>
        /// <param name="bOnlyIfNewer">Only set the properties of the template entry
        /// if it is newer than the current one.</param>
        /// <param name="bIncludeHistory">If <c>true</c>, the history will be
        /// copied, too.</param>
        /// <param name="bAssignLocationChanged">If <c>true</c>, the
        /// <c>LocationChanged</c> property is copied, otherwise not.</param>
        public void AssignProperties(PwEntry peTemplate, bool bOnlyIfNewer,
                                     bool bIncludeHistory, bool bAssignLocationChanged)
        {
            if (peTemplate == null)
            {
                Debug.Assert(false); throw new ArgumentNullException("peTemplate");
            }

            if (bOnlyIfNewer && (TimeUtil.Compare(peTemplate.m_tLastMod,
                                                  m_tLastMod, true) < 0))
            {
                return;
            }

            // Template UUID should be the same as the current one
            Debug.Assert(m_uuid.Equals(peTemplate.m_uuid));
            m_uuid = peTemplate.m_uuid;

            if (bAssignLocationChanged)
            {
                m_tParentGroupLastMod = peTemplate.m_tParentGroupLastMod;
                m_puPrevParentGroup   = peTemplate.m_puPrevParentGroup;
            }

            m_dStrings    = peTemplate.m_dStrings.CloneDeep();
            m_dBinaries   = peTemplate.m_dBinaries.CloneDeep();
            m_cfgAutoType = peTemplate.m_cfgAutoType.CloneDeep();
            if (bIncludeHistory)
            {
                m_lHistory = peTemplate.m_lHistory.CloneDeep();
            }

            m_pwIcon       = peTemplate.m_pwIcon;
            m_puCustomIcon = peTemplate.m_puCustomIcon;             // Immutable

            m_clrForeground = peTemplate.m_clrForeground;
            m_clrBackground = peTemplate.m_clrBackground;

            m_tCreation   = peTemplate.m_tCreation;
            m_tLastMod    = peTemplate.m_tLastMod;
            m_tLastAccess = peTemplate.m_tLastAccess;
            m_tExpire     = peTemplate.m_tExpire;
            m_bExpires    = peTemplate.m_bExpires;
            m_uUsageCount = peTemplate.m_uUsageCount;

            m_strOverrideUrl = peTemplate.m_strOverrideUrl;
            m_bQualityCheck  = peTemplate.m_bQualityCheck;

            m_lTags = new List <string>(peTemplate.m_lTags);

            m_dCustomData = peTemplate.m_dCustomData.CloneDeep();
        }
Esempio n. 19
0
        void editEntryFormShown(object sender, EventArgs e)
        {
            PwEntryForm               form             = sender as PwEntryForm;
            PwEntry                   entry            = null;
            TabControl                mainTabControl   = null;
            CustomListViewEx          advancedListView = null;
            ProtectedStringDictionary strings          = null;

            //This might not work, but might as well use the feature if possible.
            try
            {
                // reflection doesn't seem to be needed for 2.10 and above
                entry   = form.EntryRef;
                strings = form.EntryStrings;

                Control[] cs = form.Controls.Find("m_tabMain", true);
                if (cs.Length == 0)
                {
                    return;
                }
                mainTabControl = cs[0] as TabControl;

                Control[] cs2 = form.Controls.Find("m_lvStrings", true);
                if (cs2.Length == 0)
                {
                    return;
                }
                advancedListView = cs2[0] as CustomListViewEx;
            }
            catch
            {
                // that's life, just move on.
                return;
            }

            if (entry == null)
            {
                return;
            }

            lock (_lockRPCClientManagers)
            {
                //TODO2: Only consider managers of client types that have at least one valid client already authorised
                foreach (KeePassRPCClientManager manager in _RPCClientManagers.Values)
                {
                    if (manager.Name != "Null")
                    {
                        manager.AttachToEntryDialog(this, entry, mainTabControl, form, advancedListView, strings);
                    }
                }
            }
        }
Esempio n. 20
0
        private void WriteList(ProtectedStringDictionary dictStrings, bool bEntryStrings)
        {
            Debug.Assert(dictStrings != null);
            if (dictStrings == null)
            {
                throw new ArgumentNullException("dictStrings");
            }

            foreach (KeyValuePair <string, ProtectedString> kvp in dictStrings)
            {
                WriteObject(kvp.Key, kvp.Value, bEntryStrings);
            }
        }
Esempio n. 21
0
        /// <summary>
        /// Initialize the dialog. Needs to be called before the dialog is shown.
        /// </summary>
        public void InitEx(ProtectedStringDictionary dStrings, string strInitName,
                           ProtectedString psInitValue, PwDatabase pdContext)
        {
            if (dStrings == null)
            {
                Debug.Assert(false); throw new ArgumentNullException("dStrings");
            }

            m_dStrings    = dStrings;
            m_strInitName = strInitName;
            m_psInitValue = psInitValue;
            m_pdContext   = pdContext;
        }
Esempio n. 22
0
        internal static PEDCalcValue ReadPEDCString(this ProtectedStringDictionary psd)
        {
            string sPEDC = psd.ReadSafe(Configuration.DaysField);

            if (string.IsNullOrEmpty(sPEDC))
            {
                sPEDC = psd.ReadSafe(Configuration.Interval);
            }
            if (!string.IsNullOrEmpty(sPEDC))
            {
                return(PEDCalcValue.ConvertFromString(sPEDC));
            }
            return(null);
        }
Esempio n. 23
0
        private void CalculateHashString()
        {
            ProtectedStringDictionary stringDict = Entry.Strings;

            byte[] pw     = StrUtil.Utf8.GetBytes(stringDict.ReadSafe(KeePassLib.PwDefs.PasswordField));
            byte[] hashed = null;
            using (SHA1 sha1 = new SHA1Managed())
            {
                hashed = sha1.ComputeHash(pw);
            }
            MemUtil.ZeroByteArray(pw);
            Hash = MemUtil.ByteArrayToHexString(hashed);
            MemUtil.ZeroByteArray(hashed);
        }
Esempio n. 24
0
        /// <summary>
        /// Initialize the dialog. Needs to be called before the dialog is shown.
        /// </summary>
        /// <param name="vStringDict">String container. Must not be <c>null</c>.</param>
        /// <param name="strStringName">Initial name of the string. May be <c>null</c>.</param>
        /// <param name="psStringInitialValue">Initial value. May be <c>null</c>.</param>
        public void InitEx(ProtectedStringDictionary vStringDict, string strStringName,
                           ProtectedString psStringInitialValue, PwDatabase pwContext)
        {
            Debug.Assert(vStringDict != null); if (vStringDict == null)
            {
                throw new ArgumentNullException("vStringDict");
            }
            m_vStringDict = vStringDict;

            m_strStringName        = strStringName;
            m_psStringInitialValue = psStringInitialValue;

            m_pwContext = pwContext;
        }
Esempio n. 25
0
        public static string FindEncodeKey(ProtectedStringDictionary protectdStrings, string key)
        {
            string encodedKey = string.Empty;

            foreach (KeyValuePair <string, ProtectedString> kvp in protectdStrings)
            {
                if (DecodeKey(kvp.Key) == key)
                {
                    encodedKey = kvp.Key;
                }
            }

            return(encodedKey);
        }
Esempio n. 26
0
        public void Add(string group, ProtectedStringDictionary dict)
        {
            Client client = new Client(dict);

            if (!clientList.ContainsKey(group))
            {
                clientList.Add(group, new List<Client> { client });
            }
            else
            {
                clientList[group].Add(client);
                clientList[group] = clientList[group].OrderBy(x => x.GetTitle()).ToList();
            }
        }
Esempio n. 27
0
        public void UpdateEntryStrings(EntryModel edited, ProtectedStringDictionary m_vStrings /*, bool bGuiToInternal, bool bSetRepeatPw*/)
        {
//         if(bGuiToInternal)
//         {
            m_vStrings.Set(PwDefs.TitleField, new ProtectedString(db.MemoryProtection.ProtectTitle, edited.Title));
            m_vStrings.Set(PwDefs.UserNameField, new ProtectedString(db.MemoryProtection.ProtectUserName, edited.UserName));

            byte[] pb = edited.Password.ToUtf8(); //m_icgPassword.GetPasswordUtf8();
            m_vStrings.Set(PwDefs.PasswordField, new ProtectedString(db.MemoryProtection.ProtectPassword, pb));
            MemUtil.ZeroByteArray(pb);

            m_vStrings.Set(PwDefs.UrlField, new ProtectedString(db.MemoryProtection.ProtectUrl, edited.Url));
            m_vStrings.Set(PwDefs.NotesField, new ProtectedString(db.MemoryProtection.ProtectNotes, edited.Notes));
//         }
//         else // Internal to GUI
//         {
//            m_tbTitle.Text = m_vStrings.ReadSafe(PwDefs.TitleField);
//            m_tbUserName.Text = m_vStrings.ReadSafe(PwDefs.UserNameField);
//
//            byte[] pb = m_vStrings.GetSafe(PwDefs.PasswordField).ReadUtf8();
//            m_icgPassword.SetPassword(pb, bSetRepeatPw);
//            MemUtil.ZeroByteArray(pb);
//
//            m_tbUrl.Text = m_vStrings.ReadSafe(PwDefs.UrlField);
//            m_rtNotes.Text = m_vStrings.ReadSafe(PwDefs.NotesField);
//
//            int iTopVisible = UIUtil.GetTopVisibleItem(m_lvStrings);
//            m_lvStrings.Items.Clear();
//            foreach(KeyValuePair<string, ProtectedString> kvpStr in m_vStrings)
//            {
//               if(!PwDefs.IsStandardField(kvpStr.Key))
//               {
//                  PwIcon pwIcon = (kvpStr.Value.IsProtected ? m_pwObjectProtected :
//                     m_pwObjectPlainText);
//
//                  ListViewItem lvi = m_lvStrings.Items.Add(kvpStr.Key, (int)pwIcon);
//
//                  if(kvpStr.Value.IsProtected)
//                     lvi.SubItems.Add(PwDefs.HiddenPassword);
//                  else
//                  {
//                     string strValue = StrUtil.MultiToSingleLine(
//                        kvpStr.Value.ReadString());
//                     lvi.SubItems.Add(strValue);
//                  }
//               }
//            }
//            UIUtil.SetTopVisibleItem(m_lvStrings, iTopVisible);
        }
Esempio n. 28
0
        /// <summary>
        /// Assign properties to the current entry based on a template entry.
        /// </summary>
        /// <param name="peTemplate">Template entry. Must not be <c>null</c>.</param>
        /// <param name="bOnlyIfNewer">Only set the properties of the template entry
        /// if it is newer than the current one.</param>
        /// <param name="bIncludeHistory">If <c>true</c>, the history will be
        /// copied, too.</param>
        /// <param name="bAssignLocationChanged">If <c>true</c>, the
        /// <c>LocationChanged</c> property is copied, otherwise not.</param>
        public void AssignProperties(PwEntry peTemplate, bool bOnlyIfNewer,
                                     bool bIncludeHistory, bool bAssignLocationChanged)
        {
            Debug.Assert(peTemplate != null);
            if (peTemplate == null)
            {
                throw new ArgumentNullException("peTemplate");
            }

            if (bOnlyIfNewer && (peTemplate.m_tLastMod < m_tLastMod))
            {
                return;
            }

            // Template UUID should be the same as the current one
            Debug.Assert(m_uuid.EqualsValue(peTemplate.m_uuid));
            m_uuid = peTemplate.m_uuid;

            if (bAssignLocationChanged)
            {
                m_tParentGroupLastMod = peTemplate.m_tParentGroupLastMod;
            }

            m_listStrings  = peTemplate.m_listStrings;
            m_listBinaries = peTemplate.m_listBinaries;
            m_listAutoType = peTemplate.m_listAutoType;
            if (bIncludeHistory)
            {
                m_listHistory = peTemplate.m_listHistory;
            }

            m_pwIcon         = peTemplate.m_pwIcon;
            m_pwCustomIconID = peTemplate.m_pwCustomIconID; // Immutable

            m_clrForeground = peTemplate.m_clrForeground;
            m_clrBackground = peTemplate.m_clrBackground;

            m_tCreation   = peTemplate.m_tCreation;
            m_tLastMod    = peTemplate.m_tLastMod;
            m_tLastAccess = peTemplate.m_tLastAccess;
            m_tExpire     = peTemplate.m_tExpire;
            m_bExpires    = peTemplate.m_bExpires;
            m_uUsageCount = peTemplate.m_uUsageCount;

            m_strOverrideUrl = peTemplate.m_strOverrideUrl;

            m_vTags = new List <string>(peTemplate.m_vTags);
        }
Esempio n. 29
0
        public void InitEx(AutoTypeConfig atConfig, ProtectedStringDictionary vStringDict, string strOriginalName, bool bEditSequenceOnly)
        {
            Debug.Assert(vStringDict != null); if (vStringDict == null)
            {
                throw new ArgumentNullException("vStringDict");
            }
            Debug.Assert(atConfig != null); if (atConfig == null)
            {
                throw new ArgumentNullException("atConfig");
            }

            m_atConfig          = atConfig;
            m_vStringDict       = vStringDict;
            m_strOriginalName   = strOriginalName;
            m_bEditSequenceOnly = bEditSequenceOnly;
        }
        public static bool ModIfNeeded(this PwEntry entry,
                                       string key, ProtectedString value)
        {
            ProtectedStringDictionary strings = entry.Strings;

            if (value == null)
            {
                return(strings.Remove(key));
            }
            else if (!strings.Exists(key) ||
                     !strings.Get(key).OrdinalEquals(value, true))
            {
                strings.Set(key, value);
                return(true);
            }
            return(false);
        }
Esempio n. 31
0
        void editEntryFormShown(object sender, EventArgs e)
        {
            PwEntryForm               form             = sender as PwEntryForm;
            PwEntry                   entry            = null;
            TabControl                mainTabControl   = null;
            CustomListViewEx          advancedListView = null;
            ProtectedStringDictionary strings          = null;

            //This might not work, but might as well use the feature if possible.
            try
            {
                // reflection doesn't seem to be needed for 2.10 and above
                entry   = form.EntryRef;
                strings = form.EntryStrings;

                Control[] cs = form.Controls.Find("m_tabMain", true);
                if (cs.Length == 0)
                {
                    return;
                }
                mainTabControl = cs[0] as TabControl;

                Control[] cs2 = form.Controls.Find("m_lvStrings", true);
                if (cs2.Length == 0)
                {
                    return;
                }
                advancedListView = cs2[0] as CustomListViewEx;
            }
            catch
            {
                // that's life, just move on.
                return;
            }

            if (entry == null)
            {
                return;
            }

            lock (_lockRPCClientManagers)
            {
                _lockRPCClientManagers.HeldBy = Thread.CurrentThread.ManagedThreadId;
                _RPCClientManagers["general"].AttachToEntryDialog(this, entry, mainTabControl, form, advancedListView, strings);
            }
        }
Esempio n. 32
0
 public PCAInitData(PwEntry pe)
 {
     if (pe == null)
     {
         return;
     }
     Title       = pe.Strings.ReadSafe(PwDefs.TitleField);
     User        = pe.Strings.ReadSafe(PwDefs.UserNameField);
     Expires     = pe.Expires;
     Expiry      = pe.ExpiryTime;
     OldPassword = pe.Strings.GetSafe(PwDefs.PasswordField);
     PCASequence = PasswordChangeAssistantExt.GetPCASequence(pe, Config.DefaultPCASequences[PluginTranslate.DefaultSequence01]);
     SetExpiry   = false;
     URL         = pe.Strings.ReadSafe(PwDefs.UrlField);
     URL2        = pe.Strings.ReadSafe(Config.PCAURLField);
     Strings     = pe.Strings;
 }
Esempio n. 33
0
        public static EntryConfig GetKPRPCConfig(this PwEntry entry, ProtectedStringDictionary strings, ref List <string> configErrors)
        {
            if (strings == null)
            {
                strings = entry.Strings;
            }
            EntryConfig conf = null;
            string      json = strings.ReadSafe("KPRPC JSON");

            if (string.IsNullOrEmpty(json))
            {
                conf = new EntryConfig();
            }
            else
            {
                try
                {
                    conf = (EntryConfig)Jayrock.Json.Conversion.JsonConvert.Import(typeof(EntryConfig), json);
                }
                catch (Exception)
                {
                    var url = strings.ReadSafe("URL");
                    if (string.IsNullOrEmpty(url))
                    {
                        url = "<unknown>";
                    }
                    if (configErrors != null)
                    {
                        string entryUserName = strings.ReadSafe(PwDefs.UserNameField);
                        //entryUserName = KeePassRPCPlugin.GetPwEntryStringFromDereferencableValue(entry, entryUserName, db);
                        configErrors.Add("Username: "******". URL: " + url);
                    }
                    else
                    {
                        MessageBox.Show("There are configuration errors in this entry. To fix the entry and prevent this warning message appearing, please edit the value of the 'KPRPC JSON' advanced string. Please ask for help on https://keefox.org/help/forum if you're not sure how to fix this. The URL of the entry is: " + url + " and the full configuration data is: " + json, "Warning: Configuration errors", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    return(null);
                }
            }
            return(conf);
        }
Esempio n. 34
0
		public static void NormalizeNewLines(ProtectedStringDictionary dict,
			bool bWindows)
		{
			if(dict == null) { Debug.Assert(false); return; }

			if(m_vNewLineChars == null)
				m_vNewLineChars = new char[]{ '\r', '\n' };

			List<string> vKeys = dict.GetKeys();
			foreach(string strKey in vKeys)
			{
				ProtectedString ps = dict.Get(strKey);
				if(ps == null) { Debug.Assert(false); continue; }

				string strValue = ps.ReadString();
				if(strValue.IndexOfAny(m_vNewLineChars) < 0) continue;

				dict.Set(strKey, new ProtectedString(ps.IsProtected,
					NormalizeNewLines(strValue, bWindows)));
			}
		}
Esempio n. 35
0
        public static PluginEntryFactory Create(string title,
                                                string driveScope, string clientId, ProtectedString clientSecret,
                                                string folder, bool useLegacyCreds, bool dontSaveAuthToken)
        {
            PwEntry entry = new PwEntry(true, true);
            ProtectedStringDictionary strings = entry.Strings;

            strings.Set(PwDefs.TitleField,
                        new ProtectedString(false, title));
            strings.Set(PwDefs.NotesField,
                        new ProtectedString(false,
                                            Resources.GetFormat("Msg_NewEntryNotesFmt",
                                                                GdsDefs.ProductName)));
            strings.Set(PwDefs.UrlField,
                        new ProtectedString(false, GdsDefs.AccountSearchString));

            StringDictionaryEx data = entry.CustomData;

            if (useLegacyCreds)
            {
                data.Set(SyncConfiguration.EntryDriveScopeKey, driveScope);
                data.Set(SyncConfiguration.EntryClientIdKey, clientId);
                data.Set(SyncConfiguration.EntryClientSecretKey,
                         clientSecret == null ?
                         string.Empty : clientSecret.ReadString());
            }
            data.Set(SyncConfiguration.EntryActiveAppFolderKey, folder);
            data.Set(SyncConfiguration.EntryActiveAccountKey,
                     SyncConfiguration.EntryActiveAccountTrueKey);
            data.Set(SyncConfiguration.EntryUseLegacyCredsKey, useLegacyCreds ?
                     GdsDefs.ConfigTrue : GdsDefs.ConfigFalse);
            data.Set(SyncConfiguration.EntryDontCacheAuthTokenKey,
                     dontSaveAuthToken ?
                     GdsDefs.ConfigTrue : GdsDefs.ConfigFalse);
            data.Set(SyncConfiguration.EntryVersionKey,
                     SyncConfiguration.CurrentVersion.ToString(2));

            entry.IconId = PwIcon.WorldComputer;
            return(new PluginEntryFactory(entry));
        }
Esempio n. 36
0
 public KeeFoxEntryUserControl(KeePassRPCExt keePassRPCPlugin, PwEntry entry,
     CustomListViewEx advancedListView, PwEntryForm pwEntryForm, ProtectedStringDictionary strings)
 {
     KeePassRPCPlugin = keePassRPCPlugin;
     _entry = entry;
     InitializeComponent();
     _pwEntryForm = pwEntryForm;
     _strings = strings;
     string json = strings.ReadSafe("KPRPC JSON");
     if (string.IsNullOrEmpty(json))
         _conf = new EntryConfig();
     else
     {
         try
         {
             _conf = (EntryConfig)Jayrock.Json.Conversion.JsonConvert.Import(typeof(EntryConfig), json);
         }
         catch (Exception)
         {
             MessageBox.Show("There are configuration errors in this entry. To fix the entry and prevent this warning message appearing, please edit the value of the 'KeePassRPC JSON config' advanced string. Please ask for help on http://keefox.org/help/forum if you're not sure how to fix this.", "Warning: Configuration errors", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
 }
Esempio n. 37
0
        public void InitEx(PwEntry pwEntry, PwEditMode pwMode, PwDatabase pwDatabase,
            ImageList ilIcons, bool bShowAdvancedByDefault, bool bSelectFullTitle)
        {
            Debug.Assert(pwEntry != null); if(pwEntry == null) throw new ArgumentNullException("pwEntry");
            Debug.Assert(pwMode != PwEditMode.Invalid); if(pwMode == PwEditMode.Invalid) throw new ArgumentException();
            Debug.Assert(ilIcons != null); if(ilIcons == null) throw new ArgumentNullException("ilIcons");

            m_pwEntry = pwEntry;
            m_pwEditMode = pwMode;
            m_pwDatabase = pwDatabase;
            m_ilIcons = ilIcons;
            m_bShowAdvancedByDefault = bShowAdvancedByDefault;
            m_bSelectFullTitle = bSelectFullTitle;

            m_vStrings = m_pwEntry.Strings.CloneDeep();
            m_vBinaries = m_pwEntry.Binaries.CloneDeep();
            m_atConfig = m_pwEntry.AutoType.CloneDeep();
            m_vHistory = m_pwEntry.History.CloneDeep();
        }
Esempio n. 38
0
        private void WriteList(ProtectedStringDictionary dictStrings, bool bEntryStrings)
        {
            Debug.Assert(dictStrings != null);
            if(dictStrings == null) throw new ArgumentNullException("dictStrings");

            foreach(KeyValuePair<string, ProtectedString> kvp in dictStrings)
                WriteObject(kvp.Key, kvp.Value, bEntryStrings);
        }
Esempio n. 39
0
 public virtual void AttachToEntryDialog(KeePassRPCExt plugin, PwEntry entry, TabControl mainTabControl, PwEntryForm form, CustomListViewEx advancedListView, ProtectedStringDictionary strings)
 {
     return;
 }
Esempio n. 40
0
 public static EntryConfig GetKPRPCConfig(this PwEntry entry, ProtectedStringDictionary strings)
 {
     List<string> dummy = null;
     return entry.GetKPRPCConfig(strings, ref dummy);
 }
Esempio n. 41
0
 public Client(ProtectedStringDictionary dict)
 {
     this.dict = dict;
     safeTitle = ReplaceInvalidChars(GetTitle());
 }
Esempio n. 42
0
        public void UpdateEntryStrings(EntryModel edited, ProtectedStringDictionary m_vStrings /*, bool bGuiToInternal, bool bSetRepeatPw*/)
        {
            //         if(bGuiToInternal)
            //         {
            m_vStrings.Set(PwDefs.TitleField, new ProtectedString(db.MemoryProtection.ProtectTitle, edited.Title));
            m_vStrings.Set(PwDefs.UserNameField, new ProtectedString(db.MemoryProtection.ProtectUserName, edited.UserName));

            byte[] pb = edited.Password.ToUtf8(); //m_icgPassword.GetPasswordUtf8();
            m_vStrings.Set(PwDefs.PasswordField, new ProtectedString(db.MemoryProtection.ProtectPassword, pb));
            MemUtil.ZeroByteArray(pb);

            m_vStrings.Set(PwDefs.UrlField, new ProtectedString(db.MemoryProtection.ProtectUrl, edited.Url));
            m_vStrings.Set(PwDefs.NotesField, new ProtectedString(db.MemoryProtection.ProtectNotes, edited.Notes));
            //         }
            //         else // Internal to GUI
            //         {
            //            m_tbTitle.Text = m_vStrings.ReadSafe(PwDefs.TitleField);
            //            m_tbUserName.Text = m_vStrings.ReadSafe(PwDefs.UserNameField);
            //
            //            byte[] pb = m_vStrings.GetSafe(PwDefs.PasswordField).ReadUtf8();
            //            m_icgPassword.SetPassword(pb, bSetRepeatPw);
            //            MemUtil.ZeroByteArray(pb);
            //
            //            m_tbUrl.Text = m_vStrings.ReadSafe(PwDefs.UrlField);
            //            m_rtNotes.Text = m_vStrings.ReadSafe(PwDefs.NotesField);
            //
            //            int iTopVisible = UIUtil.GetTopVisibleItem(m_lvStrings);
            //            m_lvStrings.Items.Clear();
            //            foreach(KeyValuePair<string, ProtectedString> kvpStr in m_vStrings)
            //            {
            //               if(!PwDefs.IsStandardField(kvpStr.Key))
            //               {
            //                  PwIcon pwIcon = (kvpStr.Value.IsProtected ? m_pwObjectProtected :
            //                     m_pwObjectPlainText);
            //
            //                  ListViewItem lvi = m_lvStrings.Items.Add(kvpStr.Key, (int)pwIcon);
            //
            //                  if(kvpStr.Value.IsProtected)
            //                     lvi.SubItems.Add(PwDefs.HiddenPassword);
            //                  else
            //                  {
            //                     string strValue = StrUtil.MultiToSingleLine(
            //                        kvpStr.Value.ReadString());
            //                     lvi.SubItems.Add(strValue);
            //                  }
            //               }
            //            }
            //            UIUtil.SetTopVisibleItem(m_lvStrings, iTopVisible);
        }
Esempio n. 43
0
        public void InitEx(AutoTypeConfig atConfig, ProtectedStringDictionary vStringDict,
            int iOrgIndex, bool bEditSequenceOnly)
        {
            Debug.Assert(vStringDict != null); if(vStringDict == null) throw new ArgumentNullException("vStringDict");
            Debug.Assert(atConfig != null); if(atConfig == null) throw new ArgumentNullException("atConfig");

            m_atConfig = atConfig;
            m_vStringDict = vStringDict;
            m_iOrgIndex = iOrgIndex;
            m_bEditSequenceOnly = bEditSequenceOnly;
        }
        internal void ReadProtectedStringEx(XmlNode xmlNode, ProtectedStringDictionary dictStorage)
        {
            ProcessNode(xmlNode);

            string       strKey   = string.Empty;
            XorredBuffer xbValue  = null;
            string       strValue = null;

            foreach (XmlNode xmlChild in xmlNode.ChildNodes)
            {
                if (xmlChild.Name == ElemKey)
                {
                    ProcessNode(xmlChild);
                    strKey = xmlChild.InnerText;
                }
                else if (xmlChild.Name == ElemValue)
                {
                    xbValue = ProcessNode(xmlChild);

                    // If contents aren't protected: read as plain-text string
                    if (xbValue == null)
                    {
                        strValue = xmlChild.InnerText;
                    }
                }
                else
                {
                    ReadUnknown(xmlChild);
                }
            }

            if (xbValue != null)
            {
                Debug.Assert(strValue == null);
                dictStorage.Set(strKey, new ProtectedString(true, xbValue));
            }
            else
            {
                Debug.Assert(strValue != null);
                dictStorage.Set(strKey, new ProtectedString(false, strValue));
            }

#if DEBUG
            if (m_format == Kdb4Format.Default)
            {
                if (strKey == PwDefs.TitleField)
                {
                    Debug.Assert(m_pwDatabase.MemoryProtection.ProtectTitle ==
                                 dictStorage.Get(strKey).IsProtected);
                }
                else if (strKey == PwDefs.UserNameField)
                {
                    Debug.Assert(m_pwDatabase.MemoryProtection.ProtectUserName ==
                                 dictStorage.Get(strKey).IsProtected);
                }
                else if (strKey == PwDefs.PasswordField)
                {
                    Debug.Assert(m_pwDatabase.MemoryProtection.ProtectPassword ==
                                 dictStorage.Get(strKey).IsProtected);
                }
                else if (strKey == PwDefs.UrlField)
                {
                    Debug.Assert(m_pwDatabase.MemoryProtection.ProtectUrl ==
                                 dictStorage.Get(strKey).IsProtected);
                }
                else if (strKey == PwDefs.NotesField)
                {
                    Debug.Assert(m_pwDatabase.MemoryProtection.ProtectNotes ==
                                 dictStorage.Get(strKey).IsProtected);
                }
            }
#endif
        }
 private static string[] get_protected_dictionary_names(ProtectedStringDictionary Strings)
 {
     String[] names = new string[Strings.UCount];
     int pos = 0;
     foreach (KeyValuePair<string, ProtectedString> kvpStr in Strings)
         names[pos++] = kvpStr.Key;
     return names;
 }
Esempio n. 46
0
        private void ReadProtectedStringEx(XmlNode xmlNode, ProtectedStringDictionary dictStorage)
        {
            ProcessNode(xmlNode);

            string strKey = string.Empty;
            XorredBuffer xbValue = null;
            string strValue = null;

            foreach(XmlNode xmlChild in xmlNode.ChildNodes)
            {
                if(xmlChild.Name == ElemKey)
                {
                    ProcessNode(xmlChild);
                    strKey = xmlChild.InnerText;
                }
                else if(xmlChild.Name == ElemValue)
                {
                    xbValue = ProcessNode(xmlChild);

                    // If contents aren't protected: read as plain-text string
                    if(xbValue == null) strValue = xmlChild.InnerText;
                }
                else ReadUnknown(xmlChild);
            }

            if(xbValue != null)
            {
                Debug.Assert(strValue == null);
                dictStorage.Set(strKey, new ProtectedString(true, xbValue));
            }
            else
            {
                Debug.Assert(strValue != null);
                dictStorage.Set(strKey, new ProtectedString(false, strValue));
            }

            #if DEBUG
            if(m_format == Kdb4Format.Default)
            {
                if(strKey == PwDefs.TitleField)
                {
                    Debug.Assert(m_pwDatabase.MemoryProtection.ProtectTitle ==
                        dictStorage.Get(strKey).IsProtected);
                }
                else if(strKey == PwDefs.UserNameField)
                {
                    Debug.Assert(m_pwDatabase.MemoryProtection.ProtectUserName ==
                        dictStorage.Get(strKey).IsProtected);
                }
                else if(strKey == PwDefs.PasswordField)
                {
                    Debug.Assert(m_pwDatabase.MemoryProtection.ProtectPassword ==
                        dictStorage.Get(strKey).IsProtected);
                }
                else if(strKey == PwDefs.UrlField)
                {
                    Debug.Assert(m_pwDatabase.MemoryProtection.ProtectUrl ==
                        dictStorage.Get(strKey).IsProtected);
                }
                else if(strKey == PwDefs.NotesField)
                {
                    Debug.Assert(m_pwDatabase.MemoryProtection.ProtectNotes ==
                        dictStorage.Get(strKey).IsProtected);
                }
            }
            #endif
        }
Esempio n. 47
0
        public override void AttachToEntryDialog(KeePassRPCExt plugin, PwEntry entry, TabControl mainTabControl, PwEntryForm form, CustomListViewEx advancedListView, ProtectedStringDictionary strings)
        {
            KeeFoxEntryUserControl entryControl = new KeeFoxEntryUserControl(plugin, entry, advancedListView, form, strings);
            TabPage keefoxTabPage = new TabPage("KeeFox");

            entryControl.Dock = DockStyle.Fill;
            keefoxTabPage.Controls.Add(entryControl);
            if (mainTabControl.ImageList == null)
            {
                mainTabControl.ImageList = new ImageList();
            }
            int imageIndex = mainTabControl.ImageList.Images.Add(global::KeePassRPC.Properties.Resources.KeeFox16, Color.Transparent);

            keefoxTabPage.ImageIndex = imageIndex;
            mainTabControl.TabPages.Add(keefoxTabPage);
        }
        private static List<EntryTemplate> parse_entry(ProtectedStringDictionary Strings)
        {
            List<EntryTemplate> ret = new List<EntryTemplate>();
            string[] names = get_protected_dictionary_names(Strings);
            foreach (string name in names) {
                if (name.StartsWith("_etm_title_")) {
                    String fieldName = name.Substring("_etm_title_".Length);
                    ProtectedString str = Strings.Get("_etm_title_" + fieldName);
                    String title = str == null ? "" : str.ReadString();
                    str = Strings.Get("_etm_type_" + fieldName);
                    String type = str == null ? "" : str.ReadString();
                    str = Strings.Get("_etm_position_" + fieldName);
                    String position = str == null ? "" : str.ReadString();
                    str = Strings.Get("_etm_options_" + fieldName);
                    String options = str == null ? "" : str.ReadString();
                    ret.Add(new EntryTemplate(title, fieldName, type, position, options));
                }
            }
            ret.Sort((t1, t2) => t1.position.CompareTo(t2.position));

            return ret;
        }
Esempio n. 49
0
 public static ISshKey GetSshKey(this EntrySettings settings,
     ProtectedStringDictionary strings, ProtectedBinaryDictionary binaries,
     SprContext sprContext)
 {
     if (!settings.AllowUseOfSshKey) {
     return null;
       }
       KeyFormatter.GetPassphraseCallback getPassphraseCallback =
     delegate(string comment)
     {
       var securePassphrase = new SecureString();
     var passphrase = SprEngine.Compile(strings.ReadSafe(
                   PwDefs.PasswordField), sprContext);
       foreach (var c in passphrase) {
     securePassphrase.AppendChar(c);
       }
       return securePassphrase;
     };
       Func<Stream> getPrivateKeyStream;
       Func<Stream> getPublicKeyStream = null;
       switch (settings.Location.SelectedType) {
     case EntrySettings.LocationType.Attachment:
       if (string.IsNullOrWhiteSpace(settings.Location.AttachmentName)) {
     throw new NoAttachmentException();
       }
       var privateKeyData = binaries.Get(settings.Location.AttachmentName);
       var publicKeyData = binaries.Get(settings.Location.AttachmentName + ".pub");
       getPrivateKeyStream = () => new MemoryStream(privateKeyData.ReadData());
       if (publicKeyData != null)
     getPublicKeyStream = () => new MemoryStream(publicKeyData.ReadData());
       return GetSshKey(getPrivateKeyStream, getPublicKeyStream,
                    settings.Location.AttachmentName, getPassphraseCallback);
     case EntrySettings.LocationType.File:
       getPrivateKeyStream = () => File.OpenRead(settings.Location.FileName);
       var publicKeyFile = settings.Location.FileName + ".pub";
       if (File.Exists(publicKeyFile))
     getPublicKeyStream = () => File.OpenRead(publicKeyFile);
       return GetSshKey(getPrivateKeyStream, getPublicKeyStream,
                    settings.Location.AttachmentName, getPassphraseCallback);
     default:
       return null;
       }
 }
Esempio n. 50
0
		public static void NormalizeNewLines(ProtectedStringDictionary dict,
			bool bWindows)
		{
			if(dict == null) { Debug.Assert(false); return; }

			if(m_vNewLineChars == null)
				m_vNewLineChars = new char[]{ '\r', '\n' };

			List<string> vKeys = dict.GetKeys();
			foreach(string strKey in vKeys)
			{
				ProtectedString ps = dict.Get(strKey);
				if(ps == null) { Debug.Assert(false); continue; }

				string strValue = ps.ReadString();
				if(strValue.IndexOfAny(m_vNewLineChars) < 0) continue;

				dict.Set(strKey, new ProtectedString(ps.IsProtected,
					NormalizeNewLines(strValue, bWindows)));
			}
		}
 private void erase_entry_template_items(ProtectedStringDictionary Strings)
 {
     string[] names = get_protected_dictionary_names(Strings);
     foreach (string name in names) {
         if (name.StartsWith("_etm_"))
             Strings.Remove(name);
     }
 }