Search in sources :

Example 11 with UserCert

use of com.itrus.portal.db.UserCert in project portal by ixinportal.

the class CustomerServerClientController method onLine.

/**
 * 用户登录后的客服在线
 * @param certSn
 * @param keySn
 * @param enterpriseName
 * @param session
 * @param uiModel
 * @return
 */
@RequestMapping("/online")
public String onLine(@RequestParam(value = "certSn", required = false) String certSn, @RequestParam(value = "keySn", required = false) String keySn, @RequestParam(value = "enterpriseName", required = false) String enterpriseName, HttpSession session, Model uiModel) {
    // TODO
    Boolean verifyCodeStatus = (Boolean) session.getAttribute(ComNames.WEB_VERIFY_CODE_STATUS);
    Enterprise enterprise = (Enterprise) session.getAttribute(ComNames.WEB_ENTERPRISE);
    UserInfo userInfo = (UserInfo) session.getAttribute(ComNames.WEB_USER_INFO);
    if (null == verifyCodeStatus || !verifyCodeStatus || null == userInfo) {
        // 登录状态失效,跳转到登录页面
        return ComNames.DENG_LU_CLIENT;
    }
    // 先根据key序列号取项目,若没有,则根据用户所属项目取项目信息
    Project project = null;
    if (StringUtils.isNotBlank(keySn)) {
        ProjectKeyInfo projectKeyInfo = cacheCustomer.findProjectByKey(keySn);
        if (null == projectKeyInfo) {
            uiModel.addAttribute("errorMsg", "无法识别的key序列号:" + keySn + ", 请联系系统管理员进行配置");
            return ComNames.CLIENTFW_ERRORPAGE;
        }
        project = projectService.selectByPrimaryKey(projectKeyInfo.getProject());
    }
    // 若项目为Null,而certsn不为null,则尝试从数据库获取keysn,查找项目
    if (null == project && StringUtils.isNotBlank(certSn)) {
        UserCert userCert = userCertService.getUserCertByCertSn(certSn);
        if (null != userCert && StringUtils.isNotBlank(userCert.getKeySn())) {
            ProjectKeyInfo projectKeyInfo = cacheCustomer.findProjectByKey(userCert.getKeySn());
            if (null != projectKeyInfo) {
                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) Enterprise(com.itrus.portal.db.Enterprise) UserInfo(com.itrus.portal.db.UserInfo) UserCert(com.itrus.portal.db.UserCert) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 12 with UserCert

use of com.itrus.portal.db.UserCert in project portal by ixinportal.

the class DoUnlockKeyController method toDoUnlockPage.

/**
 * 执行证书解锁的页面
 *
 * @param billId
 * @param uiModel
 * @return
 */
@RequestMapping("/toDoUnlockPage")
public String toDoUnlockPage(@RequestParam("billId") Long billId, @RequestParam("certSn") String certSn, @RequestParam("keySn") String keySn, @RequestParam("enterpriseName") String enterpriseName, Model uiModel) {
    UserCert userCert = userCertService.getUserCertByCertSn(certSn);
    if (null == userCert) {
        uiModel.addAttribute("errorMsg", "无法识别该证书,请检查您插入的key是否正确!");
        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.getUnlockUserCert().equals(userCert.getId())) {
        uiModel.addAttribute("errorMsg", "您无权操作该订单");
        return ComNames.CLIENTFW_ERRORPAGE;
    }
    Proxy proxy = proxyService.getProxyByBillId(bill.getId());
    Product product = productService.getProduct(bill.getProduct());
    UserInfo userInfo = userInfoService.selectByPrimaryKey(bill.getUniqueId());
    uiModel.addAttribute("mPhone", userInfo.getmPhone());
    uiModel.addAttribute("userCert", userCert);
    uiModel.addAttribute("product", product);
    uiModel.addAttribute("bill", bill);
    if (null != proxy) {
        // 授权书不一定有
        uiModel.addAttribute("proxy", proxy);
    }
    // TODO 解锁订单信息页面
    return "clientFW/zhengshujiesuo";
}
Also used : Proxy(com.itrus.portal.db.Proxy) Bill(com.itrus.portal.db.Bill) Product(com.itrus.portal.db.Product) UserInfo(com.itrus.portal.db.UserInfo) UserCert(com.itrus.portal.db.UserCert) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 13 with UserCert

use of com.itrus.portal.db.UserCert in project portal by ixinportal.

the class DoUnlockKeyController method toUnlockKeyPage.

/**
 * key已经申请了解锁订单,跳转解锁页面
 * 1.订单处于未支付,则跳转支付页面
 * 2.订单处于已支付,待解锁审批,则跳转查询页面
 * 3.订单为审批拒绝,跳转审核拒绝重新提交页面
 * 4.订单为审批通过,待解锁,跳转解锁页面
 * 5.订单为解锁异常,则跳转解锁异常页面
 * 6.订单为解锁完成,则跳转解锁完成页面
 * @param certSn
 * @param keySn
 * @param enterpriseName
 * @param uiModel
 * @return
 */
@RequestMapping("/toUnlockKeyPage")
public String toUnlockKeyPage(@RequestParam("billId") Long billId, @RequestParam("certSn") String certSn, @RequestParam("keySn") String keySn, @RequestParam("enterpriseName") String enterpriseName, Model uiModel, HttpSession session) {
    UserCert userCert = userCertService.getUserCertByCertSn(certSn);
    if (null == userCert) {
        uiModel.addAttribute("errorMsg", "无法识别该证书,请检查您插入的key是否正确!");
        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.getUnlockUserCert().equals(userCert.getId())) {
        uiModel.addAttribute("errorMsg", "您无权操作该订单");
        return ComNames.CLIENTFW_ERRORPAGE;
    }
    Proxy proxy = proxyService.getProxyByBillId(bill.getId());
    Product product = productService.getProduct(bill.getProduct());
    UserInfo userInfo = userInfoService.selectByPrimaryKey(bill.getUniqueId());
    OnPayInfo onPayInfo = onPayInfoService.selectByPrimaryKey(bill.getOnPayInfo());
    Enterprise enterprise = enterpriseService.getEnterpriseById(bill.getEnterprise());
    // UserInfo webUserInfo = (UserInfo) session.getAttribute(ComNames.WEB_USER_INFO);
    if (null == session.getAttribute(ComNames.WEB_USER_INFO)) {
        session.setAttribute(ComNames.WEB_USER_INFO, userInfo);
    }
    uiModel.addAttribute("mPhone", userInfo.getmPhone());
    uiModel.addAttribute("userCert", userCert);
    uiModel.addAttribute("keySn", userCert.getKeySn());
    uiModel.addAttribute("certSn", userCert.getCertSn());
    uiModel.addAttribute("product", product);
    uiModel.addAttribute("bill", bill);
    uiModel.addAttribute("onPayInfo", onPayInfo);
    uiModel.addAttribute("enterprise", enterprise);
    uiModel.addAttribute("enterpriseName", enterprise != null ? enterprise.getEnterpriseName() : "");
    if (null != proxy) {
        // 授权书不一定有
        uiModel.addAttribute("proxy", proxy);
    }
    if (bill.getBillStatus().equals(ComNames.BILL_STATUS_1)) {
        // * 1.订单处于未支付,则跳转支付页面 OK
        return "redirect:/unlockKeyBill/zhifu/" + billId;
    } else if (bill.getBillStatus().equals(ComNames.BILL_STATUS_14)) {
        // * 2.订单处于已支付,待解锁审批,则跳转查询页面,
        return "clientFW/dengdaishenhe_unlock";
    } else if (bill.getBillStatus().equals(ComNames.BILL_STATUS_15)) {
        // * 3.订单为审批拒绝,跳转审核拒绝重新提交页面
        return "clientFW/dengdaishenhe_unlock";
    } else if (bill.getBillStatus().equals(ComNames.BILL_STATUS_16)) {
        // * 4.订单为审批通过,待解锁,跳转解锁页面
        return "clientFW/unlock";
    } else if (bill.getBillStatus().equals(ComNames.BILL_STATUS_17)) {
        // * 5.订单为解锁异常,则跳转解锁异常页面
        return "redirect:/doUnlockKey/toUnlockFailPage/" + billId;
    } else {
        uiModel.addAttribute("errorMsg", "订单不处于解锁状态");
        return ComNames.CLIENTFW_ERRORPAGE;
    }
}
Also used : Proxy(com.itrus.portal.db.Proxy) OnPayInfo(com.itrus.portal.db.OnPayInfo) Bill(com.itrus.portal.db.Bill) Enterprise(com.itrus.portal.db.Enterprise) Product(com.itrus.portal.db.Product) UserInfo(com.itrus.portal.db.UserInfo) UserCert(com.itrus.portal.db.UserCert) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 14 with UserCert

use of com.itrus.portal.db.UserCert in project portal by ixinportal.

the class RenewUserCertClientController method toPages.

/**
 * 跳转到更新成功页面或是更新失败页面 certs为新证书,若不为空则更新成功,若为空则更新失败 szy 2016年9月7日 上午9:49:15
 *
 * @param id
 *            订单编号
 */
@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(ComNames.WEB_USER_INFO);
    Enterprise enterprise = (Enterprise) session.getAttribute(ComNames.WEB_ENTERPRISE);
    if (null == userInfo || null == enterprise) {
        return ComNames.DENG_LU_CLIENT;
    }
    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()) {
        uiModel.addAttribute("errorMsg", "更新订单不存在");
        return ComNames.CLIENTFW_ERRORPAGE;
    }
    // 审核记录
    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) {
        Map<Long, OnPayInfo> opiMap = sqlSession.selectMap("com.itrus.portal.db.OnPayInfoMapper.selectByExample", "id");
        uiModel.addAttribute("opiMap", opiMap);
    }
    PayInfoExample payInfoex = new PayInfoExample();
    Map<Long, PayInfo> payinfoMap = sqlSession.selectMap("com.itrus.portal.db.PayInfoMapper.selectByExample", payInfoex, "id");
    uiModel.addAttribute("payinfomap", payinfoMap);
    UserCertExample uce = new UserCertExample();
    UserCertExample.Criteria ucec = uce.or();
    ucec.andBillEqualTo(id);
    List<UserCert> certs = sqlSession.selectList("com.itrus.portal.db.UserCertMapper.selectByExample", uce);
    if (ret == 1) {
        // 更新成功页面
        UserCert userCert = certs.get(0);
        uiModel.addAttribute("doneTime", userCert.getCertStartTime());
        try {
            // 将客户端更新后的证书绑定给当前用户
            userCert.setUserinfo(userInfo.getId());
            userCertService.updateByPrimaryKeySelective(userCert);
        } catch (Exception e) {
        // TODO: handle exception
        }
        // 刷新session中的当前证书
        session.setAttribute(ComNames.WEB_USER_CERT_SN, userCert.getCertSn());
        return "clientFW/dingdanxiangqing_gengxinchenggong";
    } else {
        // 更新失败页面
        return "clientFW/dingdanxiangqing_gengxinshibai";
    }
}
Also used : PayInfoExample(com.itrus.portal.db.PayInfoExample) HashMap(java.util.HashMap) HttpSession(javax.servlet.http.HttpSession) UserCertExample(com.itrus.portal.db.UserCertExample) UserInfo(com.itrus.portal.db.UserInfo) EncDecException(com.itrus.portal.exception.EncDecException) PayInfo(com.itrus.portal.db.PayInfo) OnPayInfo(com.itrus.portal.db.OnPayInfo) OnPayInfo(com.itrus.portal.db.OnPayInfo) Enterprise(com.itrus.portal.db.Enterprise) ReviewLog(com.itrus.portal.db.ReviewLog) HashMap(java.util.HashMap) Map(java.util.Map) UserCert(com.itrus.portal.db.UserCert) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 15 with UserCert

use of com.itrus.portal.db.UserCert in project portal by ixinportal.

the class ApplicationInfoController method update.

// 修改处理
@RequestMapping(method = RequestMethod.PUT, produces = "text/html")
public String update(@Valid ApplicationInfo applicationInfo, Long isupdate, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) {
    if (bindingResult.hasErrors()) {
        uiModel.addAttribute("applicationInfo", applicationInfo);
        return "applicationinfo/update";
    }
    ApplicationInfo applicationInfo0 = applicationInfoService.selectById(applicationInfo.getId());
    applicationInfo.setAppId(applicationInfo0.getAppId());
    applicationInfo.setSecretKey(applicationInfo0.getSecretKey());
    applicationInfo.setAppServiceItems(applicationInfo0.getAppServiceItems());
    applicationInfo.setCreator(applicationInfo0.getCreator());
    applicationInfo.setCreateTime(applicationInfo0.getCreateTime());
    applicationInfo.setModifier(getAdmin().getId());
    applicationInfo.setModifyTime(new Date());
    applicationInfo.setAppId2(applicationInfo0.getAppId2());
    applicationInfo.setSecretKey2(applicationInfo0.getSecretKey2());
    // applicationInfo.setCallback(applicationInfo0.getCallback());
    EvidenceCert cert = new EvidenceCert();
    if (isupdate == null) {
        if (!"applicationinfo.certBase64".equals(applicationInfo.getCertBase64())) {
            String result = null;
            try {
                sun.misc.BASE64Decoder decoder = new sun.misc.BASE64Decoder();
                byte[] bt = decoder.decodeBuffer(applicationInfo.getCertBase64());
                result = new String(bt, "utf-8");
                UserCert userCert = CertUtil.getCertFromBase64(result);
                cert.setCreateTime(new Date());
                result = result.replaceAll("-----BEGIN CERTIFICATE-----", "").replaceAll("-----END CERTIFICATE-----", "").replaceAll("\r", "").replaceAll("\n", "");
                cert.setCertBase64(result);
                cert.setStartTime(userCert.getCertStartTime());
                cert.setEndTime(userCert.getCertEndTime());
                cert.setCertSerialnumber(userCert.getCertSn());
                cert.setIssuerdn(userCert.getIssuerDn());
                cert.setSubjectdn(userCert.getCertDn());
                /*if(userCert.getCertBuf()!=null){
						cert.setEvidenceBuf(userCert.getCertBuf().toString());
					}*/
                sqlSession.insert("com.itrus.portal.db.EvidenceCertMapper.insert", cert);
                String certDn = userCert.getCertDn();
                // applicationInfo.setCertBase64(cert.getId().toString());
                applicationInfo.setCertBase64(cert.getId().toString());
                applicationInfo.setCertDn(certDn);
                applicationInfo.setCertCn(EvidenceSaveServiceApi.getCertCn(certDn));
            // applicationInfo.setCertBase64(result);
            /*UserCert userCert = CertUtil.getCertFromBase64(result);
					String certDn = userCert.getCertDn();
					applicationInfo.setCertDn(certDn);
					applicationInfo.setCertCn(EvidenceSaveServiceApi.getCertCn(certDn));*/
            } 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 {
            applicationInfo.setCertBase64(null);
        }
        applicationInfoService.updateByApplicationInfo(applicationInfo);
    } else {
        applicationInfo.setCertBase64(applicationInfo0.getCertBase64());
        applicationInfo.setCertDn(applicationInfo0.getCertDn());
        applicationInfo.setCertCn(applicationInfo0.getCertCn());
        applicationInfoService.updateByApplicationInfo(applicationInfo);
    }
    /*else if(isupdate==1){
			try {
				applicationInfo.setCertBase64(applicationInfo0.getCertBase64());
				UserCert userCert = CertUtil.getCertFromBase64(applicationInfo0.getCertBase64());
				String certDn = userCert.getCertDn();
				applicationInfo.setCertDn(certDn);
				applicationInfo.setCertCn(EvidenceSaveServiceApi.getCertCn(certDn));
			} catch (CertificateException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (SigningServerException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}*/
    String oper = "修改应用";
    String info = "应用名称: " + applicationInfo.getName();
    LogUtil.adminlog(sqlSession, oper, info);
    return "redirect:applicationinfo/" + applicationInfo.getId();
}
Also used : ApplicationInfo(com.itrus.portal.db.ApplicationInfo) UnsupportedEncodingException(java.io.UnsupportedEncodingException) CertificateException(java.security.cert.CertificateException) IOException(java.io.IOException) 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)

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