class PasswordStrength::Validators::Windows2008

Validates a Windows 2008 password against the following rules:

Reference: technet.microsoft.com/en-us/library/cc264456.aspx

Public Instance Methods

password_contains_username?() click to toggle source
# File lib/password_strength/validators/windows2008.rb, line 27
def password_contains_username?
  0.upto(password.size - 1) do |i|
    substring = password[i, 3]
    return true if username.include?(substring)
  end

  false
end
test() click to toggle source
# File lib/password_strength/validators/windows2008.rb, line 12
def test
  return invalid! if password.size < 6

  variety = 0
  variety += 1 if password =~ /[A-Z]/
  variety += 1 if password =~ /[a-z]/
  variety += 1 if password =~ /[0-9]/
  variety += 1 if password =~ PasswordStrength::Base::SYMBOL_RE

  return invalid! if variety < 3
  return invalid! if password_contains_username?

  strong!
end