Search in sources :

Example 6 with PFX

use of org.mozilla.jss.pkcs12.PFX 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)4 ASN1Exception (codec.asn1.ASN1Exception)3 IOException (java.io.IOException)3 AMPassword (com.sun.identity.security.keystore.AMPassword)2 BufferedInputStream (java.io.BufferedInputStream)2 GeneralSecurityException (java.security.GeneralSecurityException)2 MessageDigest (java.security.MessageDigest)2 Certificate (java.security.cert.Certificate)2 SecretKey (javax.crypto.SecretKey)2 IFileStore (org.eclipse.core.filesystem.IFileStore)2 CoreException (org.eclipse.core.runtime.CoreException)2 ImportDescriptor (org.jcryptool.crypto.keystore.descriptors.ImportDescriptor)2 IImportDescriptor (org.jcryptool.crypto.keystore.descriptors.interfaces.IImportDescriptor)2 BMPString (org.mozilla.jss.asn1.BMPString)2 SEQUENCE (org.mozilla.jss.asn1.SEQUENCE)2 AuthenticatedSafes (org.mozilla.jss.pkcs12.AuthenticatedSafes)2 PFX (org.mozilla.jss.pkcs12.PFX)2 Password (org.mozilla.jss.util.Password)2 DERDecoder (codec.asn1.DERDecoder)1 DEREncoder (codec.asn1.DEREncoder)1