Search in sources :

Example 1 with JDistinguishedName

use of org.kse.gui.crypto.JDistinguishedName 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 JDistinguishedName

use of org.kse.gui.crypto.JDistinguishedName in project keystore-explorer by kaikramer.

the class DViewCrl method initComponents.

private void initComponents() {
    GridBagConstraints gbcLbl = new GridBagConstraints();
    gbcLbl.gridx = 0;
    gbcLbl.gridwidth = 1;
    gbcLbl.gridheight = 1;
    gbcLbl.insets = new Insets(5, 5, 5, 5);
    gbcLbl.anchor = GridBagConstraints.EAST;
    GridBagConstraints gbcCtrl = new GridBagConstraints();
    gbcCtrl.gridx = 1;
    gbcCtrl.gridwidth = 1;
    gbcCtrl.gridheight = 1;
    gbcCtrl.insets = new Insets(5, 5, 5, 5);
    gbcCtrl.anchor = GridBagConstraints.WEST;
    jlVersion = new JLabel(res.getString("DViewCrl.jlVersion.text"));
    GridBagConstraints gbc_jlVersion = (GridBagConstraints) gbcLbl.clone();
    gbc_jlVersion.gridy = 0;
    jtfVersion = new JTextField(3);
    jtfVersion.setEditable(false);
    jtfVersion.setToolTipText(res.getString("DViewCrl.jtfVersion.tooltip"));
    GridBagConstraints gbc_jtfVersion = (GridBagConstraints) gbcCtrl.clone();
    gbc_jtfVersion.gridy = 0;
    jlIssuer = new JLabel(res.getString("DViewCrl.jlIssuer.text"));
    GridBagConstraints gbc_jlIssuer = (GridBagConstraints) gbcLbl.clone();
    gbc_jlIssuer.gridy = 1;
    jdnIssuer = new JDistinguishedName(res.getString("DViewCrl.Issuer.Title"), 30, false);
    jdnIssuer.setToolTipText(res.getString("DViewCrl.jdnIssuer.tooltip"));
    GridBagConstraints gbc_jdnIssuer = (GridBagConstraints) gbcCtrl.clone();
    gbc_jdnIssuer.gridy = 1;
    jlEffectiveDate = new JLabel(res.getString("DViewCrl.jlEffectiveDate.text"));
    GridBagConstraints gbc_jlEffectiveDate = (GridBagConstraints) gbcLbl.clone();
    gbc_jlEffectiveDate.gridy = 2;
    jtfEffectiveDate = new JTextField(30);
    jtfEffectiveDate.setEditable(false);
    jtfEffectiveDate.setToolTipText(res.getString("DViewCrl.jtfEffectiveDate.tooltip"));
    GridBagConstraints gbc_jtfEffectiveDate = (GridBagConstraints) gbcCtrl.clone();
    gbc_jtfEffectiveDate.gridy = 2;
    jlNextUpdate = new JLabel(res.getString("DViewCrl.jlNextUpdate.text"));
    GridBagConstraints gbc_jlNextUpdate = (GridBagConstraints) gbcLbl.clone();
    gbc_jlNextUpdate.gridy = 3;
    jtfNextUpdate = new JTextField(30);
    jtfNextUpdate.setEditable(false);
    jtfNextUpdate.setToolTipText(res.getString("DViewCrl.jtfNextUpdate.tooltip"));
    GridBagConstraints gbc_jtfNextUpdate = (GridBagConstraints) gbcCtrl.clone();
    gbc_jtfNextUpdate.gridy = 3;
    jlSignatureAlgorithm = new JLabel(res.getString("DViewCrl.jlSignatureAlgorithm.text"));
    GridBagConstraints gbc_jlSignatureAlgorithm = (GridBagConstraints) gbcLbl.clone();
    gbc_jlSignatureAlgorithm.gridy = 4;
    jtfSignatureAlgorithm = new JTextField(15);
    jtfSignatureAlgorithm.setEditable(false);
    jtfSignatureAlgorithm.setToolTipText(res.getString("DViewCrl.jtfSignatureAlgorithm.tooltip"));
    GridBagConstraints gbc_jtfSignatureAlgorithm = (GridBagConstraints) gbcCtrl.clone();
    gbc_jtfSignatureAlgorithm.gridy = 4;
    jbCrlExtensions = new JButton(res.getString("DViewCrl.jbCrlExtensions.text"));
    PlatformUtil.setMnemonic(jbCrlExtensions, res.getString("DViewCrl.jbCrlExtensions.mnemonic").charAt(0));
    jbCrlExtensions.setToolTipText(res.getString("DViewCrl.jbCrlExtensions.tooltip"));
    jbCrlExtensions.addActionListener(new ActionListener() {

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

        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DViewCrl.this);
                asn1DumpPressed();
            } finally {
                CursorUtil.setCursorFree(DViewCrl.this);
            }
        }
    });
    jpCrlButtons = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0));
    jpCrlButtons.add(jbCrlExtensions);
    jpCrlButtons.add(jbCrlAsn1);
    GridBagConstraints gbc_jpCrlButtons = new GridBagConstraints();
    gbc_jpCrlButtons.gridx = 0;
    gbc_jpCrlButtons.gridy = 5;
    gbc_jpCrlButtons.gridwidth = 2;
    gbc_jpCrlButtons.gridheight = 1;
    gbc_jpCrlButtons.insets = new Insets(5, 0, 5, 0);
    gbc_jpCrlButtons.anchor = GridBagConstraints.EAST;
    jlRevokedCerts = new JLabel(res.getString("DViewCrl.jlRevokedCerts.text"));
    RevokedCertsTableModel rcModel = new RevokedCertsTableModel();
    jtRevokedCerts = new JKseTable(rcModel);
    RowSorter<TableModel> sorter = new TableRowSorter<TableModel>(rcModel);
    jtRevokedCerts.setRowSorter(sorter);
    jtRevokedCerts.setShowGrid(false);
    jtRevokedCerts.setRowMargin(0);
    jtRevokedCerts.getColumnModel().setColumnMargin(0);
    jtRevokedCerts.getTableHeader().setReorderingAllowed(false);
    jtRevokedCerts.setAutoResizeMode(JKseTable.AUTO_RESIZE_ALL_COLUMNS);
    for (int i = 0; i < jtRevokedCerts.getColumnCount(); i++) {
        TableColumn column = jtRevokedCerts.getColumnModel().getColumn(i);
        if (i == 0) {
            column.setPreferredWidth(100);
        }
        column.setHeaderRenderer(new RevokedCertsTableHeadRend(jtRevokedCerts.getTableHeader().getDefaultRenderer()));
        column.setCellRenderer(new RevokedCertsTableCellRend());
    }
    ListSelectionModel listSelectionModel = jtRevokedCerts.getSelectionModel();
    listSelectionModel.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent evt) {
            if (// Ignore spurious
            !evt.getValueIsAdjusting()) // events
            {
                try {
                    CursorUtil.setCursorBusy(DViewCrl.this);
                    crlEntrySelection();
                } finally {
                    CursorUtil.setCursorFree(DViewCrl.this);
                }
            }
        }
    });
    jtRevokedCerts.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent evt) {
            maybeDisplayCrlEntryExtensions(evt);
        }
    });
    jspRevokedCertsTable = PlatformUtil.createScrollPane(jtRevokedCerts, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    jspRevokedCertsTable.getViewport().setBackground(jtRevokedCerts.getBackground());
    jpRevokedCertsTable = new JPanel(new BorderLayout(10, 10));
    jpRevokedCertsTable.setPreferredSize(new Dimension(100, 200));
    jpRevokedCertsTable.add(jlRevokedCerts, BorderLayout.NORTH);
    jpRevokedCertsTable.add(jspRevokedCertsTable, BorderLayout.CENTER);
    jpRevokedCertsTable.setBorder(new CompoundBorder(new EtchedBorder(), new EmptyBorder(5, 5, 5, 5)));
    jbCrlEntryExtensions = new JButton(res.getString("DViewCrl.jbCrlEntryExtensions.text"));
    PlatformUtil.setMnemonic(jbCrlEntryExtensions, res.getString("DViewCrl.jbCrlEntryExtensions.mnemonic").charAt(0));
    jbCrlEntryExtensions.setToolTipText(res.getString("DViewCrl.jbCrlEntryExtensions.tooltip"));
    jbCrlEntryExtensions.setEnabled(false);
    jbCrlEntryExtensions.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DViewCrl.this);
                crlEntryExtensionsPressed();
            } finally {
                CursorUtil.setCursorFree(DViewCrl.this);
            }
        }
    });
    jpCrlEntryExtensions = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    jpCrlEntryExtensions.add(jbCrlEntryExtensions);
    jpRevokedCertsTable.add(jpCrlEntryExtensions, BorderLayout.SOUTH);
    GridBagConstraints gbc_jpRevokedCertsTable = new GridBagConstraints();
    gbc_jpRevokedCertsTable.gridx = 0;
    gbc_jpRevokedCertsTable.gridy = 6;
    gbc_jpRevokedCertsTable.gridwidth = 2;
    gbc_jpRevokedCertsTable.gridheight = 1;
    gbc_jpRevokedCertsTable.insets = new Insets(5, 5, 5, 5);
    gbc_jpRevokedCertsTable.fill = GridBagConstraints.BOTH;
    gbc_jpRevokedCertsTable.anchor = GridBagConstraints.CENTER;
    jpCRL = new JPanel(new GridBagLayout());
    jpCRL.setBorder(new CompoundBorder(new EmptyBorder(10, 10, 10, 10), new EtchedBorder()));
    jpCRL.add(jlVersion, gbc_jlVersion);
    jpCRL.add(jtfVersion, gbc_jtfVersion);
    jpCRL.add(jlIssuer, gbc_jlIssuer);
    jpCRL.add(jdnIssuer, gbc_jdnIssuer);
    jpCRL.add(jlEffectiveDate, gbc_jlEffectiveDate);
    jpCRL.add(jtfEffectiveDate, gbc_jtfEffectiveDate);
    jpCRL.add(jlNextUpdate, gbc_jlNextUpdate);
    jpCRL.add(jtfNextUpdate, gbc_jtfNextUpdate);
    jpCRL.add(jlSignatureAlgorithm, gbc_jlSignatureAlgorithm);
    jpCRL.add(jtfSignatureAlgorithm, gbc_jtfSignatureAlgorithm);
    jpCRL.add(jpCrlButtons, gbc_jpCrlButtons);
    jpCRL.add(jpRevokedCertsTable, gbc_jpRevokedCertsTable);
    populateDialog();
    jbOK = new JButton(res.getString("DViewCrl.jbOK.text"));
    jbOK.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            okPressed();
        }
    });
    jpOK = PlatformUtil.createDialogButtonPanel(jbOK, false);
    getContentPane().add(jpCRL, BorderLayout.CENTER);
    getContentPane().add(jpOK, BorderLayout.SOUTH);
    setResizable(false);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent evt) {
            closeDialog();
        }
    });
    getRootPane().setDefaultButton(jbOK);
    pack();
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            jbOK.requestFocus();
        }
    });
}
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) ListSelectionEvent(javax.swing.event.ListSelectionEvent) WindowAdapter(java.awt.event.WindowAdapter) JTextField(javax.swing.JTextField) JDistinguishedName(org.kse.gui.crypto.JDistinguishedName) BorderLayout(java.awt.BorderLayout) CompoundBorder(javax.swing.border.CompoundBorder) EmptyBorder(javax.swing.border.EmptyBorder) TableRowSorter(javax.swing.table.TableRowSorter) MouseEvent(java.awt.event.MouseEvent) JKseTable(org.kse.gui.JKseTable) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) ListSelectionModel(javax.swing.ListSelectionModel) Dimension(java.awt.Dimension) TableColumn(javax.swing.table.TableColumn) Point(java.awt.Point) ListSelectionListener(javax.swing.event.ListSelectionListener) EtchedBorder(javax.swing.border.EtchedBorder) ActionListener(java.awt.event.ActionListener) WindowEvent(java.awt.event.WindowEvent) TableModel(javax.swing.table.TableModel)

Example 3 with JDistinguishedName

use of org.kse.gui.crypto.JDistinguishedName in project keystore-explorer by kaikramer.

the class DGeneralNameChooser method initComponents.

private void initComponents(GeneralName generalName) {
    jrbDirectoryName = new JRadioButton(res.getString("DGeneralNameChooser.jrbDirectoryName.text"));
    jrbDirectoryName.setToolTipText(res.getString("DGeneralNameChooser.jrbDirectoryName.tooltip"));
    jrbDnsName = new JRadioButton(res.getString("DGeneralNameChooser.jrbDnsName.text"));
    jrbDnsName.setToolTipText(res.getString("DGeneralNameChooser.jrbDnsName.tooltip"));
    jrbIpAddress = new JRadioButton(res.getString("DGeneralNameChooser.jrbIpAddress.text"));
    jrbIpAddress.setToolTipText(res.getString("DGeneralNameChooser.jrbIpAddress.tooltip"));
    jrbRegisteredId = new JRadioButton(res.getString("DGeneralNameChooser.jrbRegisteredId.text"));
    jrbRegisteredId.setToolTipText(res.getString("DGeneralNameChooser.jrbRegisteredId.tooltip"));
    jrbRfc822Name = new JRadioButton(res.getString("DGeneralNameChooser.jrbRfc822Name.text"));
    jrbRfc822Name.setToolTipText(res.getString("DGeneralNameChooser.jrbRfc822Name.tooltip"));
    jrbUniformResourceIdentifier = new JRadioButton(res.getString("DGeneralNameChooser.jrbUniformResourceIdentifier.text"));
    jrbUniformResourceIdentifier.setToolTipText(res.getString("DGeneralNameChooser.jrbUniformResourceIdentifier.tooltip"));
    jrbPrincipalName = new JRadioButton(res.getString("DGeneralNameChooser.jrbPrincipalName.text"));
    jrbPrincipalName.setToolTipText(res.getString("DGeneralNameChooser.jrbPrincipalName.tooltip"));
    ButtonGroup bgGeneralName = new ButtonGroup();
    bgGeneralName.add(jrbDirectoryName);
    bgGeneralName.add(jrbDnsName);
    bgGeneralName.add(jrbIpAddress);
    bgGeneralName.add(jrbRegisteredId);
    bgGeneralName.add(jrbRfc822Name);
    bgGeneralName.add(jrbUniformResourceIdentifier);
    bgGeneralName.add(jrbPrincipalName);
    jlGeneralNameType = new JLabel(res.getString("DGeneralNameChooser.jlGeneralNameType.text"));
    jlGeneralNameValue = new JLabel(res.getString("DGeneralNameChooser.jlGeneralNameValue.text"));
    jpGeneralNameValue = new JPanel(new FlowLayout(FlowLayout.LEFT));
    jdnDirectoryName = new JDistinguishedName(res.getString("DGeneralNameChooser.DirectoryName.Title"), 20, true);
    jtfDnsName = new JTextField(30);
    jtfIpAddress = new JTextField(30);
    joiRegisteredId = new JObjectId(res.getString("DGeneralNameChooser.RegisteredId.Title"));
    jtfRfc822Name = new JTextField(30);
    jtfUniformResourceIdentifier = new JTextField(30);
    jtfPrincipalName = new JTextField(30);
    jbOK = new JButton(res.getString("DGeneralNameChooser.jbOK.text"));
    jbCancel = new JButton(res.getString("DGeneralNameChooser.jbCancel.text"));
    jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), CANCEL_KEY);
    jpButtons = PlatformUtil.createDialogButtonPanel(jbOK, jbCancel);
    Container pane = getContentPane();
    pane.setLayout(new MigLayout("insets dialog, fill", "[]rel[]", ""));
    pane.add(jlGeneralNameType, "spanx, wrap");
    pane.add(jrbDirectoryName, "");
    pane.add(jrbDnsName, "");
    pane.add(jrbIpAddress, "");
    pane.add(jrbRegisteredId, "wrap");
    pane.add(jrbRfc822Name, "");
    pane.add(jrbUniformResourceIdentifier, "");
    pane.add(jrbPrincipalName, "wrap");
    pane.add(jlGeneralNameValue, "spanx");
    pane.add(jpGeneralNameValue, "spanx, wrap");
    pane.add(new JSeparator(), "spanx, growx, wrap para");
    pane.add(jpButtons, "right, spanx");
    // actions
    jrbDirectoryName.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent evt) {
            generalNameTypeChanged();
        }
    });
    jrbDnsName.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent evt) {
            generalNameTypeChanged();
        }
    });
    jrbRegisteredId.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent evt) {
            generalNameTypeChanged();
        }
    });
    jrbIpAddress.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent evt) {
            generalNameTypeChanged();
        }
    });
    jrbRfc822Name.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent evt) {
            generalNameTypeChanged();
        }
    });
    jrbUniformResourceIdentifier.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent evt) {
            generalNameTypeChanged();
        }
    });
    jrbPrincipalName.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent evt) {
            generalNameTypeChanged();
        }
    });
    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();
        }
    });
    populate(generalName);
    setResizable(false);
    getRootPane().setDefaultButton(jbOK);
    pack();
}
Also used : JPanel(javax.swing.JPanel) ItemEvent(java.awt.event.ItemEvent) JRadioButton(javax.swing.JRadioButton) FlowLayout(java.awt.FlowLayout) JObjectId(org.kse.gui.oid.JObjectId) ActionEvent(java.awt.event.ActionEvent) MigLayout(net.miginfocom.swing.MigLayout) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) JSeparator(javax.swing.JSeparator) Container(java.awt.Container) JDistinguishedName(org.kse.gui.crypto.JDistinguishedName) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) ItemListener(java.awt.event.ItemListener) AbstractAction(javax.swing.AbstractAction)

Example 4 with JDistinguishedName

use of org.kse.gui.crypto.JDistinguishedName in project keystore-explorer by kaikramer.

the class DViewCertificate method initComponents.

private void initComponents(X509Certificate[] certs) throws CryptoException {
    jlHierarchy = new JLabel(res.getString("DViewCertificate.jlHierarchy.text"));
    jtrHierarchy = new JTree(createCertificateNodes(certs));
    jtrHierarchy.setRowHeight(Math.max(18, jtrHierarchy.getRowHeight()));
    jtrHierarchy.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    ToolTipManager.sharedInstance().registerComponent(jtrHierarchy);
    jtrHierarchy.setCellRenderer(new CertificateTreeCellRend());
    jtrHierarchy.setRootVisible(false);
    TreeNode topNode = (TreeNode) jtrHierarchy.getModel().getRoot();
    expandTree(jtrHierarchy, new TreePath(topNode));
    jtrHierarchy.addTreeSelectionListener(new TreeSelectionListener() {

        @Override
        public void valueChanged(TreeSelectionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DViewCertificate.this);
                populateDetails();
            } finally {
                CursorUtil.setCursorFree(DViewCertificate.this);
            }
        }
    });
    jspHierarchy = PlatformUtil.createScrollPane(jtrHierarchy, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    jspHierarchy.setPreferredSize(new Dimension(100, 75));
    jpHierarchy = new JPanel(new BorderLayout(5, 5));
    jpHierarchy.add(jlHierarchy, BorderLayout.NORTH);
    jpHierarchy.add(jspHierarchy, BorderLayout.CENTER);
    jpHierarchy.setBorder(new EmptyBorder(5, 5, 5, 5));
    GridBagConstraints gbcLbl = new GridBagConstraints();
    gbcLbl.gridx = 0;
    gbcLbl.gridwidth = 1;
    gbcLbl.gridheight = 1;
    gbcLbl.insets = new Insets(5, 5, 5, 5);
    gbcLbl.anchor = GridBagConstraints.EAST;
    GridBagConstraints gbcCtrl = new GridBagConstraints();
    gbcCtrl.gridx = 1;
    gbcCtrl.gridwidth = 1;
    gbcCtrl.gridheight = 1;
    gbcCtrl.insets = new Insets(5, 5, 5, 5);
    gbcCtrl.anchor = GridBagConstraints.WEST;
    jlVersion = new JLabel(res.getString("DViewCertificate.jlVersion.text"));
    GridBagConstraints gbc_jlVersion = (GridBagConstraints) gbcLbl.clone();
    gbc_jlVersion.gridy = 0;
    jtfVersion = new JTextField(3);
    jtfVersion.setEditable(false);
    jtfVersion.setToolTipText(res.getString("DViewCertificate.jtfVersion.tooltip"));
    GridBagConstraints gbc_jtfVersion = (GridBagConstraints) gbcCtrl.clone();
    gbc_jtfVersion.gridy = 0;
    jlSubject = new JLabel(res.getString("DViewCertificate.jlSubject.text"));
    GridBagConstraints gbc_jlSubject = (GridBagConstraints) gbcLbl.clone();
    gbc_jlSubject.gridy = 1;
    jdnSubject = new JDistinguishedName(res.getString("DViewCertificate.Subject.Title"), 40, false);
    jdnSubject.setToolTipText(res.getString("DViewCertificate.jdnSubject.tooltip"));
    GridBagConstraints gbc_jdnSubject = (GridBagConstraints) gbcCtrl.clone();
    gbc_jdnSubject.gridy = 1;
    jlIssuer = new JLabel(res.getString("DViewCertificate.jlIssuer.text"));
    GridBagConstraints gbc_jlIssuer = (GridBagConstraints) gbcLbl.clone();
    gbc_jlIssuer.gridy = 2;
    jdnIssuer = new JDistinguishedName(res.getString("DViewCertificate.Issuer.Title"), 40, false);
    jdnIssuer.setToolTipText(res.getString("DViewCertificate.jdnIssuer.tooltip"));
    GridBagConstraints gbc_jdnIssuer = (GridBagConstraints) gbcCtrl.clone();
    gbc_jdnIssuer.gridy = 2;
    jlSerialNumber = new JLabel(res.getString("DViewCertificate.jlSerialNumber.text"));
    GridBagConstraints gbc_jlSerialNumber = (GridBagConstraints) gbcLbl.clone();
    gbc_jlSerialNumber.gridy = 3;
    jtfSerialNumber = new JTextField(30);
    jtfSerialNumber.setEditable(false);
    jtfSerialNumber.setToolTipText(res.getString("DViewCertificate.jtfSerialNumber.tooltip"));
    GridBagConstraints gbc_jtfSerialNumber = (GridBagConstraints) gbcCtrl.clone();
    gbc_jtfSerialNumber.gridy = 3;
    jlValidFrom = new JLabel(res.getString("DViewCertificate.jlValidFrom.text"));
    GridBagConstraints gbc_jlValidFrom = (GridBagConstraints) gbcLbl.clone();
    gbc_jlValidFrom.gridy = 4;
    jtfValidFrom = new JTextField(30);
    jtfValidFrom.setEditable(false);
    jtfValidFrom.setToolTipText(res.getString("DViewCertificate.jtfValidFrom.tooltip"));
    GridBagConstraints gbc_jtfValidFrom = (GridBagConstraints) gbcCtrl.clone();
    gbc_jtfValidFrom.gridy = 4;
    jlValidUntil = new JLabel(res.getString("DViewCertificate.jlValidUntil.text"));
    GridBagConstraints gbc_jlValidUntil = (GridBagConstraints) gbcLbl.clone();
    gbc_jlValidUntil.gridy = 5;
    jtfValidUntil = new JTextField(30);
    jtfValidUntil.setEditable(false);
    jtfValidUntil.setToolTipText(res.getString("DViewCertificate.jtfValidUntil.tooltip"));
    GridBagConstraints gbc_jtfValidUntil = (GridBagConstraints) gbcCtrl.clone();
    gbc_jtfValidUntil.gridy = 5;
    jlPublicKey = new JLabel(res.getString("DViewCertificate.jlPublicKey.text"));
    GridBagConstraints gbc_jlPublicKey = (GridBagConstraints) gbcLbl.clone();
    gbc_jlPublicKey.gridy = 6;
    jtfPublicKey = new JTextField(15);
    jtfPublicKey.setEditable(false);
    jtfPublicKey.setToolTipText(res.getString("DViewCertificate.jtfPublicKey.tooltip"));
    jbViewPublicKeyDetails = new JButton();
    jbViewPublicKeyDetails.setToolTipText(res.getString("DViewCertificate.jbViewPublicKeyDetails.tooltip"));
    jbViewPublicKeyDetails.setIcon(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(res.getString("DViewCertificate.jbViewPublicKeyDetails.image")))));
    jbViewPublicKeyDetails.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DViewCertificate.this);
                pubKeyDetailsPressed();
            } finally {
                CursorUtil.setCursorFree(DViewCertificate.this);
            }
        }
    });
    jpPublicKey = new JPanel(new GridBagLayout());
    GridBagConstraints gbc_jpPublicKey = (GridBagConstraints) gbcCtrl.clone();
    gbc_jpPublicKey.gridy = 6;
    GridBagConstraints gbc_jtfPublicKey = new GridBagConstraints();
    gbc_jtfPublicKey.gridwidth = 1;
    gbc_jtfPublicKey.gridheight = 1;
    gbc_jtfPublicKey.gridx = 0;
    gbc_jtfPublicKey.gridy = 0;
    gbc_jtfPublicKey.insets = new Insets(0, 0, 0, 5);
    GridBagConstraints gbc_jbViewPublicKeyDetails = new GridBagConstraints();
    gbc_jbViewPublicKeyDetails.gridwidth = 1;
    gbc_jbViewPublicKeyDetails.gridheight = 1;
    gbc_jbViewPublicKeyDetails.gridx = 1;
    gbc_jbViewPublicKeyDetails.gridy = 0;
    gbc_jbViewPublicKeyDetails.insets = new Insets(0, 5, 0, 0);
    jpPublicKey.add(jtfPublicKey, gbc_jtfPublicKey);
    jpPublicKey.add(jbViewPublicKeyDetails, gbc_jbViewPublicKeyDetails);
    jlSignatureAlgorithm = new JLabel(res.getString("DViewCertificate.jlSignatureAlgorithm.text"));
    GridBagConstraints gbc_jlSignatureAlgorithm = (GridBagConstraints) gbcLbl.clone();
    gbc_jlSignatureAlgorithm.gridy = 7;
    jtfSignatureAlgorithm = new JTextField(15);
    jtfSignatureAlgorithm.setEditable(false);
    jtfSignatureAlgorithm.setToolTipText(res.getString("DViewCertificate.jtfSignatureAlgorithm.tooltip"));
    GridBagConstraints gbc_jtfSignatureAlgorithm = (GridBagConstraints) gbcCtrl.clone();
    gbc_jtfSignatureAlgorithm.gridy = 7;
    jlFingerprint = new JLabel(res.getString("DViewCertificate.jlFingerprint.text"));
    GridBagConstraints gbc_jlFingerprint = (GridBagConstraints) gbcLbl.clone();
    gbc_jlFingerprint.gridy = 8;
    jcfFingerprint = new JCertificateFingerprint(30);
    GridBagConstraints gbc_jcfFingerprint = (GridBagConstraints) gbcCtrl.clone();
    gbc_jcfFingerprint.gridy = 8;
    jbExtensions = new JButton(res.getString("DViewCertificate.jbExtensions.text"));
    PlatformUtil.setMnemonic(jbExtensions, res.getString("DViewCertificate.jbExtensions.mnemonic").charAt(0));
    jbExtensions.setToolTipText(res.getString("DViewCertificate.jbExtensions.tooltip"));
    jbExtensions.addActionListener(new ActionListener() {

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

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

        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DViewCertificate.this);
                asn1DumpPressed();
            } finally {
                CursorUtil.setCursorFree(DViewCertificate.this);
            }
        }
    });
    if (importExport == IMPORT) {
        jbImportExport = new JButton(res.getString("DViewCertificate.jbImportExport.import.text"));
        jbImportExport.setToolTipText(res.getString("DViewCertificate.jbImportExport.import.tooltip"));
    } else {
        jbImportExport = new JButton(res.getString("DViewCertificate.jbImportExport.export.text"));
        jbImportExport.setToolTipText(res.getString("DViewCertificate.jbImportExport.export.tooltip"));
    }
    PlatformUtil.setMnemonic(jbImportExport, res.getString("DViewCertificate.jbImportExport.mnemonic").charAt(0));
    jbImportExport.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DViewCertificate.this);
                importExportPressed();
            } finally {
                CursorUtil.setCursorFree(DViewCertificate.this);
            }
        }
    });
    jpButtons = new JPanel();
    if (importExport != NONE) {
        jpButtons.add(jbImportExport);
    }
    jpButtons.add(jbExtensions);
    jpButtons.add(jbPem);
    jpButtons.add(jbAsn1);
    GridBagConstraints gbc_jpButtons = new GridBagConstraints();
    gbc_jpButtons.gridx = 0;
    gbc_jpButtons.gridy = 9;
    gbc_jpButtons.gridwidth = 2;
    gbc_jpButtons.gridheight = 1;
    gbc_jpButtons.anchor = GridBagConstraints.EAST;
    jpDetail = new JPanel(new GridBagLayout());
    jpDetail.setBorder(new EmptyBorder(5, 5, 5, 5));
    jpDetail.add(jlVersion, gbc_jlVersion);
    jpDetail.add(jtfVersion, gbc_jtfVersion);
    jpDetail.add(jlSubject, gbc_jlSubject);
    jpDetail.add(jdnSubject, gbc_jdnSubject);
    jpDetail.add(jlIssuer, gbc_jlIssuer);
    jpDetail.add(jdnIssuer, gbc_jdnIssuer);
    jpDetail.add(jlSerialNumber, gbc_jlSerialNumber);
    jpDetail.add(jtfSerialNumber, gbc_jtfSerialNumber);
    jpDetail.add(jlValidFrom, gbc_jlValidFrom);
    jpDetail.add(jtfValidFrom, gbc_jtfValidFrom);
    jpDetail.add(jlValidUntil, gbc_jlValidUntil);
    jpDetail.add(jtfValidUntil, gbc_jtfValidUntil);
    jpDetail.add(jlPublicKey, gbc_jlPublicKey);
    jpDetail.add(jpPublicKey, gbc_jpPublicKey);
    jpDetail.add(jlSignatureAlgorithm, gbc_jlSignatureAlgorithm);
    jpDetail.add(jtfSignatureAlgorithm, gbc_jtfSignatureAlgorithm);
    jpDetail.add(jlFingerprint, gbc_jlFingerprint);
    jpDetail.add(jcfFingerprint, gbc_jcfFingerprint);
    jpDetail.add(jpButtons, gbc_jpButtons);
    jpCertificates = new JPanel(new BorderLayout(0, 0));
    jpCertificates.setBorder(new CompoundBorder(new EmptyBorder(5, 5, 5, 5), new EtchedBorder()));
    jpCertificates.add(jpHierarchy, BorderLayout.NORTH);
    jpCertificates.add(jpDetail, BorderLayout.CENTER);
    jbOK = new JButton(res.getString("DViewCertificate.jbOK.text"));
    jbOK.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent evt) {
            okPressed();
        }
    });
    jpOK = PlatformUtil.createDialogButtonPanel(jbOK, false);
    getContentPane().add(jpCertificates, BorderLayout.CENTER);
    getContentPane().add(jpOK, BorderLayout.SOUTH);
    jtrHierarchy.setSelectionRow(0);
    setResizable(false);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent evt) {
            closeDialog();
        }
    });
    getRootPane().setDefaultButton(jbOK);
    pack();
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            jbOK.requestFocus();
        }
    });
}
Also used : JPanel(javax.swing.JPanel) ImageIcon(javax.swing.ImageIcon) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) WindowAdapter(java.awt.event.WindowAdapter) TreeSelectionListener(javax.swing.event.TreeSelectionListener) JTextField(javax.swing.JTextField) JDistinguishedName(org.kse.gui.crypto.JDistinguishedName) BorderLayout(java.awt.BorderLayout) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) TreeNode(javax.swing.tree.TreeNode) CompoundBorder(javax.swing.border.CompoundBorder) EmptyBorder(javax.swing.border.EmptyBorder) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) JTree(javax.swing.JTree) EtchedBorder(javax.swing.border.EtchedBorder) TreePath(javax.swing.tree.TreePath) ActionListener(java.awt.event.ActionListener) WindowEvent(java.awt.event.WindowEvent) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent) JCertificateFingerprint(org.kse.gui.crypto.JCertificateFingerprint)

Example 5 with JDistinguishedName

use of org.kse.gui.crypto.JDistinguishedName in project keystore-explorer by kaikramer.

the class DViewCsr method initComponents.

private void initComponents() throws CryptoException {
    jlFormat = new JLabel(res.getString("DViewCsr.jlFormat.text"));
    jtfFormat = new JTextField(15);
    jtfFormat.setEditable(false);
    jtfFormat.setToolTipText(res.getString("DViewCsr.jtfFormat.tooltip"));
    jlSubject = new JLabel(res.getString("DViewCsr.jlSubject.text"));
    jdnSubject = new JDistinguishedName(res.getString("DViewCsr.Subject.Title"), 30, false);
    jdnSubject.setToolTipText(res.getString("DViewCsr.jdnSubject.tooltip"));
    jlPublicKey = new JLabel(res.getString("DViewCsr.jlPublicKey.text"));
    jtfPublicKey = new JTextField(15);
    jtfPublicKey.setEditable(false);
    jtfPublicKey.setToolTipText(res.getString("DViewCsr.jtfPublicKey.tooltip"));
    jbViewPublicKeyDetails = new JButton();
    jbViewPublicKeyDetails.setToolTipText(res.getString("DViewCsr.jbViewPublicKeyDetails.tooltip"));
    jbViewPublicKeyDetails.setIcon(new ImageIcon(Toolkit.getDefaultToolkit().createImage(getClass().getResource(res.getString("DViewCsr.jbViewPublicKeyDetails.image")))));
    jlSignatureAlgorithm = new JLabel(res.getString("DViewCsr.jlSignatureAlgorithm.text"));
    jtfSignatureAlgorithm = new JTextField(15);
    jtfSignatureAlgorithm.setEditable(false);
    jtfSignatureAlgorithm.setToolTipText(res.getString("DViewCsr.jtfSignatureAlgorithm.tooltip"));
    jlChallenge = new JLabel(res.getString("DViewCsr.jlChallenge.text"));
    jtfChallenge = new JTextField(15);
    jtfChallenge.setEditable(false);
    jtfChallenge.setToolTipText(res.getString("DViewCsr.jtfChallenge.tooltip"));
    jlUnstructuredName = new JLabel(res.getString("DViewCsr.jlUnstructuredName.text"));
    jtfUnstructuredName = new JTextField(30);
    jtfUnstructuredName.setEditable(false);
    jtfUnstructuredName.setToolTipText(res.getString("DViewCsr.jtfUnstructuredName.tooltip"));
    jbExtensions = new JButton(res.getString("DViewCsr.jbExtensions.text"));
    PlatformUtil.setMnemonic(jbExtensions, res.getString("DViewCsr.jbExtensions.mnemonic").charAt(0));
    jbExtensions.setToolTipText(res.getString("DViewCsr.jbExtensions.tooltip"));
    jbPem = new JButton(res.getString("DViewCsr.jbPem.text"));
    PlatformUtil.setMnemonic(jbPem, res.getString("DViewCsr.jbPem.mnemonic").charAt(0));
    jbPem.setToolTipText(res.getString("DViewCsr.jbPem.tooltip"));
    jbAsn1 = new JButton(res.getString("DViewCsr.jbAsn1.text"));
    PlatformUtil.setMnemonic(jbAsn1, res.getString("DViewCsr.jbAsn1.mnemonic").charAt(0));
    jbAsn1.setToolTipText(res.getString("DViewCsr.jbAsn1.tooltip"));
    jbOK = new JButton(res.getString("DViewCsr.jbOK.text"));
    Container pane = getContentPane();
    pane.setLayout(new MigLayout("insets dialog, fill", "[right]unrel[]", "[]unrel[]"));
    pane.add(jlFormat, "");
    pane.add(jtfFormat, "wrap");
    pane.add(jlSubject, "");
    pane.add(jdnSubject, "wrap");
    pane.add(jlPublicKey, "");
    pane.add(jtfPublicKey, "split 2");
    pane.add(jbViewPublicKeyDetails, "wrap");
    pane.add(jlSignatureAlgorithm, "");
    pane.add(jtfSignatureAlgorithm, "wrap");
    pane.add(jlChallenge, "");
    pane.add(jtfChallenge, "wrap");
    pane.add(jlUnstructuredName, "");
    pane.add(jtfUnstructuredName, "wrap para");
    pane.add(jbExtensions, "spanx, split");
    pane.add(jbPem, "");
    pane.add(jbAsn1, "wrap");
    pane.add(new JSeparator(), "spanx, growx, wrap 15:push");
    pane.add(jbOK, "spanx, tag ok");
    populateCsrDetails();
    jbViewPublicKeyDetails.addActionListener(new ActionListener() {

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

        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DViewCsr.this);
                extensionsPressed();
            } finally {
                CursorUtil.setCursorFree(DViewCsr.this);
            }
        }
    });
    jbPem.addActionListener(new ActionListener() {

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

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

        @Override
        public void actionPerformed(ActionEvent evt) {
            try {
                CursorUtil.setCursorBusy(DViewCsr.this);
                asn1DumpPressed();
            } finally {
                CursorUtil.setCursorFree(DViewCsr.this);
            }
        }
    });
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent evt) {
            closeDialog();
        }
    });
    setResizable(false);
    getRootPane().setDefaultButton(jbOK);
    pack();
}
Also used : ImageIcon(javax.swing.ImageIcon) ActionEvent(java.awt.event.ActionEvent) MigLayout(net.miginfocom.swing.MigLayout) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) WindowAdapter(java.awt.event.WindowAdapter) JTextField(javax.swing.JTextField) JSeparator(javax.swing.JSeparator) Container(java.awt.Container) JDistinguishedName(org.kse.gui.crypto.JDistinguishedName) ActionListener(java.awt.event.ActionListener) WindowEvent(java.awt.event.WindowEvent)

Aggregations

ActionEvent (java.awt.event.ActionEvent)6 ActionListener (java.awt.event.ActionListener)6 JButton (javax.swing.JButton)6 JLabel (javax.swing.JLabel)6 JTextField (javax.swing.JTextField)6 JDistinguishedName (org.kse.gui.crypto.JDistinguishedName)6 WindowAdapter (java.awt.event.WindowAdapter)5 WindowEvent (java.awt.event.WindowEvent)5 JPanel (javax.swing.JPanel)5 EtchedBorder (javax.swing.border.EtchedBorder)4 BorderLayout (java.awt.BorderLayout)3 GridBagConstraints (java.awt.GridBagConstraints)3 GridBagLayout (java.awt.GridBagLayout)3 Insets (java.awt.Insets)3 AbstractAction (javax.swing.AbstractAction)3 ImageIcon (javax.swing.ImageIcon)3 JRadioButton (javax.swing.JRadioButton)3 CompoundBorder (javax.swing.border.CompoundBorder)3 EmptyBorder (javax.swing.border.EmptyBorder)3 MigLayout (net.miginfocom.swing.MigLayout)3