Search in sources :

Example 6 with IKeyStoreListener

use of org.jcryptool.crypto.keystore.ui.views.interfaces.IKeyStoreListener in project core by jcryptool.

the class KeyPairContainerNode method addKeyPair.

public void addKeyPair(IKeyStoreAlias privateKey, IKeyStoreAlias publicKey) {
    if (privateKey != null && publicKey != null) {
        KeyPairNode child = new KeyPairNode(privateKey, publicKey);
        setAppropriateNameForNode(child);
        nodes.put(privateKey.getHashValue(), child);
        addChild(child);
    } else if (privateKey != null) {
        if (nodes.containsKey(privateKey.getHashValue())) {
            nodes.get(privateKey.getHashValue()).addPrivateKey(privateKey);
        } else {
            KeyPairNode child = new KeyPairNode(privateKey, null);
            setAppropriateNameForNode(child);
            nodes.put(privateKey.getHashValue(), child);
            addChild(child);
        }
    } else if (publicKey != null) {
        if (nodes.containsKey(publicKey.getHashValue())) {
            nodes.get(publicKey.getHashValue()).addPublicKey(publicKey);
        } else {
            KeyPairNode child = new KeyPairNode(null, publicKey);
            setAppropriateNameForNode(child);
            nodes.put(publicKey.getHashValue(), child);
            addChild(child);
        }
    }
    Iterator<IKeyStoreListener> it = ContactManager.getInstance().getKeyStoreListeners();
    while (it.hasNext()) {
        it.next().fireKeyStoreModified(this);
    }
}
Also used : KeyPairNode(org.jcryptool.crypto.keystore.ui.views.nodes.keys.KeyPairNode) IKeyStoreListener(org.jcryptool.crypto.keystore.ui.views.interfaces.IKeyStoreListener)

Aggregations

IKeyStoreListener (org.jcryptool.crypto.keystore.ui.views.interfaces.IKeyStoreListener)6 AbstractKeyNode (org.jcryptool.crypto.keystore.ui.views.nodes.keys.AbstractKeyNode)4 CertificateNode (org.jcryptool.crypto.keystore.ui.views.nodes.keys.CertificateNode)2 KeyPairNode (org.jcryptool.crypto.keystore.ui.views.nodes.keys.KeyPairNode)2 SecretKeyNode (org.jcryptool.crypto.keystore.ui.views.nodes.keys.SecretKeyNode)2