com.archivas.clienttools.arcmover.gui.ssl.SSLCertificateForm.java Source code

Java tutorial

Introduction

Here is the source code for com.archivas.clienttools.arcmover.gui.ssl.SSLCertificateForm.java

Source

// Copyright 2007 Hitachi Data Systems
// All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.

package com.archivas.clienttools.arcmover.gui.ssl;

import java.awt.*;
import javax.swing.*;

import com.archivas.clienttools.arcutils.utils.net.SSLCertChain;
import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.FormLayout;

public class SSLCertificateForm extends JPanel {
    protected JTabbedPane tabbedPane1;
    protected JLabel issuedToCommonNameLabel;
    protected JLabel issuedByCommonNameLabel;
    protected JLabel validDateRangeLabel;
    protected JLabel md5FingerprintLabel;
    protected JLabel issuedToOrganizationLabel;
    protected JLabel issuedByOrganizationLabel;
    protected JLabel issuedToOrganizationalUnitLabel;
    protected JLabel issuedByOrganizationalUnitLabel;
    protected JLabel serialNumberLabel;
    protected JLabel shaFingerprintLabel;
    protected JTextArea detailsTextArea;
    protected JPanel contentPane;
    protected JCheckBox permStoreCertCheckBox;
    protected JTextPane otherWarnings;

    public static final ImageIcon sslFrameIcon = new ImageIcon(
            SSLCertificateForm.class.getResource("/images/lockedstate.gif"));

    public void setSSLCertChain(final SSLCertChain sslCerts) {
        issuedToCommonNameLabel.setText(sslCerts.getIssuedToCommonName());
        issuedToOrganizationLabel.setText(sslCerts.getIssuedToOrganization());
        issuedToOrganizationalUnitLabel.setText(sslCerts.getIssuedToOrgUnit());

        issuedByCommonNameLabel.setText(sslCerts.getIssuedByCommonName());
        issuedByOrganizationLabel.setText(sslCerts.getIssuedByOrganization());
        issuedByOrganizationalUnitLabel.setText(sslCerts.getIssuedByOrgUnit());

        serialNumberLabel.setText(sslCerts.getSerialNumberString());
        md5FingerprintLabel.setText(sslCerts.getMD5FingerprintString());
        shaFingerprintLabel.setText(sslCerts.getShaFingerprintString());

        validDateRangeLabel.setText(sslCerts.getValidRangeString());
        detailsTextArea.setText(sslCerts.toDetailString());

        // Hide this by default. It only gets used when confirming the cert.
        setPermStoreCertCheckBoxVisible(false);
    }

    public void setOtherWarningsText(String text) {
        otherWarnings.setText(text);
    }

    public void setPermStoreCertCheckBoxVisible(boolean visible) {
        permStoreCertCheckBox.setVisible(visible);
    }

    public void setPermStoreCertCheckBoxEnabled(boolean enabled) {
        permStoreCertCheckBox.setEnabled(enabled);
    }

    public JCheckBox getPermStoreCertCheckBox() {
        return permStoreCertCheckBox;
    }

    public void setPermStoreCertCheckBox(final JCheckBox permStoreCertCheckBox) {
        this.permStoreCertCheckBox = permStoreCertCheckBox;
    }

    {
        // GUI initializer generated by IntelliJ IDEA GUI Designer
        // >>> IMPORTANT!! <<<
        // DO NOT EDIT OR ADD ANY CODE HERE!
        $$$setupUI$$$();
    }

    /**
     * Method generated by IntelliJ IDEA GUI Designer >>> IMPORTANT!! <<< DO NOT edit this method OR
     * call it in your code!
     *
     * @noinspection ALL
     */
    private void $$$setupUI$$$() {
        contentPane = new JPanel();
        contentPane.setLayout(new FormLayout("fill:d:grow", "center:d:grow"));
        contentPane.setMinimumSize(new Dimension(400, 390));
        tabbedPane1 = new JTabbedPane();
        tabbedPane1.setMinimumSize(new Dimension(400, 200));
        tabbedPane1.setOpaque(false);
        tabbedPane1.setPreferredSize(new Dimension(400, 200));
        CellConstraints cc = new CellConstraints();
        contentPane.add(tabbedPane1, cc.xy(1, 1, CellConstraints.DEFAULT, CellConstraints.FILL));
        final JPanel panel1 = new JPanel();
        panel1.setLayout(new FormLayout("fill:6dlu:noGrow,right:d:noGrow,fill:d:grow,left:5dlu:noGrow",
                "center:7dlu:noGrow,center:max(d;4px):noGrow,center:d:noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow,top:8dlu:noGrow,center:max(d;4px):noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow,center:max(d;4px):noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow,top:4dlu:noGrow,center:16px:noGrow,top:8dlu:noGrow,center:max(d;4px):noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow,top:8dlu:noGrow,center:max(d;4px):noGrow,center:max(d;4px):noGrow,top:4dlu:noGrow,center:max(d;4px):noGrow,center:max(d;4px):noGrow,top:4dlu:noGrow,top:15px:grow,top:4dlu:noGrow,center:d:grow,center:18px:noGrow,top:15dlu:noGrow"));
        panel1.setMinimumSize(new Dimension(400, 220));
        panel1.setPreferredSize(new Dimension(400, 220));
        tabbedPane1.addTab("General", panel1);
        final JLabel label1 = new JLabel();
        label1.setName("Issued to:");
        label1.setText("Common Name (CN)");
        panel1.add(label1, cc.xy(2, 3, CellConstraints.RIGHT, CellConstraints.DEFAULT));
        issuedToCommonNameLabel = new JLabel();
        issuedToCommonNameLabel.setText("Issued to Value");
        panel1.add(issuedToCommonNameLabel, cc.xy(3, 3));
        final JLabel label2 = new JLabel();
        label2.setText("Common Name (CN)");
        panel1.add(label2, cc.xy(2, 14));
        issuedByCommonNameLabel = new JLabel();
        issuedByCommonNameLabel.setText("Issued by Value");
        panel1.add(issuedByCommonNameLabel, cc.xy(3, 14));
        final JLabel label3 = new JLabel();
        label3.setText("Valid From");
        panel1.add(label3, cc.xy(2, 22));
        validDateRangeLabel = new JLabel();
        validDateRangeLabel.setAutoscrolls(false);
        validDateRangeLabel.setText("Valid from Value");
        panel1.add(validDateRangeLabel, cc.xy(3, 22));
        final JLabel label4 = new JLabel();
        label4.setText("MD5 Fingerprint");
        panel1.add(label4, cc.xy(2, 27));
        md5FingerprintLabel = new JLabel();
        md5FingerprintLabel.setAutoscrolls(true);
        md5FingerprintLabel.setEnabled(true);
        md5FingerprintLabel.setText("MD5 Fingerprint value");
        panel1.add(md5FingerprintLabel, cc.xy(3, 27));
        final JLabel label5 = new JLabel();
        label5.setText("Organization (O)");
        panel1.add(label5, cc.xy(2, 5));
        issuedToOrganizationLabel = new JLabel();
        issuedToOrganizationLabel.setText("Organization Value");
        panel1.add(issuedToOrganizationLabel, cc.xy(3, 5));
        final JLabel label6 = new JLabel();
        label6.setFont(new Font(label6.getFont().getName(), Font.BOLD, label6.getFont().getSize()));
        label6.setText("Issued To");
        panel1.add(label6, cc.xy(2, 2, CellConstraints.LEFT, CellConstraints.DEFAULT));
        final JLabel label7 = new JLabel();
        label7.setFont(new Font(label7.getFont().getName(), Font.BOLD, label7.getFont().getSize()));
        label7.setText("Issued By");
        panel1.add(label7, cc.xy(2, 11, CellConstraints.LEFT, CellConstraints.DEFAULT));
        final JLabel label8 = new JLabel();
        label8.setText("Organization (O)");
        panel1.add(label8, cc.xy(2, 16));
        issuedByOrganizationLabel = new JLabel();
        issuedByOrganizationLabel.setText("Organization Value");
        panel1.add(issuedByOrganizationLabel, cc.xy(3, 16));
        final JLabel label9 = new JLabel();
        label9.setText("Organizational Unit (OU)");
        panel1.add(label9, cc.xy(2, 7));
        issuedToOrganizationalUnitLabel = new JLabel();
        issuedToOrganizationalUnitLabel.setText("Organizational Unit Value");
        panel1.add(issuedToOrganizationalUnitLabel, cc.xy(3, 7));
        final JLabel label10 = new JLabel();
        label10.setText("Organizational Unit (OU)");
        panel1.add(label10, cc.xy(2, 18));
        issuedByOrganizationalUnitLabel = new JLabel();
        issuedByOrganizationalUnitLabel.setText("Organizational Unit Value");
        panel1.add(issuedByOrganizationalUnitLabel, cc.xy(3, 18));
        final JLabel label11 = new JLabel();
        label11.setFont(new Font(label11.getFont().getName(), Font.BOLD, label11.getFont().getSize()));
        label11.setText("Validity");
        panel1.add(label11, cc.xy(2, 20, CellConstraints.LEFT, CellConstraints.DEFAULT));
        final JLabel label12 = new JLabel();
        label12.setFont(new Font(label12.getFont().getName(), Font.BOLD, label12.getFont().getSize()));
        label12.setText("Fingerprints");
        panel1.add(label12, cc.xy(2, 24, CellConstraints.LEFT, CellConstraints.DEFAULT));
        final JLabel label13 = new JLabel();
        label13.setText("Serial Number");
        panel1.add(label13, cc.xy(2, 9));
        serialNumberLabel = new JLabel();
        serialNumberLabel.setEnabled(true);
        serialNumberLabel.setText("Serial Number Value");
        panel1.add(serialNumberLabel, cc.xy(3, 9));
        final JLabel label14 = new JLabel();
        label14.setText("SHA1 Fingerprint");
        panel1.add(label14, cc.xy(2, 25));
        shaFingerprintLabel = new JLabel();
        shaFingerprintLabel.setText("SHA1 Fingerprint vale");
        panel1.add(shaFingerprintLabel, cc.xy(3, 25));
        permStoreCertCheckBox = new JCheckBox();
        permStoreCertCheckBox.setEnabled(false);
        permStoreCertCheckBox.setText("Permanently store this exception");
        permStoreCertCheckBox.setToolTipText("Save this exception permanently");
        permStoreCertCheckBox.setVisible(true);
        panel1.add(permStoreCertCheckBox, cc.xy(2, 33));
        final JLabel label15 = new JLabel();
        label15.setFont(new Font(label15.getFont().getName(), Font.BOLD, label15.getFont().getSize()));
        label15.setText("Other Warnings");
        panel1.add(label15, cc.xy(2, 30, CellConstraints.LEFT, CellConstraints.DEFAULT));
        otherWarnings = new JTextPane();
        otherWarnings.setBackground(UIManager.getColor("Label.background"));
        otherWarnings.setEditable(false);
        panel1.add(otherWarnings, cc.xyw(2, 32, 2, CellConstraints.CENTER, CellConstraints.CENTER));
        final JPanel panel2 = new JPanel();
        panel2.setLayout(new FormLayout("fill:d:grow", "center:d:grow"));
        tabbedPane1.addTab("Details", panel2);
        final JScrollPane scrollPane1 = new JScrollPane();
        panel2.add(scrollPane1, cc.xy(1, 1, CellConstraints.FILL, CellConstraints.FILL));
        detailsTextArea = new JTextArea();
        detailsTextArea.setEditable(false);
        detailsTextArea.setEnabled(true);
        scrollPane1.setViewportView(detailsTextArea);
    }

    /**
     * @noinspection ALL
     */
    public JComponent $$$getRootComponent$$$() {
        return contentPane;
    }
}