Beispiel #1
0
        public PwEntry Get(string text)
        {
            var unlocker = new Unlocker {
                Host = Host
            };

            unlocker.Unlock();

            var p = new SearchParameters
            {
                SearchInTitles = true,
                SearchString   = text
            };

            var databases = Host.MainWindow.DocumentManager.GetOpenDatabases();

            foreach (var database in databases)
            {
                var list = new PwObjectList <PwEntry>();
                database.RootGroup.SearchEntries(p, list);
                if (list.UCount > 0)
                {
                    var e     = list.GetAt(0);
                    var title = e.Strings.ReadSafe(PwDefs.TitleField);
                    ShowBalloonNotification($"Entry {title} was read.");
                    return(e);
                }
            }
            throw new Exception("No " + text + " entry found!");
        }
        public override bool Initialize(IPluginHost host)
        {
            var unlocker = new Unlocker {
                Host = host
            };

            db = new EntryDB {
                Host = host
            };

            var pinentry = new Pinentry {
                PasswordFetcher = (keyInfo) => {
                    return(db.Get("GPG").Strings.ReadSafe(PwDefs.PasswordField));
                },
            };

            int port = -1;

            if (!int.TryParse(Environment.GetEnvironmentVariable("STDPROXY_PORT"), out port))
            {
                port = 500;
            }

            server = new LocalServer()
            {
                Address     = "127.0.0.1",
                Port        = port,
                Handler     = pinentry.Handle,
                Certificate = () => {
                    var entry = db.Get("TLSKEY");
                    var data  = entry.Binaries.Get("certificate.p12").ReadData();
                    var pwd   = entry.Strings.ReadSafe(PwDefs.PasswordField);
                    return(new X509Certificate2(data, pwd));
                },
            };

            server.Start();

            return(true);
        }
Beispiel #3
0
        public PwEntry Get(string text)
        {
            var unlocker = new Unlocker {
                Host = Host
            };

            unlocker.Unlock();

            var p = new SearchParameters
            {
                SearchInTitles = true,
                SearchString   = text
            };

            var list = new PwObjectList <PwEntry>();

            Host.Database.RootGroup.SearchEntries(p, list);

            var e     = list.GetAt(0); // TODO(djherbis): might throw
            var title = e.Strings.ReadSafe(PwDefs.TitleField);

            ShowBalloonNotification($"Entry {title} was read.");
            return(e);
        }