Search in sources :

Example 1 with DViewPublicKey

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

the class ExamineFileAction method openPublicKey.

private void openPublicKey(File file) throws IOException, CryptoException {
    PublicKey publicKey = OpenSslPubUtil.load(new FileInputStream(file));
    DViewPublicKey dViewPublicKey = new DViewPublicKey(frame, MessageFormat.format(res.getString("ExamineFileAction.PublicKeyDetailsFile.Title"), file.getName()), publicKey);
    dViewPublicKey.setLocationRelativeTo(frame);
    dViewPublicKey.setVisible(true);
}
Also used : DViewPublicKey(org.kse.gui.dialogs.DViewPublicKey) PublicKey(java.security.PublicKey) DViewPublicKey(org.kse.gui.dialogs.DViewPublicKey) FileInputStream(java.io.FileInputStream)

Example 2 with DViewPublicKey

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

the class TrustedCertificatePublicKeyDetailsAction method doAction.

/**
 * Do action.
 */
@Override
protected void doAction() {
    try {
        KeyStoreHistory history = kseFrame.getActiveKeyStoreHistory();
        KeyStoreState currentState = history.getCurrentState();
        KeyStore keyStore = currentState.getKeyStore();
        String alias = kseFrame.getSelectedEntryAlias();
        PublicKey pubKey = keyStore.getCertificate(alias).getPublicKey();
        DViewPublicKey dViewPublicKey = new DViewPublicKey(frame, MessageFormat.format(res.getString("TrustedCertificatePublicKeyDetailsAction.PubKeyDetailsEntry.Title"), alias), pubKey);
        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) DViewPublicKey(org.kse.gui.dialogs.DViewPublicKey) PublicKey(java.security.PublicKey) DViewPublicKey(org.kse.gui.dialogs.DViewPublicKey) KeyStore(java.security.KeyStore)

Example 3 with DViewPublicKey

use of org.kse.gui.dialogs.DViewPublicKey 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)

Example 4 with DViewPublicKey

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

the class KeyPairPublicKeyDetailsAction method doAction.

/**
 * Do action.
 */
@Override
protected void doAction() {
    try {
        KeyStoreHistory history = kseFrame.getActiveKeyStoreHistory();
        KeyStoreState currentState = history.getCurrentState();
        KeyStore keyStore = currentState.getKeyStore();
        String alias = kseFrame.getSelectedEntryAlias();
        PublicKey pubKey = X509CertUtil.orderX509CertChain(X509CertUtil.convertCertificates(keyStore.getCertificateChain(alias)))[0].getPublicKey();
        DViewPublicKey dViewPublicKey = new DViewPublicKey(frame, MessageFormat.format(res.getString("KeyPairPublicKeyDetailsAction.PubKeyDetailsEntry.Title"), alias), pubKey);
        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) DViewPublicKey(org.kse.gui.dialogs.DViewPublicKey) PublicKey(java.security.PublicKey) DViewPublicKey(org.kse.gui.dialogs.DViewPublicKey) KeyStore(java.security.KeyStore)

Example 5 with DViewPublicKey

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

the class DSignCsr method pubKeyDetailsPressed.

private void pubKeyDetailsPressed() {
    try {
        DViewPublicKey dViewPublicKey = new DViewPublicKey(this, res.getString("DSignCsr.PubKeyDetails.Title"), csrPublicKey);
        dViewPublicKey.setLocationRelativeTo(this);
        dViewPublicKey.setVisible(true);
    } catch (CryptoException ex) {
        DError dError = new DError(this, ex);
        dError.setLocationRelativeTo(this);
        dError.setVisible(true);
    }
}
Also used : DViewPublicKey(org.kse.gui.dialogs.DViewPublicKey) CryptoException(org.kse.crypto.CryptoException) DError(org.kse.gui.error.DError)

Aggregations

DViewPublicKey (org.kse.gui.dialogs.DViewPublicKey)5 PublicKey (java.security.PublicKey)4 KeyStore (java.security.KeyStore)3 KeyStoreHistory (org.kse.utilities.history.KeyStoreHistory)3 KeyStoreState (org.kse.utilities.history.KeyStoreState)3 FileInputStream (java.io.FileInputStream)1 Key (java.security.Key)1 PrivateKey (java.security.PrivateKey)1 SecretKey (javax.crypto.SecretKey)1 CryptoException (org.kse.crypto.CryptoException)1 Password (org.kse.crypto.Password)1 DViewPrivateKey (org.kse.gui.dialogs.DViewPrivateKey)1 DViewSecretKey (org.kse.gui.dialogs.DViewSecretKey)1 DError (org.kse.gui.error.DError)1