Search in sources :

Example 1 with JDateTime

use of org.kse.gui.datetime.JDateTime in project keystore-explorer by kaikramer.

the class DSignCsr method initComponents.

private void initComponents() throws CryptoException {
    jlCsrFormat = new JLabel(res.getString("DSignCsr.jlCsrFormat.text"));
    jtfCsrFormat = new JTextField(15);
    jtfCsrFormat.setEditable(false);
    jtfCsrFormat.setToolTipText(res.getString("DSignCsr.jtfCsrFormat.tooltip"));
    jlCsrSubject = new JLabel(res.getString("DSignCsr.jlCsrSubject.text"));
    jdnCsrSubject = new JDistinguishedName(res.getString("DSignCsr.Subject.Title"), 30, false);
    jdnCsrSubject.setToolTipText(res.getString("DSignCsr.jdnCsrSubject.tooltip"));
    jlCsrPublicKey = new JLabel(res.getString("DSignCsr.jlCsrPublicKey.text"));
    jtfCsrPublicKey = new JTextField(15);
    jtfCsrPublicKey.setEditable(false);
    jtfCsrPublicKey.setToolTipText(res.getString("DSignCsr.jtfCsrPublicKey.tooltip"));
    jbViewCsrPublicKeyDetails = new JButton();
    jbViewCsrPublicKeyDetails.setToolTipText(res.getString("DSignCsr.jbViewCsrPublicKeyDetails.tooltip"));
    jbViewCsrPublicKeyDetails.setIcon(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(res.getString("DSignCsr.jbViewCsrPublicKeyDetails.image")))));
    jlCsrSignatureAlgorithm = new JLabel(res.getString("DSignCsr.jlCsrSignatureAlgorithm.text"));
    jtfCsrSignatureAlgorithm = new JTextField(15);
    jtfCsrSignatureAlgorithm.setEditable(false);
    jtfCsrSignatureAlgorithm.setToolTipText(res.getString("DSignCsr.jtfCsrSignatureAlgorithm.tooltip"));
    jlCsrChallenge = new JLabel(res.getString("DSignCsr.jlCsrChallenge.text"));
    jtfCsrChallenge = new JTextField(15);
    jtfCsrChallenge.setEditable(false);
    jtfCsrChallenge.setToolTipText(res.getString("DSignCsr.jtfCsrChallenge.tooltip"));
    populateCsrDetails();
    jlVersion = new JLabel(res.getString("DSignCsr.jlVersion.text"));
    jrbVersion1 = new JRadioButton(res.getString("DSignCsr.jrbVersion1.text"));
    jrbVersion1.setToolTipText(res.getString("DSignCsr.jrbVersion1.tooltip"));
    jrbVersion3 = new JRadioButton(res.getString("DSignCsr.jrbVersion3.text"));
    jrbVersion3.setToolTipText(res.getString("DSignCsr.jrbVersion3.tooltip"));
    jlSignatureAlgorithm = new JLabel(res.getString("DSignCsr.jlSignatureAlgorithm.text"));
    jcbSignatureAlgorithm = new JComboBox<SignatureType>();
    jcbSignatureAlgorithm.setMaximumRowCount(10);
    DialogHelper.populateSigAlgs(signKeyPairType, this.signPrivateKey, provider, jcbSignatureAlgorithm);
    jcbSignatureAlgorithm.setToolTipText(res.getString("DSignCsr.jcbSignatureAlgorithm.tooltip"));
    Date now = new Date();
    jlValidityStart = new JLabel(res.getString("DSignCsr.jlValidityStart.text"));
    jdtValidityStart = new JDateTime(res.getString("DSignCsr.jdtValidityStart.text"), false);
    jdtValidityStart.setDateTime(now);
    jdtValidityStart.setToolTipText(res.getString("DSignCsr.jdtValidityStart.tooltip"));
    jlValidityEnd = new JLabel(res.getString("DSignCsr.jlValidityEnd.text"));
    jdtValidityEnd = new JDateTime(res.getString("DSignCsr.jdtValidityEnd.text"), false);
    jdtValidityEnd.setDateTime(new Date(now.getTime() + TimeUnit.DAYS.toMillis(365)));
    jdtValidityEnd.setToolTipText(res.getString("DSignCsr.jdtValidityEnd.tooltip"));
    jlValidityPeriod = new JLabel(res.getString("DSignCsr.jlValidityPeriod.text"));
    jvpValidityPeriod = new JValidityPeriod(JValidityPeriod.YEARS);
    jvpValidityPeriod.setToolTipText(res.getString("DSignCsr.jvpValidityPeriod.tooltip"));
    jvpValidityPeriod.addApplyActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            Date startDate = jdtValidityStart.getDateTime();
            if (startDate == null) {
                startDate = new Date();
                jdtValidityStart.setDateTime(startDate);
            }
            Date validityEnd = jvpValidityPeriod.getValidityEnd(startDate);
            jdtValidityEnd.setDateTime(validityEnd);
        }
    });
    jlSerialNumber = new JLabel(res.getString("DSignCsr.jlSerialNumber.text"));
    jtfSerialNumber = new JTextField("" + generateSerialNumber(), 15);
    jtfSerialNumber.setToolTipText(res.getString("DSignCsr.jtfSerialNumber.tooltip"));
    jlCaReplyFile = new JLabel(res.getString("DSignCsr.jlCaReplyFile.text"));
    jtfCaReplyFile = new JTextField(30);
    jtfCaReplyFile.setToolTipText(res.getString("DSignCsr.jtfCaReplyFile.tooltip"));
    populateCaReplyFileName();
    jbBrowse = new JButton(res.getString("DSignCsr.jbBrowse.text"));
    jbBrowse.setToolTipText(res.getString("DSignCsr.jbBrowse.tooltip"));
    PlatformUtil.setMnemonic(jbBrowse, res.getString("DSignCsr.jbBrowse.mnemonic").charAt(0));
    jbBrowse.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DSignCsr.this);
                browsePressed();
            } finally {
                CursorUtil.setCursorFree(DSignCsr.this);
            }
        }
    });
    jbAddExtensions = new JButton(res.getString("DSignCsr.jbAddExtensions.text"));
    jbAddExtensions.setMnemonic(res.getString("DSignCsr.jbAddExtensions.mnemonic").charAt(0));
    jbAddExtensions.setToolTipText(res.getString("DSignCsr.jbAddExtensions.tooltip"));
    jbAddExtensions.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DSignCsr.this);
                addExtensionsPressed();
            } finally {
                CursorUtil.setCursorFree(DSignCsr.this);
            }
        }
    });
    jrbVersion3.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent evt) {
            jbAddExtensions.setEnabled(jrbVersion3.isSelected());
        }
    });
    jrbVersion3.setSelected(true);
    jbOK = new JButton(res.getString("DSignCsr.jbOK.text"));
    jbCancel = new JButton(res.getString("DSignCsr.jbCancel.text"));
    jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), CANCEL_KEY);
    JPanel buttons = PlatformUtil.createDialogButtonPanel(jbOK, jbCancel);
    JPanel jpCsr = new JPanel();
    jpCsr.setBorder(new TitledBorder(new EtchedBorder(), res.getString("DSignCsr.jpCsrDetails.text")));
    JPanel jpSignOptions = new JPanel();
    jpSignOptions.setBorder(new TitledBorder(new EtchedBorder(), res.getString("DSignCsr.jpSigningOptions.text")));
    // layout
    getContentPane().setLayout(new MigLayout("fill", "", ""));
    getContentPane().add(jpCsr, "grow, wrap");
    getContentPane().add(jpSignOptions, "wrap unrel");
    getContentPane().add(buttons, "growx");
    jpCsr.setLayout(new MigLayout("fill", "[right]unrel[]", "[]unrel[]"));
    jpCsr.add(jlCsrFormat, "");
    jpCsr.add(jtfCsrFormat, "wrap");
    jpCsr.add(jlCsrSubject, "");
    jpCsr.add(jdnCsrSubject, "wrap");
    jpCsr.add(jlCsrPublicKey, "");
    jpCsr.add(jtfCsrPublicKey, "split 2");
    jpCsr.add(jbViewCsrPublicKeyDetails, "wrap");
    jpCsr.add(jlCsrSignatureAlgorithm, "");
    jpCsr.add(jtfCsrSignatureAlgorithm, "wrap");
    jpCsr.add(jlCsrChallenge, "");
    jpCsr.add(jtfCsrChallenge, "wrap");
    jpSignOptions.setLayout(new MigLayout("fill", "[right]unrel[]", "[]unrel[]"));
    jpSignOptions.add(jlVersion, "");
    jpSignOptions.add(jrbVersion1, "split 2");
    jpSignOptions.add(jrbVersion3, "wrap");
    jpSignOptions.add(jlSignatureAlgorithm, "");
    jpSignOptions.add(jcbSignatureAlgorithm, "wrap");
    jpSignOptions.add(jlValidityStart, "");
    jpSignOptions.add(jdtValidityStart, "wrap");
    jpSignOptions.add(jlValidityPeriod, "");
    jpSignOptions.add(jvpValidityPeriod, "wrap");
    jpSignOptions.add(jlValidityEnd, "");
    jpSignOptions.add(jdtValidityEnd, "wrap");
    jpSignOptions.add(jlSerialNumber, "");
    jpSignOptions.add(jtfSerialNumber, "wrap");
    jpSignOptions.add(jlCaReplyFile, "");
    jpSignOptions.add(jtfCaReplyFile, "split 2");
    jpSignOptions.add(jbBrowse, "wrap");
    jpSignOptions.add(jbAddExtensions, "spanx, wrap");
    jbViewCsrPublicKeyDetails.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DSignCsr.this);
                pubKeyDetailsPressed();
            } finally {
                CursorUtil.setCursorFree(DSignCsr.this);
            }
        }
    });
    jbOK.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            okPressed();
        }
    });
    jbCancel.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelPressed();
        }
    });
    jbCancel.getActionMap().put(CANCEL_KEY, new AbstractAction() {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelPressed();
        }
    });
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent evt) {
            closeDialog();
        }
    });
    setResizable(false);
    getRootPane().setDefaultButton(jbOK);
    pack();
}
Also used : ImageIcon(javax.swing.ImageIcon) JPanel(javax.swing.JPanel) JRadioButton(javax.swing.JRadioButton) ActionEvent(java.awt.event.ActionEvent) MigLayout(net.miginfocom.swing.MigLayout) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) WindowAdapter(java.awt.event.WindowAdapter) JValidityPeriod(org.kse.gui.crypto.JValidityPeriod) SignatureType(org.kse.crypto.signing.SignatureType) JTextField(javax.swing.JTextField) TitledBorder(javax.swing.border.TitledBorder) Date(java.util.Date) EtchedBorder(javax.swing.border.EtchedBorder) JDistinguishedName(org.kse.gui.crypto.JDistinguishedName) ActionListener(java.awt.event.ActionListener) ChangeEvent(javax.swing.event.ChangeEvent) WindowEvent(java.awt.event.WindowEvent) JDateTime(org.kse.gui.datetime.JDateTime) ChangeListener(javax.swing.event.ChangeListener) AbstractAction(javax.swing.AbstractAction)

Example 2 with JDateTime

use of org.kse.gui.datetime.JDateTime in project keystore-explorer by kaikramer.

the class DPrivateKeyUsagePeriod method initComponents.

private void initComponents() {
    jlNotBefore = new JLabel(res.getString("DPrivateKeyUsagePeriod.jlNotBefore.text"));
    GridBagConstraints gbc_jlNotBefore = new GridBagConstraints();
    gbc_jlNotBefore.gridx = 0;
    gbc_jlNotBefore.gridy = 0;
    gbc_jlNotBefore.gridwidth = 1;
    gbc_jlNotBefore.gridheight = 1;
    gbc_jlNotBefore.insets = new Insets(5, 5, 5, 5);
    gbc_jlNotBefore.anchor = GridBagConstraints.EAST;
    jdtNotBefore = new JDateTime(res.getString("DPrivateKeyUsagePeriod.jdtNotBefore.text"));
    jdtNotBefore.setToolTipText(res.getString("DPrivateKeyUsagePeriod.jdtNotBefore.tooltip"));
    GridBagConstraints gbc_jdtNotBefore = new GridBagConstraints();
    gbc_jdtNotBefore.gridx = 1;
    gbc_jdtNotBefore.gridy = 0;
    gbc_jdtNotBefore.gridwidth = 1;
    gbc_jdtNotBefore.gridheight = 1;
    gbc_jdtNotBefore.insets = new Insets(5, 5, 5, 5);
    gbc_jdtNotBefore.anchor = GridBagConstraints.WEST;
    jlNotAfter = new JLabel(res.getString("DPrivateKeyUsagePeriod.jlNotAfter.text"));
    GridBagConstraints gbc_jlNotAfter = new GridBagConstraints();
    gbc_jlNotAfter.gridx = 0;
    gbc_jlNotAfter.gridy = 1;
    gbc_jlNotAfter.gridwidth = 1;
    gbc_jlNotAfter.gridheight = 1;
    gbc_jlNotAfter.insets = new Insets(5, 5, 5, 5);
    gbc_jlNotAfter.anchor = GridBagConstraints.EAST;
    jdtNotAfter = new JDateTime(res.getString("DPrivateKeyUsagePeriod.jdtNotAfter.text"));
    jdtNotAfter.setToolTipText(res.getString("DPrivateKeyUsagePeriod.jdtNotAfter.tooltip"));
    GridBagConstraints gbc_jdtNotAfter = new GridBagConstraints();
    gbc_jdtNotAfter.gridx = 1;
    gbc_jdtNotAfter.gridy = 1;
    gbc_jdtNotAfter.gridwidth = 1;
    gbc_jdtNotAfter.gridheight = 1;
    gbc_jdtNotAfter.insets = new Insets(5, 5, 5, 5);
    gbc_jdtNotAfter.anchor = GridBagConstraints.WEST;
    jpPrivateKeyUsagePeriod = new JPanel(new FlowLayout());
    jpPrivateKeyUsagePeriod.add(jlNotBefore);
    jpPrivateKeyUsagePeriod.add(jdtNotBefore);
    jpPrivateKeyUsagePeriod.add(jlNotAfter);
    jpPrivateKeyUsagePeriod.add(jdtNotAfter);
    jpPrivateKeyUsagePeriod = new JPanel(new GridBagLayout());
    jpPrivateKeyUsagePeriod.add(jlNotBefore, gbc_jlNotBefore);
    jpPrivateKeyUsagePeriod.add(jdtNotBefore, gbc_jdtNotBefore);
    jpPrivateKeyUsagePeriod.add(jlNotAfter, gbc_jlNotAfter);
    jpPrivateKeyUsagePeriod.add(jdtNotAfter, gbc_jdtNotAfter);
    jpPrivateKeyUsagePeriod.setBorder(new CompoundBorder(new EmptyBorder(5, 5, 5, 5), new EtchedBorder()));
    jbOK = new JButton(res.getString("DPrivateKeyUsagePeriod.jbOK.text"));
    jbOK.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            okPressed();
        }
    });
    jbCancel = new JButton(res.getString("DPrivateKeyUsagePeriod.jbCancel.text"));
    jbCancel.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelPressed();
        }
    });
    jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), CANCEL_KEY);
    jbCancel.getActionMap().put(CANCEL_KEY, new AbstractAction() {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelPressed();
        }
    });
    jpButtons = PlatformUtil.createDialogButtonPanel(jbOK, jbCancel, false);
    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(jpPrivateKeyUsagePeriod, BorderLayout.CENTER);
    getContentPane().add(jpButtons, BorderLayout.SOUTH);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent evt) {
            closeDialog();
        }
    });
    setResizable(false);
    getRootPane().setDefaultButton(jbOK);
    pack();
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) FlowLayout(java.awt.FlowLayout) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) WindowAdapter(java.awt.event.WindowAdapter) EtchedBorder(javax.swing.border.EtchedBorder) ActionListener(java.awt.event.ActionListener) BorderLayout(java.awt.BorderLayout) WindowEvent(java.awt.event.WindowEvent) JDateTime(org.kse.gui.datetime.JDateTime) CompoundBorder(javax.swing.border.CompoundBorder) EmptyBorder(javax.swing.border.EmptyBorder) AbstractAction(javax.swing.AbstractAction)

Example 3 with JDateTime

use of org.kse.gui.datetime.JDateTime in project keystore-explorer by kaikramer.

the class DGenerateKeyPairCert method initComponents.

private void initComponents(String title) throws CryptoException {
    GridBagConstraints gbcLbl = new GridBagConstraints();
    gbcLbl.gridx = 0;
    gbcLbl.gridwidth = 3;
    gbcLbl.gridheight = 1;
    gbcLbl.insets = new Insets(5, 5, 5, 5);
    gbcLbl.anchor = GridBagConstraints.EAST;
    GridBagConstraints gbcEdCtrl = new GridBagConstraints();
    gbcEdCtrl.gridx = 3;
    gbcEdCtrl.gridwidth = 3;
    gbcEdCtrl.gridheight = 1;
    gbcEdCtrl.insets = new Insets(5, 5, 5, 5);
    gbcEdCtrl.anchor = GridBagConstraints.WEST;
    jlVersion = new JLabel(res.getString("DGenerateKeyPairCert.jlVersion.text"));
    GridBagConstraints gbc_jlVersion = (GridBagConstraints) gbcLbl.clone();
    gbc_jlVersion.gridy = 0;
    jrbVersion1 = new JRadioButton(res.getString("DGenerateKeyPairCert.jrbVersion1.text"));
    jrbVersion1.setToolTipText(res.getString("DGenerateKeyPairCert.jrbVersion1.tooltip"));
    GridBagConstraints gbc_jrbVersion1 = (GridBagConstraints) gbcEdCtrl.clone();
    gbc_jrbVersion1.gridy = 0;
    gbc_jrbVersion1.gridwidth = 1;
    jrbVersion3 = new JRadioButton(res.getString("DGenerateKeyPairCert.jrbVersion3.text"));
    jrbVersion3.setToolTipText(res.getString("DGenerateKeyPairCert.jrbVersion3.tooltip"));
    GridBagConstraints gbc_jrbVersion3 = (GridBagConstraints) gbcEdCtrl.clone();
    gbc_jrbVersion3.gridx = 4;
    gbc_jrbVersion3.gridy = 0;
    gbc_jrbVersion3.gridwidth = 1;
    ButtonGroup buttonGroup = new ButtonGroup();
    buttonGroup.add(jrbVersion1);
    buttonGroup.add(jrbVersion3);
    jlSigAlg = new JLabel(res.getString("DGenerateKeyPairCert.jlSigAlg.text"));
    GridBagConstraints gbc_jlSigAlg = (GridBagConstraints) gbcLbl.clone();
    gbc_jlSigAlg.gridy = 1;
    jcbSignatureAlgorithm = new JComboBox<SignatureType>();
    jcbSignatureAlgorithm.setToolTipText(res.getString("DGenerateKeyPairCert.jcbSignatureAlgorithm.tooltip"));
    jcbSignatureAlgorithm.setMaximumRowCount(10);
    GridBagConstraints gbc_jcbSigAlg = (GridBagConstraints) gbcEdCtrl.clone();
    gbc_jcbSigAlg.gridy = 1;
    // populate signature algorithm selector
    if (issuerPrivateKey != null) {
        KeyPairType issuerKeyPairType = KeyPairType.resolveJce(issuerPrivateKey.getAlgorithm());
        DialogHelper.populateSigAlgs(issuerKeyPairType, issuerPrivateKey, provider, jcbSignatureAlgorithm);
    } else {
        // self-signed
        DialogHelper.populateSigAlgs(keyPairType, keyPair.getPrivate(), provider, jcbSignatureAlgorithm);
    }
    Date now = new Date();
    jlValidityStart = new JLabel(res.getString("DGenerateKeyPairCert.jlValidityStart.text"));
    GridBagConstraints gbc_jlValidityStart = (GridBagConstraints) gbcLbl.clone();
    gbc_jlValidityStart.gridy = 2;
    jdtValidityStart = new JDateTime(res.getString("DGenerateKeyPairCert.jdtValidityStart.text"), false);
    jdtValidityStart.setDateTime(now);
    jdtValidityStart.setToolTipText(res.getString("DGenerateKeyPairCert.jdtValidityStart.tooltip"));
    GridBagConstraints gbc_jdtValidityStart = (GridBagConstraints) gbcEdCtrl.clone();
    gbc_jdtValidityStart.gridy = 2;
    jlValidityPeriod = new JLabel(res.getString("DGenerateKeyPairCert.jlValidityPeriod.text"));
    GridBagConstraints gbc_jlValidityPeriod = (GridBagConstraints) gbcLbl.clone();
    gbc_jlValidityPeriod.gridy = 3;
    jvpValidityPeriod = new JValidityPeriod(JValidityPeriod.YEARS);
    jvpValidityPeriod.setToolTipText(res.getString("DGenerateKeyPairCert.jvpValidityPeriod.tooltip"));
    jvpValidityPeriod.addApplyActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            Date startDate = jdtValidityStart.getDateTime();
            if (startDate == null) {
                startDate = new Date();
                jdtValidityStart.setDateTime(startDate);
            }
            Date validityEnd = jvpValidityPeriod.getValidityEnd(startDate);
            jdtValidityEnd.setDateTime(validityEnd);
        }
    });
    GridBagConstraints gbc_jvpValidityPeriod = (GridBagConstraints) gbcEdCtrl.clone();
    gbc_jvpValidityPeriod.gridy = 3;
    jlValidityEnd = new JLabel(res.getString("DGenerateKeyPairCert.jlValidityEnd.text"));
    GridBagConstraints gbc_jlValidityEnd = (GridBagConstraints) gbcLbl.clone();
    gbc_jlValidityEnd.gridy = 4;
    jdtValidityEnd = new JDateTime(res.getString("DGenerateKeyPairCert.jdtValidityEnd.text"), false);
    jdtValidityEnd.setDateTime(new Date(now.getTime() + TimeUnit.DAYS.toMillis(365)));
    jdtValidityEnd.setToolTipText(res.getString("DGenerateKeyPairCert.jdtValidityEnd.tooltip"));
    GridBagConstraints gbc_jdtValidityEnd = (GridBagConstraints) gbcEdCtrl.clone();
    gbc_jdtValidityEnd.gridy = 4;
    jlSerialNumber = new JLabel(res.getString("DGenerateKeyPairCert.jlSerialNumber.text"));
    GridBagConstraints gbc_jlSerialNumber = (GridBagConstraints) gbcLbl.clone();
    gbc_jlSerialNumber.gridy = 5;
    jtfSerialNumber = new JTextField("" + generateSerialNumber(), 20);
    jtfSerialNumber.setToolTipText(res.getString("DGenerateKeyPairCert.jtfSerialNumber.tooltip"));
    GridBagConstraints gbc_jtfSerialNumber = (GridBagConstraints) gbcEdCtrl.clone();
    gbc_jtfSerialNumber.gridy = 5;
    jlName = new JLabel(res.getString("DGenerateKeyPairCert.jlName.text"));
    GridBagConstraints gbc_jlName = (GridBagConstraints) gbcLbl.clone();
    gbc_jlName.gridy = 6;
    jdnName = new JDistinguishedName("Name", 30, true);
    jdnName.setToolTipText(res.getString("DGenerateKeyPairCert.jdnName.tooltip"));
    GridBagConstraints gbc_jdnName = (GridBagConstraints) gbcEdCtrl.clone();
    gbc_jdnName.gridy = 6;
    jbAddExtensions = new JButton(res.getString("DGenerateKeyPairCert.jbAddExtensions.text"));
    jbAddExtensions.setMnemonic(res.getString("DGenerateKeyPairCert.jbAddExtensions.mnemonic").charAt(0));
    jbAddExtensions.setToolTipText(res.getString("DGenerateKeyPairCert.jbAddExtensions.tooltip"));
    GridBagConstraints gbc_jbAddExtensions = (GridBagConstraints) gbcEdCtrl.clone();
    gbc_jbAddExtensions.gridy = 7;
    gbc_jbAddExtensions.gridwidth = 8;
    gbc_jbAddExtensions.anchor = GridBagConstraints.EAST;
    jbAddExtensions.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DGenerateKeyPairCert.this);
                addExtensionsPressed();
            } finally {
                CursorUtil.setCursorFree(DGenerateKeyPairCert.this);
            }
        }
    });
    jrbVersion3.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent evt) {
            jbAddExtensions.setEnabled(jrbVersion3.isSelected());
        }
    });
    jrbVersion3.setSelected(true);
    jpOptions = new JPanel(new GridBagLayout());
    jpOptions.setBorder(new CompoundBorder(new EmptyBorder(5, 5, 5, 5), new EtchedBorder()));
    jpOptions.add(jlVersion, gbc_jlVersion);
    jpOptions.add(jrbVersion1, gbc_jrbVersion1);
    jpOptions.add(jrbVersion3, gbc_jrbVersion3);
    jpOptions.add(jlSigAlg, gbc_jlSigAlg);
    jpOptions.add(jcbSignatureAlgorithm, gbc_jcbSigAlg);
    jpOptions.add(jlValidityStart, gbc_jlValidityStart);
    jpOptions.add(jdtValidityStart, gbc_jdtValidityStart);
    jpOptions.add(jlValidityPeriod, gbc_jlValidityPeriod);
    jpOptions.add(jvpValidityPeriod, gbc_jvpValidityPeriod);
    jpOptions.add(jlValidityEnd, gbc_jlValidityEnd);
    jpOptions.add(jdtValidityEnd, gbc_jdtValidityEnd);
    jpOptions.add(jlSerialNumber, gbc_jlSerialNumber);
    jpOptions.add(jtfSerialNumber, gbc_jtfSerialNumber);
    jpOptions.add(jlName, gbc_jlName);
    jpOptions.add(jdnName, gbc_jdnName);
    jpOptions.add(jbAddExtensions, gbc_jbAddExtensions);
    jbOK = new JButton(res.getString("DGenerateKeyPairCert.jbOK.text"));
    jbOK.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            okPressed();
        }
    });
    jbCancel = new JButton(res.getString("DGenerateKeyPairCert.jbCancel.text"));
    jbCancel.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelPressed();
        }
    });
    jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), CANCEL_KEY);
    jbCancel.getActionMap().put(CANCEL_KEY, new AbstractAction() {

        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelPressed();
        }
    });
    jpButtons = PlatformUtil.createDialogButtonPanel(jbOK, jbCancel, false);
    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(jpOptions, BorderLayout.CENTER);
    getContentPane().add(jpButtons, BorderLayout.SOUTH);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent evt) {
            closeDialog();
        }
    });
    setTitle(title);
    setResizable(false);
    getRootPane().setDefaultButton(jbOK);
    pack();
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) JRadioButton(javax.swing.JRadioButton) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) WindowAdapter(java.awt.event.WindowAdapter) JValidityPeriod(org.kse.gui.crypto.JValidityPeriod) JTextField(javax.swing.JTextField) JDistinguishedName(org.kse.gui.crypto.JDistinguishedName) BorderLayout(java.awt.BorderLayout) ChangeListener(javax.swing.event.ChangeListener) CompoundBorder(javax.swing.border.CompoundBorder) KeyPairType(org.kse.crypto.keypair.KeyPairType) EmptyBorder(javax.swing.border.EmptyBorder) AbstractAction(javax.swing.AbstractAction) JLabel(javax.swing.JLabel) SignatureType(org.kse.crypto.signing.SignatureType) Date(java.util.Date) EtchedBorder(javax.swing.border.EtchedBorder) ActionListener(java.awt.event.ActionListener) ChangeEvent(javax.swing.event.ChangeEvent) ButtonGroup(javax.swing.ButtonGroup) WindowEvent(java.awt.event.WindowEvent) JDateTime(org.kse.gui.datetime.JDateTime)

Aggregations

ActionEvent (java.awt.event.ActionEvent)3 ActionListener (java.awt.event.ActionListener)3 WindowAdapter (java.awt.event.WindowAdapter)3 WindowEvent (java.awt.event.WindowEvent)3 AbstractAction (javax.swing.AbstractAction)3 JButton (javax.swing.JButton)3 JLabel (javax.swing.JLabel)3 JPanel (javax.swing.JPanel)3 EtchedBorder (javax.swing.border.EtchedBorder)3 JDateTime (org.kse.gui.datetime.JDateTime)3 BorderLayout (java.awt.BorderLayout)2 GridBagConstraints (java.awt.GridBagConstraints)2 GridBagLayout (java.awt.GridBagLayout)2 Insets (java.awt.Insets)2 Date (java.util.Date)2 JRadioButton (javax.swing.JRadioButton)2 JTextField (javax.swing.JTextField)2 CompoundBorder (javax.swing.border.CompoundBorder)2 EmptyBorder (javax.swing.border.EmptyBorder)2 ChangeEvent (javax.swing.event.ChangeEvent)2