/** Save user data. Store the properties. */
  public synchronized void save(User usr) throws FtpException {
    lazyInit();

    // null value check
    if (usr.getName() == null) {
      throw new NullPointerException("User name is null.");
    }
    String thisPrefix = PREFIX + usr.getName() + '.';

    // set other properties
    userDataProp.setProperty(thisPrefix + ATTR_PASSWORD, getPassword(usr));

    String home = usr.getHomeDirectory();
    if (home == null) {
      home = "/";
    }
    userDataProp.setProperty(thisPrefix + ATTR_HOME, home);
    userDataProp.setProperty(thisPrefix + ATTR_ENABLE, usr.getEnabled());
    userDataProp.setProperty(
        thisPrefix + ATTR_WRITE_PERM, usr.authorize(new WriteRequest()) != null);
    userDataProp.setProperty(thisPrefix + ATTR_MAX_IDLE_TIME, usr.getMaxIdleTime());

    TransferRateRequest transferRateRequest = new TransferRateRequest();
    transferRateRequest = (TransferRateRequest) usr.authorize(transferRateRequest);

    if (transferRateRequest != null) {
      userDataProp.setProperty(
          thisPrefix + ATTR_MAX_UPLOAD_RATE, transferRateRequest.getMaxUploadRate());
      userDataProp.setProperty(
          thisPrefix + ATTR_MAX_DOWNLOAD_RATE, transferRateRequest.getMaxDownloadRate());
    } else {
      userDataProp.remove(thisPrefix + ATTR_MAX_UPLOAD_RATE);
      userDataProp.remove(thisPrefix + ATTR_MAX_DOWNLOAD_RATE);
    }

    // request that always will succeed
    ConcurrentLoginRequest concurrentLoginRequest = new ConcurrentLoginRequest(0, 0);
    concurrentLoginRequest = (ConcurrentLoginRequest) usr.authorize(concurrentLoginRequest);

    if (concurrentLoginRequest != null) {
      userDataProp.setProperty(
          thisPrefix + ATTR_MAX_LOGIN_NUMBER, concurrentLoginRequest.getMaxConcurrentLogins());
      userDataProp.setProperty(
          thisPrefix + ATTR_MAX_LOGIN_PER_IP, concurrentLoginRequest.getMaxConcurrentLoginsPerIP());
    } else {
      userDataProp.remove(thisPrefix + ATTR_MAX_LOGIN_NUMBER);
      userDataProp.remove(thisPrefix + ATTR_MAX_LOGIN_PER_IP);
    }

    saveUserData();
  }