Search in sources :

Example 21 with DError

use of org.kse.gui.error.DError in project keystore-explorer by kaikramer.

the class CreateApplicationGui method run.

/**
 * Create and show KeyStore Explorer.
 */
@Override
public void run() {
    try {
        if (!checkJreVersion()) {
            System.exit(1);
        }
        initLookAndFeel(applicationSettings);
        // try to remove crypto restrictions
        JcePolicyUtil.removeRestrictions();
        // if crypto strength still limited, start upgrade assistant
        if (JcePolicyUtil.isLocalPolicyCrytoStrengthLimited()) {
            upgradeCryptoStrength();
        }
        final KseFrame kseFrame = new KseFrame();
        // workaround to a bug in initializing JEditorPane that seems to be a 1-in-10000 problem
        if (Thread.currentThread().getContextClassLoader() == null) {
            Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader());
        }
        if (OperatingSystem.isMacOs()) {
            integrateWithMacOs(kseFrame);
        }
        kseFrame.display();
        // check if stored location of cacerts file still exists
        checkCaCerts(kseFrame);
        // open file list passed via command line params (basically same as if files were dropped on application)
        DroppedFileHandler.openFiles(kseFrame, parameterFiles);
        // start update check in background (disabled if KSE was packaged as rpm)
        if (!Boolean.getBoolean(KseFrame.KSE_UPDATE_CHECK_DISABLED)) {
            checkForUpdates(kseFrame);
        }
    } catch (Throwable t) {
        DError dError = new DError(new JFrame(), t);
        dError.setLocationRelativeTo(null);
        dError.setVisible(true);
        System.exit(1);
    } finally {
        closeSplash();
    }
}
Also used : JFrame(javax.swing.JFrame) DError(org.kse.gui.error.DError)

Example 22 with DError

use of org.kse.gui.error.DError in project keystore-explorer by kaikramer.

the class JKeyIdentifier method editKeyIdentifier.

private void editKeyIdentifier() {
    Container container = getTopLevelAncestor();
    try {
        DKeyIdentifierChooser dKeyIdentifierChooser = null;
        if (container instanceof JDialog) {
            dKeyIdentifierChooser = new DKeyIdentifierChooser((JDialog) container, title, publicKey, keyIdentifier);
            dKeyIdentifierChooser.setLocationRelativeTo(container);
            dKeyIdentifierChooser.setVisible(true);
        } else if (container instanceof JFrame) {
            dKeyIdentifierChooser = new DKeyIdentifierChooser((JFrame) container, title, publicKey, keyIdentifier);
            dKeyIdentifierChooser.setLocationRelativeTo(container);
            dKeyIdentifierChooser.setVisible(true);
        }
        byte[] newKeyIdentifier = dKeyIdentifierChooser.getKeyIdentifier();
        if (newKeyIdentifier == null) {
            return;
        }
        setKeyIdentifier(newKeyIdentifier);
    } catch (CryptoException ex) {
        DError dError = null;
        if (container instanceof JDialog) {
            dError = new DError((JDialog) container, ex);
        } else {
            dError = new DError((JFrame) container, ex);
        }
        dError.setLocationRelativeTo(container);
        dError.setVisible(true);
    }
}
Also used : Container(java.awt.Container) JFrame(javax.swing.JFrame) CryptoException(org.kse.crypto.CryptoException) JDialog(javax.swing.JDialog) DError(org.kse.gui.error.DError)

Example 23 with DError

use of org.kse.gui.error.DError 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)

Example 24 with DError

use of org.kse.gui.error.DError in project keystore-explorer by kaikramer.

the class DViewCertificate method pemEncodingPressed.

private void pemEncodingPressed() {
    X509Certificate cert = getSelectedCertificate();
    try {
        DViewPem dViewCertPem = new DViewPem(this, res.getString("DViewCertificate.Pem.Title"), cert);
        dViewCertPem.setLocationRelativeTo(this);
        dViewCertPem.setVisible(true);
    } catch (CryptoException ex) {
        DError dError = new DError(this, ex);
        dError.setLocationRelativeTo(this);
        dError.setVisible(true);
    }
}
Also used : CryptoException(org.kse.crypto.CryptoException) X509Certificate(java.security.cert.X509Certificate) DError(org.kse.gui.error.DError)

Example 25 with DError

use of org.kse.gui.error.DError in project keystore-explorer by kaikramer.

the class DAddExtensions method editSelectedExtension.

private void editSelectedExtension() {
    try {
        int selectedRow = jtExtensions.getSelectedRow();
        if (selectedRow != -1) {
            String oid = ((ASN1ObjectIdentifier) jtExtensions.getValueAt(selectedRow, 2)).getId();
            X509ExtensionType extensionType = X509ExtensionType.resolveOid(oid);
            byte[] extensionValue = extensions.getExtensionValue(oid);
            boolean isCritical = extensions.getCriticalExtensionOIDs().contains(oid);
            byte[] newExtensionValue = null;
            DExtension dExtension = null;
            switch(extensionType) {
                case AUTHORITY_INFORMATION_ACCESS:
                    {
                        dExtension = new DAuthorityInformationAccess(this, extensionValue);
                        break;
                    }
                case AUTHORITY_KEY_IDENTIFIER:
                    {
                        dExtension = new DAuthorityKeyIdentifier(this, extensionValue, authorityPublicKey);
                        break;
                    }
                case BASIC_CONSTRAINTS:
                    {
                        dExtension = new DBasicConstraints(this, extensionValue);
                        break;
                    }
                case CERTIFICATE_POLICIES:
                    {
                        dExtension = new DCertificatePolicies(this, extensionValue);
                        break;
                    }
                case EXTENDED_KEY_USAGE:
                    {
                        dExtension = new DExtendedKeyUsage(this, extensionValue);
                        break;
                    }
                case INHIBIT_ANY_POLICY:
                    {
                        dExtension = new DInhibitAnyPolicy(this, extensionValue);
                        break;
                    }
                case ISSUER_ALTERNATIVE_NAME:
                    {
                        dExtension = new DIssuerAlternativeName(this, extensionValue);
                        break;
                    }
                case KEY_USAGE:
                    {
                        dExtension = new DKeyUsage(this, extensionValue);
                        break;
                    }
                case NAME_CONSTRAINTS:
                    {
                        dExtension = new DNameConstraints(this, extensionValue);
                        break;
                    }
                case NETSCAPE_BASE_URL:
                    {
                        dExtension = new DNetscapeBaseUrl(this, extensionValue);
                        break;
                    }
                case NETSCAPE_CERTIFICATE_RENEWAL_URL:
                    {
                        dExtension = new DNetscapeCertificateRenewalUrl(this, extensionValue);
                        break;
                    }
                case NETSCAPE_CA_POLICY_URL:
                    {
                        dExtension = new DNetscapeCaPolicyUrl(this, extensionValue);
                        break;
                    }
                case NETSCAPE_CA_REVOCATION_URL:
                    {
                        dExtension = new DNetscapeCaRevocationUrl(this, extensionValue);
                        break;
                    }
                case NETSCAPE_CERTIFICATE_TYPE:
                    {
                        dExtension = new DNetscapeCertificateType(this, extensionValue);
                        break;
                    }
                case NETSCAPE_COMMENT:
                    {
                        dExtension = new DNetscapeComment(this, extensionValue);
                        break;
                    }
                case NETSCAPE_REVOCATION_URL:
                    {
                        dExtension = new DNetscapeRevocationUrl(this, extensionValue);
                        break;
                    }
                case NETSCAPE_SSL_SERVER_NAME:
                    {
                        dExtension = new DNetscapeSslServerName(this, extensionValue);
                        break;
                    }
                case POLICY_CONSTRAINTS:
                    {
                        dExtension = new DPolicyConstraints(this, extensionValue);
                        break;
                    }
                case POLICY_MAPPINGS:
                    {
                        dExtension = new DPolicyMappings(this, extensionValue);
                        break;
                    }
                case PRIVATE_KEY_USAGE_PERIOD:
                    {
                        dExtension = new DPrivateKeyUsagePeriod(this, extensionValue);
                        break;
                    }
                case SUBJECT_ALTERNATIVE_NAME:
                    {
                        dExtension = new DSubjectAlternativeName(this, extensionValue);
                        break;
                    }
                case SUBJECT_INFORMATION_ACCESS:
                    {
                        dExtension = new DSubjectInformationAccess(this, extensionValue);
                        break;
                    }
                case SUBJECT_KEY_IDENTIFIER:
                    {
                        dExtension = new DSubjectKeyIdentifier(this, extensionValue, subjectPublicKey);
                        break;
                    }
                default:
                    {
                        return;
                    }
            }
            dExtension.setLocationRelativeTo(this);
            dExtension.setVisible(true);
            newExtensionValue = dExtension.getValue();
            if (newExtensionValue == null) {
                return;
            }
            extensions.addExtension(oid, isCritical, newExtensionValue);
            reloadExtensionsTable();
            selectExtensionInTable(oid);
            updateButtonControls();
        }
    } catch (IOException ex) {
        DError dError = new DError(this, ex);
        dError.setLocationRelativeTo(this);
        dError.setVisible(true);
    }
}
Also used : IOException(java.io.IOException) Point(java.awt.Point) DError(org.kse.gui.error.DError) X509ExtensionType(org.kse.crypto.x509.X509ExtensionType) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier)

Aggregations

DError (org.kse.gui.error.DError)52 IOException (java.io.IOException)38 CryptoException (org.kse.crypto.CryptoException)11 DERIA5String (org.bouncycastle.asn1.DERIA5String)9 JFrame (javax.swing.JFrame)8 ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)8 Asn1Exception (org.kse.utilities.asn1.Asn1Exception)7 Container (java.awt.Container)6 JDialog (javax.swing.JDialog)6 X509Certificate (java.security.cert.X509Certificate)4 ASN1EncodableVector (org.bouncycastle.asn1.ASN1EncodableVector)4 DERSequence (org.bouncycastle.asn1.DERSequence)4 GeneralNames (org.bouncycastle.asn1.x509.GeneralNames)4 PolicyInformation (org.bouncycastle.asn1.x509.PolicyInformation)4 PolicyQualifierInfo (org.bouncycastle.asn1.x509.PolicyQualifierInfo)4 JGeneralNames (org.kse.gui.crypto.generalname.JGeneralNames)4 Point (java.awt.Point)3 BigInteger (java.math.BigInteger)3 Date (java.util.Date)3 ArrayList (java.util.ArrayList)2