/**
   * Get user password. Returns the encrypted value.
   *
   * <p>
   *
   * <pre>
   * If the password value is not null
   *    password = new password
   * else
   *   if user does exist
   *     password = old password
   *   else
   *     password = &quot;&quot;
   * </pre>
   */
  private String getPassword(User usr) {
    String name = usr.getName();
    String password = usr.getPassword();

    if (password != null) {
      password = passwordEncryptor.encrypt(password);
    } else {
      String blankPassword = passwordEncryptor.encrypt("");

      if (doesExist(name)) {
        String key = PREFIX + name + '.' + ATTR_PASSWORD;
        password = userDataProp.getProperty(key, blankPassword);
      } else {
        password = blankPassword;
      }
    }
    return password;
  }
  protected void updateSettings(List<MirrorSettings> mirrorSettings, Settings settings) {

    Map<String, Object> values = new HashMap<String, Object>();

    // Store each mirror setting
    for (MirrorSettings ms : mirrorSettings) {
      values.put(SETTING_MIRROR_REPO_URL + ms.suffix, ms.mirrorRepoUrl);
      values.put(SETTING_USERNAME + ms.suffix, ms.username);
      values.put(
          SETTING_PASSWORD + ms.suffix,
          (ms.password.isEmpty() ? ms.password : passwordEncryptor.encrypt(ms.password)));
    }

    // Unfortunately the settings are stored in an immutable map, so need to cheat with reflection
    settingsReflectionHelper.set(values, settings);
  }