当前位置: 首页>>代码示例>>C#>>正文


C# PwEntry.SetKPRPCConfig方法代码示例

本文整理汇总了C#中PwEntry.SetKPRPCConfig方法的典型用法代码示例。如果您正苦于以下问题:C# PwEntry.SetKPRPCConfig方法的具体用法?C# PwEntry.SetKPRPCConfig怎么用?C# PwEntry.SetKPRPCConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PwEntry的用法示例。


在下文中一共展示了PwEntry.SetKPRPCConfig方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConvertKPRPCSeperateStringsToJSON


//.........这里部分代码省略.........


            EntryConfig conf = new EntryConfig();
            conf.Hide = false;
            string hide = "";
            try
            {
                hide = GetPwEntryString(pwe, "Hide from KeeFox", db);
                if (!string.IsNullOrEmpty(hide))
                    conf.Hide = true;
            }
            catch (Exception) { hide = ""; }
            if (string.IsNullOrEmpty(hide))
            {
                try
                {
                    hide = GetPwEntryString(pwe, "Hide from KPRPC", db);
                    if (!string.IsNullOrEmpty(hide))
                        conf.Hide = true;
                }
                catch (Exception) { hide = ""; }
            }

            conf.BlockHostnameOnlyMatch = false;
            string block = "";
            try
            {
                block = GetPwEntryString(pwe, "KPRPC Block hostname-only match", db);
                if (!string.IsNullOrEmpty(block))
                    conf.BlockHostnameOnlyMatch = true;
            }
            catch (Exception) { block = ""; }


            FormField[] temp = (FormField[])formFieldList.ToArray(typeof(FormField));

            conf.AltURLs = (string[])URLs.ToArray(typeof(string));

            try
            {
                List<string> listNormalBlockedURLs = new List<string>();
                string urls = GetPwEntryString(pwe, "KPRPC Blocked URLs", db);
                foreach (string url in urls.Split(' '))
                    if (!string.IsNullOrEmpty(url)) listNormalBlockedURLs.Add(url);
                conf.BlockedURLs = listNormalBlockedURLs.ToArray();
            }
            catch (Exception) { }

            try
            {
                List<string> listRegExURLs = new List<string>();
                string urls = GetPwEntryString(pwe, "KPRPC URL Regex match", db);
                foreach (string url in urls.Split(' '))
                    if (!string.IsNullOrEmpty(url)) listRegExURLs.Add(url);
                conf.RegExURLs = listRegExURLs.ToArray();
            }
            catch (Exception) { }

            try
            {
                List<string> listRegExBlockedURLs = new List<string>();
                string urls = GetPwEntryString(pwe, "KPRPC URL Regex block", db);
                foreach (string url in urls.Split(' '))
                    if (!string.IsNullOrEmpty(url)) listRegExBlockedURLs.Add(url);
                conf.RegExBlockedURLs = listRegExBlockedURLs.ToArray();
            }
            catch (Exception) { }


            conf.AlwaysAutoFill = alwaysAutoFill;
            conf.AlwaysAutoSubmit = alwaysAutoSubmit;
            conf.FormActionURL = GetPwEntryString(pwe, "Form match URL", db);
            conf.FormFieldList = temp;
            conf.HTTPRealm = realm;
            conf.NeverAutoFill = neverAutoFill;
            conf.NeverAutoSubmit = neverAutoSubmit;
            conf.Priority = priority;
            conf.Version = 1;

            // Store the new config info
            pwe.SetKPRPCConfig(conf);

            // Delete all old advanced strings...

            List<string> advancedStringKeysToDelete = new List<string>();

            foreach (KeyValuePair<string, ProtectedString> kvp in pwe.Strings)
            {
                if (StringIsFromKPRPCv1(kvp.Key))
                {
                    // Not sure how kindly KeePass would take to DB changes while iterating so we'll store a list for later
                    advancedStringKeysToDelete.Add(kvp.Key);
                }
            }

            foreach (string item in advancedStringKeysToDelete)
            {
                pwe.Strings.Remove(item);
            }
        }
开发者ID:PabloElPatron,项目名称:KeeFox,代码行数:101,代码来源:KeePassRPCExt.cs

示例2: MergeEntries

        private void MergeEntries(PwEntry destination, PwEntry source, int urlMergeMode, PwDatabase db)
        {
            EntryConfig destConfig = destination.GetKPRPCConfig();
            if (destConfig == null)
                return;

            EntryConfig sourceConfig = source.GetKPRPCConfig();
            if (sourceConfig == null)
                return;

            destination.CreateBackup(db);

            destConfig.HTTPRealm = sourceConfig.HTTPRealm;
            destination.IconId = source.IconId;
            destination.CustomIconUuid = source.CustomIconUuid;
            destination.Strings.Set("UserName", new ProtectedString(
                host.Database.MemoryProtection.ProtectUserName, source.Strings.ReadSafe("UserName")));
            destination.Strings.Set("Password", new ProtectedString(
                host.Database.MemoryProtection.ProtectPassword, source.Strings.ReadSafe("Password")));
            destConfig.FormFieldList = sourceConfig.FormFieldList;

            // This algorithm could probably be made more efficient (lots of O(n) operations
            // but we're dealing with pretty small n so I've gone with the conceptually
            // easiest approach for now).

            List<string> destURLs = new List<string>();
            destURLs.Add(destination.Strings.ReadSafe("URL"));
            if (destConfig.AltURLs != null)
                destURLs.AddRange(destConfig.AltURLs);

            List<string> sourceURLs = new List<string>();
            sourceURLs.Add(source.Strings.ReadSafe("URL"));
            if (sourceConfig.AltURLs != null)
                sourceURLs.AddRange(sourceConfig.AltURLs);

            switch (urlMergeMode)
            {
                case 1:
                    MergeInNewURLs(destURLs, sourceURLs);
                    break;
                case 2:
                    destURLs.RemoveAt(0);
                    MergeInNewURLs(destURLs, sourceURLs);
                    break;
                case 3:
                    if (sourceURLs.Count > 0)
                    {
                        foreach (string sourceUrl in sourceURLs)
                            if (!destURLs.Contains(sourceUrl))
                                destURLs.Add(sourceUrl);
                    }
                    break;
                case 4:
                default:
                    // No changes to URLs
                    break;
            }

            // These might not have changed but meh
            destination.Strings.Set("URL", new ProtectedString(host.Database.MemoryProtection.ProtectUrl, destURLs[0]));
            destConfig.AltURLs = new string[0];
            if (destURLs.Count > 1)
                destConfig.AltURLs = destURLs.GetRange(1,destURLs.Count-1).ToArray();

            destination.SetKPRPCConfig(destConfig);
            destination.Touch(true);
        }
开发者ID:PabloElPatron,项目名称:KeeFox,代码行数:67,代码来源:KeePassRPCService.cs

示例3: setPwEntryFromEntry

        private void setPwEntryFromEntry(PwEntry pwe, Entry login)
        {
            bool firstPasswordFound = false;
            EntryConfig conf = new EntryConfig();
            List<FormField> ffl = new List<FormField>();

            // Go through each form field, mostly just making a copy but with occasional tweaks such as default username and password selection
            // by convention, we'll always have the first text field as the username when both reading and writing from the EntryConfig
            foreach (FormField kpff in login.FormFieldList)
            {
                if (kpff.Type == FormFieldType.FFTpassword && !firstPasswordFound)
                {
                    ffl.Add(new FormField(kpff.Name, "KeePass password", "{PASSWORD}", kpff.Type, kpff.Id, kpff.Page));
                    pwe.Strings.Set("Password", new ProtectedString(host.Database.MemoryProtection.ProtectPassword, kpff.Value));
                    firstPasswordFound = true;
                }
                else if (kpff.Type == FormFieldType.FFTusername)
                {
                    ffl.Add(new FormField(kpff.Name, "KeePass username", "{USERNAME}", kpff.Type, kpff.Id, kpff.Page));
                    pwe.Strings.Set("UserName", new ProtectedString(host.Database.MemoryProtection.ProtectUserName, kpff.Value));
                }
                else
                {
                    ffl.Add(new FormField(kpff.Name, kpff.Name, kpff.Value, kpff.Type, kpff.Id, kpff.Page));
                }
            }
            conf.FormFieldList = ffl.ToArray();

            List<string> altURLs = new List<string>();

            for (int i = 0; i < login.URLs.Length; i++)
            {
                string url = login.URLs[i];
                if (i == 0)
                {
                    URLSummary urlsum = URLSummary.FromURL(url);

                    // Require more strict default matching for entries that come
                    // with a port configured (user can override in the rare case
                    // that they want the loose domain-level matching)
                    if (!string.IsNullOrEmpty(urlsum.Port))
                        conf.BlockDomainOnlyMatch = true;

                    pwe.Strings.Set("URL", new ProtectedString(host.Database.MemoryProtection.ProtectUrl, url ?? ""));
                }
                else
                    altURLs.Add(url);
            }
            conf.AltURLs = altURLs.ToArray();
            conf.HTTPRealm = login.HTTPRealm;
            conf.Version = 1;

            // Set some of the string fields
            pwe.Strings.Set(PwDefs.TitleField, new ProtectedString(host.Database.MemoryProtection.ProtectTitle, login.Title ?? ""));

            // update the icon for this entry (in most cases we'll 
            // just detect that it is the same standard icon as before)
            PwUuid customIconUUID = PwUuid.Zero;
            PwIcon iconId = PwIcon.Key;
            if (login.IconImageData != null
                && login.IconImageData.Length > 0
                && base64ToIcon(login.IconImageData, ref customIconUUID, ref iconId))
            {
                if (customIconUUID == PwUuid.Zero)
                    pwe.IconId = iconId;
                else
                    pwe.CustomIconUuid = customIconUUID;
            }

            pwe.SetKPRPCConfig(conf);
        }
开发者ID:PabloElPatron,项目名称:KeeFox,代码行数:71,代码来源:KeePassRPCService.cs

示例4: AddPasswordBackupLogin

        private void AddPasswordBackupLogin(string password, string url)
        {
            if (!host.Database.IsOpen)
                return;

            PwDatabase chosenDB = SelectDatabase("");
            var parentGroup = KeePassRPCPlugin.GetAndInstallKeeFoxPasswordBackupGroup(chosenDB);

            PwEntry newLogin = new PwEntry(true, true);
            newLogin.Strings.Set(PwDefs.TitleField, new ProtectedString(
                chosenDB.MemoryProtection.ProtectTitle, "KeeFox generated password at: " + DateTime.Now));
            newLogin.Strings.Set(PwDefs.UrlField, new ProtectedString(
                chosenDB.MemoryProtection.ProtectUrl, url));
            newLogin.Strings.Set(PwDefs.PasswordField, new ProtectedString(
                chosenDB.MemoryProtection.ProtectPassword, password));
            EntryConfig conf = new EntryConfig();
            conf.BlockDomainOnlyMatch = true;
            conf.Hide = true;
            newLogin.SetKPRPCConfig(conf);
            parentGroup.AddEntry(newLogin, true);

            // We can't save the database at this point because KeePass steals
            // window focus while saving; that breaks Firefox's Australis UI panels.
            host.MainWindow.BeginInvoke(new dlgUpdateUINoSave(updateUINoSave));

            return;
        }
开发者ID:PabloElPatron,项目名称:KeeFox,代码行数:27,代码来源:KeePassRPCService.cs


注:本文中的PwEntry.SetKPRPCConfig方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。