Search in sources :

Example 1 with KeyPairNode

use of org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.keys.KeyPairNode in project core by jcryptool.

the class SelectKeyHandler method execute.

public Object execute(ExecutionEvent event) throws ExecutionException {
    ISelection selection = HandlerUtil.getCurrentSelection(event);
    if (selection instanceof IStructuredSelection) {
        Object selectedNode = ((IStructuredSelection) selection).getFirstElement();
        if (selectedNode instanceof KeyNode) {
            KeyNode keyNode = (KeyNode) selectedNode;
            IKeyStoreAlias selectionFromDialog = null;
            if (keyNode instanceof KeyPairNode) {
                selectionFromDialog = select(Style.SHOW_PRIVATEKEYNODES | Style.SHOW_PUBLICKEYNODES, event);
                if (this.cancel)
                    return null;
                if (selectionFromDialog != null) {
                    if (!(selectionFromDialog.getKeyStoreEntryType() == KeyType.KEYPAIR_PRIVATE_KEY || selectionFromDialog.getKeyStoreEntryType() == KeyType.KEYPAIR_PUBLIC_KEY)) {
                        selectionFromDialog = null;
                    }
                }
            }
            if (keyNode instanceof SecretKeyNode) {
                selectionFromDialog = select(Style.SHOW_SECRETKEYNODES, event);
                if (this.cancel)
                    return null;
                if (selectionFromDialog != null) {
                    if (!(selectionFromDialog.getKeyStoreEntryType() == KeyType.SECRETKEY)) {
                        selectionFromDialog = null;
                    }
                }
            }
            if (selectionFromDialog == null) {
                JCTMessageDialog.showInfoDialog(new Status(IStatus.INFO, FlexiProviderOperationsPlugin.PLUGIN_ID, Messages.SelectKeyHandler_WrongKey));
                return null;
            }
            FlexiProviderOperationsView operationsView = (FlexiProviderOperationsView) HandlerUtil.getActivePart(event);
            EntryNode operationNode = operationsView.getFlexiProviderOperation();
            operationNode.setKeyStoreAlias(selectionFromDialog);
        }
    }
    return null;
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) FlexiProviderOperationsView(org.jcryptool.crypto.flexiprovider.operations.ui.views.FlexiProviderOperationsView) ISelection(org.eclipse.jface.viewers.ISelection) EntryNode(org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.EntryNode) SecretKeyNode(org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.keys.SecretKeyNode) KeyNode(org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.keys.KeyNode) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SecretKeyNode(org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.keys.SecretKeyNode) IKeyStoreAlias(org.jcryptool.crypto.keystore.keys.IKeyStoreAlias) KeyPairNode(org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.keys.KeyPairNode)

Aggregations

IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1 ISelection (org.eclipse.jface.viewers.ISelection)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 FlexiProviderOperationsView (org.jcryptool.crypto.flexiprovider.operations.ui.views.FlexiProviderOperationsView)1 EntryNode (org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.EntryNode)1 KeyNode (org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.keys.KeyNode)1 KeyPairNode (org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.keys.KeyPairNode)1 SecretKeyNode (org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.keys.SecretKeyNode)1 IKeyStoreAlias (org.jcryptool.crypto.keystore.keys.IKeyStoreAlias)1