コード例 #1
0
  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$
    }
  }
コード例 #2
0
  public Control createControl(Composite parent) {
    Composite comp = new Composite(parent, SWT.NONE);
    comp.setLayout(new GridLayout(3, false));
    comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    fButton = new Button(comp, SWT.CHECK);
    fButton.setText(PDEUIMessages.AdvancedPluginExportPage_signButton);
    GridData gd = new GridData();
    gd.horizontalSpan = 3;
    fButton.setLayoutData(gd);
    fButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            updateGroup(fButton.getSelection());
            fPage.pageChanged();
          }
        });

    fKeystoreLabel = createLabel(comp, PDEUIMessages.AdvancedPluginExportPage_keystore);
    fKeystoreText = createText(comp, 1);

    fBrowseButton = new Button(comp, SWT.PUSH);
    fBrowseButton.setText(PDEUIMessages.ExportWizard_browse);
    fBrowseButton.setLayoutData(new GridData());
    SWTUtil.setButtonDimensionHint(fBrowseButton);
    fBrowseButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            FileDialog dialog = new FileDialog(fPage.getShell(), SWT.OPEN);
            String path = fKeystoreText.getText();
            if (path.trim().length() == 0)
              path = PDEPlugin.getWorkspace().getRoot().getLocation().toString();
            dialog.setFileName(path);
            String res = dialog.open();
            if (res != null) {
              fKeystoreText.setText(res);
            }
          }
        });

    fKeypassLabel = createLabel(comp, PDEUIMessages.JARSigningTab_keypass);
    fKeypassText = createText(comp, 2);
    fKeypassText.setEchoChar('*');

    fAliasLabel = createLabel(comp, PDEUIMessages.AdvancedPluginExportPage_alias);
    fAliasText = createText(comp, 2);

    fPasswordLabel = createLabel(comp, PDEUIMessages.AdvancedPluginExportPage_password);
    fPasswordText = createText(comp, 2);
    fPasswordText.setEchoChar('*');

    Dialog.applyDialogFont(comp);
    PlatformUI.getWorkbench().getHelpSystem().setHelp(comp, IHelpContextIds.ADVANCED_PLUGIN_EXPORT);
    return comp;
  }
コード例 #3
0
 protected String[] getSigningInfo() {
   if (fButton.getSelection()) {
     return new String[] {
       fAliasText.getText().trim(),
       fKeystoreText.getText().trim(),
       fPasswordText.getText().trim(),
       fKeypassText.getText().trim()
     };
   }
   return null;
 }
コード例 #4
0
 private void updateGroup(boolean enabled) {
   fKeystoreLabel.setEnabled(enabled);
   fKeystoreText.setEnabled(enabled);
   fBrowseButton.setEnabled(enabled);
   fAliasLabel.setEnabled(enabled);
   fAliasText.setEnabled(enabled);
   fPasswordLabel.setEnabled(enabled);
   fPasswordText.setEnabled(enabled);
   fKeypassLabel.setEnabled(enabled);
   fKeypassText.setEnabled(enabled);
 }
コード例 #5
0
 protected String validate() {
   String error = null;
   if (fButton.getSelection()) {
     if (fKeystoreText.getText().trim().length() == 0) {
       error = PDEUIMessages.AdvancedPluginExportPage_noKeystore;
     } else if (fAliasText.getText().trim().length() == 0) {
       error = PDEUIMessages.AdvancedPluginExportPage_noAlias;
     } else if (fPasswordText.getText().trim().length() == 0) {
       error = PDEUIMessages.AdvancedPluginExportPage_noPassword;
     }
   }
   return error;
 }
コード例 #6
0
 protected Text createText(Composite group, int span) {
   Text text = new Text(group, SWT.SINGLE | SWT.BORDER);
   GridData gd = new GridData(GridData.FILL_HORIZONTAL);
   gd.horizontalSpan = span;
   text.setLayoutData(gd);
   text.addModifyListener(
       new ModifyListener() {
         @Override
         public void modifyText(ModifyEvent e) {
           fPage.pageChanged();
         }
       });
   return text;
 }
コード例 #7
0
  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());
  }