Search in sources :

Example 1 with DNewKeyStoreType

use of org.kse.gui.dialogs.DNewKeyStoreType in project keystore-explorer by kaikramer.

the class OpenCaCertificatesAction method doAction.

/**
 * Do action.
 */
@Override
protected void doAction() {
    File caCertificatesFile = applicationSettings.getCaCertificatesFile();
    if (caCertificatesFile.isFile()) {
        openKeyStore(caCertificatesFile, AuthorityCertificates.CACERTS_DEFAULT_PWD);
        return;
    }
    int selected = JOptionPane.showConfirmDialog(frame, res.getString("OpenCaCertificatesAction.NoCaCertificatesKeyStoreCreate.message"), res.getString("OpenCaCertificatesAction.OpenCaCertificatesKeyStore.Title"), JOptionPane.YES_NO_OPTION);
    if (selected != JOptionPane.YES_OPTION) {
        return;
    }
    try {
        DNewKeyStoreType dNewKeyStoreType = new DNewKeyStoreType(frame);
        dNewKeyStoreType.setLocationRelativeTo(frame);
        dNewKeyStoreType.setVisible(true);
        KeyStoreType keyStoreType = dNewKeyStoreType.getKeyStoreType();
        if (keyStoreType == null) {
            return;
        }
        Password password = getNewKeyStorePassword();
        if (password == null) {
            return;
        }
        KeyStore caCertificatesKeyStore = KeyStoreUtil.create(keyStoreType);
        KeyStoreUtil.save(caCertificatesKeyStore, caCertificatesFile, password);
        kseFrame.addKeyStore(caCertificatesKeyStore, caCertificatesFile, password);
    } catch (Exception ex) {
        DError.displayError(frame, ex);
    }
}
Also used : DNewKeyStoreType(org.kse.gui.dialogs.DNewKeyStoreType) KeyStoreType(org.kse.crypto.keystore.KeyStoreType) DNewKeyStoreType(org.kse.gui.dialogs.DNewKeyStoreType) File(java.io.File) KeyStore(java.security.KeyStore) Password(org.kse.crypto.Password)

Example 2 with DNewKeyStoreType

use of org.kse.gui.dialogs.DNewKeyStoreType in project keystore-explorer by kaikramer.

the class OpenDefaultAction method doAction.

/**
 * Do action.
 */
@Override
protected void doAction() {
    File defaultKeyStoreFile = new File(System.getProperty("user.home"), ".keystore");
    if (defaultKeyStoreFile.isFile()) {
        openKeyStore(defaultKeyStoreFile);
        return;
    }
    int selected = JOptionPane.showConfirmDialog(frame, res.getString("OpenDefaultAction.NoDefaultKeyStoreCreate.message"), res.getString("OpenDefaultAction.OpenDefaultKeyStore.Title"), JOptionPane.YES_NO_OPTION);
    if (selected != JOptionPane.YES_OPTION) {
        return;
    }
    try {
        DNewKeyStoreType dNewKeyStoreType = new DNewKeyStoreType(frame);
        dNewKeyStoreType.setLocationRelativeTo(frame);
        dNewKeyStoreType.setVisible(true);
        KeyStoreType keyStoreType = dNewKeyStoreType.getKeyStoreType();
        if (keyStoreType == null) {
            return;
        }
        Password password = getNewKeyStorePassword();
        if (password == null) {
            return;
        }
        KeyStore defaultKeyStore = KeyStoreUtil.create(keyStoreType);
        KeyStoreUtil.save(defaultKeyStore, defaultKeyStoreFile, password);
        kseFrame.addKeyStore(defaultKeyStore, defaultKeyStoreFile, password);
    } catch (Exception ex) {
        DError.displayError(frame, ex);
    }
}
Also used : DNewKeyStoreType(org.kse.gui.dialogs.DNewKeyStoreType) KeyStoreType(org.kse.crypto.keystore.KeyStoreType) DNewKeyStoreType(org.kse.gui.dialogs.DNewKeyStoreType) File(java.io.File) KeyStore(java.security.KeyStore) Password(org.kse.crypto.Password)

Example 3 with DNewKeyStoreType

use of org.kse.gui.dialogs.DNewKeyStoreType in project keystore-explorer by kaikramer.

the class NewAction method doAction.

/**
 * Do action.
 */
@Override
protected void doAction() {
    try {
        DNewKeyStoreType dNewKeyStoreType = new DNewKeyStoreType(frame);
        dNewKeyStoreType.setLocationRelativeTo(frame);
        dNewKeyStoreType.setVisible(true);
        KeyStoreType keyStoreType = dNewKeyStoreType.getKeyStoreType();
        if (keyStoreType == null) {
            return;
        }
        KeyStore newKeyStore = KeyStoreUtil.create(keyStoreType);
        untitledCount++;
        String untitled = MessageFormat.format(res.getString("NewAction.Untitled"), untitledCount);
        kseFrame.addKeyStore(newKeyStore, untitled, null, null);
    } catch (Exception ex) {
        DError.displayError(frame, ex);
    }
}
Also used : DNewKeyStoreType(org.kse.gui.dialogs.DNewKeyStoreType) KeyStoreType(org.kse.crypto.keystore.KeyStoreType) DNewKeyStoreType(org.kse.gui.dialogs.DNewKeyStoreType) KeyStore(java.security.KeyStore)

Aggregations

KeyStore (java.security.KeyStore)3 KeyStoreType (org.kse.crypto.keystore.KeyStoreType)3 DNewKeyStoreType (org.kse.gui.dialogs.DNewKeyStoreType)3 File (java.io.File)2 Password (org.kse.crypto.Password)2