Search in sources :

Example 6 with KeyStoreAlias

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;
}
Also used : KeyStoreAlias(org.jcryptool.crypto.keystore.backend.KeyStoreAlias)

Example 7 with KeyStoreAlias

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");
    }
}
Also used : KeyStoreAlias(org.jcryptool.crypto.keystore.backend.KeyStoreAlias) TreeItem(org.eclipse.swt.widgets.TreeItem) TreeNode(org.jcryptool.crypto.flexiprovider.ui.nodes.TreeNode) ITreeNode(org.jcryptool.crypto.flexiprovider.ui.nodes.ITreeNode) Widget(org.eclipse.swt.widgets.Widget)

Example 8 with KeyStoreAlias

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;
}
Also used : AlgorithmDescriptorElement(org.jcryptool.crypto.flexiprovider.operations.xml.algorithms.AlgorithmDescriptorElement) OperationElement(org.jcryptool.crypto.flexiprovider.operations.xml.ops.OperationElement) KeyStoreAlias(org.jcryptool.crypto.keystore.backend.KeyStoreAlias) SecureRandomDescriptorElement(org.jcryptool.crypto.flexiprovider.operations.xml.algorithms.SecureRandomDescriptorElement) AlgorithmDescriptorElement(org.jcryptool.crypto.flexiprovider.operations.xml.algorithms.AlgorithmDescriptorElement) InputSignatureElement(org.jcryptool.crypto.flexiprovider.operations.xml.io.InputSignatureElement) InputOutputElement(org.jcryptool.crypto.flexiprovider.operations.xml.io.InputOutputElement) BlockCipherDescriptorElement(org.jcryptool.crypto.flexiprovider.operations.xml.algorithms.BlockCipherDescriptorElement) OperationElement(org.jcryptool.crypto.flexiprovider.operations.xml.ops.OperationElement) KeyElement(org.jcryptool.crypto.flexiprovider.operations.xml.keys.KeyElement) OutputElement(org.jcryptool.crypto.flexiprovider.operations.xml.io.OutputElement) Element(org.jdom.Element) EntryNode(org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.EntryNode) ArrayList(java.util.ArrayList) InputOutputElement(org.jcryptool.crypto.flexiprovider.operations.xml.io.InputOutputElement) AlgorithmDescriptor(org.jcryptool.crypto.flexiprovider.descriptors.algorithms.AlgorithmDescriptor) SecureRandomDescriptorElement(org.jcryptool.crypto.flexiprovider.operations.xml.algorithms.SecureRandomDescriptorElement) KeyElement(org.jcryptool.crypto.flexiprovider.operations.xml.keys.KeyElement) InputOutputElement(org.jcryptool.crypto.flexiprovider.operations.xml.io.InputOutputElement) OutputElement(org.jcryptool.crypto.flexiprovider.operations.xml.io.OutputElement) InputSignatureElement(org.jcryptool.crypto.flexiprovider.operations.xml.io.InputSignatureElement) BlockCipherDescriptorElement(org.jcryptool.crypto.flexiprovider.operations.xml.algorithms.BlockCipherDescriptorElement) OperationType(org.jcryptool.crypto.flexiprovider.types.OperationType)

Example 9 with KeyStoreAlias

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;
}
Also used : KeyStoreAlias(org.jcryptool.crypto.keystore.backend.KeyStoreAlias) X509Certificate(java.security.cert.X509Certificate)

Example 10 with KeyStoreAlias

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

Aggregations

KeyStoreAlias (org.jcryptool.crypto.keystore.backend.KeyStoreAlias)11 ArrayList (java.util.ArrayList)2 Observable (java.util.Observable)2 Observer (java.util.Observer)2 IJobChangeEvent (org.eclipse.core.runtime.jobs.IJobChangeEvent)2 IJobChangeListener (org.eclipse.core.runtime.jobs.IJobChangeListener)2 Job (org.eclipse.core.runtime.jobs.Job)2 AlgorithmDescriptor (org.jcryptool.crypto.flexiprovider.descriptors.algorithms.AlgorithmDescriptor)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 X509Certificate (java.security.cert.X509Certificate)1 HashMap (java.util.HashMap)1 List (java.util.List)1 JAXBException (javax.xml.bind.JAXBException)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 TreeItem (org.eclipse.swt.widgets.TreeItem)1 Widget (org.eclipse.swt.widgets.Widget)1