Search in sources :

Example 1 with DViewSecretKey

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

the class KeyDetailsAction method showKeySelectedEntry.

/**
 * Show the key details of the selected KeyStore entry.
 */
public void showKeySelectedEntry() {
    try {
        KeyStoreHistory history = kseFrame.getActiveKeyStoreHistory();
        KeyStoreState currentState = history.getCurrentState();
        String alias = kseFrame.getSelectedEntryAlias();
        Password password = getEntryPassword(alias, currentState);
        if (password == null) {
            return;
        }
        KeyStore keyStore = currentState.getKeyStore();
        Key key = keyStore.getKey(alias, password.toCharArray());
        if (key instanceof SecretKey) {
            SecretKey secretKey = (SecretKey) key;
            DViewSecretKey dViewSecretKey = new DViewSecretKey(frame, MessageFormat.format(res.getString("KeyDetailsAction.SecretKeyDetailsEntry.Title"), alias), secretKey);
            dViewSecretKey.setLocationRelativeTo(frame);
            dViewSecretKey.setVisible(true);
        } else if (key instanceof PrivateKey) {
            PrivateKey privateKey = (PrivateKey) key;
            DViewPrivateKey dViewPrivateKey = new DViewPrivateKey(frame, MessageFormat.format(res.getString("KeyDetailsAction.PrivateKeyDetailsEntry.Title"), alias), privateKey, history.getExplicitProvider());
            dViewPrivateKey.setLocationRelativeTo(frame);
            dViewPrivateKey.setVisible(true);
        } else if (key instanceof PublicKey) {
            PublicKey publicKey = (PublicKey) key;
            DViewPublicKey dViewPublicKey = new DViewPublicKey(frame, MessageFormat.format(res.getString("KeyDetailsAction.PublicKeyDetailsEntry.Title"), alias), publicKey);
            dViewPublicKey.setLocationRelativeTo(frame);
            dViewPublicKey.setVisible(true);
        }
    } catch (Exception ex) {
        DError.displayError(frame, ex);
    }
}
Also used : KeyStoreState(org.kse.utilities.history.KeyStoreState) KeyStoreHistory(org.kse.utilities.history.KeyStoreHistory) DViewSecretKey(org.kse.gui.dialogs.DViewSecretKey) PrivateKey(java.security.PrivateKey) DViewPrivateKey(org.kse.gui.dialogs.DViewPrivateKey) PublicKey(java.security.PublicKey) DViewPublicKey(org.kse.gui.dialogs.DViewPublicKey) DViewPrivateKey(org.kse.gui.dialogs.DViewPrivateKey) KeyStore(java.security.KeyStore) DViewSecretKey(org.kse.gui.dialogs.DViewSecretKey) SecretKey(javax.crypto.SecretKey) DViewPublicKey(org.kse.gui.dialogs.DViewPublicKey) DViewSecretKey(org.kse.gui.dialogs.DViewSecretKey) PublicKey(java.security.PublicKey) DViewPublicKey(org.kse.gui.dialogs.DViewPublicKey) Key(java.security.Key) PrivateKey(java.security.PrivateKey) SecretKey(javax.crypto.SecretKey) DViewPrivateKey(org.kse.gui.dialogs.DViewPrivateKey) Password(org.kse.crypto.Password)

Aggregations

Key (java.security.Key)1 KeyStore (java.security.KeyStore)1 PrivateKey (java.security.PrivateKey)1 PublicKey (java.security.PublicKey)1 SecretKey (javax.crypto.SecretKey)1 Password (org.kse.crypto.Password)1 DViewPrivateKey (org.kse.gui.dialogs.DViewPrivateKey)1 DViewPublicKey (org.kse.gui.dialogs.DViewPublicKey)1 DViewSecretKey (org.kse.gui.dialogs.DViewSecretKey)1 KeyStoreHistory (org.kse.utilities.history.KeyStoreHistory)1 KeyStoreState (org.kse.utilities.history.KeyStoreState)1