/** Save application settings to persistent store. */
  public void save() {
    Preferences preferences = getUnderlyingPreferences();

    // Authority certificates
    preferences.putBoolean(KSE3_USECACERTS, useCaCertificates);
    preferences.put(KSE3_CACERTSFILE, caCertificatesFile.toString());
    preferences.putBoolean(KSE3_USEWINTRUSTROOTCERTS, useWindowsTrustedRootCertificates);

    // Trust checks
    preferences.putBoolean(
        KSE3_ENABLEIMPORTTRUSTEDCERTTRUSTCHECK, enableImportTrustedCertTrustCheck);
    preferences.putBoolean(KSE3_ENABLEIMPORTCAREPLYTRUSTCHECK, enableImportCaReplyTrustCheck);

    // Key pair generation
    preferences.put(KSE3_KEYPAIRTYPE, generateKeyPairType.jce());
    preferences.putInt(KSE3_KEYPAIRSIZE, generateKeyPairSize);

    // Secret key generation
    preferences.put(KSE3_SECKEYTYPE, generateSecretKeyType.jce());
    preferences.putInt(KSE3_SECKEYSIZE, generateSecretKeySize);

    // Certificate fingerprint
    preferences.put(KSE3_CERTFINGERTYPE, certificateFingerprintType.jce());

    // Password quality
    preferences.putBoolean(KSE3_PWDQUALENABLE, passwordQualityConfig.getEnabled());
    preferences.putBoolean(KSE3_MINPWDQUALENFORCE, passwordQualityConfig.getEnforced());
    preferences.putInt(KSE3_MINPWDQUAL, passwordQualityConfig.getMinimumQuality());

    // Internet proxy settings
    getCurrentProxySettings(preferences);

    // Application size and position
    preferences.putInt(KSE3_XPOS, sizeAndPosition.x);
    preferences.putInt(KSE3_YPOS, sizeAndPosition.y);
    preferences.putInt(KSE3_WIDTH, sizeAndPosition.width);
    preferences.putInt(KSE3_HEIGHT, sizeAndPosition.height);

    // User interface
    preferences.putBoolean(KSE3_SHOWTOOLBAR, showToolBar);
    preferences.putBoolean(KSE3_SHOWSTATUSBAR, showStatusBar);
    preferences.putInt(KSE3_TABLAYOUT, tabLayout);

    // Recent files
    clearExistingRecentFiles(preferences);
    for (int i = 1; i <= recentFiles.length; i++) {
      preferences.put(KSE3_RECENTFILE + i, recentFiles[i - 1].toString());
    }

    // Current directory
    preferences.put(KSE3_CURRENTDIR, currentDirectory.toString());

    // Look and feel
    preferences.put(KSE3_LOOKFEEL, lookAndFeelClass);
    preferences.putBoolean(KSE3_LOOKFEELDECOR, lookAndFeelDecorated);

    // Licensing
    preferences.putBoolean(KSE3_LICENSEAGREED, licenseAgreed);

    // Tip of the day
    preferences.putBoolean(KSE3_TIPSONSTARTUP, showTipsOnStartUp);
    preferences.putInt(KSE3_TIPINDEX, nextTipIndex);

    // Default distinguished name
    preferences.put(KSE3_DEFAULTDN, defaultDN);

    // SSL host names and ports for "Examine SSL"
    preferences.put(KSE3_SSLHOSTS, getSslHosts());
    preferences.put(KSE3_SSLPORTS, getSslPorts());

    // auto update check settings
    preferences.putBoolean(KSE3_AUTO_UPDATE_CHECK_ENABLED, isAutoUpdateCheckEnabled());
    preferences.putInt(KSE3_AUTO_UPDATE_CHECK_INTERVAL, getAutoUpdateCheckInterval());
    preferences.put(
        KSE3_AUTO_UPDATE_CHECK_LAST_CHECK, DATE_FORMAT.format(getAutoUpdateCheckLastCheck()));

    // PKCS#11 libraries
    preferences.put(KSE3_PKCS11_LIBS, getP11Libs());
  }