Search in sources :

Example 46 with DError

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

the class DViewExtensions method asn1DumpPressed.

private void asn1DumpPressed() {
    int selectedRow = jtExtensions.getSelectedRow();
    if (selectedRow == -1) {
        return;
    }
    String oid = ((ASN1ObjectIdentifier) jtExtensions.getValueAt(selectedRow, 2)).getId();
    byte[] value = extensions.getExtensionValue(oid);
    boolean criticality = (Boolean) jtExtensions.getValueAt(selectedRow, 0);
    X509Ext extension = new X509Ext(oid, value, criticality);
    try {
        DViewAsn1Dump dViewAsn1Dump = new DViewAsn1Dump(this, extension);
        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 : DViewAsn1Dump(org.kse.gui.dialogs.DViewAsn1Dump) IOException(java.io.IOException) Asn1Exception(org.kse.utilities.asn1.Asn1Exception) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier) X509Ext(org.kse.crypto.x509.X509Ext) DError(org.kse.gui.error.DError)

Example 47 with DError

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

the class DExtendedKeyUsage method okPressed.

private void okPressed() {
    if (!jcbTlsWebServerAuthentication.isSelected() && !jcbTlsWebClientAuthentication.isSelected() && !jcbCodeSigning.isSelected() && !jcbEmailProtection.isSelected() && !jcbIpSecurityEndSystem.isSelected() && !jcbIpSecurityTunnelTermination.isSelected() && !jcbIpSecurityUser.isSelected() && !jcbTimeStamping.isSelected() && !jcbOcspStamping.isSelected() && !jcbDocumentSigning.isSelected() && !jcbAdobePDFSigning.isSelected() && !jcbEncryptedFileSystem.isSelected() && !jcbAnyExtendedKeyUsage.isSelected()) {
        JOptionPane.showMessageDialog(this, res.getString("DExtendedKeyUsage.ValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
        return;
    }
    ArrayList<KeyPurposeId> keyPurposeIds = new ArrayList<KeyPurposeId>();
    if (jcbTlsWebServerAuthentication.isSelected()) {
        keyPurposeIds.add(KeyPurposeId.getInstance(new ASN1ObjectIdentifier(SERVER_AUTH.oid())));
    }
    if (jcbTlsWebClientAuthentication.isSelected()) {
        keyPurposeIds.add(KeyPurposeId.getInstance(new ASN1ObjectIdentifier(CLIENT_AUTH.oid())));
    }
    if (jcbCodeSigning.isSelected()) {
        keyPurposeIds.add(KeyPurposeId.getInstance(new ASN1ObjectIdentifier(CODE_SIGNING.oid())));
    }
    if (jcbDocumentSigning.isSelected()) {
        keyPurposeIds.add(KeyPurposeId.getInstance(new ASN1ObjectIdentifier(DOCUMENT_SIGNING.oid())));
    }
    if (jcbAdobePDFSigning.isSelected()) {
        keyPurposeIds.add(KeyPurposeId.getInstance(new ASN1ObjectIdentifier(ADOBE_PDF_SIGNING.oid())));
    }
    if (jcbEmailProtection.isSelected()) {
        keyPurposeIds.add(KeyPurposeId.getInstance(new ASN1ObjectIdentifier(EMAIL_PROTECTION.oid())));
    }
    if (jcbEncryptedFileSystem.isSelected()) {
        keyPurposeIds.add(KeyPurposeId.getInstance(new ASN1ObjectIdentifier(ENCRYPTED_FILE_SYSTEM.oid())));
    }
    if (jcbIpSecurityEndSystem.isSelected()) {
        keyPurposeIds.add(KeyPurposeId.getInstance(new ASN1ObjectIdentifier(IPSEC_END_SYSTEM.oid())));
    }
    if (jcbIpSecurityTunnelTermination.isSelected()) {
        keyPurposeIds.add(KeyPurposeId.getInstance(new ASN1ObjectIdentifier(IPSEC_TUNNEL.oid())));
    }
    if (jcbIpSecurityUser.isSelected()) {
        keyPurposeIds.add(KeyPurposeId.getInstance(new ASN1ObjectIdentifier(IPSEC_USER.oid())));
    }
    if (jcbTimeStamping.isSelected()) {
        keyPurposeIds.add(KeyPurposeId.getInstance(new ASN1ObjectIdentifier(TIME_STAMPING.oid())));
    }
    if (jcbOcspStamping.isSelected()) {
        keyPurposeIds.add(KeyPurposeId.getInstance(new ASN1ObjectIdentifier(OCSP_SIGNING.oid())));
    }
    if (jcbSmartcardLogon.isSelected()) {
        keyPurposeIds.add(KeyPurposeId.getInstance(new ASN1ObjectIdentifier(SMARTCARD_LOGON.oid())));
    }
    if (jcbAnyExtendedKeyUsage.isSelected()) {
        keyPurposeIds.add(KeyPurposeId.getInstance(new ASN1ObjectIdentifier(ANY_EXTENDED_KEY_USAGE.oid())));
    }
    ExtendedKeyUsage extendedKeyUsage = new ExtendedKeyUsage(keyPurposeIds.toArray(new KeyPurposeId[keyPurposeIds.size()]));
    try {
        value = extendedKeyUsage.getEncoded(ASN1Encoding.DER);
    } catch (IOException ex) {
        DError dError = new DError(this, ex);
        dError.setLocationRelativeTo(this);
        dError.setVisible(true);
        return;
    }
    closeDialog();
}
Also used : KeyPurposeId(org.bouncycastle.asn1.x509.KeyPurposeId) ArrayList(java.util.ArrayList) IOException(java.io.IOException) ExtendedKeyUsage(org.bouncycastle.asn1.x509.ExtendedKeyUsage) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier) DError(org.kse.gui.error.DError)

Example 48 with DError

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

the class DInhibitAnyPolicy method okPressed.

private void okPressed() {
    int skipCertificates = -1;
    String skipCertificatesStr = jtfSkipCertificates.getText().trim();
    if (skipCertificatesStr.length() == 0) {
        JOptionPane.showMessageDialog(this, res.getString("DInhibitAnyPolicy.ValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
        return;
    }
    try {
        skipCertificates = Integer.parseInt(skipCertificatesStr);
    } catch (NumberFormatException ex) {
        JOptionPane.showMessageDialog(this, res.getString("DInhibitAnyPolicy.InvalidLengthValue.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
        return;
    }
    if (skipCertificates < 0) {
        JOptionPane.showMessageDialog(this, res.getString("DInhibitAnyPolicy.InvalidLengthValue.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
        return;
    }
    InhibitAnyPolicy inhibitAnyPolicy = new InhibitAnyPolicy(skipCertificates);
    try {
        value = inhibitAnyPolicy.getEncoded(ASN1Encoding.DER);
    } catch (IOException ex) {
        DError dError = new DError(this, ex);
        dError.setLocationRelativeTo(this);
        dError.setVisible(true);
        return;
    }
    closeDialog();
}
Also used : InhibitAnyPolicy(org.kse.crypto.x509.InhibitAnyPolicy) IOException(java.io.IOException) DError(org.kse.gui.error.DError)

Example 49 with DError

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

the class DIssuerAlternativeName method okPressed.

private void okPressed() {
    GeneralNames issuerAlternativeName = jgnAlternativeName.getGeneralNames();
    if (issuerAlternativeName.getNames().length == 0) {
        JOptionPane.showMessageDialog(this, res.getString("DIssuerAlternativeName.ValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
        return;
    }
    try {
        value = issuerAlternativeName.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) IOException(java.io.IOException) DError(org.kse.gui.error.DError)

Example 50 with DError

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

the class DKeyUsage method okPressed.

private void okPressed() {
    if (!jcbDigitalSignature.isSelected() && !jcbNonRepudiation.isSelected() && !jcbKeyEncipherment.isSelected() && !jcbDataEncipherment.isSelected() && !jcbKeyAgreement.isSelected() && !jcbCertificateSigning.isSelected() && !jcbCrlSign.isSelected() && !jcbEncipherOnly.isSelected() && !jcbDecipherOnly.isSelected()) {
        JOptionPane.showMessageDialog(this, res.getString("DKeyUsage.ValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
        return;
    }
    int keyUsageIntValue = 0;
    keyUsageIntValue |= jcbDigitalSignature.isSelected() ? KeyUsage.digitalSignature : 0;
    keyUsageIntValue |= jcbNonRepudiation.isSelected() ? KeyUsage.nonRepudiation : 0;
    keyUsageIntValue |= jcbKeyEncipherment.isSelected() ? KeyUsage.keyEncipherment : 0;
    keyUsageIntValue |= jcbDataEncipherment.isSelected() ? KeyUsage.dataEncipherment : 0;
    keyUsageIntValue |= jcbKeyAgreement.isSelected() ? KeyUsage.keyAgreement : 0;
    keyUsageIntValue |= jcbCertificateSigning.isSelected() ? KeyUsage.keyCertSign : 0;
    keyUsageIntValue |= jcbCrlSign.isSelected() ? KeyUsage.cRLSign : 0;
    keyUsageIntValue |= jcbEncipherOnly.isSelected() ? KeyUsage.encipherOnly : 0;
    keyUsageIntValue |= jcbDecipherOnly.isSelected() ? KeyUsage.decipherOnly : 0;
    KeyUsage keyUsage = new KeyUsage(keyUsageIntValue);
    try {
        value = keyUsage.getEncoded(ASN1Encoding.DER);
    } catch (IOException ex) {
        DError dError = new DError(this, ex);
        dError.setLocationRelativeTo(this);
        dError.setVisible(true);
        return;
    }
    closeDialog();
}
Also used : KeyUsage(org.bouncycastle.asn1.x509.KeyUsage) IOException(java.io.IOException) 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