Search in sources :

Example 26 with DError

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

the class DAuthorityInformationAccess method okPressed.

private void okPressed() {
    List<AccessDescription> accessDescriptions = jadAccessDescriptions.getAccessDescriptions();
    if (accessDescriptions.size() == 0) {
        JOptionPane.showMessageDialog(this, res.getString("DAuthorityInformationAccess.ValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
        return;
    }
    ASN1EncodableVector vec = new ASN1EncodableVector();
    for (AccessDescription accessDescription : accessDescriptions) {
        vec.add(accessDescription);
    }
    AuthorityInformationAccess authorityInformationAccess = AuthorityInformationAccess.getInstance(new DERSequence(vec));
    try {
        value = authorityInformationAccess.getEncoded(ASN1Encoding.DER);
    } catch (IOException ex) {
        DError dError = new DError(this, ex);
        dError.setLocationRelativeTo(this);
        dError.setVisible(true);
        return;
    }
    closeDialog();
}
Also used : AuthorityInformationAccess(org.bouncycastle.asn1.x509.AuthorityInformationAccess) DERSequence(org.bouncycastle.asn1.DERSequence) AccessDescription(org.bouncycastle.asn1.x509.AccessDescription) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector) IOException(java.io.IOException) DError(org.kse.gui.error.DError)

Example 27 with DError

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

the class DAuthorityKeyIdentifier method prepopulateWithAuthorityCertDetails.

private void prepopulateWithAuthorityCertDetails(X500Name authorityCertName, BigInteger authorityCertSerialNumber) {
    if (authorityCertName != null) {
        try {
            GeneralName generalName = new GeneralName(GeneralName.directoryName, authorityCertName);
            GeneralNames generalNames = new GeneralNames(generalName);
            jgnAuthorityCertIssuer.setGeneralNames(generalNames);
        } catch (Exception ex) {
            DError dError = new DError(this, ex);
            dError.setLocationRelativeTo(this);
            dError.setVisible(true);
            return;
        }
    }
    if (authorityCertSerialNumber != null) {
        jtfAuthorityCertSerialNumber.setText("" + authorityCertSerialNumber.toString());
        jtfAuthorityCertSerialNumber.setCaretPosition(0);
    }
}
Also used : JGeneralNames(org.kse.gui.crypto.generalname.JGeneralNames) GeneralNames(org.bouncycastle.asn1.x509.GeneralNames) GeneralName(org.bouncycastle.asn1.x509.GeneralName) IOException(java.io.IOException) DError(org.kse.gui.error.DError)

Example 28 with DError

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

the class DAuthorityKeyIdentifier method okPressed.

private void okPressed() {
    byte[] keyIdentifier = jkiKeyIdentifier.getKeyIdentifier();
    GeneralNames authorityCertIssuer = jgnAuthorityCertIssuer.getGeneralNames();
    BigInteger authorityCertSerialNumber = null;
    String authorityCertSerialNumberStr = jtfAuthorityCertSerialNumber.getText().trim();
    if (authorityCertSerialNumberStr.length() != 0) {
        try {
            authorityCertSerialNumber = new BigInteger(authorityCertSerialNumberStr);
            if (authorityCertSerialNumber.compareTo(BigInteger.ONE) < 0) {
                JOptionPane.showMessageDialog(this, res.getString("DAuthorityKeyIdentifier.AuthorityCertSerialNumberNonZero.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
                return;
            }
        } catch (NumberFormatException ex) {
            JOptionPane.showMessageDialog(this, res.getString("DAuthorityKeyIdentifier.AuthorityCertSerialNumberNotInteger.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
            return;
        }
    }
    // serial number are required
    if ((keyIdentifier == null) && ((authorityCertIssuer.getNames().length == 0) || (authorityCertSerialNumber == null))) {
        JOptionPane.showMessageDialog(this, res.getString("DAuthorityKeyIdentifier.ValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
        return;
    }
    AuthorityKeyIdentifier authorityKeyIdentifier;
    if ((keyIdentifier != null) && (authorityCertSerialNumber == null)) {
        // only key identifier
        authorityKeyIdentifier = new AuthorityKeyIdentifier(keyIdentifier);
    } else if (keyIdentifier == null) {
        // only issuer / serial
        authorityKeyIdentifier = new AuthorityKeyIdentifier(authorityCertIssuer, authorityCertSerialNumber);
    } else {
        // both
        authorityKeyIdentifier = new AuthorityKeyIdentifier(keyIdentifier, authorityCertIssuer, authorityCertSerialNumber);
    }
    try {
        value = authorityKeyIdentifier.getEncoded(ASN1Encoding.DER);
    } catch (IOException ex) {
        DError dError = new DError(this, ex);
        dError.setLocationRelativeTo(this);
        dError.setVisible(true);
        return;
    }
    closeDialog();
}
Also used : JGeneralNames(org.kse.gui.crypto.generalname.JGeneralNames) GeneralNames(org.bouncycastle.asn1.x509.GeneralNames) BigInteger(java.math.BigInteger) AuthorityKeyIdentifier(org.bouncycastle.asn1.x509.AuthorityKeyIdentifier) IOException(java.io.IOException) DError(org.kse.gui.error.DError)

Example 29 with DError

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

the class DViewCertificate method pubKeyDetailsPressed.

private void pubKeyDetailsPressed() {
    try {
        X509Certificate cert = getSelectedCertificate();
        DViewPublicKey dViewPublicKey = new DViewPublicKey(this, res.getString("DViewCertificate.PubKeyDetails.Title"), cert.getPublicKey());
        dViewPublicKey.setLocationRelativeTo(this);
        dViewPublicKey.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 30 with DError

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

the class DViewCrl method asn1DumpPressed.

private void asn1DumpPressed() {
    try {
        DViewAsn1Dump dViewAsn1Dump = new DViewAsn1Dump(this, crl);
        dViewAsn1Dump.setLocationRelativeTo(this);
        dViewAsn1Dump.setVisible(true);
    } catch (Asn1Exception ex) {
        DError dError = new DError(this, ex);
        dError.setLocationRelativeTo(this);
        dError.setVisible(true);
    } catch (IOException ex) {
        DError dError = new DError(this, ex);
        dError.setLocationRelativeTo(this);
        dError.setVisible(true);
    }
}
Also used : IOException(java.io.IOException) Asn1Exception(org.kse.utilities.asn1.Asn1Exception) DError(org.kse.gui.error.DError)

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