use of com.itrus.portal.db.UserCert in project portal by ixinportal.
the class BindCertWebController method getProjectByCertBase64.
/**
* 获取产品信息
*
* @param certBase64
* @return
* @throws UserInfoServiceException
*/
public Product getProjectByCertBase64(String certBase64) throws UserInfoServiceException {
UserCert userCert;
try {
userCert = userCertService.getUserCert(certBase64);
} catch (CertificateException e) {
throw new UserInfoServiceException(e.getMessage());
} catch (SigningServerException e) {
throw new UserInfoServiceException(e.getMessage());
}
Product product = null;
// 证书序列号
String CertSerialNumber = userCert.getCertSn();
if (userCert.getBill() == null) {
String accountHash = getRaInfo.getRaInfoByCertSerialNumber(CertSerialNumber);
if (StringUtils.isBlank(accountHash))
throw new UserInfoServiceException("获取AccountHash失败,请联系管理员");
// Ra
RaAccount raAccount = raAccountService.getRaByAccountHash(accountHash);
if (null == raAccount)
throw new UserInfoServiceException("获取RA信息失败,请联系管理员");
// 产品
// product = productService.getProductByRa(raAccount.getId());
product = productService.getRenewProduct(raAccount.getId(), null, null, userCert.getCertDn());
} else {
// 证书关联了订单,根据订单获得projectId和productId
Bill bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", userCert.getBill());
if (null == bill) {
throw new UserInfoServiceException("获取产品信息失败,请联系管理员");
}
product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct());
}
if (null == product)
throw new UserInfoServiceException("获取对应产品信息失败");
userCert.setProduct(product.getId());
sqlSession.update("com.itrus.portal.db.UserCertMapper.updateByPrimaryKey", userCert);
return product;
}
use of com.itrus.portal.db.UserCert in project portal by ixinportal.
the class DownLoadCertWebController method toPages.
/**
* 跳转到下载成功或失败页面 2016年11月3日 下午4:52:36
*
* @param id
* 订单id
* @param ret
* 参数 1 成功, 0失败
* @return 逻辑视图
*/
@RequestMapping(value = "/toPages/{id}", produces = "text/html")
public String toPages(@PathVariable("id") Long id, @RequestParam(value = "ret", required = false) int ret, 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";
}
Map<String, Object> param = new HashMap<String, Object>();
// 设置查询条件,选择属于当前用户,当前企业的订单
param.put("id", id);
List<Map<String, Object>> billAll = sqlSession.selectList("com.itrus.portal.db.BillMapper.selectProductBillCertById", param);
if (0 == billAll.size()) {
return "redirect:/userInfoWeb/denglu.html";
}
// 审核记录
ReviewLog reviewLog = reviewLogService.getReviewLog(id);
if (reviewLog != null) {
uiModel.addAttribute("reviewLog", reviewLog);
}
uiModel.addAttribute("bills", billAll.get(0));
// 获取订单在线支付方式
if (billAll.get(0).get("on_pay_info") != null) {
OnPayInfo onPayInfo = sqlSession.selectOne("com.itrus.portal.db.OnPayInfoMapper.selectByPrimaryKey", billAll.get(0).get("on_pay_info"));
uiModel.addAttribute("onPayInfo", onPayInfo);
} else if (billAll.get(0).get("pay_info") != null) {
PayInfo payInfo = sqlSession.selectOne("com.itrus.portal.db.PayInfoMapper.selectByPrimaryKey", billAll.get(0).get("pay_info"));
uiModel.addAttribute("payInfo", payInfo);
}
UserCertExample uce = new UserCertExample();
UserCertExample.Criteria ucec = uce.or();
ucec.andBillEqualTo(id);
List<String> certStatus = new ArrayList<String>();
List<UserCert> certs = userCertService.getUserCertByBill(id, certStatus);
certStatus.add(ComNames.CERT_STATUS_1);
certStatus.add(ComNames.CERT_STATUS_2);
if (ret == 1) {
// 下载成功页面
if (certs != null && certs.size() > 0) {
UserCert userCert = certs.get(0);
uiModel.addAttribute("doneTime", userCert.getCertStartTime());
}
return "ixinweb/dingdanxiangqing_xiazaichenggong";
} else {
// 下载失败页面
return "ixinweb/dingdanxiangqing_xiazaishibai";
}
}
use of com.itrus.portal.db.UserCert in project portal by ixinportal.
the class DownLoadCertWebController method downLoadCert.
@RequestMapping("/{id}")
@ResponseBody
public Map<String, Object> downLoadCert(@PathVariable(value = "id") Long id, @RequestParam(value = "uidIdx", required = true) Integer uidIdx, @RequestParam(value = "csr", required = true) String csr, @RequestParam(value = "keySn", required = false) String keySn, HttpSession session) {
Map<String, Object> retMap = new HashMap<String, Object>();
retMap.put("retCode", 0);
UserInfo webuserInfo = (UserInfo) session.getAttribute("webuserInfo");
Enterprise webenterprise = (Enterprise) session.getAttribute("webenterprise");
if (null == webuserInfo || null == webenterprise) {
// 2标识登录已经失效,需跳转到登录页面
retMap.put("retCode", 2);
retMap.put("retMsg", "登录状态失效");
return retMap;
}
Bill bill = billService.getBill(id);
if (null == bill) {
retMap.put("retMsg", "该订单不存在");
return retMap;
}
// 订单是否为当前用户当前企业
if (!webuserInfo.getId().equals(bill.getUniqueId()) || !webenterprise.getId().equals(bill.getEnterprise())) {
retMap.put("retMsg", "您不能操作该订单");
return retMap;
}
// 判断该订单状态是否为待下载,是否已经关联了证书
List<String> certStatus = new ArrayList<String>();
certStatus.add(ComNames.CERT_STATUS_1);
certStatus.add(ComNames.CERT_STATUS_2);
List<UserCert> userCerts = userCertService.getUserCertByBill(bill.getId(), certStatus);
if (!bill.getBillStatus().equals(ComNames.BILL_STATUS_13) || !userCerts.isEmpty()) {
retMap.put("retMsg", "该证书状态为已下载或订单还未审核");
return retMap;
}
Product product = productService.getProduct(bill.getProduct());
DigitalCert digitalCert = digitalCertService.getDigitalCert(product.getCert());
RaAccount ra = raAccountService.getRaAccount(product.getRa());
// 下载证书
String autoidType = "";
Integer autoidValue = 0;
try {
// 下载证书
CertInfo racertinfo = downLoadCertService.downLoadCert(product, ra, bill, digitalCert, uidIdx, csr, autoidType, autoidValue);
// 保存证书
downLoadCertService.saveCertInfo(racertinfo, bill, ra.getId(), uidIdx, keySn, autoidType, autoidValue);
// 返回数字证书
retMap.put("retCode", 1);
retMap.put("certChain", racertinfo.getCertSignBufP7());
retMap.put("certSn", racertinfo.getCertSerialNumber());
retMap.put("certSignBuf", racertinfo.getCertSignBuf());
retMap.put("certKmcRep1", racertinfo.getCertKmcRep1());
retMap.put("certKmcRep2", racertinfo.getCertKmcRep2());
// 加密证书
retMap.put("encUserCert", racertinfo.getCertSignBufKmc());
// 记录日志
UserLog userlog = new UserLog();
userlog.setProject(webuserInfo.getProject());
userlog.setType("用户下载证书");
userlog.setInfo(webenterprise.getEnterpriseName() + "下载证书成功");
userlog.setHostId("未知");
userlog.setSn(null == webuserInfo.getUniqueId() ? null : webuserInfo.getUniqueId());
LogUtil.userlog(sqlSession, userlog);
} catch (Exception e) {
e.printStackTrace();
retMap.put("retMsg", e.getMessage());
// 记录日志
UserLog userlog = new UserLog();
userlog.setProject(webuserInfo.getProject());
userlog.setType("用户下载证书");
userlog.setInfo("url:downLoadCert,详细错误:" + e.getMessage());
userlog.setHostId("未知");
userlog.setSn(null == webuserInfo.getUniqueId() ? null : webuserInfo.getUniqueId());
LogUtil.userlog(sqlSession, userlog);
return retMap;
}
return retMap;
}
use of com.itrus.portal.db.UserCert in project portal by ixinportal.
the class UnlockKeyBillController method reSubmitUnlockBill.
/**
* 解锁订单重新提交授权书,注意授权书的id不能为null
* @param billId
* @param certSn
* @param keySn
* @param proxy
* @param request
* @return
*/
@RequestMapping("/reSubmitUnlockBill")
@ResponseBody
public Map<String, Object> reSubmitUnlockBill(@RequestParam("billId") Long billId, @RequestParam("certSn") String certSn, @RequestParam("keySn") String keySn, @ModelAttribute("proxy") Proxy proxy, HttpServletRequest request) {
Map<String, Object> retMap = new HashMap<String, Object>();
retMap.put("retCode", 0);
UserInfo webUserInfo = null;
Project project = null;
// 校验证书和证书所绑定的用户和企业
UserCert userCert = userCertService.getUserCertByCertSn(certSn);
if (null == userCert) {
retMap.put("retMsg", "该证书未注册,请您先注册");
return retMap;
}
// if(null == userCert.getUserinfo()){
// retMap.put("retMsg", "该证书未绑定用户,请检查您插入的key是否正确");
// return retMap;
// }
// 校验订单和证书所对应的用户与企业
Bill bill = billService.getBill(billId);
if (null == bill) {
retMap.put("retMsg", "订单不存在");
return retMap;
}
webUserInfo = userInfoService.selectByPrimaryKey(bill.getUniqueId());
if (null == webUserInfo) {
retMap.put("retMsg", "订单所对应的用户不存在,请检查");
return retMap;
}
if (!(bill.getBillStatus().equals(ComNames.BILL_STATUS_1) || bill.getBillStatus().equals(ComNames.BILL_STATUS_2) || bill.getBillStatus().equals(ComNames.BILL_STATUS_15))) {
retMap.put("errorMsg", "该订单不处于可以重新提交的状态");
return retMap;
}
if (!bill.getUnlockUserCert().equals(userCert.getId())) {
retMap.put("errorMsg", "您无权操作该订单");
return retMap;
}
Product product = productService.getProduct(bill.getProduct());
if (null == product.getKeyUnlockType()) {
retMap.put("retMsg", "您选择的产品不属于解锁产品,请重新选择");
return retMap;
}
project = projectService.selectByPrimaryKey(product.getProject());
DefaultTransactionDefinition dtd = new DefaultTransactionDefinition();
dtd.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
TransactionStatus status = transactionManager.getTransaction(dtd);
try {
if (null != proxy && (StringUtils.isNotBlank(proxy.getImgFile()) || null != proxy.getId())) {
// 保存授权书
Proxy oldProxy = null;
if (null != proxy.getId()) {
oldProxy = new Proxy();
oldProxy.setId(proxy.getId());
proxy.setId(null);
}
proxy = proxyService.saveProxy1(bill.getEnterprise(), webUserInfo.getUniqueId(), bill.getId(), bill.getUniqueId(), proxy, oldProxy, project);
}
// 审核拒绝后的订单,重新提交,则修改订单状态和审核拒绝的短信发送
if (bill.getBillStatus().equals(ComNames.BILL_STATUS_15)) {
bill.setBillStatus(ComNames.BILL_STATUS_14);
bill.setIsSms(false);
billService.updateBill(bill);
}
transactionManager.commit(status);
LogUtil.userlog(sqlSession, project.getId(), "重新提交解锁订单", webUserInfo.getmPhone() + "重新提交解锁订单:" + bill.getBillId(), "未知", "", null == webUserInfo.getUniqueId() ? null : webUserInfo.getUniqueId());
retMap.put("retCode", 1);
return retMap;
} catch (Exception e) {
if (!status.isCompleted()) {
transactionManager.rollback(status);
}
UserLog userlog = new UserLog();
userlog.setProject(project.getId());
userlog.setType("重新提交解锁订单");
userlog.setInfo("url:reSubmitUnlockBill,详细错误:" + e.getMessage() + ",订单号" + bill.getBillId());
userlog.setHostId("未知");
userlog.setSn(null == webUserInfo.getUniqueId() ? null : webUserInfo.getUniqueId());
LogUtil.userlog(sqlSession, userlog);
retMap.put("retMsg", "服务端出现未知错误,请联系管理员");
return retMap;
} finally {
if (!status.isCompleted()) {
transactionManager.rollback(status);
}
}
}
use of com.itrus.portal.db.UserCert in project portal by ixinportal.
the class UnlockKeyBillController method toReSubmitUnlockBillPage.
/**
* 页面申请信息有误,或者审核拒绝,重新提交
*
* @param billId
* @param certSn
* @param keySn
* @param uiModel
* @return
*/
@RequestMapping("/toReSubmitUnlockBillPage/{billId}")
public String toReSubmitUnlockBillPage(@PathVariable("billId") Long billId, @RequestParam("certSn") String certSn, @RequestParam("keySn") String keySn, Model uiModel) {
UserCert userCert = userCertService.getUserCertByCertSn(certSn);
if (null == userCert) {
uiModel.addAttribute("errorMsg", "无法识别该证书,请检查您插入的key是否正确,证书序列号:" + certSn);
return ComNames.CLIENTFW_ERRORPAGE;
}
// if (null == userCert.getUserinfo() || null == userCert.getEnterprise()) {
// uiModel.addAttribute("errorMsg", "该证书尚未绑定用户和企业信息");
// return ComNames.CLIENTFW_ERRORPAGE;
// }
Bill bill = billService.getBill(billId);
if (null == bill) {
uiModel.addAttribute("errorMsg", "不存在解锁订单");
return ComNames.CLIENTFW_ERRORPAGE;
}
if (!(bill.getBillStatus().equals(ComNames.BILL_STATUS_1) || bill.getBillStatus().equals(ComNames.BILL_STATUS_2) || bill.getBillStatus().equals(ComNames.BILL_STATUS_15))) {
uiModel.addAttribute("errorMsg", "该订单不处于可以重新提交授权书的状态");
return ComNames.CLIENTFW_ERRORPAGE;
}
uiModel.addAttribute("bill", bill);
if (!bill.getUnlockUserCert().equals(userCert.getId())) {
uiModel.addAttribute("errorMsg", "您无权操作该订单");
return ComNames.CLIENTFW_ERRORPAGE;
}
Proxy proxy = proxyService.getProxyByBillId(bill.getId());
if (null != proxy) {
uiModel.addAttribute("proxy", proxy);
}
Product product = productService.getProduct(bill.getProduct());
uiModel.addAttribute("product", product);
uiModel.addAttribute("userCert", userCert);
return "clientWF/xiugaishouquanshu";
}
Aggregations