use of org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.keys.SecretKeyNode 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;
}
Aggregations