Search in sources :

Example 1 with SecretKeyNode

use of org.jcryptool.crypto.keystore.ui.views.nodes.keys.SecretKeyNode in project core by jcryptool.

the class SecretKeyContainerNode method add.

public void add(IKeyStoreAlias alias) {
    AbstractKeyNode child = new SecretKeyNode(alias);
    nodes.add(child);
    addChild(child);
    Iterator<IKeyStoreListener> it = ContactManager.getInstance().getKeyStoreListeners();
    while (it.hasNext()) {
        it.next().fireKeyStoreModified(this);
    }
}
Also used : AbstractKeyNode(org.jcryptool.crypto.keystore.ui.views.nodes.keys.AbstractKeyNode) SecretKeyNode(org.jcryptool.crypto.keystore.ui.views.nodes.keys.SecretKeyNode) IKeyStoreListener(org.jcryptool.crypto.keystore.ui.views.interfaces.IKeyStoreListener)

Example 2 with SecretKeyNode

use of org.jcryptool.crypto.keystore.ui.views.nodes.keys.SecretKeyNode in project core by jcryptool.

the class SecretKeyContainerNode method remove.

public void remove(IKeyStoreAlias alias) {
    AbstractKeyNode child = new SecretKeyNode(alias);
    // $NON-NLS-1$
    LogUtil.logInfo("nodes.length a priori: " + nodes.size());
    nodes.remove(child);
    // $NON-NLS-1$
    LogUtil.logInfo("nodes.length a posterior: " + nodes.size());
    removeChild(child);
    Iterator<IKeyStoreListener> it = ContactManager.getInstance().getKeyStoreListeners();
    while (it.hasNext()) {
        it.next().fireKeyStoreModified(this);
    }
}
Also used : AbstractKeyNode(org.jcryptool.crypto.keystore.ui.views.nodes.keys.AbstractKeyNode) SecretKeyNode(org.jcryptool.crypto.keystore.ui.views.nodes.keys.SecretKeyNode) IKeyStoreListener(org.jcryptool.crypto.keystore.ui.views.interfaces.IKeyStoreListener)

Example 3 with SecretKeyNode

use of org.jcryptool.crypto.keystore.ui.views.nodes.keys.SecretKeyNode in project core by jcryptool.

the class ShowPropertiesHandler method execute.

/*
     * (non-Javadoc)
     * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
     */
public Object execute(ExecutionEvent event) throws ExecutionException {
    ISelection selection = HandlerUtil.getCurrentSelection(event);
    Object selectedNode = ((IStructuredSelection) selection).getFirstElement();
    CommonPropertyDialog keyDialog = null;
    if (selectedNode instanceof SecretKeyNode) {
        keyDialog = new ShowSecretKeyDialog(HandlerUtil.getActiveShell(event), (SecretKeyNode) selectedNode);
    } else if (selectedNode instanceof PrivateKeyNode) {
        keyDialog = new ShowSecretKeyDialog(HandlerUtil.getActiveShell(event), (PrivateKeyNode) selectedNode);
    } else if (selectedNode instanceof CertificateNode) {
        keyDialog = new ShowCertificateDialog(HandlerUtil.getActiveShell(event), (CertificateNode) selectedNode);
    } else {
        LogUtil.logError(KeyStorePlugin.PLUGIN_ID, "unsupported key node type");
        return null;
    }
    keyDialog.create();
    keyDialog.open();
    return null;
}
Also used : ShowSecretKeyDialog(org.jcryptool.crypto.keystore.ui.dialogs.ShowSecretKeyDialog) ShowCertificateDialog(org.jcryptool.crypto.keystore.ui.dialogs.ShowCertificateDialog) CommonPropertyDialog(org.jcryptool.crypto.keystore.ui.dialogs.CommonPropertyDialog) CertificateNode(org.jcryptool.crypto.keystore.ui.views.nodes.keys.CertificateNode) ISelection(org.eclipse.jface.viewers.ISelection) PrivateKeyNode(org.jcryptool.crypto.keystore.ui.views.nodes.keys.PrivateKeyNode) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SecretKeyNode(org.jcryptool.crypto.keystore.ui.views.nodes.keys.SecretKeyNode)

Example 4 with SecretKeyNode

use of org.jcryptool.crypto.keystore.ui.views.nodes.keys.SecretKeyNode in project core by jcryptool.

the class KeystoreView method hookContextMenu.

private void hookContextMenu() {
    // $NON-NLS-1$
    MenuManager menuMgr = new MenuManager("#PopupMenu");
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager manager) {
            if (viewer.getTree().getSelection().length == 0) {
                fillAddContactMenu(manager);
                return;
            }
            Object selection = viewer.getTree().getSelection()[0].getData();
            if (selection instanceof ContactDescriptorNode) {
                selectedNodeType = NodeType.CONTACT_NODE;
                selectedNodeInfo = ((ContactDescriptorNode) selection).getName();
                fillContactContextMenu(manager);
            } else if (selection instanceof SecretKeyNode) {
                LogUtil.logInfo(((SecretKeyNode) selection).getAlias().getAliasString());
                selectedNodeType = NodeType.SECRETKEY_NODE;
                selectedNodeAlias = ((SecretKeyNode) selection).getAlias();
                selectedSecretKeyNode = ((SecretKeyNode) selection);
                fillSecretKeyContextMenu(manager);
            } else if (selection instanceof KeyPairNode) {
                if (((KeyPairNode) selection).getPrivateKeyAlias() != null)
                    LogUtil.logInfo(((KeyPairNode) selection).getPrivateKeyAlias().getAliasString());
                selectedNodeType = NodeType.KEYPAIR_NODE;
                selectedNodeAlias = ((KeyPairNode) selection).getPrivateKeyAlias();
                selectedKeyPairNode = ((KeyPairNode) selection);
                fillKeyPairContextMenu(manager);
            } else if (selection instanceof CertificateNode) {
                IKeyStoreAlias alias = ((CertificateNode) selection).getAlias();
                if (alias.getKeyStoreEntryType().equals(KeyType.PUBLICKEY)) {
                    selectedNodeType = NodeType.PUBLICKEY_NODE;
                    selectedNodeAlias = ((CertificateNode) selection).getAlias();
                    selectedPublicKeyNode = ((CertificateNode) selection);
                    fillCertificateContextMenu(manager);
                } else if (alias.getKeyStoreEntryType().equals(KeyType.KEYPAIR_PUBLIC_KEY)) {
                    selectedNodeType = NodeType.PUBLICKEY_NODE;
                    selectedNodeAlias = ((CertificateNode) selection).getAlias();
                    selectedPublicKeyNode = ((CertificateNode) selection);
                    fillKeyPairPublicContextMenu(manager);
                }
            }
        }
    });
    Menu menu = menuMgr.createContextMenu(viewer.getControl());
    viewer.getControl().setMenu(menu);
    getSite().registerContextMenu("org.jcryptool.crypto.keystore.popup", menuMgr, viewer);
}
Also used : ContactDescriptorNode(org.jcryptool.crypto.keystore.ui.views.nodes.ContactDescriptorNode) CertificateNode(org.jcryptool.crypto.keystore.ui.views.nodes.keys.CertificateNode) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) SecretKeyNode(org.jcryptool.crypto.keystore.ui.views.nodes.keys.SecretKeyNode) Menu(org.eclipse.swt.widgets.Menu) IMenuListener(org.eclipse.jface.action.IMenuListener) KeyPairNode(org.jcryptool.crypto.keystore.ui.views.nodes.keys.KeyPairNode) IKeyStoreAlias(org.jcryptool.crypto.keystore.keys.IKeyStoreAlias)

Aggregations

SecretKeyNode (org.jcryptool.crypto.keystore.ui.views.nodes.keys.SecretKeyNode)4 IKeyStoreListener (org.jcryptool.crypto.keystore.ui.views.interfaces.IKeyStoreListener)2 AbstractKeyNode (org.jcryptool.crypto.keystore.ui.views.nodes.keys.AbstractKeyNode)2 CertificateNode (org.jcryptool.crypto.keystore.ui.views.nodes.keys.CertificateNode)2 IMenuListener (org.eclipse.jface.action.IMenuListener)1 IMenuManager (org.eclipse.jface.action.IMenuManager)1 MenuManager (org.eclipse.jface.action.MenuManager)1 ISelection (org.eclipse.jface.viewers.ISelection)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 Menu (org.eclipse.swt.widgets.Menu)1 IKeyStoreAlias (org.jcryptool.crypto.keystore.keys.IKeyStoreAlias)1 CommonPropertyDialog (org.jcryptool.crypto.keystore.ui.dialogs.CommonPropertyDialog)1 ShowCertificateDialog (org.jcryptool.crypto.keystore.ui.dialogs.ShowCertificateDialog)1 ShowSecretKeyDialog (org.jcryptool.crypto.keystore.ui.dialogs.ShowSecretKeyDialog)1 ContactDescriptorNode (org.jcryptool.crypto.keystore.ui.views.nodes.ContactDescriptorNode)1 KeyPairNode (org.jcryptool.crypto.keystore.ui.views.nodes.keys.KeyPairNode)1 PrivateKeyNode (org.jcryptool.crypto.keystore.ui.views.nodes.keys.PrivateKeyNode)1