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

📄 framefinal.java

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

import java.awt.*;
import javax.swing.*;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
//import com.microsoft.*;
import java.sql.*;
import java.net.URI;
import java.io.*;
import java.security.*;
import java.security.cert.*;
import java.util.*;
import java.math.*;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2007</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class FrameFinal extends JFrame {
    XYLayout xYLayout1 = new XYLayout();
    JLabel jLabel1 = new JLabel();
    JLabel jLabel2 = new JLabel();
    JButton jButton1 = new JButton();
    CertEntity ce;

    public FrameFinal() {
        try {
            jbInit();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }
    public FrameFinal(CertEntity ce) {
        try {
            jbInit();
            this.ce=ce;
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    private void jbInit() throws Exception {
        getContentPane().setLayout(xYLayout1);
        this.setTitle("申请证书");
        jLabel1.setText("第五步:完成。");
        jButton1.setText("完成");
        jButton1.addActionListener(new FrameFinal_jButton1_actionAdapter(this));
        this.getContentPane().add(jButton1, new XYConstraints(148, 177, 92, -1));
        this.getContentPane().add(jLabel1, new XYConstraints(30, 40, -1, -1));
        this.getContentPane().add(jLabel2, new XYConstraints(94, 108, -1, -1));
        jLabel2.setForeground(Color.red);
        jLabel2.setText("恭喜您,您已经成功申请了自己的证书!");
    }
//完成
    public void jButton1_actionPerformed(ActionEvent e) {
       //存储主体信息
        try{
            //获得证书序列号
            CertificateFactory cf=CertificateFactory.getInstance("X.509");
            FileInputStream in=new FileInputStream(""+ce.cuser+".cer");
            java.security.cert.Certificate c=cf.generateCertificate(in);
            in.close();
            X509Certificate t=(X509Certificate) c;
            String sn=t.getSerialNumber().toString(16);
            //设置原始路径和状态标志
            String cpath="f://";
            String kpath="f://";
            int sig=0;
            //存入数据库
            String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=casdb;User=sa;Password=;";
            Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
            Connection con = DriverManager.getConnection(url);
            Statement stmt = con.createStatement();
            stmt.execute("insert into subjectinf values('" + sn +
                         "','" + ce.cn +
                         "','" + ce.ou + "','"
                         + ce.o + "','" + ce.l + "','" +
                         ce.st + "','" + ce.c + "','" + cpath + "','" + kpath + "'," + sig + ")");
            stmt.close();
            con.close();
        }
        catch(Exception ex)
        {
            System.out.println(ex.getMessage());
        }
        //完成
        this.dispose();
    }
}


class FrameFinal_jButton1_actionAdapter implements ActionListener {
    private FrameFinal adaptee;
    FrameFinal_jButton1_actionAdapter(FrameFinal adaptee) {
        this.adaptee = adaptee;
    }

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

⌨️ 快捷键说明

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