use of com.itrus.portal.db.UserCertExample in project portal by ixinportal.
the class UserCertService method getCert.
public synchronized UserCert getCert(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.UserCertExample in project portal by ixinportal.
the class UserCertService method getUserCertByUserInfoId.
/**
* 根据用户id,获取用户下所绑定的所有证书
* @param userinfoId
* @param certStatus
* @return
*/
public List<UserCert> getUserCertByUserInfoId(Long userinfoId, List<String> certStatus) {
UserCertExample example = new UserCertExample();
UserCertExample.Criteria criteria = example.or();
criteria.andUserinfoEqualTo(userinfoId);
if (null != certStatus && !certStatus.isEmpty()) {
criteria.andCertStatusIn(certStatus);
}
example.setOrderByClause("cert_start_time desc");
return sqlSession.selectList("com.itrus.portal.db.UserCertMapper.selectByExample", example);
}
use of com.itrus.portal.db.UserCertExample in project portal by ixinportal.
the class SendReNewInfoTask method sendReNewInfo.
/**
* 心跳更新。启动时执行一次,之后每隔24小时执行一次
*/
@Scheduled(fixedRate = 1000 * 60 * 60 * 24)
public void sendReNewInfo() {
// 筛选出所有是待更新的,而且未发送短信的订单
BillExample billExample = new BillExample();
BillExample.Criteria criteria = billExample.or();
// 订单状态是12的时候,表示是待更新的订单
criteria.andBillStatusEqualTo(ComNames.BILL_STATUS_12);
// 订单的短信发送时间是Null的时候,表示未发送过通知短信
criteria.andRenewSendTimeIsNull();
criteria.andIsDeleteEqualTo(false);
// billExample.setLimit(100);
List<Bill> bills = sqlSession.selectList("com.itrus.portal.db.BillMapper.selectByExample", billExample);
if (null == bills || bills.size() < 1) {
return;
}
String billSn = "";
String mPhone = "";
try {
// 向每个订单发送短信通知
for (int i = 0; i < bills.size(); i++) {
billSn = bills.get(i).getBillId();
UserInfo userInfo = sqlSession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey", bills.get(i).getUniqueId());
mPhone = userInfo.getmPhone();
UserCertExample userCertExample = new UserCertExample();
UserCertExample.Criteria ucriteria = userCertExample.or();
ucriteria.andIdEqualTo(bills.get(i).getOldUserCert());
UserCert userCert = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByExample", userCertExample);
Enterprise enterprise = sqlSession.selectOne("com.itrus.portal.db.EnterpriseMapper.selectByPrimaryKey", bills.get(i).getEnterprise());
Long projectId = bills.get(i).getProject();
String keySn = "";
if (null == userCert.getKeySn()) {
keySn = "该证书未绑定key";
} else {
keySn = userCert.getKeySn();
}
String enterpriseName = enterprise.getEnterpriseName();
Date endTime = userCert.getCertEndTime();
// 获取订单对应的产品信息
Product product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bills.get(i).getProduct());
String productName = product.getName();
try {
makeCerServiceImpl.sendReNewInfo(bills.get(i), mPhone, projectId, "ZSGX", keySn, enterpriseName, endTime, productName);
} catch (UserInfoServiceException e) {
String type = "发送证书更新通知失败";
String info = "用户手机号:" + mPhone + ",订单号" + bills.get(i).getBillId() + "错误信息:" + e.getMessage();
LogUtil.syslog(sqlSession, type, info);
log.error("ERRORLOG证书更新通知 {}", info);
return;
} catch (Exception e) {
String type = "发送证书更新通知失败";
String info = "用户手机号:" + mPhone + ",订单号" + bills.get(i).getBillId() + "错误信息:" + e.getMessage();
LogUtil.syslog(sqlSession, type, info);
log.error("ERRORLOG证书更新通知 {}", info);
return;
}
}
} catch (Exception e) {
String type = "发送证书更新通知失败";
String info = "用户手机号:" + mPhone + ",订单号" + billSn + "错误信息:" + e.getMessage();
LogUtil.syslog(sqlSession, type, info);
log.error("ERRORLOG证书更新通知 {}", info);
return;
}
}
Aggregations