⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 framemaincpro.java

📁 数字证书注册和签发系统
💻 JAVA
字号:
package cproissue;

import java.awt.BorderLayout;

import java.io.*;
import java.security.*;
import java.awt.Color;
import com.borland.jbcl.layout.*;
import javax.swing.*;
import java.awt.event.*;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2007</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class FrameMainCPro extends JFrame {
    XYLayout xYLayout1 = new XYLayout();
    JLabel jLabel1 = new JLabel();
    JLabel jLabel2 = new JLabel();
    JLabel jLabel3 = new JLabel();
    JLabel jLabel4 = new JLabel();
    JLabel jLabel5 = new JLabel();
    JLabel jLabel6 = new JLabel();
    JTextField ouText = new JTextField();
    JTextField oText = new JTextField();
    JTextField lText = new JTextField();
    JTextField stText = new JTextField();
    JTextField cText = new JTextField();
    JButton jButton1 = new JButton();
    JButton jButton2 = new JButton();
    JLabel jLabel7 = new JLabel();
    JLabel jLabel8 = new JLabel();
  JLabel jLabel9 = new JLabel();
  JLabel jLabel10 = new JLabel();
  JPasswordField storepass = new JPasswordField();
  JPasswordField capass = new JPasswordField();
  JButton jButton3 = new JButton();
  JPasswordField storepassok = new JPasswordField();
  JPasswordField capassok = new JPasswordField();
  JLabel jinggao = new JLabel();
    public FrameMainCPro() {
        try {
            jbInit();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    private void jbInit() throws Exception {
        this.setSize(400,350);
        this.setLocation(312, 234);
        this.setTitle("欢迎您第一次使用本系统");
        getContentPane().setLayout(xYLayout1);
        jLabel1.setText("部门");
        jLabel6.setText("根证书私钥保护密码");
        jLabel5.setText("国家");
        jLabel4.setText("省市");
        jLabel3.setText("县市");
        jButton2.setText("退出");
        jButton2.addActionListener(new FrameMainCPro_jButton2_actionAdapter(this));
        jButton1.setText("确定");
        jButton1.addActionListener(new FrameMainCPro_jButton1_actionAdapter(this));
        jLabel7.setText("密钥库密码");
        jLabel8.setText("请您配置密钥库和根证书:");
        jLabel9.setText("确认");
    jLabel10.setText("确认");
    jButton3.setText("jButton3");
    storepass.setText("");
    capass.setText("");
    storepassok.setText("");
    capassok.setText("");
    jinggao.setForeground(Color.red);
    jinggao.setText("");
        jLabel2.setText("单位");
        this.getContentPane().add(jLabel8, new XYConstraints(26, 13, 341, -1));
        this.getContentPane().add(jButton3, new XYConstraints(178, 134, 1, 116));
        this.getContentPane().add(capassok, new XYConstraints(248, 200, 83, 21));
        this.getContentPane().add(capass, new XYConstraints(248, 157, 83, 21));
        this.getContentPane().add(ouText, new XYConstraints(89, 37, 85, -1));
        this.getContentPane().add(lText, new XYConstraints(89, 76, 85, -1));
        this.getContentPane().add(cText, new XYConstraints(89, 116, 85, -1));
        this.getContentPane().add(jButton1, new XYConstraints(90, 246, 78, -1));
        this.getContentPane().add(jButton2, new XYConstraints(248, 246, 81, -1));
        this.getContentPane().add(jLabel7, new XYConstraints(15, 164, 65, -1));

        this.getContentPane().add(storepass, new XYConstraints(89, 162, 85, 22));

        this.getContentPane().add(storepassok,
                                  new XYConstraints(89, 201, 85, 21));
        this.getContentPane().add(jLabel10, new XYConstraints(203, 203, -1, -1));
        this.getContentPane().add(jLabel9, new XYConstraints(20, 203, -1, -1));
        this.getContentPane().add(jLabel1, new XYConstraints(26, 42, -1, -1));
        this.getContentPane().add(oText, new XYConstraints(248, 37, 83, -1));
        this.getContentPane().add(stText, new XYConstraints(248, 78, 83, -1));
        this.getContentPane().add(jLabel2, new XYConstraints(195, 42, -1, -1));
        this.getContentPane().add(jLabel3, new XYConstraints(26, 78, -1, -1));
        this.getContentPane().add(jLabel5, new XYConstraints(26, 117, -1, -1));
        this.getContentPane().add(jLabel4, new XYConstraints(195, 78, -1, -1));
        this.getContentPane().add(jinggao, new XYConstraints(195, 114, 129, 20));
        this.getContentPane().add(jLabel6, new XYConstraints(195, 139, 140, 18));
        this.setVisible(true);
    }
//取消
    public void jButton2_actionPerformed(ActionEvent e) {
        System.exit(0);
    }
//产生密钥库,根证书
    public void jButton1_actionPerformed(ActionEvent e) {
        try
              {
                  if((new String(storepass.getPassword()).equals(new String(storepassok.getPassword())))&&(new String(capass.getPassword()).equals(new String(capassok.getPassword()))))
                  {
                    //产生密钥库,根证书
                    String ss = "keytool -genkey -dname \"CN=mykey,OU=" +
                                ouText.getText() + ",O=" + oText.getText() + ",L=" +
                                lText.getText() + ", ST=" + stText.getText() + ", C=" +
                                cText.getText() +
                        "\" -alias mykey -keyalg RSA -keysize 1024 -keystore mykeystore -keypass " +
                                new String(capass.getPassword()) + " -storepass " +
                               new String(storepass.getPassword()) + " -validity 3500";
                    String cmd = "cmd /E:ON /c start " + ss;
                    Runtime.getRuntime().exec(cmd);
                    FrameMainCProOk qd = new FrameMainCProOk();
                    qd.setSize(400, 350);
                    qd.setLocation(312, 234);
                    qd.lable.setText("恭喜您,密钥库和根证书已经配置好!");
                    //导出自签证书


                    qd.setVisible(true);

                    this.dispose();
                  }
                  else
                  {
                     jinggao.setText("前后密码不一致,重输!");
                  }
               }
               catch (Exception ex) {
                   System.out.println(ex.getMessage());
         }
    }


}


class FrameMainCPro_jButton1_actionAdapter implements ActionListener {
    private FrameMainCPro adaptee;
    FrameMainCPro_jButton1_actionAdapter(FrameMainCPro adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jButton1_actionPerformed(e);
    }
}


class FrameMainCPro_jButton2_actionAdapter implements ActionListener {
    private FrameMainCPro adaptee;
    FrameMainCPro_jButton2_actionAdapter(FrameMainCPro adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jButton2_actionPerformed(e);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -