Search in sources :

Example 1 with JCertificateFingerprint

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

Aggregations

BorderLayout (java.awt.BorderLayout)1 Dimension (java.awt.Dimension)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 Insets (java.awt.Insets)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 WindowAdapter (java.awt.event.WindowAdapter)1 WindowEvent (java.awt.event.WindowEvent)1 ImageIcon (javax.swing.ImageIcon)1 JButton (javax.swing.JButton)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1 JTextField (javax.swing.JTextField)1 JTree (javax.swing.JTree)1 CompoundBorder (javax.swing.border.CompoundBorder)1 EmptyBorder (javax.swing.border.EmptyBorder)1 EtchedBorder (javax.swing.border.EtchedBorder)1 TreeSelectionEvent (javax.swing.event.TreeSelectionEvent)1 TreeSelectionListener (javax.swing.event.TreeSelectionListener)1