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;
}
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();
}
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);
}
}
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();
}
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();
}
Aggregations