通過JAVA來讀取數(shù)字證書的方法獲取20位指紋:
成都創(chuàng)新互聯(lián)堅信:善待客戶,將會成為終身客戶。我們能堅持多年,是因為我們一直可值得信賴。我們從不忽悠初訪客戶,我們用心做好本職工作,不忘初心,方得始終。10年網(wǎng)站建設(shè)經(jīng)驗成都創(chuàng)新互聯(lián)是成都老牌網(wǎng)站營銷服務(wù)商,為您提供網(wǎng)站設(shè)計制作、做網(wǎng)站、網(wǎng)站設(shè)計、HTML5建站、網(wǎng)站制作、品牌網(wǎng)站建設(shè)、微信小程序開發(fā)服務(wù),給眾多知名企業(yè)提供過好品質(zhì)的建站服務(wù)。
CARead.java文件代碼:
public class CARead extends JPanel {
private String CA_Name;
private String CA_ItemData[][] = new String[9][2];
private String[] columnNames = { "證書字段標(biāo)記", "內(nèi)容" };
public CARead(String CertName) {
CA_Name = CertName;
/* 三個Panel用來顯示證書內(nèi)容 */
JTabbedPane tabbedPane = new JTabbedPane();
JPanel panelNormal = new JPanel();
tabbedPane.addTab("普通信息", panelNormal);
JPanel panelAll = new JPanel();
panelAll.setLayout(new BorderLayout());
tabbedPane.addTab("所有信息", panelAll);
JPanel panelBase64 = new JPanel();
panelBase64.setLayout(new BorderLayout());
tabbedPane.addTab("Base64編碼形式的信息", panelBase64);
/* 讀取證書常規(guī)信息 */
Read_Normal(panelNormal);
/* 讀取證書文件字符串表示內(nèi)容 */
Read_Bin(panelAll);
/* 以Base64編碼形式讀取證書文件的信息 */
Read_Raw(panelBase64);
tabbedPane.setSelectedIndex(0);
setLayout(new GridLayout(1, 1));
add(tabbedPane);
}
private int Read_Normal(JPanel panel) {
String Field;
try {
CertificateFactory certificate_factory = CertificateFactory
.getInstance("X.509");
FileInputStream file_inputstream = new FileInputStream(CA_Name);
X509Certificate x509certificate = (X509Certificate) certificate_factory
.generateCertificate(file_inputstream);
Field = x509certificate.getType();
CA_ItemData[0][0] = "類型";
CA_ItemData[0][1] = Field;
Field = Integer.toString(x509certificate.getVersion());
CA_ItemData[1][0] = "版本";
CA_ItemData[1][1] = Field;
Field = x509certificate.getSubjectDN().getName();
CA_ItemData[2][0] = "標(biāo)題";
CA_ItemData[2][1] = Field;
Field=x509certificate.getNotBefore().toString();//得到開始有效日期
CA_ItemData[3][0] = "開始有效日期";
CA_ItemData[3][1] = Field;
Field=x509certificate. getNotAfter().toString();//得到截止日期
CA_ItemData[4][0] = "截止日期";
CA_ItemData[4][1] = Field;
Field=x509certificate.getSerialNumber().toString(16);//得到序列號
CA_ItemData[5][0] = "序列號";
CA_ItemData[5][1] = Field;
Field=x509certificate.getIssuerDN().getName();//得到發(fā)行者名
CA_ItemData[6][0] = "發(fā)行者名";
CA_ItemData[6][1] = Field;
Field=x509certificate.getSigAlgName();//得到簽名算法
CA_ItemData[7][0] = "簽名算法";
CA_ItemData[7][1] = Field;
Field=x509certificate.getPublicKey().getAlgorithm();//得到公鑰算法
CA_ItemData[8][0] = "公鑰算法";
CA_ItemData[8][1] = Field;
//關(guān)閉輸入流對象
file_inputstream.close();
final JTable table = new JTable(CA_ItemData, columnNames);
TableColumn tc = null; //表格列控制
tc = table.getColumnModel().getColumn(1);//得到表頭
tc.setPreferredWidth(600);//設(shè)置寬度
panel.add(table);//增加到布局面板
} catch (Exception exception) {
exception.printStackTrace(); //異常捕獲、
return -1;
}
return 0;
}
//讀取二進(jìn)制指紋文件
private int Read_Bin(JPanel panel) {
try {
FileInputStream file_inputstream = new FileInputStream(CA_Name);
DataInputStream data_inputstream = new DataInputStream(
file_inputstream);
CertificateFactory certificatefactory = CertificateFactory
.getInstance("X.509");
byte[] bytes = new byte[data_inputstream.available()];
data_inputstream.readFully(bytes);
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
JEditorPane Cert_EditorPane;
Cert_EditorPane = new JEditorPane();
X509Certificate cert=null;
//遍歷得到所有的證書屬性
if (bais.available() 0)
{
cert = (X509Certificate) certificatefactory .generateCertificate(bais);
Cert_EditorPane.setText(cert.toString());
}
Cert_EditorPane.disable();
JScrollPane edit_scroll = new JScrollPane(Cert_EditorPane);
panel.add(edit_scroll);
file_inputstream.close();
data_inputstream.close();
} catch (Exception exception) {
exception.printStackTrace();
return -1;
}
return 0;
}
private int Read_Raw(JPanel panel) {
try {
JEditorPane Cert_EditorPane = new JEditorPane();
StringBuffer strBuffer =new StringBuffer();
File inputFile = new File(CA_Name);
FileReader in = new FileReader(inputFile);
char[] buf = new char[2000];
int len = in.read(buf, 0, 2000);
for (int i = 1; i len; i++) {
strBuffer.append(buf[i]);
}
in.close();
Cert_EditorPane.setText(strBuffer.toString());
Cert_EditorPane.disable();
JScrollPane edit_scroll = new JScrollPane(Cert_EditorPane);
panel.add(edit_scroll);
} catch (Exception exception) {
exception.printStackTrace();
return -1;
}
return 0;
}
}
不會耶,應(yīng)該需要什么硬件提供些接口什么的吧,然后把
指紋信息
放到數(shù)據(jù)庫中,刷的時候,獲取指紋,然后拿到數(shù)據(jù)庫中比較下。
如果,獲得了指紋信息,那么其他的就沒問題了。
你要先學(xué)會截圖哦,你發(fā)的看不清楚,重新寫了一個你參考參考!
import java.awt.GridLayout;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
public class Day30A extends JFrame {
private static final long serialVersionUID = 1L;
private JLabel labelName,labelId,labelPass,labelMoney,labelSelect,labelCar;
private JComboBoxString jcb;
private JPanel jp1,jp2,jp3,jp4,jp5,jp6,jp7;
private ButtonGroup btg;
private JRadioButton jr1,jr2;
Day30A(){
this.setTitle("注冊賬戶");
this.setLayout(new GridLayout(7,1));
this.setSize(300,280);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
init();
this.setVisible(true);
}
private void init() {
String str="卡片類型1,卡片類型2,卡片類型3,卡片類型4,卡片類型5";
jcb=new JComboBox(str.split(","));
labelId=new JLabel("賬號: ");
labelName=new JLabel("姓名: ");
labelPass=new JLabel("密碼: ");
labelMoney=new JLabel("開戶金額:");
labelSelect=new JLabel("存款類型:");
labelCar=new JLabel("卡片類型:");
addFun1();
addFun2();
}
private void addFun2() {
this.add(jp1);
this.add(jp2);
this.add(jp3);
this.add(jp4);
this.add(jp5);
this.add(jp6);
this.add(jp7);
}
private void addFun1() {
jp1=new JPanel();
jp1.add(labelId);
jp1.add(new JTextField(15));
jp2=new JPanel();
jp2.add(labelName);
jp2.add(new JTextField(15));
jp3=new JPanel();
jp3.add(labelPass);
jp3.add(new JTextField(15));
jp4=new JPanel();
jp4.add(labelMoney);
jp4.add(new JTextField(13));
jp5=new JPanel();
jp5.add(labelSelect);
btg=new ButtonGroup();
jr1=new JRadioButton("定期");
jr2=new JRadioButton("活期",true);
btg.add(jr1);
btg.add(jr2);
jp5.add(jr1);
jp5.add(jr2);
jp6=new JPanel();
jp6.add(labelCar);
jp6.add(jcb);
jp7=new JPanel();
jp7.add(new JButton("確定"));
jp7.add(new JButton("取消"));
}
public static void main(String[] args) {
new Day30A();
}
}
1.打開編程工具:
打開java編程的界面,采用的是eclipse軟件;
2
2.建立一個java工程:
簡潔操作如下:單擊“file”-“new”-“java project”;
然后,在工程菜單中選中工程,單擊鼠標(biāo)右鍵出出來菜單,依次選中“new”-“class”;
具體查看“?eclipse如何建立一個java工程”;
0eclipse如何建立一個java工程
END
2.代碼實現(xiàn)步驟
1.建立輸入掃描:
采用java中的Scanner類實現(xiàn)輸入數(shù)據(jù)的獲取,具體代碼如下;
Scanner scan = new Scanner(System.in);
2.接收用戶名:
建立一個提示信息,提示輸入用戶名,并儲存輸入的用戶名,代碼如下:
System.out.println("請輸入登陸用戶名:");
String usename=scan.nextLine();
3.接收密碼:
建立一個提示信息,提示輸入密碼,并存儲輸入的密碼,代碼如下:
System.out.println("請輸入登陸的密碼:");
String password=scan.nextLine();
4.驗證信息:
采用if else語句來實現(xiàn)對用戶名和密碼的驗證,并打印提示信息,代碼如下:
if(!usename.equals("me")){
System.out.println("用戶名非法。");
}else if(!password.equals("123456")){
System.out.println("登陸密碼錯誤。");
}else{
System.out.println("恭喜您,登陸信息通過驗證。");
}
網(wǎng)頁標(biāo)題:指紋登錄java代碼實現(xiàn) java實現(xiàn)指紋識別
鏈接分享:http://jinyejixie.com/article42/dochgec.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供ChatGPT、網(wǎng)站內(nèi)鏈、網(wǎng)站營銷、面包屑導(dǎo)航、Google、做網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)