code: def validate_password(entry, username, check_function, password=None, retries=1, save_on_success=True, prompt=None, **check_args):
      
  
      if password is None:
          password = get_password(entry, username, prompt)
  
      for _ in xrange(retries + 1):
  
          if check_function(username, password, **check_args):
              if save_on_success:
                  save_password(entry, password, username)
  
              return True
  
          log.error("Couldn't successfully authenticate your username & password..")
  
          password = get_password(entry, username, prompt, always_ask=True)
  
      return False
docs: Validate a password with a check function & retry if the password is incorrect.
  
        Useful for after a user has changed their password in LDAP, but their local keychain entry is then out of sync.
  
        :param str entry: The keychain entry to fetch a password from.
        :param str username: The username to authenticate
        :param func check_function: Check function to use. Should take (username, password, **check_args)
        :param str password: The password to validate. If `None`, the user will be prompted.
        :param int retries: Number of retries to prompt the user for.
        :param bool save_on_success: Save the password if the validation was successful.
        :param str prompt: Alternate prompt to use when asking for the user's password.
  
        :returns: `True` on successful authentication. `False` otherwise.
        :rtype: bool