📄 framecpmain.java
字号:
package cproissue;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.Color;
import java.io.*;
import java.util.Enumeration;
import java.lang.reflect.Method;
import java.security.*;
import java.security.cert.*;
import java.util.Date;
import java.math.*;
import sun.security.x509.*;
import com.borland.jbcl.layout.*;
import javax.swing.*;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class FrameCPMain extends JFrame {
JPanel contentPane;
XYLayout xYLayout1 = new XYLayout();
JLabel jLabel1 = new JLabel();
JButton jButton1 = new JButton();
JLabel jLabel2 = new JLabel();
JLabel jingao = new JLabel();
CertEntity ce=new CertEntity();
JLabel jLabel3 = new JLabel();
JButton jButton2 = new JButton();
JPasswordField storepass = new JPasswordField();
JPasswordField capass = new JPasswordField();
public FrameCPMain() {
try {
setDefaultCloseOperation(EXIT_ON_CLOSE);
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
/**
* Component initialization.
*
* @throws java.lang.Exception
*/
private void jbInit() throws Exception {
contentPane = (JPanel) getContentPane();
contentPane.setLayout(xYLayout1);
setSize(new Dimension(400, 320));
setTitle("登陆");
jLabel1.setText("欢迎您进入证书签发中心!");
jButton1.setText("确定");
jButton1.addActionListener(new FrameCPMain_jButton1_actionAdapter(this));
jLabel2.setText("密钥库密码:");
jingao.setForeground(Color.red);
jingao.setText("密码错误,请重新输入!");
jingao.setVisible(false);
jLabel3.setText("根证书私钥保护密码:");
jButton2.setText("退出");
jButton2.addActionListener(new FrameCPMain_jButton2_actionAdapter(this));
storepass.setText("");
capass.setText("");
contentPane.add(jingao, new XYConstraints(134, 194, -1, -1));
contentPane.add(jButton2, new XYConstraints(239, 221, 80, -1));
contentPane.add(jButton1, new XYConstraints(75, 221, 80, -1));
contentPane.add(jLabel2, new XYConstraints(49, 87, -1, -1));
contentPane.add(jLabel3, new XYConstraints(44, 150, 133, -1));
contentPane.add(jLabel1, new XYConstraints(119, 29, -1, -1));
contentPane.add(storepass, new XYConstraints(182, 86, 113, -1));
contentPane.add(capass, new XYConstraints(182, 145, 115, -1));
}
public void jButton1_actionPerformed(ActionEvent e) {
try
{
//验证主密钥库和根证书私钥保护密码
FileInputStream in = new FileInputStream("mykeystore");
KeyStore ks = KeyStore.getInstance("JKS");
ks.load(in, storepass.getPassword());
java.security.cert.Certificate c1 = ks.getCertificate("mykey");
PrivateKey caprk = (PrivateKey) ks.getKey("mykey",capass.getPassword());
in.close();
//获得公有变量的值
ce.stroepass = new String(storepass.getPassword());
ce.capass= new String(capass.getPassword());
//进入主界面
FrameMain cm = new FrameMain(ce);
cm.setSize(400, 350);
cm.setLocation(312, 234);
cm.setVisible(true);
this.dispose();
}
catch(Exception ex)
{
//密码错误提示
jingao.setVisible(true);
}
}
public void jButton2_actionPerformed(ActionEvent e) {
System.exit(0);
}
}
class FrameCPMain_jButton2_actionAdapter implements ActionListener {
private FrameCPMain adaptee;
FrameCPMain_jButton2_actionAdapter(FrameCPMain adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton2_actionPerformed(e);
}
}
class FrameCPMain_jButton1_actionAdapter implements ActionListener {
private FrameCPMain adaptee;
FrameCPMain_jButton1_actionAdapter(FrameCPMain adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -