标签:final 客户端 substring 数字 链接 indexof index ring null
if(request.isSecure()) //判断是否采用SSL { final String attname= "javax.servlet.request.X509Certificate"; X509Certificate[] chain= (X509Certificate[])request.getAttribute(attname);//客户证书链 if(chain == null) { resultBasicVO.setMessage("没有客户端证书链"); return resultBasicVO; } X509Certificate userCert= chain[0]; //客户证书 String dname = userCert.getSubjectDN().getName(); String field = "CN="; String udata = dname.substring(dname.indexOf(field) + field.length()); String[] dataArr = udata.split(","); String nameAndId = dataArr[0]; String idcard = nameAndId.split(" ")[1]; resultBasicVO.setMessage(idcard); resultBasicVO.setResult(true); return resultBasicVO; }
参考链接:
https://blog.csdn.net/loman_yt/article/details/44675105
标签:final 客户端 substring 数字 链接 indexof index ring null
原文地址:https://www.cnblogs.com/tianjifa/p/9533092.html