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; }
internal PasswordHistoryCollection(RecordCollection records) { Records = records; if (Records.Contains(RecordType.PasswordHistory)) { var text = Records[RecordType.PasswordHistory].Text; if ((text != null) && (text.Length >= 5)) { _enabled = (text[0] != '0'); if (!int.TryParse(text.AsSpan(1, 2), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out _maximumCount)) { _maximumCount = DefaultMaximumCount; } if (int.TryParse(text.AsSpan(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.AsSpan(j, 8), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out var time) && int.TryParse(text.AsSpan(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)); 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 } } } } } }