use of org.jcryptool.crypto.keystore.backend.KeyStoreAlias in project core by jcryptool.
the class IntegratorWizardPage method getKeyItems.
private String[] getKeyItems() {
Vector<KeyStoreAlias> map;
if (encrypt) {
if (publicKeyMap.isEmpty() || privateKeyMap.isEmpty())
if (showPaddingGroup) {
// {Messages.getString("DummyWizardPage.15")}; //$NON-NLS-1$
return new String[0];
} else {
// {Messages.getString("DummyWizardPage.25")}; //$NON-NLS-1$
return new String[0];
}
map = publicKeyMap;
} else {
if (publicKeyMap.isEmpty() || privateKeyMap.isEmpty())
if (showPaddingGroup) {
// {Messages.getString("DummyWizardPage.15")}; //$NON-NLS-1$
return new String[0];
} else {
// {Messages.getString("DummyWizardPage.26")}; //$NON-NLS-1$
return new String[0];
}
map = privateKeyMap;
}
String[] items = new String[map.size()];
int i = 0;
for (KeyStoreAlias item : map) {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
items[i++] = "\"" + item.getContactName() + "\" - " + translateKeyStoreEntryType(item.getKeyStoreEntryType().getType()) + " - " + item.getKeyLength() + " bit";
}
return items;
}
use of org.jcryptool.crypto.keystore.backend.KeyStoreAlias in project core by jcryptool.
the class KeyDropListener method drop.
public void drop(DropTargetEvent event) {
Widget item = event.item;
Object tmp = event.data;
if (item != null && tmp != null) {
if (item instanceof TreeItem) {
entryNode = getTopLevel((TreeNode) ((TreeItem) item).getData());
// $NON-NLS-1$
LogUtil.logInfo("target: " + entryNode.getTimestamp());
entryNode.setKeyStoreAlias(new KeyStoreAlias((String) tmp));
}
} else {
// $NON-NLS-1$
LogUtil.logInfo("item is null");
}
}
use of org.jcryptool.crypto.keystore.backend.KeyStoreAlias in project core by jcryptool.
the class OperationsViewEntryRootElement method getEntryNodes.
@SuppressWarnings("unchecked")
public List<EntryNode> getEntryNodes() {
List<EntryNode> nodes = new ArrayList<EntryNode>();
// $NON-NLS-1$
Iterator<Element> it = getChildren("Entry").iterator();
while (it.hasNext()) {
Element element = it.next();
// $NON-NLS-1$
String name = element.getAttributeValue("name");
// $NON-NLS-1$
long timestamp = Long.valueOf(element.getAttributeValue("timestamp"));
// algorithm
AlgorithmDescriptor descriptor = null;
if (element.getChild("AlgorithmDescriptor") != null) {
// $NON-NLS-1$
// $NON-NLS-1$
AlgorithmDescriptorElement descriptorElement = new AlgorithmDescriptorElement(element.getChild("AlgorithmDescriptor"));
descriptor = descriptorElement.getDescriptor();
} else if (element.getChild("SecureRandomDescriptor") != null) {
// $NON-NLS-1$
// $NON-NLS-1$
SecureRandomDescriptorElement descriptorElement = new SecureRandomDescriptorElement(element.getChild("SecureRandomDescriptor"));
descriptor = descriptorElement.getDescriptor();
} else if (element.getChild("BlockCipherDescriptor") != null) {
// $NON-NLS-1$
// $NON-NLS-1$
BlockCipherDescriptorElement descriptorElement = new BlockCipherDescriptorElement(element.getChild("BlockCipherDescriptor"));
descriptor = descriptorElement.getDescriptor();
}
EntryNode entryNode = new EntryNode(name, timestamp, descriptor);
nodes.add(entryNode);
// supplemental information below
// key
KeyStoreAlias alias = null;
if (element.getChild("Key") != null) {
// $NON-NLS-1$
// $NON-NLS-1$
KeyElement keyElement = new KeyElement(element.getChild("Key"));
alias = keyElement.getAlias();
entryNode.setKeyStoreAlias(alias);
}
// operation
OperationType type = null;
if (element.getChild("Operation") != null) {
// $NON-NLS-1$
// $NON-NLS-1$
OperationElement opsElement = new OperationElement(element.getChild("Operation"));
type = opsElement.getOperationType();
if (!type.equals(OperationType.UNKNOWN)) {
entryNode.setOperation(type);
}
}
// i/o
String input = null;
String output = null;
String signature = null;
if (element.getChild("Output") != null) {
// $NON-NLS-1$
// $NON-NLS-1$
OutputElement outElement = new OutputElement(element.getChild("Output"));
output = outElement.getOutput();
entryNode.setOutput(output);
} else if (element.getChild("InputOutput") != null) {
// $NON-NLS-1$
// $NON-NLS-1$
InputOutputElement inOutElement = new InputOutputElement(element.getChild("InputOutput"));
input = inOutElement.getInput();
output = inOutElement.getOutput();
entryNode.setInput(input);
entryNode.setOutput(output);
} else if (element.getChild("InputSignature") != null) {
// $NON-NLS-1$
// $NON-NLS-1$
InputSignatureElement inSigElement = new InputSignatureElement(element.getChild("InputSignature"));
input = inSigElement.getInput();
signature = inSigElement.getSignature();
entryNode.setInput(input);
entryNode.setSignature(signature);
}
}
return nodes;
}
use of org.jcryptool.crypto.keystore.backend.KeyStoreAlias in project core by jcryptool.
the class AbstractKeyStoreHandler method addKeyPairStatic.
public static KeyStoreAlias addKeyPairStatic(INewEntryDescriptor descriptor, PrivateKey privateKey, PublicKey publicKey) {
KeyStoreAlias privateAlias = new KeyStoreAlias(descriptor.getContactName(), KeyType.KEYPAIR_PRIVATE_KEY, descriptor.getDisplayedName(), descriptor.getKeyLength(), ByteArrayUtils.toHexString(getHashValue(descriptor)), privateKey.getClass().getName());
KeyStoreAlias publicAlias = new KeyStoreAlias(descriptor.getContactName(), KeyType.KEYPAIR_PUBLIC_KEY, descriptor.getDisplayedName(), descriptor.getKeyLength(), ByteArrayUtils.toHexString(getHashValue(descriptor)), publicKey.getClass().getName());
X509Certificate jctCertificate = CertificateFactory.createJCrypToolCertificate(publicKey);
KeyStoreManager.getInstance().addKeyPair(privateKey, jctCertificate, descriptor.getPassword().toCharArray(), privateAlias, publicAlias);
return publicAlias;
}
use of org.jcryptool.crypto.keystore.backend.KeyStoreAlias 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();
}
Aggregations