Search in sources :

Example 41 with UserCert

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";
}
Also used : UnsupportedEncodingException(java.io.UnsupportedEncodingException) CertificateException(java.security.cert.CertificateException) EvidenceCertificationChargingHandler(com.itrus.portal.evidence.service.EvidenceCertificationChargingHandler) ServiceNullException(com.itrus.portal.exception.ServiceNullException) IOException(java.io.IOException) ServiceNullException(com.itrus.portal.exception.ServiceNullException) IOException(java.io.IOException) CertificateException(java.security.cert.CertificateException) SigningServerException(com.itrus.cryptorole.SigningServerException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Date(java.util.Date) EvidenceCert(com.itrus.portal.db.EvidenceCert) SigningServerException(com.itrus.cryptorole.SigningServerException) UserCert(com.itrus.portal.db.UserCert) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 42 with UserCert

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";
}
Also used : Project(com.itrus.portal.db.Project) ProjectKeyInfo(com.itrus.portal.db.ProjectKeyInfo) UserInfo(com.itrus.portal.db.UserInfo) UserCert(com.itrus.portal.db.UserCert) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 43 with UserCert

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;
}
Also used : HashMap(java.util.HashMap) Bill(com.itrus.portal.db.Bill) UserCert(com.itrus.portal.db.UserCert) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 44 with UserCert

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";
}
Also used : Proxy(com.itrus.portal.db.Proxy) OnPayInfo(com.itrus.portal.db.OnPayInfo) Bill(com.itrus.portal.db.Bill) UserInfo(com.itrus.portal.db.UserInfo) UserCert(com.itrus.portal.db.UserCert) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 45 with UserCert

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;
}
Also used : KeyUnlock(com.itrus.portal.db.KeyUnlock) DefaultTransactionDefinition(org.springframework.transaction.support.DefaultTransactionDefinition) HashMap(java.util.HashMap) TransactionStatus(org.springframework.transaction.TransactionStatus) UserInfo(com.itrus.portal.db.UserInfo) Date(java.util.Date) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) Bill(com.itrus.portal.db.Bill) UserCert(com.itrus.portal.db.UserCert) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

UserCert (com.itrus.portal.db.UserCert)54 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)39 UserInfo (com.itrus.portal.db.UserInfo)25 HashMap (java.util.HashMap)24 Bill (com.itrus.portal.db.Bill)22 IOException (java.io.IOException)21 Enterprise (com.itrus.portal.db.Enterprise)19 Product (com.itrus.portal.db.Product)19 UserInfoServiceException (com.itrus.portal.exception.UserInfoServiceException)15 Date (java.util.Date)15 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)14 JSONObject (com.alibaba.fastjson.JSONObject)13 ArrayList (java.util.ArrayList)11 UserCertExample (com.itrus.portal.db.UserCertExample)10 CertBuf (com.itrus.portal.db.CertBuf)9 UnsupportedEncodingException (java.io.UnsupportedEncodingException)8 SigningServerException (com.itrus.cryptorole.SigningServerException)7 Project (com.itrus.portal.db.Project)7 UserinfoEnterprise (com.itrus.portal.db.UserinfoEnterprise)7 CertificateException (java.security.cert.CertificateException)7