use of com.itrus.portal.db.CertBuf in project portal by ixinportal.
the class UserCertService method getUserCert.
public synchronized UserCert getUserCert(X509Certificate cert) throws CertificateException, SigningServerException {
// trustService.verifyCertificate(cert); //检查证书状态
// 检查证书信息是否在数据库中
String certHexSN = CertUtilsOfUkey.getValidSerialNumber(cert.getHexSerialNumber());
String issuerDN = cert.getIssuerDNString();
UserCertExample ucExample = new UserCertExample();
UserCertExample.Criteria ucCriteria = ucExample.or();
// ucCriteria.andIssuerDnEqualTo(issuerDN);
ucCriteria.andCertSnEqualTo(certHexSN);
UserCert userCert = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByExample", ucExample);
if (userCert == null) {
// 若不存在证书则添加证书信息
CertBuf certBuf = new CertBuf();
certBuf.setCreateTime(new Date());
certBuf.setCertBuf(Base64.encode(cert.getEncoded()).replaceAll("\n", ""));
// 将公钥证书存入数据库
sqlSession.insert("com.itrus.portal.db.CertBufMapper.insert", certBuf);
userCert = new UserCert();
userCert.setCertDn(cert.getSubjectDNString());
userCert.setIssuerDn(issuerDN);
userCert.setCertSn(certHexSN);
userCert.setCertStartTime(cert.getNotBefore());
userCert.setCertEndTime(cert.getNotAfter());
// 证书验证不通过,则直接抛出异常,不会进行到此处
userCert.setCertStatus(ComNames.CERT_STATUS_1);
userCert.setSha1Fingerprint(CipherUtils.sha1(cert.getEncoded()));
userCert.setCertBuf(certBuf.getId());
// 0标识非门户申请的证书(因为非门户下载的证书才会不存在我们数据库中)
userCert.setCertSource(ComNames.CERT_SOURCE_0);
sqlSession.insert("com.itrus.portal.db.UserCertMapper.insertSelective", userCert);
}
return userCert;
}
use of com.itrus.portal.db.CertBuf in project portal by ixinportal.
the class DownLoadCertServiceImpl method savePfxCertInfo.
public void savePfxCertInfo(CertInfo racertinfo, Bill bill, Long raId, Integer uidIdx, String keySn, String autoidType, Integer autoidValue, String pfxCert) throws ParseException {
CertBuf certbuf = new CertBuf();
Date date = new Date();
certbuf.setCreateTime(date);
certbuf.setCertBuf(racertinfo.getCertSignBuf());
certbuf.setCertKmcRep1(racertinfo.getCertKmcRep1());
certbuf.setCertKmcRep2(racertinfo.getCertKmcRep2());
certbuf.setCertsignBuf(racertinfo.getCertSignBuf());
certbuf.setEncUserCert(racertinfo.getCertSignBufKmc());
certbuf.setPfxCert(pfxCert);
certbuf.setLastDownloadTime(date);
certbuf.setCertDownloadNumber(1);
sqlSession.insert("com.itrus.portal.db.CertBufMapper.insert", certbuf);
UserCert usercert = new UserCert();
usercert.setBill(bill.getId());
usercert.setRaAccount(raId);
usercert.setCertBuf(certbuf.getId());
usercert.setUidIdx(uidIdx);
usercert.setCertDn(racertinfo.getCertSubjectDn());
usercert.setCertSn(racertinfo.getCertSerialNumber());
usercert.setIssuerDn(racertinfo.getCertIssuerDn());
usercert.setCertStatus("1");
usercert.setCertUid("certUid");
if (StringUtils.isNotBlank(keySn))
// 设置证书keySn
usercert.setKeySn(keySn);
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss");
usercert.setCertStartTime(sdf.parse(racertinfo.getCertNotBefore()));
usercert.setCertEndTime(sdf.parse(racertinfo.getCertNotAfter()));
usercert.setSha1Fingerprint("setSha1Fingerprint");
// autoid 数据
if (!autoidType.equals("")) {
usercert.setAutoidType(autoidType);
usercert.setAutoidValue(autoidValue);
}
usercert.setEnterprise(bill.getEnterprise());
sqlSession.insert("com.itrus.portal.db.UserCertMapper.insert", usercert);
// 将设置订单状态
bill.setBillStatus(ComNames.BILL_STATUS_6);
if (null == bill.getDelivery()) {
bill.setBillStatus(ComNames.BILL_STATUS_8);
} else if (null != bill.getIsInvoiced() && bill.getIsInvoiced().equals(1)) {
bill.setBillStatus(ComNames.BILL_STATUS_7);
}
// 当订单价格是0的时候,又不需要开票,设置为已开票代配送
if (0 == bill.getBillSum() && null == bill.getInvoice() && null == bill.geteInvoice()) {
bill.setBillStatus(ComNames.BILL_STATUS_7);
if (null == bill.getDelivery()) {
bill.setBillStatus(ComNames.BILL_STATUS_8);
}
}
sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKey", bill);
}
use of com.itrus.portal.db.CertBuf in project portal by ixinportal.
the class BillWebServiceImpl method getPfxCertBufByBills.
/**
* 根据订单.判断订单是否该显示下载证书的按钮
* @param bills
* @return Map<Long, Long>,键为bill.id,值为certBuf.id;
*/
public Map<Long, Long> getPfxCertBufByBills(List<Bill> bills) {
Map<Long, Long> map = new HashMap<Long, Long>();
if (null == bills || bills.isEmpty()) {
return map;
}
Date date = new Date();
for (Bill bill : bills) {
Product product = productService.getProduct(bill.getProduct());
if (null == product.getCert()) {
continue;
}
DigitalCert digitalCert = digitalCertService.getDigitalCert(product.getCert());
Integer billStatus = bill.getBillStatus();
// 判断订单是pfx类型的用户下载证书,且订单状态是678.
boolean pfx_download = null != digitalCert && null != digitalCert.getCertType() && null != digitalCert.getInitBuy() && digitalCert.getCertType().equals(ComNames.DIGITALCERT_CERTTYPE_PFX) && digitalCert.getInitBuy().equals(ComNames.DIGITALCERT_INITBUYS_2) && (billStatus == ComNames.BILL_STATUS_6 || billStatus == ComNames.BILL_STATUS_7 || billStatus == ComNames.BILL_STATUS_8);
if (pfx_download) {
// 根据订单号,找到订单对应的证书信息
CertBuf certBuf = sqlSession.selectOne("com.itrus.portal.db.CertBufMapper.selectPfxCertByBillId", bill.getId());
// 获取证书第一次下载时间和当前时间比较,如果超过了十五天,则不允许下载
int day = DateUtils.daysOfTwo(date, certBuf.getCreateTime());
if (day < 16) {
map.put(bill.getId(), certBuf.getId());
}
}
}
return map;
}
use of com.itrus.portal.db.CertBuf in project portal by ixinportal.
the class BillWebController method reNewCertConfirm.
// 订单详情,待更新确认
@RequestMapping(value = "/reNewCertConfirm/{id}", produces = "text/html")
public String reNewCertConfirm(@PathVariable("id") Long id, HttpServletRequest request, Model uiModel) {
HttpSession session = request.getSession();
UserInfo userInfo = (UserInfo) session.getAttribute("webuserInfo");
Enterprise enterprise = (Enterprise) session.getAttribute("webenterprise");
if (null == userInfo || null == enterprise) {
return "redirect:/userInfoWeb/denglu.html";
}
// 审核记录
ReviewLog reviewLog = reviewLogService.getReviewLog(id);
if (reviewLog != null) {
uiModel.addAttribute("reviewLog", reviewLog);
}
Map param = new HashMap();
// 设置查询条件,选择属于当前用户,当前企业的订单
param.put("id", id);
// param.put("userinfoid", userInfo.getId());
// param.put("enterpriseid", enterprise.getId());
List<Map> billAll = sqlSession.selectList("com.itrus.portal.db.BillMapper.selectProductBillCertById", param);
log.error("--------获取订单数量-------" + billAll.size() + "*****获取订单信息***" + billAll);
log.error("------获取订单id--------" + billAll.get(0).get("id"));
log.error("========获取订单编号=========" + billAll.get(0).get("bill_id"));
if (0 == billAll.size()) {
return "redirect:/userInfoWeb/denglu.html";
}
uiModel.addAttribute("bills", billAll.get(0));
// 获取数字证书
Product product = productService.getProduct((Long) billAll.get(0).get("product"));
log.error("****获取产品id*****" + product.getId());
DigitalCert digitalCert = digitalCertService.getDigitalCert(product.getCert());
// 获取订单在线支付方式
if (billAll.get(0).get("on_pay_info") != null) {
Map<Long, OnPayInfo> opiMap = sqlSession.selectMap("com.itrus.portal.db.OnPayInfoMapper.selectByExample", "id");
uiModel.addAttribute("opiMap", opiMap);
Map<Long, OnlinePay> opMap = sqlSession.selectMap("com.itrus.portal.db.OnlinePayMapper.selectByExample", "id");
uiModel.addAttribute("opMap", opMap);
}
PayInfoExample payInfoex = new PayInfoExample();
Map<Long, PayInfo> payinfoMap = sqlSession.selectMap("com.itrus.portal.db.PayInfoMapper.selectByExample", payInfoex, "id");
uiModel.addAttribute("payinfomap", payinfoMap);
// 获取产品规格
ProductSpec productSpec = null;
if (null != billAll.get(0).get("product_spec") && !"0".equals(billAll.get(0).get("product_spec"))) {
productSpec = productSpecService.getProductSpec((Long) billAll.get(0).get("product_spec"));
}
uiModel.addAttribute("productSpec", productSpec);
uiModel.addAttribute("digitalCert", digitalCert);
// 返回订单对应的老证书的base64
CertBuf certBuf = sqlSession.selectOne("com.itrus.portal.db.CertBufMapper.selectCertBufByBillId", id);
if (null != certBuf) {
uiModel.addAttribute("oldCertB64", certBuf.getCertBuf().replaceAll("\n", ""));
}
log.error("*********签章服务******" + product.getMakeSealServer());
// 判断是否有签章服务,有则显示授权
if (null != product.getMakeSealServer()) {
uiModel.addAttribute("makesealserver", product.getMakeSealServer());
uiModel.addAttribute("billId", billAll.get(0).get("id"));
// 签章服务配置
List<MakeSealConfig> makeSealConfigs = sqlSession.selectList("com.itrus.portal.db.MakeSealConfigMapper.selectByExample");
if (!makeSealConfigs.isEmpty()) {
MakeSealConfig makeSealConfig = makeSealConfigs.get(0);
try {
makeSealConfig.setAddressKey(AESencrp.decrypt(makeSealConfig.getAddressKey(), dbEncKey));
} catch (EncDecException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
uiModel.addAttribute("makeSealConfig", makeSealConfig);
}
}
return "ixinweb/dingdanxiangqing_gengxinqueren";
}
use of com.itrus.portal.db.CertBuf in project portal by ixinportal.
the class BindCertWebController method bindPage.
@RequestMapping("/bindCertPage")
public String bindPage(@RequestParam(value = "certSn", required = true) String certSn, HttpSession session, Model uiModel) throws UserInfoServiceException {
// 是否登录
UserInfo webuserInfo = (UserInfo) session.getAttribute("webuserInfo");
Enterprise webenterprise = (Enterprise) session.getAttribute("webenterprise");
if (null == webuserInfo || null == webenterprise) {
// 登录状态失效,跳转到注册页面
return "redirect:/userInfoWeb/denglu.html";
}
// 返回所有信任源所有
List<String> allIssUerDn = new ArrayList<String>();
allIssUerDn = sqlSession.selectList("com.itrus.portal.db.CrlContextMapper.selectAllIssUerDn");
try {
uiModel.addAttribute("allIssUerDn", jsonTool.writeValueAsString(allIssUerDn));
} catch (JsonGenerationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JsonMappingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
UserCert userCert = null;
userCert = userCertService.getUserCertByCertSn(certSn);
if (null == userCert)
throw new UserInfoServiceException("未找到对应的证书信息");
// DateFormat df = new SimpleDateFormat("yyyy/MM/dd");
UserCertPojo ucp = new UserCertPojo(userCert, userCert.getCertStartTime().getTime() + "", userCert.getCertEndTime().getTime() + "");
CertBuf certBuf = sqlSession.selectOne("com.itrus.portal.db.CertBufMapper.selectByPrimaryKey", userCert.getCertBuf());
uiModel.addAttribute("userCert", ucp);
uiModel.addAttribute("certBase64", certBuf.getCertBuf().replaceAll("\n", ""));
return "ixinweb/bangding";
}
Aggregations