java安全性编程实例电子版书附源码,是网络安全编程者不可多得的好书

源代码在线查看: valisubissu.java

软件大小: 2426 K
上传用户: rentianchou
关键词: java 安全性 编程实例 电子版
下载地址: 免注册下载 普通下载 VIP

相关代码

				import java.io.*;
				import java.security.*;
				import java.security.cert.*;
				import java.security.cert.Certificate;
				import java.util.*;
				
				public class ValiSubIssu{
				   public static void main(String args[ ]) throws Exception{
				          Certificate[] certpath=new Certificate[args.length];
				          CertificateFactory cf = CertificateFactory.getInstance("X.509");
				
				          for (int i=0;i						  FileInputStream in=new FileInputStream(args[i]);
				                  certpath[i]=cf.generateCertificate(in);
				          }
					  boolean pass=true;	  
				          String reason="";
				          for(int i=0;i				               Principal issuer = ((X509Certificate)certpath[i]).getIssuerDN();
				               Principal subject =((X509Certificate)certpath[i+1]).getSubjectDN();
				               if(! issuer.equals(subject) ){
						      pass=false;
				                      reason+="in "+i+"\n";
				                      reason+="issuer is " +issuer+"\n";
					 	      reason+="But in "+(i+1)+"\n";
						      reason+="subject is "+subject+"\n";
						      break;
				               }
					  }
				          if(pass){
				                 System.out.println("subject/issuer verification OK");
					  }
					  else{
				                 System.out.println("subject/issuer verification Wrong \n"+reason);
					  }
				   }  
				}			

相关资源