use of com.itrus.portal.db.UserCert in project portal by ixinportal.
the class RealNameAuthenticationController method update.
// 修改处理
@RequestMapping(method = RequestMethod.POST, produces = "text/html")
public String update(RealNameAuthentication realName, @RequestParam(value = "status", required = false) Integer status, Model uiModel) {
if (realName.getId() == null) {
realName.setType(status);
try {
realnameauthent.addRealName(realName);
} catch (ServiceNullException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
if (realName != null && realName.getCertificate() != null) {
if (!"realName.certificate".equals(realName.getCertificate())) {
String result = null;
try {
sun.misc.BASE64Decoder decoder = new sun.misc.BASE64Decoder();
byte[] bt = decoder.decodeBuffer(realName.getCertificate());
result = new String(bt, "utf-8");
result = result.replaceAll("-----BEGIN CERTIFICATE-----", "").replaceAll("-----END CERTIFICATE-----", "").replaceAll("\r", "").replaceAll("\n", "");
// System.out.println(result);
realName.setCertificate(result);
UserCert usercert = CertUtil.getCertFromBase64(result);
;
String certDn = usercert.getCertDn();
EvidenceCert evidenceCert = new EvidenceCert();
evidenceCert.setCertBase64(result);
evidenceCert.setCertSerialnumber(usercert.getCertSn());
evidenceCert.setCreateTime(new Date());
evidenceCert.setEndTime(usercert.getCertEndTime());
if (usercert.getCertBuf() != null) {
evidenceCert.setEvidenceBuf(usercert.getCertBuf().toString());
}
evidenceCert.setIssuerdn(usercert.getIssuerDn());
evidenceCert.setStartTime(usercert.getCertStartTime());
evidenceCert.setSubjectdn(usercert.getCertDn());
sqlSession.insert("com.itrus.portal.db.EvidenceCertMapper.insertSelective", evidenceCert);
if (evidenceCert.getId() != null) {
realName.setCertificateCn(evidenceCert.getId().toString());
}
} catch (CertificateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SigningServerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
realName.setCertificate(null);
}
}
try {
realnameauthent.updateRealName(realName);
} catch (ServiceNullException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
// 通知其他机器,加载缓存
EvidenceCertificationChargingHandler cch = new EvidenceCertificationChargingHandler();
cch.setType(2);
QueueThread.buildCertificationTask(cch);
cacheCustomer.initEvidence(2);
return "redirect:/realname";
}
use of com.itrus.portal.db.UserCert in project portal by ixinportal.
the class CustomerServerClientController method onLineByJieSuoYiChang.
/**
* 解锁异常的的客服在线
* @param certSn
* @param keySn
* @param enterpriseName
* @param session
* @param uiModel
* @return
*/
@RequestMapping("/onLineByJieSuoYiChang")
public String onLineByJieSuoYiChang(@RequestParam(value = "certSn", required = true) String certSn, @RequestParam(value = "keySn", required = true) String keySn, HttpSession session, Model uiModel) {
UserCert userCert = userCertService.getUserCertByCertSn(certSn);
if (null == userCert || null == userCert.getUserinfo()) {
return ComNames.DENG_LU_CLIENT;
}
UserInfo userInfo = userInfoService.getUserInfoById(userCert.getUserinfo());
// 先根据key序列号取项目,若没有,则根据用户所属项目取项目信息
Project project = null;
if (StringUtils.isNotBlank(keySn) && StringUtils.isNotBlank(certSn)) {
ProjectKeyInfo projectKeyInfo = cacheCustomer.findProjectByKey(keySn);
if (null == projectKeyInfo) {
uiModel.addAttribute("errorMsg", "无法识别的key序列号:" + keySn + ", 请联系系统管理员进行配置");
return ComNames.CLIENTFW_ERRORPAGE;
}
project = projectService.selectByPrimaryKey(projectKeyInfo.getProject());
}
if (null == project) {
project = projectService.selectByPrimaryKey(userInfo.getProject());
}
Map<String, String> map = questionService.auth(project.getId());
if (map != null && !map.isEmpty()) {
uiModel.addAttribute("qq", map.get("qq"));
uiModel.addAttribute("phone", map.get("phone"));
uiModel.addAttribute("questionUrl", map.get("questionUrl"));
uiModel.addAttribute("downloadUrl", map.get("downloadUrl"));
}
return "clientFW/kefuzaixian";
}
use of com.itrus.portal.db.UserCert in project portal by ixinportal.
the class DoUnlockKeyController method queryWhetherHasUnlockBill.
/**
* 用户登录首页,根据用户插入的key,判断用户是否有待解锁的订单:
* 如果有,则显示:查询解锁审批结果
* 如果没有,则显示:忘记证书口令
* retcode0,没有订单,1有订单
* @param certSn
* @param keySn
* @param enterpriseName
* @return
*/
@RequestMapping("/queryWhetherHasUnlockBill")
@ResponseBody
public Map<String, Object> queryWhetherHasUnlockBill(@RequestParam("certSn") String certSn, @RequestParam("keySn") String keySn, @RequestParam("enterpriseName") String enterpriseName) {
Map<String, Object> retMap = new HashMap<>();
retMap.put("retCode", 0);
UserCert userCert = userCertService.getUserCertByCertSn(certSn);
if (null == userCert) {
retMap.put("retMsg", "无法识别该证书,请检查您插入的key是否正确,证书序列号:" + certSn);
return retMap;
}
// if (null== userCert.getUserinfo() || null == userCert.getEnterprise()) {
// retMap.put("retMsg", "该证书尚未绑定用户和企业信息");
// return retMap;
// }
// 一个key可能会申请多个解锁订单(之前的订单已经解锁完了)
Bill bill = billService.getBillWaitingForUnlock(userCert.getId());
if (null == bill) {
retMap.put("retMsg", "不存在解锁订单");
return retMap;
}
retMap.put("billId", bill.getId());
retMap.put("retCode", 1);
return retMap;
}
use of com.itrus.portal.db.UserCert in project portal by ixinportal.
the class DoUnlockKeyController method toUnlockFailPage.
@RequestMapping("/toUnlockFailPage/{billId}")
public String toUnlockFailPage(@PathVariable("billId") Long billId, Model uiModel) {
Bill bill = billService.getBill(billId);
UserInfo userInfo = userInfoService.getUserInfoById(bill.getUniqueId());
Proxy proxy = proxyService.getProxyByBillId(bill.getId());
OnPayInfo onPayInfo = onPayInfoService.selectByPrimaryKey(bill.getOnPayInfo());
UserCert userCert = userCertService.selectByPrimaryKey(bill.getUnlockUserCert());
uiModel.addAttribute("mPhone", userInfo.getmPhone());
uiModel.addAttribute("userCert", userCert);
uiModel.addAttribute("bill", bill);
uiModel.addAttribute("onPayInfo", onPayInfo);
uiModel.addAttribute("proxy", proxy);
uiModel.addAttribute("keySn", userCert.getKeySn());
uiModel.addAttribute("certSn", userCert.getCertSn());
return "clientFW/jiesuoyichang";
}
use of com.itrus.portal.db.UserCert in project portal by ixinportal.
the class DoUnlockKeyController method unlockResult.
/**
* 解锁结果.
* @param isUnlockSuccess,是否解锁成功.true解锁成功,false解锁失败
* @param certSn
* @param keySn
* @param enterpriseName
* @param newPassword
* @param uiModel
* @return
*/
@RequestMapping("/unlockResult")
@ResponseBody
public Map<String, Object> unlockResult(@RequestParam("isUnlockSuccess") Boolean isUnlockSuccess, @RequestParam("billId") Long billId, @RequestParam("certSn") String certSn, @RequestParam("keySn") String keySn, @RequestParam(value = "enterpriseName", required = false) String enterpriseName, @RequestParam("newPassword") String newPassword, @RequestParam(value = "errorMsg", required = false) String errorMsg, Model uiModel, HttpSession session) {
Map<String, Object> retMap = new HashMap<String, Object>();
retMap.put("retCode", 0);
boolean verifyCodeZSJS = (boolean) session.getAttribute("verifyCodeZSJS");
if (!verifyCodeZSJS) {
// 查看解锁短信验证是否成功
retMap.put("retMsg", "短信验证失败");
return retMap;
}
session.removeAttribute("verifyCodeZSJS");
DefaultTransactionDefinition dtd = new DefaultTransactionDefinition();
dtd.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
TransactionStatus status = transactionManager.getTransaction(dtd);
UserInfo userInfo = null;
Bill bill = null;
try {
bill = billService.getBill(billId);
if (null == bill) {
retMap.put("retMsg", "订单不存在");
return retMap;
}
userInfo = userInfoService.getUserInfoById(bill.getUniqueId());
KeyUnlock keyUnlock = keyUnlockService.getKeyUnlockByBillId(billId);
if (null == keyUnlock) {
retMap.put("retMsg", "解锁信息不存证");
return retMap;
}
UserCert userCert = userCertService.getUserCertByCertSn(certSn);
if (isUnlockSuccess) {
// 解锁成功,若不需要开票,则直接完成
if (null == bill.geteInvoice() && null == bill.getInvoice()) {
bill.setBillStatus(ComNames.BILL_STATUS_8);
} else {
// 需要开票,校验是否已经开票了
if (null != bill.getIsInvoiced() && bill.getIsInvoiced().equals(1)) {
bill.setBillStatus(ComNames.BILL_STATUS_8);
} else {
bill.setBillStatus(ComNames.BILL_STATUS_18);
}
}
keyUnlock.setUnlockTime(new Date());
keyUnlock.setStatus("UNLOCK");
// 审批解锁成功后,证书和手机号绑定成功,无需登录时再次绑定
if (null == userCert.getUserinfo() || !userCert.getUserinfo().equals(userInfo.getId())) {
userCert.setUserinfo(userInfo.getId());
if (null == userCert.getEnterprise()) {
userCert.setEnterprise(bill.getEnterprise());
}
// 若进行管理员解锁,且订单用户与证书绑定用户不一致,则更换证书所绑定的用户为当前订单用户
if (null != userCert.getUserinfo() && !userCert.getUserinfo().equals(userInfo.getId())) {
userCert.setUserinfo(userInfo.getId());
}
userCertService.updateByPrimaryKeySelective(userCert);
}
} else {
// 解锁异常
bill.setBillStatus(ComNames.BILL_STATUS_17);
}
billService.updateBill(bill);
keyUnlockService.updateByPrimaryKey(keyUnlock);
transactionManager.commit(status);
if (isUnlockSuccess) {
LogUtil.userlog(sqlSession, bill.getProject(), "证书解锁", "解锁成功,keySn:" + keySn, "未知", "", null == userInfo.getUniqueId() ? null : userInfo.getUniqueId());
} else {
LogUtil.userlog(sqlSession, bill.getProject(), "证书解锁", "解锁失败,keySn:" + keySn + ", 错误信息" + errorMsg, "未知", "", null == userInfo.getUniqueId() ? null : userInfo.getUniqueId());
}
retMap.put("retCode", 1);
} catch (Exception e) {
if (!status.isCompleted()) {
transactionManager.rollback(status);
}
LogUtil.userlog(sqlSession, bill.getProject(), "证书解锁", "解锁异常,keySn:" + keySn + "异常信息:" + e.getMessage(), "未知", "", null == userInfo.getUniqueId() ? null : userInfo.getUniqueId());
retMap.put("retMsg", "证书解锁出现异常,请联系系统管理员进行处理!");
} finally {
if (!status.isCompleted()) {
transactionManager.rollback(status);
}
}
return retMap;
}
Aggregations