Пример #1
0
        internal PasswordHistoryCollection(RecordCollection records)
        {
            this.Records = records;

            if (this.Records.Contains(RecordType.PasswordHistory))
            {
                var text = this.Records[RecordType.PasswordHistory].Text;
                if (text.Length >= 5)
                {
                    this._enabled = text[0] == '0' ? false : true;
                    if (!int.TryParse(text.Substring(1, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out this._maximumCount))
                    {
                        this._maximumCount = DefaultMaximumCount;
                    }

                    if (int.TryParse(text.Substring(3, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out var count))
                    {
                        var j = 5; //where parsing starts
                        for (var i = 0; i < count; i++)
                        {
                            if (text.Length >= j + 12)
                            {
                                if (int.TryParse(text.Substring(j, 8), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out var time) &&
                                    int.TryParse(text.Substring(j + 8, 4), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out var length))
                                {
                                    j += 12; //skip time and length
                                    if (text.Length >= j + length)
                                    {
                                        var item = new PasswordHistoryItem(this, UnixEpoch.AddSeconds(time), text.Substring(j, length));
                                        this.BaseCollection.Add(item);
                                        j += length; //skip password
                                    }
                                    else
                                    {
                                        break; //something is wrong with parsing
                                    }
                                }
                                else
                                {
                                    break; //something is wrong with parsing
                                }
                            }
                            else
                            {
                                break; //something is wrong with parsing
                            }
                        }
                    }
                }
            }
        }
Пример #2
0
        internal PasswordPolicy(RecordCollection records)
        {
            if (records.Contains(RecordType.PasswordPolicy))
            {
                var text = records[RecordType.PasswordPolicy].Text;
                FillPolicy(new StringBuilder(text));
            }

            if (records.Contains(RecordType.OwnSymbolsForPassword))
            {
                var text = records[RecordType.OwnSymbolsForPassword].Text;
                this.SetSpecialSymbolSet(text.ToCharArray());
            }

            this.Records = records;
        }
Пример #3
0
 internal Entry(ICollection <Record> records)
 {
     Records = new RecordCollection(this, records);
 }
Пример #4
0
 internal Record(RecordCollection owner, RecordType type)
     : this(type) {
     Owner = owner;
 }