Search in sources :

Example 46 with CryptoException

use of org.kse.crypto.CryptoException in project keystore-explorer by kaikramer.

the class ExportKeyPairCertificateChainAction method getCertificateChain.

private X509Certificate[] getCertificateChain(String alias) throws CryptoException {
    try {
        KeyStoreHistory history = kseFrame.getActiveKeyStoreHistory();
        KeyStore keyStore = history.getCurrentState().getKeyStore();
        X509Certificate[] certChain = X509CertUtil.convertCertificates(keyStore.getCertificateChain(alias));
        return certChain;
    } catch (KeyStoreException ex) {
        String message = MessageFormat.format(res.getString("ExportKeyPairCertificateChainAction.NoAccessEntry.message"), alias);
        throw new CryptoException(message, ex);
    }
}
Also used : KeyStoreHistory(org.kse.utilities.history.KeyStoreHistory) KeyStoreException(java.security.KeyStoreException) CryptoException(org.kse.crypto.CryptoException) KeyStore(java.security.KeyStore) X509Certificate(java.security.cert.X509Certificate)

Example 47 with CryptoException

use of org.kse.crypto.CryptoException in project keystore-explorer by kaikramer.

the class DImportKeyPairOpenSsl method privateKeyDetailsPressed.

private void privateKeyDetailsPressed() {
    try {
        String path = new File(jtfPrivateKeyPath.getText()).getName();
        PrivateKey privateKey = loadPrivateKey();
        if (privateKey != null) {
            DViewPrivateKey dViewPrivateKey = new DViewPrivateKey(this, MessageFormat.format(res.getString("DImportKeyPairOpenSsl.ViewPrivateKeyDetails.Title"), path), privateKey, new BouncyCastleProvider());
            dViewPrivateKey.setLocationRelativeTo(this);
            dViewPrivateKey.setVisible(true);
        }
    } catch (CryptoException ex) {
        DError.displayError(this, ex);
    }
}
Also used : PrivateKey(java.security.PrivateKey) DViewPrivateKey(org.kse.gui.dialogs.DViewPrivateKey) DViewPrivateKey(org.kse.gui.dialogs.DViewPrivateKey) CryptoException(org.kse.crypto.CryptoException) File(java.io.File) BouncyCastleProvider(org.bouncycastle.jce.provider.BouncyCastleProvider)

Example 48 with CryptoException

use of org.kse.crypto.CryptoException in project keystore-explorer by kaikramer.

the class DImportKeyPairOpenSsl method certificateDetailsPressed.

private void certificateDetailsPressed() {
    try {
        X509Certificate[] certs = loadCertificates();
        if ((certs != null) && (certs.length != 0)) {
            String path = new File(jtfCertificatePath.getText()).getName();
            DViewCertificate dViewCertificate = new DViewCertificate(this, MessageFormat.format(res.getString("DImportKeyPairOpenSsl.ViewCertificateDetails.Title"), path), certs, null, DViewCertificate.NONE);
            dViewCertificate.setLocationRelativeTo(this);
            dViewCertificate.setVisible(true);
        }
    } catch (CryptoException ex) {
        DError.displayError(this, ex);
    }
}
Also used : DViewCertificate(org.kse.gui.dialogs.DViewCertificate) CryptoException(org.kse.crypto.CryptoException) File(java.io.File) X509Certificate(java.security.cert.X509Certificate)

Example 49 with CryptoException

use of org.kse.crypto.CryptoException in project keystore-explorer by kaikramer.

the class DImportKeyPairPkcs8 method privateKeyDetailsPressed.

private void privateKeyDetailsPressed() {
    try {
        String path = new File(jtfPrivateKeyPath.getText()).getName();
        PrivateKey privateKey = loadPrivateKey();
        if (privateKey != null) {
            DViewPrivateKey dViewPrivateKey = new DViewPrivateKey(this, MessageFormat.format(res.getString("DImportKeyPairPkcs8.ViewPrivateKeyDetails.Title"), path), privateKey, new BouncyCastleProvider());
            dViewPrivateKey.setLocationRelativeTo(this);
            dViewPrivateKey.setVisible(true);
        }
    } catch (CryptoException ex) {
        DError.displayError(this, ex);
    }
}
Also used : PrivateKey(java.security.PrivateKey) DViewPrivateKey(org.kse.gui.dialogs.DViewPrivateKey) DViewPrivateKey(org.kse.gui.dialogs.DViewPrivateKey) CryptoException(org.kse.crypto.CryptoException) File(java.io.File) BouncyCastleProvider(org.bouncycastle.jce.provider.BouncyCastleProvider)

Example 50 with CryptoException

use of org.kse.crypto.CryptoException in project keystore-explorer by kaikramer.

the class DImportKeyPairPvk method certificateDetailsPressed.

private void certificateDetailsPressed() {
    try {
        X509Certificate[] certs = loadCertificates();
        if ((certs != null) && (certs.length != 0)) {
            String path = new File(jtfCertificatePath.getText()).getName();
            DViewCertificate dViewCertificate = new DViewCertificate(this, MessageFormat.format(res.getString("DImportKeyPairPvk.ViewCertificateDetails.Title"), path), certs, null, DViewCertificate.NONE);
            dViewCertificate.setLocationRelativeTo(this);
            dViewCertificate.setVisible(true);
        }
    } catch (CryptoException ex) {
        DError.displayError(this, ex);
    }
}
Also used : DViewCertificate(org.kse.gui.dialogs.DViewCertificate) CryptoException(org.kse.crypto.CryptoException) File(java.io.File) X509Certificate(java.security.cert.X509Certificate)

Aggregations

CryptoException (org.kse.crypto.CryptoException)80 GeneralSecurityException (java.security.GeneralSecurityException)22 IOException (java.io.IOException)21 X509Certificate (java.security.cert.X509Certificate)21 KeyStore (java.security.KeyStore)16 KeyStoreException (java.security.KeyStoreException)13 BigInteger (java.math.BigInteger)11 DError (org.kse.gui.error.DError)10 ByteArrayInputStream (java.io.ByteArrayInputStream)9 File (java.io.File)9 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)9 ByteBuffer (java.nio.ByteBuffer)8 CertificateException (java.security.cert.CertificateException)8 PrivateKey (java.security.PrivateKey)7 KeyFactory (java.security.KeyFactory)6 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)6 CertificateFactory (java.security.cert.CertificateFactory)6 DSAPrivateKey (java.security.interfaces.DSAPrivateKey)6 RSAPrivateCrtKey (java.security.interfaces.RSAPrivateCrtKey)6 Cipher (javax.crypto.Cipher)6