コード例 #1
0
        public IEnumerable <Firefox.Login> GetLoginsBy(Firefox.LoginHeader by, object value)
        {
            List <Firefox.Login> cookies = new List <Firefox.Login>();

            if (value == null)
            {
                throw new ArgumentNullException("value");                // throw a ArgumentNullException if value was not defined
            }
            if (!LoginsExist())
            {
                throw new LoginDatabaseNotFoundException(FirefoxLoginPath);                 // throw a LoginDatabaseNotFoundException if the Login File was not found
            }
            foreach (Firefox.Login l in Deserialize <_LoginDB>(File.ReadAllText(FirefoxLoginPath)).Logins)
            {
                switch (by)
                {
                case Firefox.LoginHeader.id:
                    if (l.Id == (int)value)
                    {
                        cookies.Add(l);
                    }
                    break;

                case Firefox.LoginHeader.hostname:
                    if (l.Hostname == (string)value)
                    {
                        cookies.Add(l);
                    }
                    break;

                case Firefox.LoginHeader.httpRealm:
                    if (l.HttpRealm == (string)value)
                    {
                        cookies.Add(l);
                    }
                    break;

                case Firefox.LoginHeader.formSubmitURL:
                    if (l.FormSubmitURL == (string)value)
                    {
                        cookies.Add(l);
                    }
                    break;

                case Firefox.LoginHeader.usernameField:
                    if (l.UsernameField == (string)value)
                    {
                        cookies.Add(l);
                    }
                    break;

                case Firefox.LoginHeader.passwordField:
                    if (l.PasswordField == (string)value)
                    {
                        cookies.Add(l);
                    }
                    break;

                case Firefox.LoginHeader.encryptedUsername:
                    if (l.EncryptedUsername == (string)value)
                    {
                        cookies.Add(l);
                    }
                    break;

                case Firefox.LoginHeader.encryptedPassword:
                    if (l.EncryptedPassword == (string)value)
                    {
                        cookies.Add(l);
                    }
                    break;

                case Firefox.LoginHeader.guid:
                    if (l.Guid == (string)value)
                    {
                        cookies.Add(l);
                    }
                    break;

                case Firefox.LoginHeader.encType:
                    if (l.EncType == (short)value)
                    {
                        cookies.Add(l);
                    }
                    break;

                case Firefox.LoginHeader.timeCreated:
                    if (l.TimeCreated == (long)value)
                    {
                        cookies.Add(l);
                    }
                    break;

                case Firefox.LoginHeader.timeLastUsed:
                    if (l.TimeLastUsed == (long)value)
                    {
                        cookies.Add(l);
                    }
                    break;

                case Firefox.LoginHeader.timePasswordChanged:
                    if (l.TimePasswordChanged == (long)value)
                    {
                        cookies.Add(l);
                    }
                    break;

                case Firefox.LoginHeader.timesUsed:
                    if (l.TimesUsed == (int)value)
                    {
                        cookies.Add(l);
                    }
                    break;
                }
            }
            return(cookies);
        }
コード例 #2
0
 public Tuple <IEnumerable <Chromium.Login>, IEnumerable <Firefox.Login> > GetAllLoginsByFirefox(Firefox.LoginHeader by, object value)
 => new Tuple <IEnumerable <Chromium.Login>, IEnumerable <Firefox.Login> >(GetAllChromiumLogins(), FG.GetLoginsBy(by, value));