Search in sources :

Example 1 with DError

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

the class DPolicyInformationChooser method okPressed.

private void okPressed() {
    ASN1ObjectIdentifier policyIdentifer = joiPolicyIdentifier.getObjectId();
    if (policyIdentifer == null) {
        JOptionPane.showMessageDialog(this, res.getString("DPolicyInformationChooser.PolicyIdentifierValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
        return;
    }
    List<PolicyQualifierInfo> policyQualifierInfo = jpqPolicyQualifiers.getPolicyQualifierInfo();
    if (policyQualifierInfo.size() > 0) {
        ASN1EncodableVector policyQualifiersVec = new ASN1EncodableVector();
        for (PolicyQualifierInfo policyQualInfo : policyQualifierInfo) {
            try {
                policyQualifiersVec.add(policyQualInfo);
            } catch (Exception ex) {
                DError dError = new DError(this, ex);
                dError.setLocationRelativeTo(this);
                dError.setVisible(true);
                return;
            }
        }
        DERSequence policyQualifiersSeq = new DERSequence(policyQualifiersVec);
        policyInformation = new PolicyInformation(policyIdentifer, policyQualifiersSeq);
    } else {
        policyInformation = new PolicyInformation(policyIdentifer);
    }
    closeDialog();
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) PolicyInformation(org.bouncycastle.asn1.x509.PolicyInformation) PolicyQualifierInfo(org.bouncycastle.asn1.x509.PolicyQualifierInfo) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier) IOException(java.io.IOException) DError(org.kse.gui.error.DError)

Example 2 with DError

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

the class JPolicyQualifierInfo method editSelectedPolicQualifier.

private void editSelectedPolicQualifier() {
    int selectedRow = jtPolicyQualifierInfo.getSelectedRow();
    if (selectedRow != -1) {
        PolicyQualifierInfo policyQualInfo = (PolicyQualifierInfo) jtPolicyQualifierInfo.getValueAt(selectedRow, 0);
        Container container = getTopLevelAncestor();
        try {
            DPolicyQualifierInfoChooser dPolicyQualifierInfoChooser = null;
            if (container instanceof JDialog) {
                dPolicyQualifierInfoChooser = new DPolicyQualifierInfoChooser((JDialog) container, title, policyQualInfo);
                dPolicyQualifierInfoChooser.setLocationRelativeTo(container);
                dPolicyQualifierInfoChooser.setVisible(true);
            } else if (container instanceof JFrame) {
                dPolicyQualifierInfoChooser = new DPolicyQualifierInfoChooser((JFrame) container, title, policyQualInfo);
                dPolicyQualifierInfoChooser.setLocationRelativeTo(container);
                dPolicyQualifierInfoChooser.setVisible(true);
            }
            PolicyQualifierInfo newPolicyQualifierInfo = dPolicyQualifierInfoChooser.getPolicyQualifierInfo();
            if (newPolicyQualifierInfo == null) {
                return;
            }
            policyQualifierInfo.remove(policyQualInfo);
            policyQualifierInfo.add(newPolicyQualifierInfo);
            populate();
            selectPolicyQualifierInfoInTable(newPolicyQualifierInfo);
        } catch (IOException 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) PolicyQualifierInfo(org.bouncycastle.asn1.x509.PolicyQualifierInfo) IOException(java.io.IOException) Point(java.awt.Point) JDialog(javax.swing.JDialog) DError(org.kse.gui.error.DError)

Example 3 with DError

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

the class DGeneralNameChooser method okPressed.

private void okPressed() {
    try {
        GeneralName newGeneralName = null;
        if (jrbDirectoryName.isSelected()) {
            X500Name directoryName = jdnDirectoryName.getDistinguishedName();
            if (directoryName == null) {
                JOptionPane.showMessageDialog(this, res.getString("DGeneralNameChooser.DirectoryNameValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
                return;
            }
            newGeneralName = new GeneralName(GeneralName.directoryName, directoryName);
        } else if (jrbDnsName.isSelected()) {
            String dnsName = jtfDnsName.getText().trim();
            if (dnsName.length() == 0) {
                JOptionPane.showMessageDialog(this, res.getString("DGeneralNameChooser.DnsNameValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
                return;
            }
            newGeneralName = new GeneralName(GeneralName.dNSName, new DERIA5String(dnsName));
        } else if (jrbIpAddress.isSelected()) {
            String ipAddress = jtfIpAddress.getText().trim();
            if (ipAddress.length() == 0) {
                JOptionPane.showMessageDialog(this, res.getString("DGeneralNameChooser.IpAddressValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
                return;
            }
            if (!IPAddress.isValid(ipAddress)) {
                JOptionPane.showMessageDialog(this, res.getString("DGeneralNameChooser.NotAValidIP.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
                return;
            }
            newGeneralName = new GeneralName(GeneralName.iPAddress, ipAddress);
        } else if (jrbRegisteredId.isSelected()) {
            ASN1ObjectIdentifier registeredId = joiRegisteredId.getObjectId();
            if (registeredId == null) {
                JOptionPane.showMessageDialog(this, res.getString("DGeneralNameChooser.RegisteredIdValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
                return;
            }
            newGeneralName = new GeneralName(GeneralName.registeredID, registeredId);
        } else if (jrbRfc822Name.isSelected()) {
            String rfc822Name = jtfRfc822Name.getText().trim();
            if (rfc822Name.length() == 0) {
                JOptionPane.showMessageDialog(this, res.getString("DGeneralNameChooser.Rfc822NameValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
                return;
            }
            newGeneralName = new GeneralName(GeneralName.rfc822Name, new DERIA5String(rfc822Name));
        } else if (jrbUniformResourceIdentifier.isSelected()) {
            String uniformResourceIdentifier = jtfUniformResourceIdentifier.getText().trim();
            if (uniformResourceIdentifier.length() == 0) {
                JOptionPane.showMessageDialog(this, res.getString("DGeneralNameChooser.UniformResourceIdentifierValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
                return;
            }
            newGeneralName = new GeneralName(GeneralName.uniformResourceIdentifier, new DERIA5String(uniformResourceIdentifier));
        } else if (jrbPrincipalName.isSelected()) {
            String upnString = jtfPrincipalName.getText().trim();
            if (upnString.length() == 0) {
                JOptionPane.showMessageDialog(this, res.getString("DGeneralNameChooser.PrincipalNameValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE);
                return;
            }
            ASN1EncodableVector asn1Vector = new ASN1EncodableVector();
            asn1Vector.add(new ASN1ObjectIdentifier(GeneralNameUtil.UPN_OID));
            asn1Vector.add(new DERTaggedObject(true, 0, new DERUTF8String(upnString)));
            newGeneralName = new GeneralName(GeneralName.otherName, new DERSequence(asn1Vector));
        }
        generalName = newGeneralName;
    } catch (Exception ex) {
        DError dError = new DError(this, ex);
        dError.setLocationRelativeTo(this);
        dError.setVisible(true);
        return;
    }
    closeDialog();
}
Also used : DERUTF8String(org.bouncycastle.asn1.DERUTF8String) DERIA5String(org.bouncycastle.asn1.DERIA5String) DERSequence(org.bouncycastle.asn1.DERSequence) DERTaggedObject(org.bouncycastle.asn1.DERTaggedObject) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector) GeneralName(org.bouncycastle.asn1.x509.GeneralName) X500Name(org.bouncycastle.asn1.x500.X500Name) ASN1OctetString(org.bouncycastle.asn1.ASN1OctetString) DERIA5String(org.bouncycastle.asn1.DERIA5String) DERUTF8String(org.bouncycastle.asn1.DERUTF8String) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier) UnknownHostException(java.net.UnknownHostException) DError(org.kse.gui.error.DError)

Example 4 with DError

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

the class KSE method main.

/**
 * Start the KeyStore Explorer application. Takes one optional argument -
 * the location of a KeyStore file to open upon startup.
 *
 * @param args
 *            the command line arguments
 */
public static void main(String[] args) {
    try {
        // To take affect these must be set before the splash screen is instantiated
        if (OperatingSystem.isMacOs()) {
            setAppleSystemProperties();
        } else if (OperatingSystem.isWindows7() || OperatingSystem.isWindows8() || OperatingSystem.isWindows10()) {
            String appId = props.getString("KSE.AppUserModelId");
            Shell32 shell32 = (Shell32) Native.loadLibrary("shell32", Shell32.class);
            shell32.SetCurrentProcessExplicitAppUserModelID(new WString(appId)).longValue();
        } else if (OperatingSystem.isLinux()) {
            fixAppClassName();
        }
        setInstallDirProperty();
        SplashScreen splash = SplashScreen.getSplashScreen();
        updateSplashMessage(splash, res.getString("KSE.LoadingApplicationSettings.splash.message"));
        ApplicationSettings applicationSettings = ApplicationSettings.getInstance();
        setCurrentDirectory(applicationSettings);
        updateSplashMessage(splash, res.getString("KSE.InitializingSecurity.splash.message"));
        initialiseSecurity();
        // list of files to open after start
        List<File> parameterFiles = new ArrayList<File>();
        for (String arg : args) {
            File parameterFile = new File(arg);
            if (parameterFile.exists()) {
                parameterFiles.add(parameterFile);
            }
        }
        // Create application GUI on the event handler thread
        updateSplashMessage(splash, res.getString("KSE.CreatingApplicationGui.splash.message"));
        SwingUtilities.invokeLater(new CreateApplicationGui(applicationSettings, splash, parameterFiles));
    } catch (Throwable t) {
        DError dError = new DError(new JFrame(), t);
        dError.setLocationRelativeTo(null);
        dError.setVisible(true);
        System.exit(1);
    }
}
Also used : WString(com.sun.jna.WString) JFrame(javax.swing.JFrame) ArrayList(java.util.ArrayList) SplashScreen(java.awt.SplashScreen) CreateApplicationGui(org.kse.gui.CreateApplicationGui) WString(com.sun.jna.WString) File(java.io.File) DError(org.kse.gui.error.DError)

Example 5 with DError

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

the class JObjectId method editObjectId.

private void editObjectId() {
    Container container = getTopLevelAncestor();
    try {
        DObjectIdChooser dObjectIdChooser = null;
        if (container instanceof JDialog) {
            dObjectIdChooser = new DObjectIdChooser((JDialog) container, title, objectId);
            dObjectIdChooser.setLocationRelativeTo(container);
            dObjectIdChooser.setVisible(true);
        } else if (container instanceof JFrame) {
            dObjectIdChooser = new DObjectIdChooser((JFrame) container, title, objectId);
            dObjectIdChooser.setLocationRelativeTo(container);
            dObjectIdChooser.setVisible(true);
        }
        ASN1ObjectIdentifier newObjectId = dObjectIdChooser.getObjectId();
        if (newObjectId == null) {
            return;
        }
        setObjectId(newObjectId);
    } catch (InvalidObjectIdException 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) JDialog(javax.swing.JDialog) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier) InvalidObjectIdException(org.kse.utilities.oid.InvalidObjectIdException) 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