Search in sources :

Example 11 with CertBuf

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

the class APIService method lookup.

/**
 * 证书查询接口
 * @param authHmac
 * @param appId
 * @param billId
 * @param request
 * @return
 */
@PostMapping(value = "/cert/search")
@ResponseBody
public Map<String, Object> lookup(@RequestHeader("Content-Signature") String authHmac, @RequestParam(value = "appId", required = true) String appId, @RequestParam(value = "billId", required = true) String billId, HttpServletRequest request) {
    Map<String, Object> result = new HashMap<String, Object>();
    result.put("status", 0);
    log.error("appId=" + appId + "billId=" + billId);
    // 验证参数是否完整
    if (StringUtils.isEmpty(authHmac) || StringUtils.isEmpty(appId) || StringUtils.isEmpty(billId)) {
        result.put("status", 0);
        result.put("message", "提交的参数信息不完整");
        return result;
    }
    // 得到应用信息 改成service
    Map<String, ApplicationInfo> appInfoMap = CacheCustomer.getAPP_INFO_MAP();
    ApplicationInfo applicationInfo = appInfoMap.get(appId);
    if (applicationInfo == null) {
        ApplicationInfoExample applicationInfoExample = new ApplicationInfoExample();
        ApplicationInfoExample.Criteria appInfoExampleCriteria = applicationInfoExample.createCriteria();
        appInfoExampleCriteria.andAppIdEqualTo(appId);
        applicationInfo = sqlSession.selectOne("com.itrus.portal.db.ApplicationInfoMapper.selectByExample", applicationInfoExample);
    }
    if (applicationInfo == null) {
        result.put("message", "应用标识不存在");
        return result;
    }
    if (!applicationInfo.getAccessIp().contains(request.getRemoteAddr()) && "1".equals(applicationInfo.getIsIpStatus())) {
        result.put("status", -1);
        result.put("message", "没有此服务权限");
        log.error("APIService_AccsessIp : " + request.getRemoteAddr());
        return result;
    }
    // 验证hmac有效性
    try {
        String macVal = CertService.hmacSha1(applicationInfo.getSecretKey().getBytes(), (appId + billId).getBytes("utf-8"));
        if (!authHmac.equals("HMAC-SHA1 " + macVal)) {
            result.put("status", -2);
            result.put("message", "服务密钥错误");
            return result;
        }
    } catch (Exception e) {
        result.put("status", -3);
        result.put("message", "Hmac验证错误");
        e.printStackTrace();
        return result;
    }
    BillExample billExample = new BillExample();
    BillExample.Criteria criteria = billExample.or();
    criteria.andBillIdEqualTo(billId);
    Bill bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByExample", billExample);
    if (bill == null) {
        result.put("message", "没有此订单");
        return result;
    }
    Product product = productService.getProduct(bill.getProduct());
    DigitalCert dcert = sqlSession.selectOne("com.itrus.portal.db.DigitalCertMapper.selectByPrimaryKey", product.getCert());
    List<String> listcert = new ArrayList<String>();
    if ("3".equals(dcert.getCertType())) {
        Integer uidIdx = 1;
        // 用户已经下载过了,再次下载
        boolean downLoadFlag = bill.getBillStatus().equals(ComNames.BILL_STATUS_6) || bill.getBillStatus().equals(ComNames.BILL_STATUS_7) || bill.getBillStatus().equals(ComNames.BILL_STATUS_8);
        if (downLoadFlag) {
            // 根据订单号,找到订单对应的证书信息
            CertBuf certBuf = sqlSession.selectOne("com.itrus.portal.db.CertBufMapper.selectPfxCertByBillId", bill.getId());
            listcert.add(certBuf.getPfxCert());
            result.put("status", 1);
            result.put("pfxData", listcert);
        } else {
            // 用户未下载过,第一次下载
            if (bill.getBillStatus().equals(ComNames.BILL_STATUS_13)) {
                // 查询项目产品
                // Product product = productService.getProduct(bill.getProduct());
                // 企业
                Enterprise enterprise = enterpriseService.getEnterpriseById(bill.getEnterprise());
                // 获取产品、RA配置
                RaAccount ra = raAccountService.getRaAccount(product.getRa());
                // 证书配置
                DigitalCert digitalcert = digitalCertService.getDigitalCert(product.getCert());
                // 下载证书
                String autoidType = "";
                Integer autoidValue = 0;
                String pfxCert = "";
                // 用户ID,用来最终匹配公钥证书和密钥对
                String userid = bill.getBillId() + (Math.random() * 1000 + 9000);
                // TODO 20170410pfx私钥证书保护密码:需要根据产品配置的密码或获取
                String certPass = product.getPassword();
                // 产生CSR证书请求
                String certReqBuf = "";
                // 算法
                String algorithm = digitalCertService.getAlgorithm(digitalcert);
                // 下载证书
                CertInfo racertinfo = null;
                try {
                    certReqBuf = GenUtil.GenP10(userid, "", algorithm);
                    racertinfo = downLoadCertService.downLoadCert(product, ra, bill, digitalcert, uidIdx, certReqBuf, autoidType, autoidValue);
                    // pfxCert = GenUtil.GenPFX(userid, certPass,
                    // racertinfo.getCertSignBuf(), false);
                    // pfxCert = GenUtil2.GenPFX(userid, certPass, racertinfo.getCertSignBuf(), pfxCert, false, enterprise.getEnterpriseName());
                    pfxCert = GenUtil.GenPFX(userid, certPass, racertinfo.getCertSignBuf(), false, enterprise.getEnterpriseName());
                    // 保存证书
                    downLoadCertService.savePfxCertInfo(racertinfo, bill, ra.getId(), uidIdx, "", autoidType, autoidValue, pfxCert);
                    listcert.add(pfxCert);
                    result.put("status", 1);
                    result.put("pfxData", listcert);
                } catch (Exception e) {
                    result.put("status", -1);
                    result.put("message", "pfx证书下载错误" + e.getMessage());
                }
            }
        }
    } else {
        List<UserCert> certlist = userCertService.getUserCertByBill(bill.getId(), null);
        for (UserCert uc : certlist) {
            CertBuf cb = sqlSession.selectOne("com.itrus.portal.db.CertBufMapper.selectByPrimaryKey", uc.getCertBuf());
            listcert.add(cb.getCertBuf());
        }
        if (listcert.size() > 0) {
            result.put("status", 1);
            result.put("cerData", listcert);
        } else {
            result.put("message", "没有查找到相应证书");
        }
    }
    return result;
}
Also used : CertInfo(cn.topca.tca.ra.service.CertInfo) ApplicationInfoExample(com.itrus.portal.db.ApplicationInfoExample) HashMap(java.util.HashMap) ApplicationInfo(com.itrus.portal.db.ApplicationInfo) ArrayList(java.util.ArrayList) Product(com.itrus.portal.db.Product) JSONException(org.json.JSONException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) DigitalCert(com.itrus.portal.db.DigitalCert) BillExample(com.itrus.portal.db.BillExample) RaAccount(com.itrus.portal.db.RaAccount) Bill(com.itrus.portal.db.Bill) CertBuf(com.itrus.portal.db.CertBuf) Enterprise(com.itrus.portal.db.Enterprise) UserinfoEnterprise(com.itrus.portal.db.UserinfoEnterprise) JSONObject(com.alibaba.fastjson.JSONObject) UserCert(com.itrus.portal.db.UserCert) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 12 with CertBuf

use of com.itrus.portal.db.CertBuf 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 13 with CertBuf

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

the class DownLoadCertServiceImpl method saveCertInfo.

/**
 * 保存证书信息并更新订单
 *
 * @param racertinfo
 * @param bill
 * @param raId
 * @param uidIdx
 * @param keySn
 * @param autoidType
 * @param autoidValue
 * @throws ParseException
 */
public void saveCertInfo(CertInfo racertinfo, Bill bill, Long raId, Integer uidIdx, String keySn, String autoidType, Integer autoidValue) throws ParseException {
    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(raId);
    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");
    if (StringUtils.isNotBlank(keySn))
        // 设置证书keySn
        usercert.setKeySn(keySn);
    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss");
    usercert.setCertStartTime(sdf.parse(racertinfo.getCertNotBefore()));
    usercert.setCertEndTime(sdf.parse(racertinfo.getCertNotAfter()));
    usercert.setSha1Fingerprint("setSha1Fingerprint");
    // autoid 数据
    if (!autoidType.equals("")) {
        usercert.setAutoidType(autoidType);
        usercert.setAutoidValue(autoidValue);
    }
    usercert.setEnterprise(bill.getEnterprise());
    sqlSession.insert("com.itrus.portal.db.UserCertMapper.insert", usercert);
    // 将设置订单状态
    bill.setBillStatus(ComNames.BILL_STATUS_8);
    if (null != bill.getInvoice() || null != bill.geteInvoice()) {
        bill.setBillStatus(ComNames.BILL_STATUS_6);
    }
    sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKey", bill);
}
Also used : CertBuf(com.itrus.portal.db.CertBuf) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) UserCert(com.itrus.portal.db.UserCert)

Example 14 with CertBuf

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

the class UserCertService method getCert.

public synchronized UserCert getCert(X509Certificate cert) throws CertificateException, SigningServerException {
    // trustService.verifyCertificate(cert); //检查证书状态
    // 检查证书信息是否在数据库中
    String certHexSN = CertUtilsOfUkey.getValidSerialNumber(cert.getHexSerialNumber());
    String issuerDN = cert.getIssuerDNString();
    UserCertExample ucExample = new UserCertExample();
    UserCertExample.Criteria ucCriteria = ucExample.or();
    // ucCriteria.andIssuerDnEqualTo(issuerDN);
    ucCriteria.andCertSnEqualTo(certHexSN);
    UserCert userCert = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByExample", ucExample);
    if (userCert == null) {
        // 若不存在证书则添加证书信息
        CertBuf certBuf = new CertBuf();
        certBuf.setCreateTime(new Date());
        certBuf.setCertBuf(Base64.encode(cert.getEncoded()).replaceAll("\n", ""));
        // 将公钥证书存入数据库
        sqlSession.insert("com.itrus.portal.db.CertBufMapper.insert", certBuf);
        userCert = new UserCert();
        userCert.setCertDn(cert.getSubjectDNString());
        userCert.setIssuerDn(issuerDN);
        userCert.setCertSn(certHexSN);
        userCert.setCertStartTime(cert.getNotBefore());
        userCert.setCertEndTime(cert.getNotAfter());
        userCert.setCertStatus(ComNames.CERT_STATUS_1);
        userCert.setSha1Fingerprint(CipherUtils.sha1(cert.getEncoded()));
        userCert.setCertBuf(certBuf.getId());
        // 0标识非门户申请的证书(因为非门户下载的证书才会不存在我们数据库中)
        userCert.setCertSource(ComNames.CERT_SOURCE_0);
        sqlSession.insert("com.itrus.portal.db.UserCertMapper.insertSelective", userCert);
    }
    return userCert;
}
Also used : UserCertExample(com.itrus.portal.db.UserCertExample) CertBuf(com.itrus.portal.db.CertBuf) Date(java.util.Date) UserCert(com.itrus.portal.db.UserCert)

Aggregations

CertBuf (com.itrus.portal.db.CertBuf)14 UserCert (com.itrus.portal.db.UserCert)9 Product (com.itrus.portal.db.Product)8 Date (java.util.Date)8 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8 DigitalCert (com.itrus.portal.db.DigitalCert)7 Bill (com.itrus.portal.db.Bill)6 Enterprise (com.itrus.portal.db.Enterprise)6 UserInfo (com.itrus.portal.db.UserInfo)6 IOException (java.io.IOException)6 HashMap (java.util.HashMap)6 EncDecException (com.itrus.portal.exception.EncDecException)5 CertInfo (cn.topca.tca.ra.service.CertInfo)4 RaAccount (com.itrus.portal.db.RaAccount)4 SimpleDateFormat (java.text.SimpleDateFormat)4 RaServiceUnavailable_Exception (cn.topca.tca.ra.service.RaServiceUnavailable_Exception)3 JSONObject (com.alibaba.fastjson.JSONObject)3 MakeSealConfig (com.itrus.portal.db.MakeSealConfig)3 ProductSpec (com.itrus.portal.db.ProductSpec)3 UserCertExample (com.itrus.portal.db.UserCertExample)3