Search in sources :

Example 1 with IContactDescriptor

use of org.jcryptool.crypto.keystore.descriptors.interfaces.IContactDescriptor in project core by jcryptool.

the class ContactManager method newContact.

public IContactDescriptor newContact(Contact contact) {
    IContactDescriptor newContactDesc = new ContactDescriptorNode(contact);
    addContact(newContactDesc);
    return newContactDesc;
}
Also used : IContactDescriptor(org.jcryptool.crypto.keystore.descriptors.interfaces.IContactDescriptor)

Example 2 with IContactDescriptor

use of org.jcryptool.crypto.keystore.descriptors.interfaces.IContactDescriptor in project core by jcryptool.

the class ContactManager method addCertificate.

public void addCertificate(IKeyStoreAlias alias) {
    // $NON-NLS-1$
    LogUtil.logInfo("Adding certificate " + alias.getAliasString());
    if (contactExists(alias.getContactName())) {
        contactsDesc.get(alias.getContactName()).addCertificate(alias);
    } else {
        IContactDescriptor contact = newContact(new Contact(alias.getContactName(), null, null, null, null));
        contact.addCertificate(alias);
    }
    notifyListeners();
}
Also used : IContactDescriptor(org.jcryptool.crypto.keystore.descriptors.interfaces.IContactDescriptor)

Example 3 with IContactDescriptor

use of org.jcryptool.crypto.keystore.descriptors.interfaces.IContactDescriptor in project core by jcryptool.

the class ContactManager method initTreeModel.

/**
 * When a backup of the keystore is restored, we need to call
 * resetInvisbleRoot() followed by initTreeModel().
 * Also, getInstance() calls initTreeModel() internally
 */
/*private*/
public void initTreeModel() {
    if (invisibleRoot == null) {
        init();
        // $NON-NLS-1$
        invisibleRoot = new TreeNode("INVISIBLE_ROOT");
        for (IContactDescriptor desc : contactsDesc.values()) {
            if (desc instanceof ContactDescriptorNode) {
                // $NON-NLS-1$
                LogUtil.logInfo("adding: " + desc.getContact().getName());
                invisibleRoot.addChild((ContactDescriptorNode) desc);
            }
        }
        // $NON-NLS-1$
        LogUtil.logInfo("children.length: " + invisibleRoot.getChildrenArray().length);
    }
}
Also used : IContactDescriptor(org.jcryptool.crypto.keystore.descriptors.interfaces.IContactDescriptor)

Example 4 with IContactDescriptor

use of org.jcryptool.crypto.keystore.descriptors.interfaces.IContactDescriptor in project core by jcryptool.

the class ContactManager method init.

private void init() {
    try {
        contactsDesc = loadContacts(getContactStore());
    } catch (Exception ex) {
        LogUtil.logError(KeyStorePlugin.PLUGIN_ID, Messages.ContactManager_6, ex, true);
        return;
    }
    Enumeration<String> aliases = KeyStoreManager.getInstance().getAliases();
    Map<String, List<KeyStoreAlias>> aliasesHashed = new HashMap<String, List<KeyStoreAlias>>();
    while (aliases.hasMoreElements()) {
        KeyStoreAlias alias = new KeyStoreAlias(aliases.nextElement());
        if (!aliasesHashed.containsKey(alias.getContactName())) {
            aliasesHashed.put(alias.getContactName(), new ArrayList<KeyStoreAlias>());
        }
        aliasesHashed.get(alias.getContactName()).add(alias);
    }
    for (Entry<String, IContactDescriptor> entry : contactsDesc.entrySet()) {
        if (aliasesHashed.containsKey(entry.getKey())) {
            for (KeyStoreAlias alias : aliasesHashed.get(entry.getKey())) {
                addEntryToContact(entry.getValue(), alias);
            }
        }
    }
    notifyListeners();
}
Also used : IKeyStoreAlias(org.jcryptool.crypto.keystore.keys.IKeyStoreAlias) KeyStoreAlias(org.jcryptool.crypto.keystore.backend.KeyStoreAlias) IContactDescriptor(org.jcryptool.crypto.keystore.descriptors.interfaces.IContactDescriptor) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) IOException(java.io.IOException) JAXBException(javax.xml.bind.JAXBException) FileNotFoundException(java.io.FileNotFoundException)

Example 5 with IContactDescriptor

use of org.jcryptool.crypto.keystore.descriptors.interfaces.IContactDescriptor in project core by jcryptool.

the class ContactManager method addKeyPair.

public void addKeyPair(IKeyStoreAlias privateKey, IKeyStoreAlias publicKey) {
    // $NON-NLS-1$
    LogUtil.logInfo("Adding key pair " + publicKey.getAliasString());
    if (contactExists(privateKey.getContactName())) {
        contactsDesc.get(privateKey.getContactName()).addKeyPair(privateKey, publicKey);
    } else {
        IContactDescriptor contact = newContact(new Contact(privateKey.getContactName(), null, null, null, null));
        contact.addKeyPair(privateKey, publicKey);
    }
    notifyListeners();
}
Also used : IContactDescriptor(org.jcryptool.crypto.keystore.descriptors.interfaces.IContactDescriptor)

Aggregations

IContactDescriptor (org.jcryptool.crypto.keystore.descriptors.interfaces.IContactDescriptor)6 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 JAXBException (javax.xml.bind.JAXBException)1 KeyStoreAlias (org.jcryptool.crypto.keystore.backend.KeyStoreAlias)1 IKeyStoreAlias (org.jcryptool.crypto.keystore.keys.IKeyStoreAlias)1