Search in sources :

Example 46 with UserCert

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

the class SignatureRecordController method detail.

/**
 * 前往详情界面
 * @param
 * @return
 */
@RequestMapping(value = "/detail")
public String detail(@RequestParam(value = "enterpriseName", required = false) String enterpriseName, @RequestParam(value = "userId", required = false) Long userId, Model uiModel) {
    Map<String, Object> param = new HashMap<>();
    Calendar calendar = Calendar.getInstance();
    // 今天日期
    Date queryDate2 = calendar.getTime();
    calendar.add(Calendar.MONTH, 0);
    calendar.set(Calendar.DAY_OF_MONTH, 1);
    calendar.set(Calendar.HOUR_OF_DAY, 0);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);
    calendar.set(Calendar.MILLISECOND, 0);
    // 当月第一天
    Date queryDate1 = calendar.getTime();
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.MONTH, -6);
    // 前6个月
    Date queryDate = cal.getTime();
    param.put("queryDate2", queryDate2);
    param.put("queryDate1", queryDate1);
    param.put("queryDate", queryDate);
    param.put("enterpriseName", enterpriseName);
    param.put("userId", userId);
    // 当月统计数目
    List<Map<String, Object>> monthList = sqlSession.selectList("com.itrus.portal.db.SignatureRecordMapper.selectOneMonth", param);
    Map<Object, Object> monthMap = signatureRecordService.dealMonthList(monthList);
    // 前六月统计数目
    List<Map<String, Object>> sixMonthList = sqlSession.selectList("com.itrus.portal.db.SignatureRecordMapper.selectSixMonth", param);
    Map<Object, Object> sixthMap = signatureRecordService.dealSixList(sixMonthList);
    // 展示详情页面最上端信息
    Map<String, Object> signatureRecord = signatureRecordService.getBean(sixMonthList);
    // 签名证书信息
    UserCert userCert = userCertService.getUserCertByCertSn((String) signatureRecord.get("cert_sn"));
    uiModel.addAttribute("key_sn", signatureRecord.get("key_sn"));
    uiModel.addAttribute("userCert", userCert);
    uiModel.addAttribute("signatureRecord", signatureRecord);
    uiModel.addAttribute("monthMap", monthMap);
    uiModel.addAttribute("sixMonthList", sixMonthList);
    uiModel.addAttribute("sixthMap", sixthMap);
    return "signature/detail";
}
Also used : UserCert(com.itrus.portal.db.UserCert) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 47 with UserCert

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

the class MakeCertController method sendReNewInfo.

/**
 * 发送待更新短信通知
 *
 * @param id
 *            订单id
 * @return
 */
@RequestMapping("/sendReNewInfo")
@ResponseBody
public Map<String, Object> sendReNewInfo(@RequestParam(value = "billId") Long id) {
    Map<String, Object> retMap = new HashMap<String, Object>();
    // 0标识发送验证码失败,1标识成功
    retMap.put("retCode", 0);
    Bill bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", id);
    if (null != bill.getRenewSms() && bill.getRenewSms() == true) {
        retMap.put("message", "该用户已经发送过短信通知了,不能重复发送");
        return retMap;
    }
    // 获取订单对应的产品信息
    Product product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct());
    String productName = product.getName();
    // 发送短信所需要的信息
    UserInfo userInfo = sqlSession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey", bill.getUniqueId());
    UserCertExample userCertExample = new UserCertExample();
    UserCertExample.Criteria criteria = userCertExample.or();
    criteria.andIdEqualTo(bill.getOldUserCert());
    UserCert userCert = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByExample", userCertExample);
    Enterprise enterprise = sqlSession.selectOne("com.itrus.portal.db.EnterpriseMapper.selectByPrimaryKey", bill.getEnterprise());
    Long projectId = bill.getProject();
    String mPhone = userInfo.getmPhone();
    String keySn = userCert.getKeySn();
    if (null == keySn) {
        keySn = "该证书未绑定key";
    }
    String enterpriseName = enterprise.getEnterpriseName();
    Date endTime = userCert.getCertEndTime();
    // 执行发送
    try {
        makeCerServiceImpl.sendReNewInfo(bill, mPhone, projectId, "ZSGX", keySn, enterpriseName, endTime, productName);
        retMap.put("retCode", 1);
        retMap.put("message", "发送更新通知短信成功");
    } catch (Exception e) {
        // TODO: handle exception
        e.printStackTrace();
        retMap.put("message", "发送短信失败,请联系管理员");
        String type = "发送更新证书通知失败";
        String info = "用户电话:" + mPhone + "错误信息:" + e.getMessage();
        LogUtil.syslog(sqlSession, type, info);
    }
    return retMap;
}
Also used : HashMap(java.util.HashMap) UserCertExample(com.itrus.portal.db.UserCertExample) Product(com.itrus.portal.db.Product) UserInfo(com.itrus.portal.db.UserInfo) Date(java.util.Date) EncDecException(com.itrus.portal.exception.EncDecException) IOException(java.io.IOException) RaServiceUnavailable_Exception(cn.topca.tca.ra.service.RaServiceUnavailable_Exception) Bill(com.itrus.portal.db.Bill) Enterprise(com.itrus.portal.db.Enterprise) JSONObject(com.alibaba.fastjson.JSONObject) UserCert(com.itrus.portal.db.UserCert) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 48 with UserCert

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

the class MakeCertController method makecert.

// 制作证书
@RequestMapping(value = "/make/{id}", produces = "text/html")
@ResponseBody
public Map<String, Object> makecert(@RequestParam(value = "uidIdx", required = true) Integer uidIdx, @RequestParam(value = "csr", required = true) String csr, @RequestParam(value = "pid", required = true) Long pid, @RequestParam(value = "index", required = false) Integer index, @RequestParam(value = "keySn", required = false) String keySn, @PathVariable("id") Long id) {
    Map<String, Object> ret = new HashMap<String, Object>();
    // 查询订单
    Bill bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", id);
    // 查询项目产品
    Product product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", pid);
    // 解析项目产品中,certinfo配置信息
    JSONArray certinfo = JSONArray.parseArray(product.getCertinfo());
    // 解析订单中uid信息{"ADDTIONAL_FIELD1_1":"","ADDTIONAL_FIELD3_1":"","ADDTIONAL_FIELD4_1":"G2016071301","inputName":"inputValue"}
    JSONObject uid = JSONObject.parseObject(bill.getUid());
    if (null != index) {
        if (index == 1) {
            uid = JSONObject.parseObject(bill.getUid1());
        }
        if (index == 2) {
            uid = JSONObject.parseObject(bill.getUid2());
        }
        if (index == 3) {
            uid = JSONObject.parseObject(bill.getUid3());
        }
    }
    // 获取产品、RA配置
    RaAccount ra = sqlSession.selectOne("com.itrus.portal.db.RaAccountMapper.selectByPrimaryKey", product.getRa());
    com.itrus.portal.utils.CertUtlis certutil = new com.itrus.portal.utils.CertUtlis();
    // 证书配置
    DigitalCert digitalcert = sqlSession.selectOne("com.itrus.portal.db.DigitalCertMapper.selectByPrimaryKey", product.getCert());
    // 组织RA参数
    cn.topca.tca.ra.service.UserInfo rauserinfo = new cn.topca.tca.ra.service.UserInfo();
    UIDInfoUtils uidutils = new UIDInfoUtils();
    uidutils.initService(businessService, orgCodeService, taxCertService, identityCardService, userInfoService, enterpriseService);
    String autoidType = "";
    Integer autoidValue = 0;
    for (int i = 0; i < certinfo.size(); i++) {
        JSONObject obj = certinfo.getJSONObject(i);
        String raParaName = obj.getString("raParaName");
        if (raParaName == null)
            continue;
        // "autoid":"yes",
        String autoid = obj.getString("autoid");
        // "raParaName": "userName",
        String constValue = obj.getString("constValue");
        // "constValue": "test@itrus.com.cn"
        String refName = obj.getString("refName");
        String val = null;
        if (constValue != null) {
            val = constValue;
        } else if (refName != null) {
            if (refName.indexOf("?") == -1)
                val = uidutils.getUidInfo(bill.getId(), refName);
            else {
                val = "";
                String[] arr = refName.split("\\?", 2);
                if (arr.length == 2) {
                    String condition = arr[0].trim();
                    String[] refarr = arr[1].split(":", 2);
                    if (refarr.length == 2) {
                        boolean bret = uidutils.checkCondition(bill.getId(), condition);
                        if (bret)
                            val = uidutils.getUidInfo(bill.getId(), refarr[0].trim());
                        else
                            val = uidutils.getUidInfo(bill.getId(), refarr[1].trim());
                    }
                }
            }
        } else if (autoid != null) {
            // "autoidPrev":"G",
            String autoidPrev = obj.getString("autoidPrev");
            // "autoidType":"mytestautoid",
            autoidType = obj.getString("autoidType");
            // "inputName": "ADDTIONAL_FIELD4",存在多个值
            String uidval = uid.getString(obj.getString("inputName") + "_" + uidIdx.toString());
            val = uidval;
            if (StringUtils.isNotBlank(uidval) && uidval.indexOf(autoidPrev) == 0) {
                // "autoidPrevDate":"yyyyMMdd",
                String autoidPrevDate = obj.getString("autoidPrevDate");
                try {
                    if (autoidPrevDate == null || autoidPrevDate.length() == 0)
                        autoidValue = Integer.parseInt(uidval.substring(autoidPrev.length()));
                    else
                        autoidValue = Integer.parseInt(uidval.substring(autoidPrev.length() + autoidPrevDate.length()));
                } catch (Exception e) {
                    e.printStackTrace();
                    autoidValue = 0;
                }
            }
        } else {
            val = uid.getString(obj.getString("inputName") + "_" + uidIdx.toString());
        }
        certutil.setUserInfoVal(rauserinfo, raParaName, val);
    }
    // 证书有效期
    // {"0":"1年","1":"2年","2":"3年","3":"5年","4":"10年"})
    Integer certValidity = 5;
    boolean hasProductSpec = false;
    // 判断订单中是否配了产品规格且有期限
    ProductSpec productSpec = null;
    if (null != bill.getProductSpec() && 0 != bill.getProductSpec()) {
        productSpec = productSpecService.getProductSpec(bill.getProductSpec());
        if (StringUtils.isNotBlank(productSpec.getProductValid())) {
            hasProductSpec = true;
        }
    }
    if (null != index) {
        if (index == 1)
            if (null != bill.getProductSpec1() && 0 != bill.getProductSpec1()) {
                productSpec = productSpecService.getProductSpec(bill.getProductSpec1());
                if (StringUtils.isNotBlank(productSpec.getProductValid())) {
                    hasProductSpec = true;
                }
            }
        if (index == 2)
            if (null != bill.getProductSpec2() && 0 != bill.getProductSpec2()) {
                productSpec = productSpecService.getProductSpec(bill.getProductSpec2());
                if (StringUtils.isNotBlank(productSpec.getProductValid())) {
                    hasProductSpec = true;
                }
            }
        if (index == 3)
            if (null != bill.getProductSpec3() && 0 != bill.getProductSpec3()) {
                productSpec = productSpecService.getProductSpec(bill.getProductSpec3());
                if (StringUtils.isNotBlank(productSpec.getProductValid())) {
                    hasProductSpec = true;
                }
            }
    }
    if (hasProductSpec) {
        Integer day = Integer.parseInt(productSpec.getProductValid());
        if (day == 100) {
            // TODO 测试时候,配置年限为100年,则有效期为10天
            certValidity = 1;
        } else {
            certValidity = 365 * day + 1 + (day / 4);
        }
    } else {
        if ("0".compareTo(digitalcert.getCertDeadline()) == 0) {
            certValidity = 365 * 1 + 1;
        } else if ("1".compareTo(digitalcert.getCertDeadline()) == 0) {
            certValidity = 365 * 2 + 1;
        } else if ("2".compareTo(digitalcert.getCertDeadline()) == 0) {
            certValidity = 365 * 3 + 1;
        } else if ("3".compareTo(digitalcert.getCertDeadline()) == 0) {
            certValidity = 365 * 5 + 2;
        } else if ("4".compareTo(digitalcert.getCertDeadline()) == 0) {
            certValidity = 365 * 10 + 2;
        } else if ("-1".compareTo(digitalcert.getCertDeadline()) == 0) {
            // 数字证书没有配置年限(-1),默认10天有效期
            certValidity = 10;
        }
    }
    log.error("证书期限*********" + certValidity);
    // 调用RA
    CertInfo racertinfo = null;
    try {
        if (ra.getAaPassword() != null)
            ra.setAaPassword(AESencrp.decrypt(ra.getAaPassword(), dbEncKey));
        racertinfo = certutil.enrollCertByWS(csr, ra, rauserinfo, certValidity);
    } catch (RaServiceUnavailable_Exception e) {
        e.printStackTrace();
        ret.put("status", 1001);
        ret.put("message", e.getMessage());
        // 记录日志
        String oper = "制作证书失败";
        String info = "企业名称: " + uidutils.getUidInfo(bill.getId(), "enterprise.enterpriseName") + ",参数:" + ToStringBuilder.reflectionToString(rauserinfo) + ",异常信息: " + e.toString();
        LogUtil.adminlog(sqlSession, oper, info);
        return ret;
    } catch (Exception e) {
        e.printStackTrace();
        ret.put("status", 1002);
        ret.put("message", e.getMessage());
        // 记录日志
        String oper = "制作证书失败";
        String info = "企业名称: " + uidutils.getUidInfo(bill.getId(), "enterprise.enterpriseName") + "参数:" + ToStringBuilder.reflectionToString(rauserinfo) + ",异常信息: " + e.toString();
        LogUtil.adminlog(sqlSession, oper, info);
        return ret;
    }
    // 解析数字证书信息
    // 存储数字证书信息
    CertBuf certbuf = new CertBuf();
    certbuf.setCreateTime(new Date());
    certbuf.setCertBuf(racertinfo.getCertSignBuf());
    certbuf.setCertKmcRep1(racertinfo.getCertKmcRep1());
    certbuf.setCertKmcRep2(racertinfo.getCertKmcRep2());
    certbuf.setCertsignBuf(racertinfo.getCertSignBuf());
    certbuf.setEncUserCert(racertinfo.getCertSignBufKmc());
    sqlSession.insert("com.itrus.portal.db.CertBufMapper.insert", certbuf);
    UserCert usercert = new UserCert();
    usercert.setBill(bill.getId());
    usercert.setRaAccount(ra.getId());
    usercert.setCertBuf(certbuf.getId());
    usercert.setUidIdx(uidIdx);
    usercert.setCertDn(racertinfo.getCertSubjectDn());
    usercert.setCertSn(racertinfo.getCertSerialNumber());
    usercert.setIssuerDn(racertinfo.getCertIssuerDn());
    usercert.setCertStatus("1");
    usercert.setCertUid("certUid");
    usercert.setProduct(pid);
    if (StringUtils.isNotBlank(keySn))
        // 设置证书keySn
        usercert.setKeySn(keySn);
    try {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss");
        usercert.setCertStartTime(sdf.parse(racertinfo.getCertNotBefore()));
        usercert.setCertEndTime(sdf.parse(racertinfo.getCertNotAfter()));
    } catch (java.text.ParseException e) {
        e.printStackTrace();
    }
    usercert.setSha1Fingerprint("setSha1Fingerprint");
    // autoid 数据
    if (!autoidType.equals("")) {
        usercert.setAutoidType(autoidType);
        usercert.setAutoidValue(autoidValue);
    }
    usercert.setEnterprise(bill.getEnterprise());
    try {
        sqlSession.insert("com.itrus.portal.db.UserCertMapper.insert", usercert);
    } catch (Exception e) {
        e.printStackTrace();
    }
    // 查询userCert中,该bill的记录数目,如果数据 大于等于 bill 里面的购买数量,则修改该bill为制证完成
    updateBillStatus(bill, product);
    // 记录日志
    String oper = "制作证书";
    String info = "数字证书: " + racertinfo.getCertSerialNumber() + ", " + racertinfo.getCertSubjectDn();
    LogUtil.adminlog(sqlSession, oper, info);
    // 返回数字证书
    ret.put("certChain", racertinfo.getCertSignBufP7());
    ret.put("certsignBuf", racertinfo.getCertSignBuf());
    ret.put("certKmcRep1", racertinfo.getCertKmcRep1());
    ret.put("certKmcRep2", racertinfo.getCertKmcRep2());
    // 加密证书
    ret.put("encUserCert", racertinfo.getCertSignBufKmc());
    ret.put("status", 0);
    return ret;
}
Also used : CertInfo(cn.topca.tca.ra.service.CertInfo) RaServiceUnavailable_Exception(cn.topca.tca.ra.service.RaServiceUnavailable_Exception) HashMap(java.util.HashMap) Product(com.itrus.portal.db.Product) UserInfo(com.itrus.portal.db.UserInfo) UIDInfoUtils(com.itrus.portal.utils.UIDInfoUtils) DigitalCert(com.itrus.portal.db.DigitalCert) RaAccount(com.itrus.portal.db.RaAccount) CertBuf(com.itrus.portal.db.CertBuf) UserCert(com.itrus.portal.db.UserCert) JSONArray(com.alibaba.fastjson.JSONArray) ProductSpec(com.itrus.portal.db.ProductSpec) EncDecException(com.itrus.portal.exception.EncDecException) IOException(java.io.IOException) RaServiceUnavailable_Exception(cn.topca.tca.ra.service.RaServiceUnavailable_Exception) Date(java.util.Date) BigInteger(java.math.BigInteger) JSONObject(com.alibaba.fastjson.JSONObject) Bill(com.itrus.portal.db.Bill) JSONObject(com.alibaba.fastjson.JSONObject) SimpleDateFormat(java.text.SimpleDateFormat) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 49 with UserCert

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

the class MakeCertController method updateBillStatus.

/**
 * 修改订单状态:1、订单关联的证书数量大于或等于订单购买的产品数量;2、假如该产品配了签章服务,则判断该订单关联的所有证书,是否都已经签章并且授权,
 * 假如都已经签章授权,则改变订单状态。
 *
 * @param bill
 * @param product
 */
private void updateBillStatus(Bill bill, Product product) {
    // 查询userCert中,该bill的记录数目,如果数据 大于等于 bill 里面的购买数量,则修改该bill为制证完成
    UserCertExample example = new UserCertExample();
    UserCertExample.Criteria criteria = example.or();
    criteria.andCertStatusNotEqualTo("0");
    criteria.andBillEqualTo(bill.getId());
    List<UserCert> usercertall = sqlSession.selectList("com.itrus.portal.db.UserCertMapper.selectByExample", example);
    Product p = productService.getProductById(bill.getProduct());
    Integer num1 = 0;
    Integer num2 = 0;
    Integer num3 = 0;
    if (null != bill.getProductNum1()) {
        num1 = bill.getProductNum1();
    }
    if (null != bill.getProductNum2()) {
        num2 = bill.getProductNum2();
    }
    if (null != bill.getProductNum3()) {
        num3 = bill.getProductNum3();
    }
    Integer pSum = num1 + num2 + num3;
    // 新添:组合产品判断
    if ((usercertall.size() >= bill.getProductNum() && null == p.getIsCombined()) || (usercertall.size() >= bill.getProductNum() && null != p.getIsCombined() && p.getIsCombined() != 1) || (usercertall.size() >= pSum && null != p.getIsCombined() && p.getIsCombined() == 1)) {
        // 判断产品是否配置了签章服务
        if (null != product.getMakeSealServer() && product.getMakeSealServer() > 0) {
            // 查看证书是否都已经完成了签章,授权
            for (UserCert userCert : usercertall) {
                if (null == userCert.getMakeSealmstatus() || "0".equals(userCert.getMakeSealmstatus().toString()) || null == userCert.getMakeSealastatus() || "0".equals(userCert.getMakeSealastatus().toString())) {
                    // 未签章或者未授权,则直接返回,不修改订单状态
                    return;
                }
            }
        }
        if (bill.getIsenterprisecert() != null && bill.getIsenterprisecert()) {
            // 判断友互通是否自动制证
            if (bill.getIscertinfo() != null && bill.getIscertinfo() == 1) {
                // 判断友互通自动制证是否已制证
                bill.setBillStatus(ComNames.BILL_STATUS_6);
                if (null == bill.getDelivery()) {
                    bill.setBillStatus(ComNames.BILL_STATUS_8);
                } else if (null != bill.getIsInvoiced() && bill.getIsInvoiced().equals(1)) {
                    bill.setBillStatus(ComNames.BILL_STATUS_7);
                }
                // 当订单价格是0的时候,又不需要开票,设置为已开票代配送
                if (0 == bill.getBillSum() && null == bill.getInvoice() && null == bill.geteInvoice()) {
                    bill.setBillStatus(ComNames.BILL_STATUS_7);
                    if (null == bill.getDelivery()) {
                        bill.setBillStatus(ComNames.BILL_STATUS_8);
                    }
                }
            } else {
                // 友互通管理员制证已制证
                bill.setIscertinfo(3);
            }
        } else {
            bill.setIscertinfo(4);
            bill.setBillStatus(ComNames.BILL_STATUS_6);
            if (null == bill.getDelivery()) {
                bill.setBillStatus(ComNames.BILL_STATUS_8);
            } else if (null != bill.getIsInvoiced() && bill.getIsInvoiced().equals(1)) {
                bill.setBillStatus(ComNames.BILL_STATUS_7);
            }
            // 当订单价格是0的时候,又不需要开票,设置为已开票代配送
            if (0 == bill.getBillSum() && null == bill.getInvoice() && null == bill.geteInvoice()) {
                bill.setBillStatus(ComNames.BILL_STATUS_7);
                if (null == bill.getDelivery()) {
                    bill.setBillStatus(ComNames.BILL_STATUS_8);
                }
            }
        }
        sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKey", bill);
    }
}
Also used : BigInteger(java.math.BigInteger) UserCertExample(com.itrus.portal.db.UserCertExample) Product(com.itrus.portal.db.Product) UserCert(com.itrus.portal.db.UserCert)

Example 50 with UserCert

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

the class EvidenceSaveServiceApi method verifySign.

/**
 * 验签
 * @param result
 * @param evidenceSaveService
 * @param signedBase64
 * @param realNameAuthentication
 * @return
 * @throws Exception
 */
private List<String> verifySign(Map<String, Object> result, ApplicationInfo applicationInfo, EvidenceSaveService evidenceSaveService, String hashvalue, String signedBase64, RealNameAuthentication realNameAuthentication, int type) throws Exception {
    // 得到证据申请对象认证要素配置
    String factorCertSave = evidenceSaveService.getFactorCertSave();
    JSONObject jsonCs = JSONArray.parseArray(factorCertSave).getJSONObject(0);
    List<String> certs = null;
    // 判断是否需要验证委托人的P7签名
    if (jsonCs.getBooleanValue("c_isVerify")) {
        certs = new ArrayList<>();
        if (type == 1) {
            /**
             ***********************************************     《p7验签》   start   *******************************************
             */
            verifySign(result, applicationInfo, evidenceSaveService, hashvalue, signedBase64, realNameAuthentication);
        /**
         ***********************************************     《p7验签》   end   *******************************************
         */
        } else if (type == 2) {
            /**
             ***********************************************     《裸签名验签》   start   *******************************************
             */
            // 得到应用证书
            String certBase64 = CacheCustomer.getAPP_GET_CERT_MAP().get(applicationInfo.getId());
            if (StringUtils.isEmpty(certBase64)) {
                certBase64 = applicationInfoService.getCert(applicationInfo.getId());
            }
            UserCert userCert = CertUtil.getCertFromBase64(certBase64);
            if (userCert.getCertEndTime() != null && userCert.getCertEndTime().getTime() < System.currentTimeMillis()) {
                result.put("status", -8);
                result.put("message", "证书已过期");
                return null;
            }
            // 裸签名验签
            Map<String, Object> param = new HashMap<String, Object>();
            param.put("hashAlg", "SHA-1");
            param.put("contentType", "CT_HASH");
            param.put("signedData", signedBase64);
            param.put("content", hashvalue);
            // 验签公钥的Base64编码串
            param.put("publicKey", "");
            // 验签证书的Base64编码串
            param.put("cert", certBase64);
            // 整合url
            String url = realNameAuthentication.getRealNameddress() + SIGNATURE_VERIFY;
            String rep_verify = OkHttpClientManager.post(url, AuthService.getHeader().get("Authorization").toString(), param);
            JSONObject jsonVerify = JSONObject.parseObject(rep_verify);
            result.put("dateVc", new Date());
            result.put("dateVp", new Date());
            // 判断验签是否成功
            if (jsonVerify.getIntValue("code") != 0) {
                result.put("status", -8);
                result.put("message", "验证证书失败");
                LogUtil.evidencelog(sqlSession, null, "存证_裸签名验签接口", "裸签名验签失败,失败原因:" + jsonVerify.getString("message"));
                return null;
            }
            certs.add(certBase64);
        /**
         ***********************************************     《裸签名验签》   end   *******************************************
         */
        }
    }
    return certs;
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) JSONObject(com.alibaba.fastjson.JSONObject) Map(java.util.Map) HashMap(java.util.HashMap) Date(java.util.Date) UserCert(com.itrus.portal.db.UserCert)

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