package org.eparapher.rcp.wizards; import java.security.KeyStore; import java.security.cert.X509Certificate; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.wizard.Wizard; import org.eclipse.ui.INewWizard; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchWindow; import org.eparapher.core.crypto.keystore.EPKeystoreUtils; import org.eparapher.rcp.tools.RCPGUI; public class ExportKeysCertificatesWizard extends Wizard implements INewWizard { /** The window */ private IWorkbenchWindow window; KeysAndFormatWizardPage one; PinOrPassphraseWizardPage newSecret; private X509Certificate userCert = null; private String[] selected_aliases; public ExportKeysCertificatesWizard(String[] mselected_aliases) { super(); setNeedsProgressMonitor(true); setWindowTitle("Keys and certificates export "); selected_aliases = mselected_aliases; } public void addPages() { //export settings one = new KeysAndFormatWizardPage(); //Define new keystore password newSecret = new PinOrPassphraseWizardPage(true,false,""); addPage(one); addPage(newSecret); newSecret.setPageComplete(true); } public boolean performFinish() { if (one.isPrivateKeyExported()) { //FileKeystore fk = new FileKeystore(one.getKeystoreType(), one.getKeystoreFile()); KeyStore exportedks = EPKeystoreUtils.initNewKeystore( one.getKeystoreType(), newSecret.getSecret()); if (!EPKeystoreUtils.exportUserKSPKAndCerts(selected_aliases, exportedks, newSecret.getSecret(),one.isPrivateKeyPassword())) RCPGUI.infoMessage("Export Keys/Certificates", "Error while copying keystores"); else if (!EPKeystoreUtils.saveKeystore( exportedks, one.getKeystoreFile(), newSecret.getSecret() )) RCPGUI.infoMessage("Export Keys/Certificates", "Error while saving exported keystores"); } else if (!EPKeystoreUtils.exportUserKSCerts(selected_aliases, one.getKeystoreFile())) RCPGUI.infoMessage("Export Keys/Certificates", "Error while exporting certificates"); return true; } public void init(IWorkbench workbench, IStructuredSelection selection) { window = workbench.getActiveWorkbenchWindow(); } }