/**
  * Answer secured preferences which can be used for storing sensitive information of this tab
  *
  * @return default instance of secure preferences for this tab, <code>null</code> if application
  *     was unable to create secure preferences using default location
  */
 private ISecurePreferences getPreferences(String sectionName) {
   ISecurePreferences preferences = SecurePreferencesFactory.getDefault();
   if (preferences == null) {
     return null;
   }
   return preferences.node(IPDEUIConstants.PLUGIN_ID).node(sectionName);
 }
 private String getString(ISecurePreferences settings, String key) {
   try {
     return settings.get(key, ""); // $NON-NLS-1$
   } catch (StorageException e) {
     return ""; //$NON-NLS-1$
   }
 }
 private boolean getBoolean(ISecurePreferences settings, String key) {
   try {
     return settings.getBoolean(key, false);
   } catch (StorageException e) {
     return false;
   }
 }
  protected void saveSettings(IDialogSettings settings) {
    ISecurePreferences preferences = getPreferences(settings.getName());
    if (preferences == null) {
      // only in case it is not possible to create secured storage in
      // default location -> in that case do not persist settings
      return;
    }

    try {
      preferences.putBoolean(S_SIGN_JARS, fButton.getSelection(), true);
      preferences.put(S_KEYSTORE, fKeystoreText.getText().trim(), true);
      preferences.put(S_ALIAS, fAliasText.getText().trim(), true);
      preferences.put(S_PASSWORD, fPasswordText.getText().trim(), true);
      preferences.put(S_KEYPASS, fKeypassText.getText().trim(), true);

      // bug387565 - for keys which are starting with this bugfix to be
      // stored
      // in secured storage, replace value in settings with empty string
      // to avoid keeping sensitive info in plain text
      String[] obsoleted = new String[] {S_KEYSTORE, S_ALIAS, S_PASSWORD, S_KEYPASS};
      for (String key : obsoleted) {
        if (settings.get(key) != null) {
          settings.put(key, ""); // $NON-NLS-1$
        }
      }
    } catch (StorageException e) {
      PDEPlugin.log(
          "Failed to store JarSigning settings in secured preferences store"); //$NON-NLS-1$
    }
  }
  protected void initialize(IDialogSettings settings) {
    ISecurePreferences preferences = getPreferences(settings.getName());
    if (preferences == null) {
      // only in case it is not possible to create secured storage in
      // default location -> in that case default values are used
      return;
    }

    String keystore = ""; // $NON-NLS-1$
    String keypass = ""; // $NON-NLS-1$
    String alias = ""; // $NON-NLS-1$
    String password = ""; // $NON-NLS-1$
    boolean signJars = false;
    if (preferences.keys().length <= 0) {
      // nothing stored in secured preferences, check settings for values
      // from before bug387565 fix
      keystore = getString(settings, S_KEYSTORE);
      keypass = getString(settings, S_KEYPASS);
      alias = getString(settings, S_ALIAS);
      password = getString(settings, S_PASSWORD);
      signJars = getBoolean(settings, S_SIGN_JARS);
    } else {
      // from secured preferences after bug387565 fix
      keystore = getString(preferences, S_KEYSTORE);
      keypass = getString(preferences, S_KEYPASS);
      alias = getString(preferences, S_ALIAS);
      password = getString(preferences, S_PASSWORD);
      signJars = getBoolean(preferences, S_SIGN_JARS);
    }

    fKeystoreText.setText(keystore);
    fKeypassText.setText(keypass);
    fAliasText.setText(alias);
    fPasswordText.setText(password);
    fButton.setSelection(signJars);
    updateGroup(fButton.getSelection());
  }