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

Java tutorial

Introduction

Here is the source code for com.archivas.clienttools.arcmover.gui.ssl.SSLCertificateDialog.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.Dimension;
import java.awt.event.*;

import javax.swing.*;

import com.archivas.clienttools.arcmover.gui.HCPDataMigrator;
import com.archivas.clienttools.arcutils.profile.HCAPProfile;
import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.FormLayout;

public class SSLCertificateDialog extends JDialog {

    private HCAPProfile profile;
    private JPanel contentPane;
    private JButton buttonOK;
    private JButton buttonCancel;
    protected SSLCertificateForm sslCertificateForm;
    protected JLabel issuedToCommonNameLabel;
    protected JLabel issuedByCommonNameLabel;
    protected JLabel validDateRangeLabel;
    protected JTextArea detailsTextArea;
    protected JLabel md5FingerprintLabel;
    protected JLabel issuedToOrganizationLabel;
    protected JLabel issuedByOrganizationLabel;
    protected JLabel issuedToOrganizationalUnitLabel;
    protected JLabel issuedByOrganizationalUnitLabel;
    protected JLabel serialNumberLabel;
    protected JLabel shaFingerprintLabel;
    protected JLabel validityLabel;

    public SSLCertificateDialog(HCAPProfile profile) {
        super(HCPDataMigrator.getInstance());
        this.profile = profile;
        setContentPane(contentPane);
        setModal(true);
        getRootPane().setDefaultButton(buttonOK);

        setIconImage(SSLCertificateForm.sslFrameIcon.getImage());
        setTitle("Certificate Viewer");

        buttonOK.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                onOK();
            }
        });

        buttonCancel.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                onCancel();
            }
        });

        setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                onCancel();
            }
        });

        contentPane.registerKeyboardAction(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                onCancel();
            }
        }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

        pack();
        setLocationRelativeTo(HCPDataMigrator.getInstance());
    }

    private void onOK() {
        dispose();
    }

    private void onCancel() {
        dispose();
    }

    public HCAPProfile getProfile() {
        return profile;
    }

    public void setProfile(final HCAPProfile profile) {
        this.profile = profile;
    }

    public void setVisible(boolean visible) {
        if (visible) {
            sslCertificateForm.setSSLCertChain(getProfile().getSSLCertChain());
            pack();
        }
        super.setVisible(visible);
    }

    {
        // 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:4dlu:noGrow,fill:d:grow,fill:4dlu:noGrow",
                "center:4dlu:noGrow,center:d:grow,top:4dlu:noGrow,center:max(d;15dlu):noGrow,center:4dlu:noGrow"));
        contentPane.setMinimumSize(new Dimension(300, 300));
        contentPane.setPreferredSize(new Dimension(500, 500));
        final JPanel panel1 = new JPanel();
        panel1.setLayout(
                new FormLayout("fill:d:grow,left:4dlu:noGrow,fill:50dlu:noGrow,left:4dlu:noGrow,fill:50dlu:noGrow",
                        "center:15dlu:grow"));
        panel1.setPreferredSize(new Dimension(300, 24));
        CellConstraints cc = new CellConstraints();
        contentPane.add(panel1, cc.xy(2, 4));
        buttonOK = new JButton();
        buttonOK.setText("OK");
        panel1.add(buttonOK, cc.xy(3, 1, CellConstraints.DEFAULT, CellConstraints.FILL));
        buttonCancel = new JButton();
        buttonCancel.setText("Cancel");
        panel1.add(buttonCancel, cc.xy(5, 1, CellConstraints.DEFAULT, CellConstraints.FILL));
        sslCertificateForm = new SSLCertificateForm();
        contentPane.add(sslCertificateForm.$$$getRootComponent$$$(),
                cc.xy(2, 2, CellConstraints.FILL, CellConstraints.FILL));
    }

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