private void AddProduct(PwDatabase database, PwGroup group, Product product)
        {
            var productGroup = group.FindCreateGroup(product.Name, true);

            foreach (var key in product.Keys)
            {
                if(!GroupContainsKeyAsPassword(productGroup,key))
                    AddKey(database, productGroup, key);
            }
        }
        private void AddProduct(PwDatabase database, PwGroup group, Product product)
        {
            var productGroup = group.FindCreateGroup(product.Name, true);

            foreach (var key in product.Keys)
            {
                if (!GroupContainsKeyAsPassword(productGroup, key))
                {
                    AddKey(database, productGroup, key);
                }
            }
        }
Example #3
0
        public override void Import(PwDatabase pwStorage, Stream sInput,
                                    IStatusLogger slLogger)
        {
            StreamReader sr      = new StreamReader(sInput, Encoding.Unicode, true);
            string       strData = sr.ReadToEnd();

            sr.Close();

            CsvOptions opt = new CsvOptions();

            opt.BackslashIsEscape = false;

            CsvStreamReaderEx csv = new CsvStreamReaderEx(strData, opt);

            while (true)
            {
                string[] v = csv.ReadLine();
                if (v == null)
                {
                    break;
                }
                if (v.Length < 5)
                {
                    continue;
                }

                if (v[0].Equals("url", StrUtil.CaseIgnoreCmp) &&
                    v[1].Equals("username", StrUtil.CaseIgnoreCmp) &&
                    v[2].Equals("password", StrUtil.CaseIgnoreCmp))
                {
                    continue;                     // Header
                }
                PwGroup pg       = pwStorage.RootGroup;
                string  strGroup = v[4];
                if (!string.IsNullOrEmpty(strGroup))
                {
                    pg = pg.FindCreateGroup(strGroup, true);
                }

                PwEntry pe = new PwEntry(true, true);
                pg.AddEntry(pe, true);

                ImportUtil.AppendToField(pe, PwDefs.UrlField, v[0], pwStorage);
                ImportUtil.AppendToField(pe, PwDefs.UserNameField, v[1], pwStorage);
                ImportUtil.AppendToField(pe, PwDefs.PasswordField, v[2], pwStorage);
                ImportUtil.AppendToField(pe, PwDefs.TitleField, v[3], pwStorage);
            }
        }
Example #4
0
        private static void ImportEntry(XPathNavigator xpBase, GxiProfile p,
                                        GxiContext c)
        {
            PwEntry pe = new PwEntry(true, true);

            PwGroup pg            = c.Group;  // Not the database root group
            string  strGroupPath  = QueryValueSafe(xpBase, p.EntryGroupXPath);
            string  strGroupPath2 = QueryValueSafe(xpBase, p.EntryGroupXPath2);

            if ((strGroupPath.Length > 0) && (strGroupPath2.Length > 0))
            {
                Debug.Assert(p.EntryGroupSep.Length > 0);
                strGroupPath = strGroupPath + p.EntryGroupSep + strGroupPath2;
            }
            if (strGroupPath.Length > 0)
            {
                if (p.EntryGroupSep.Length == 0)
                {
                    pg = pg.FindCreateGroup(strGroupPath, true);
                }
                else
                {
                    pg = pg.FindCreateSubTree(strGroupPath, new string[1] {
                        p.EntryGroupSep
                    }, true);
                }
            }
            pg.AddEntry(pe, true);

            GxiContext cSub = c.ModifyWith(pe);

            ImportObject(xpBase, p, p.StringKvpXPath, null,
                         GxiImporter.ImportStringKvp, cSub);
            ImportObject(xpBase, p, p.StringKvpXPath2, null,
                         GxiImporter.ImportStringKvp2, cSub);
            ImportObject(xpBase, p, p.BinaryKvpXPath, null,
                         GxiImporter.ImportBinaryKvp, cSub);
        }