Search in sources :

Example 1 with IImportWizard

use of org.jcryptool.crypto.keystore.descriptors.interfaces.IImportWizard in project core by jcryptool.

the class ImportKeyHandler method execute.

public Object execute(ExecutionEvent event) {
    shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    Wizard wizard = new ImportWizard();
    dialog = new WizardDialog(shell, wizard);
    dialog.setMinimumPageSize(300, 350);
    int result = dialog.open();
    if (result == Window.OK) {
        if (wizard instanceof IImportWizard) {
            IImportDescriptor desc = ((IImportWizard) wizard).getImportDescriptor();
            IPath path = new Path(desc.getFileName());
            if (desc.getKeyStoreEntryType().equals(KeyType.SECRETKEY)) {
                SecretKey key = ImportManager.getInstance().importSecretKey(path);
                performImportAction(new ImportDescriptor(desc.getContactName(), key.getAlgorithm(), KeyType.SECRETKEY, desc.getFileName(), desc.getPassword(), // $NON-NLS-1$
                "FlexiCore", -1), key);
            } else if (desc.getKeyStoreEntryType().equals(KeyType.KEYPAIR)) {
                PFX pfx = ImportManager.getInstance().importPFX(path);
                performImportAction(desc, pfx);
            } else if (desc.getKeyStoreEntryType().equals(KeyType.PUBLICKEY)) {
                Certificate cert = ImportManager.getInstance().importCertificate(path);
                performImportAction(desc, cert);
            }
        }
    }
    return (null);
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) SecretKey(javax.crypto.SecretKey) PFX(codec.pkcs12.PFX) ImportWizard(org.jcryptool.crypto.flexiprovider.keystore.wizards.ImportWizard) IImportWizard(org.jcryptool.crypto.keystore.descriptors.interfaces.IImportWizard) IPath(org.eclipse.core.runtime.IPath) IImportWizard(org.jcryptool.crypto.keystore.descriptors.interfaces.IImportWizard) IImportDescriptor(org.jcryptool.crypto.keystore.descriptors.interfaces.IImportDescriptor) ImportDescriptor(org.jcryptool.crypto.keystore.descriptors.ImportDescriptor) Wizard(org.eclipse.jface.wizard.Wizard) ImportWizard(org.jcryptool.crypto.flexiprovider.keystore.wizards.ImportWizard) IImportWizard(org.jcryptool.crypto.keystore.descriptors.interfaces.IImportWizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog) IImportDescriptor(org.jcryptool.crypto.keystore.descriptors.interfaces.IImportDescriptor) Certificate(java.security.cert.Certificate)

Aggregations

PFX (codec.pkcs12.PFX)1 Certificate (java.security.cert.Certificate)1 SecretKey (javax.crypto.SecretKey)1 IPath (org.eclipse.core.runtime.IPath)1 Path (org.eclipse.core.runtime.Path)1 Wizard (org.eclipse.jface.wizard.Wizard)1 WizardDialog (org.eclipse.jface.wizard.WizardDialog)1 ImportWizard (org.jcryptool.crypto.flexiprovider.keystore.wizards.ImportWizard)1 ImportDescriptor (org.jcryptool.crypto.keystore.descriptors.ImportDescriptor)1 IImportDescriptor (org.jcryptool.crypto.keystore.descriptors.interfaces.IImportDescriptor)1 IImportWizard (org.jcryptool.crypto.keystore.descriptors.interfaces.IImportWizard)1