Search in sources :

Example 1 with EvidenceCertificate

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

the class CertificateController method list.

/**
 * 证书列表
 *
 * @param queryDate1
 * @param queryDate2
 * @param queryDate3
 * @param queryDate4
 * @param queryDate5
 * @param queryDate6
 * @param alias
 * @param certificateName
 * @param subject
 * @param signaturetype
 * @param page
 * @param size
 * @param uiModel
 * @return
 * @throws Exception
 */
@RequestMapping(produces = "text/html")
public String list(@RequestParam(value = "queryDate1", required = false) Date queryDate1, @RequestParam(value = "queryDate2", required = false) Date queryDate2, @RequestParam(value = "queryDate3", required = false) Date queryDate3, @RequestParam(value = "queryDate4", required = false) Date queryDate4, @RequestParam(value = "queryDate5", required = false) Date queryDate5, @RequestParam(value = "queryDate6", required = false) Date queryDate6, @RequestParam(value = "alias", required = false) String alias, @RequestParam(value = "certificateName", required = false) String certificateName, @RequestParam(value = "subject", required = false) String subject, @RequestParam(value = "signaturetype", required = false) Integer signaturetype, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, Model uiModel) throws Exception {
    /*
		 * if (queryDate1 == null && queryDate2 == null) { Calendar calendar =
		 * Calendar.getInstance(); calendar.add(Calendar.DATE, 1);
		 * calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE,
		 * 0); calendar.set(Calendar.SECOND, 0);
		 * calendar.set(Calendar.MILLISECOND, 0);
		 * calendar.add(Calendar.MILLISECOND, -1); queryDate2 =
		 * calendar.getTime(); calendar.add(Calendar.MILLISECOND, 1);
		 * calendar.add(Calendar.MONTH, -1); queryDate1 = calendar.getTime(); }
		 * if (queryDate3 == null && queryDate4 == null) { Calendar calendar =
		 * Calendar.getInstance(); calendar.add(Calendar.DATE, 1);
		 * calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE,
		 * 0); calendar.set(Calendar.SECOND, 0);
		 * calendar.set(Calendar.MILLISECOND, 0);
		 * calendar.add(Calendar.MILLISECOND, -1); queryDate4 =
		 * calendar.getTime(); calendar.add(Calendar.MILLISECOND, 1);
		 * calendar.add(Calendar.MONTH, -1); queryDate3 = calendar.getTime(); }
		 * if (queryDate5 == null && queryDate6 == null) { Calendar calendar =
		 * Calendar.getInstance(); calendar.add(Calendar.DATE, 1);
		 * calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE,
		 * 0); calendar.set(Calendar.SECOND, 0);
		 * calendar.set(Calendar.MILLISECOND, 0);
		 * calendar.add(Calendar.MILLISECOND, -1); queryDate6 =
		 * calendar.getTime(); calendar.add(Calendar.MILLISECOND, 1);
		 * calendar.add(Calendar.MONTH, -1); queryDate5 = calendar.getTime(); }
		 */
    Map param = new HashMap();
    if (page == null || page < 1)
        page = 1;
    if (size == null || size < 1)
        size = 10;
    Integer offset = size * (page - 1);
    param.put("offset", offset);
    param.put("limit", size);
    param.put("queryDate1", queryDate1);
    param.put("queryDate2", queryDate2);
    param.put("queryDate3", queryDate3);
    param.put("queryDate4", queryDate4);
    param.put("queryDate5", queryDate5);
    param.put("queryDate6", queryDate6);
    /*
		 * EvidenceCertificateExample certificateexample = new
		 * EvidenceCertificateExample(); EvidenceCertificateExample.Criteria
		 * certificate = certificateexample.createCriteria();
		 */
    if (StringUtils.isNotEmpty(alias) && !"0".equals(alias)) {
        param.put("alias", "%" + alias + "%");
    }
    if (StringUtils.isNotEmpty(certificateName) && !"0".equals(certificateName)) {
        param.put("certificateName", "%" + certificateName + "%");
    }
    if (StringUtils.isNotEmpty(subject) && !"0".equals(subject)) {
        param.put("subject", "%" + subject + "%");
    }
    if (signaturetype != null && "0".equals(signaturetype)) {
        param.put("signaturetype", signaturetype);
    }
    /*
		 * certificate.andCreateTimeBetween(queryDate5, queryDate6);
		 * certificateexample.setLimit(size);
		 * certificateexample.setOffset(page);
		 */
    List configuration = certificateService.selectListByCertificateEnt(param);
    int count = certificateService.selectCountByCertificateEnt(param);
    uiModel.addAttribute("configuration", configuration);
    uiModel.addAttribute("count", count);
    uiModel.addAttribute("pages", (count + size - 1) / size);
    if (page > 1 && size * (page - 1) >= count) {
        page = (count + size - 1) / size;
    }
    uiModel.addAttribute("page", page);
    uiModel.addAttribute("size", size);
    List<EvidenceCertificate> econfiguration = sqlSession.selectList("com.itrus.portal.db.EvidenceCertificateMapper.selectByExample");
    List<EvidenceSecretKey> secretkey = sqlSession.selectList("com.itrus.portal.db.EvidenceSecretKeyMapper.selectByExample");
    uiModel.addAttribute("secretkey", secretkey);
    uiModel.addAttribute("econfiguration", econfiguration);
    uiModel.addAttribute("queryDate1", queryDate1);
    uiModel.addAttribute("queryDate2", queryDate2);
    uiModel.addAttribute("queryDate3", queryDate3);
    uiModel.addAttribute("queryDate4", queryDate4);
    uiModel.addAttribute("queryDate5", queryDate5);
    uiModel.addAttribute("queryDate6", queryDate6);
    uiModel.addAttribute("alias", alias);
    uiModel.addAttribute("certificateName", certificateName);
    uiModel.addAttribute("subject", subject);
    uiModel.addAttribute("signaturetype", signaturetype);
    return "certificate/list";
}
Also used : HashMap(java.util.HashMap) EvidenceCertificate(com.itrus.portal.db.EvidenceCertificate) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) EvidenceSecretKey(com.itrus.portal.db.EvidenceSecretKey) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with EvidenceCertificate

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

the class OutServiceConfigController method create.

// 新建处理
@RequestMapping(method = RequestMethod.POST, produces = "text/html")
public String create(@ModelAttribute("evidenceOutServiceConfig") EvidenceOutServiceConfig outServiceConfig, @ModelAttribute("appService") AppService appService, @RequestParam(required = false, value = "type1") Integer type1, @RequestParam(required = false, value = "keyword1") String keyword1, @RequestParam(required = false, value = "page1") String page1, @RequestParam(required = false, value = "distanceToLeft1") String distanceToLeft1, @RequestParam(required = false, value = "distanceToDown1") String distanceToDown1, @RequestParam(required = false, value = "heightOfImage1") String heightOfImage1, @RequestParam(required = false, value = "widthOfImage1") String widthOfImage1, @RequestParam(required = false, value = "type2") Integer type2, @RequestParam(required = false, value = "keyword2") String keyword2, @RequestParam(required = false, value = "page2") String page2, @RequestParam(required = false, value = "distanceToLeft2") String distanceToLeft2, @RequestParam(required = false, value = "distanceToDown2") String distanceToDown2, @RequestParam(required = false, value = "heightOfImage2") String heightOfImage2, @RequestParam(required = false, value = "widthOfImage2") String widthOfImage2, @RequestParam(required = false, value = "type3") Integer type3, @RequestParam(required = false, value = "keyword3") String keyword3, @RequestParam(required = false, value = "page3") String page3, @RequestParam(required = false, value = "distanceToLeft3") String distanceToLeft3, @RequestParam(required = false, value = "distanceToDown3") String distanceToDown3, @RequestParam(required = false, value = "heightOfImage3") String heightOfImage3, @RequestParam(required = false, value = "widthOfImage3") String widthOfImage3, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) {
    if (bindingResult.hasErrors()) {
        List<EvidenceOutTemplate> outTemplateList = outServiceConfigService.selectOutTemplateByList();
        uiModel.addAttribute("outTemplateList", outTemplateList);
        List<EvidenceCertificate> certificateList = certificateService.getSignatureList();
        uiModel.addAttribute("certificateList", certificateList);
        return "outserviceconfig/create";
    }
    if (outServiceConfig.getOutWay() == 0) {
        outServiceConfig.setOutWay(null);
    }
    if (outServiceConfig.getOutReportTemplate() == 0) {
        outServiceConfig.setOutReportTemplate(null);
    }
    if (outServiceConfig.getSaveRetTemplate() == 0) {
        outServiceConfig.setSaveRetTemplate(null);
    }
    if (outServiceConfig.getEvidenceCertificate() == 0) {
        outServiceConfig.setEvidenceCertificate(null);
    }
    EvidenceSignetPlaceConfig signetPlaceConfigOne = new EvidenceSignetPlaceConfig();
    EvidenceSignetPlaceConfig signetPlaceConfigTwo = new EvidenceSignetPlaceConfig();
    EvidenceSignetPlaceConfig signetPlaceConfigThree = new EvidenceSignetPlaceConfig();
    if (type1 != null && type1 != 0) {
        signetPlaceConfigOne.setType(type1);
        signetPlaceConfigOne.setKeyword(keyword1);
        signetPlaceConfigOne.setPage(page1);
        signetPlaceConfigOne.setDistanceToLeft(distanceToLeft1);
        signetPlaceConfigOne.setDistanceToDown(distanceToDown1);
        signetPlaceConfigOne.setHeightOfImage(heightOfImage1);
        signetPlaceConfigOne.setWidthOfImage(widthOfImage1);
    }
    if (type2 != null && type2 != 0) {
        signetPlaceConfigTwo.setType(type2);
        signetPlaceConfigTwo.setKeyword(keyword2);
        signetPlaceConfigTwo.setPage(page2);
        signetPlaceConfigTwo.setDistanceToLeft(distanceToLeft2);
        signetPlaceConfigTwo.setDistanceToDown(distanceToDown2);
        signetPlaceConfigTwo.setHeightOfImage(heightOfImage2);
        signetPlaceConfigTwo.setWidthOfImage(widthOfImage2);
    }
    if (type3 != null && type3 != 0) {
        signetPlaceConfigThree.setType(type3);
        signetPlaceConfigThree.setKeyword(keyword3);
        signetPlaceConfigThree.setPage(page3);
        signetPlaceConfigThree.setDistanceToLeft(distanceToLeft3);
        signetPlaceConfigThree.setDistanceToDown(distanceToDown3);
        signetPlaceConfigThree.setHeightOfImage(heightOfImage3);
        signetPlaceConfigThree.setWidthOfImage(widthOfImage3);
    }
    outServiceConfigService.saveEvidenceOutServiceConfig(outServiceConfig, appService, signetPlaceConfigOne, signetPlaceConfigTwo, signetPlaceConfigThree, getAdmin().getId());
    String oper = "添加出证服务配置";
    String info = "出证服务配置名称: " + appService.getAppServiceName();
    LogUtil.evidencelog(sqlSession, null, oper, info);
    return "redirect:outserviceconfig/" + outServiceConfig.getId();
}
Also used : EvidenceSignetPlaceConfig(com.itrus.portal.db.EvidenceSignetPlaceConfig) EvidenceCertificate(com.itrus.portal.db.EvidenceCertificate) EvidenceOutTemplate(com.itrus.portal.db.EvidenceOutTemplate) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with EvidenceCertificate

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

the class ServiceConfigurationController method show.

// 显示详情
@RequestMapping(produces = "text/html")
public String show(Model uiModel) {
    List<EvidenceServiceConfiguration> serviceconfig = sqlSession.selectList("com.itrus.portal.db.EvidenceServiceConfigurationMapper.selectByExample");
    if (null != serviceconfig && !serviceconfig.isEmpty()) {
        EvidenceCertificate sconfiguration = sqlSession.selectOne("com.itrus.portal.db.EvidenceCertificateMapper.selectByPrimaryKey", serviceconfig.get(0).getSignatureCertificate());
        EvidenceCertificate econfiguration = sqlSession.selectOne("com.itrus.portal.db.EvidenceCertificateMapper.selectByPrimaryKey", serviceconfig.get(0).getEncryptionCertificate());
        uiModel.addAttribute("serviceconfig", serviceconfig.get(0));
        uiModel.addAttribute("sconfiguration", sconfiguration);
        uiModel.addAttribute("econfiguration", econfiguration);
    }
    return "serviceconfiguration/show";
}
Also used : EvidenceServiceConfiguration(com.itrus.portal.db.EvidenceServiceConfiguration) EvidenceCertificate(com.itrus.portal.db.EvidenceCertificate) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with EvidenceCertificate

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

the class ServiceConfigurationController method save.

// 添加/修改处理
@RequestMapping(method = RequestMethod.POST, produces = "text/html")
public String save(EvidenceServiceConfiguration serviceconfig, Model uiModel) throws Exception {
    // uiModel.addAttribute("projects", getProjectMapOfAdmin().values());
    if (null == serviceconfig.getId()) {
        // 添加
        sqlSession.insert("com.itrus.portal.db.EvidenceServiceConfigurationMapper.insert", serviceconfig);
        Long sid = Long.valueOf(serviceconfig.getSignatureCertificate().toString());
        Long eid = Long.valueOf(serviceconfig.getEncryptionCertificate().toString());
        EvidenceCertificate scertif = certificateService.selectById(sid);
        scertif.setIsCertificate(1);
        certificateService.update(scertif);
        EvidenceCertificate ecertif = certificateService.selectById(eid);
        ecertif.setIsCertificate(1);
        certificateService.update(ecertif);
    } else {
        // 修改
        sqlSession.update("com.itrus.portal.db.EvidenceServiceConfigurationMapper.updateByPrimaryKeySelective", serviceconfig);
        Long sid = Long.valueOf(serviceconfig.getSignatureCertificate().toString());
        Long eid = Long.valueOf(serviceconfig.getEncryptionCertificate().toString());
        EvidenceCertificate scertif = certificateService.selectById(sid);
        scertif.setIsCertificate(1);
        certificateService.update(scertif);
        EvidenceCertificate ecertif = certificateService.selectById(eid);
        ecertif.setIsCertificate(1);
        certificateService.update(ecertif);
    }
    // 通知其他机器,加载缓存
    EvidenceCertificationChargingHandler cch = new EvidenceCertificationChargingHandler();
    cch.setType(1);
    QueueThread.buildCertificationTask(cch);
    cacheCustomer.initEvidence(1);
    return "redirect:/serviceconfiguration";
}
Also used : EvidenceCertificate(com.itrus.portal.db.EvidenceCertificate) EvidenceCertificationChargingHandler(com.itrus.portal.evidence.service.EvidenceCertificationChargingHandler) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with EvidenceCertificate

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

the class EvidenceSaveContractService method saveBody.

// 存证核验处理方法(pdf电子合同)
public Map<String, Object> saveBody(Map<String, Object> result1, ApplicationInfo applicationInfo1, AppService appService1, EvidenceSaveService evidenceSaveService, Date applyDate, String evidenceSn, String genSn, String signedBase64, String evidencePackage, String hashAlg, String hashvalue, Date dateVp, Date dateVc, List<String> certs, RealNameAuthentication realNameAuthentication, RealNameAuthentication realNameAuthenticationTime, RealNameAuthentication realNameAuthenticationOss, Map<String, Object> mapCharging) {
    Map<String, Object> result = result1;
    ApplicationInfo applicationInfo = applicationInfo1;
    AppService appService = appService1;
    List<Object> objs = new ArrayList<Object>();
    String info = null;
    // 证据服务记录
    EvidenceBasicInformation basicInformation = null;
    // 本次证据包大小
    int fileSize = evidencePackage.getBytes().length;
    // 定义一个证据的提交次数
    int count = 0;
    String failureReason = null;
    String sn = genSn;
    if (StringUtils.isNotBlank(evidenceSn)) {
        sn = evidenceSn;
    }
    try {
        // 得到证据包json
        JSONObject jsonEvidenceContent = JSONObject.parseObject(evidencePackage);
        // 获取证书固定服务配置
        EvidenceServiceConfiguration serviceConfiguration = null;
        serviceConfiguration = CacheCustomer.getEVIDENCE_SERVICE_CONFIG();
        if (serviceConfiguration == null) {
            List<EvidenceServiceConfiguration> serviceconfig = sqlSession.selectList("com.itrus.portal.db.EvidenceServiceConfigurationMapper.selectByExample");
            if (!serviceconfig.isEmpty()) {
                serviceConfiguration = serviceconfig.get(0);
                CacheCustomer.setEVIDENCE_SERVICE_CONFIG(serviceConfiguration);
            } else {
                result.put("status", -22);
                result.put("message", "缺少服务配置");
                return result;
            }
        }
        // 验签信息入库
        EvidenceClientSignature clientSignature = new EvidenceClientSignature();
        clientSignature.setHashAlgorithm(hashAlg);
        clientSignature.setHashvalue(hashvalue);
        clientSignature.setName("0");
        // ---- 关联证书
        clientSignature.setCertId(Long.parseLong(applicationInfo.getCertBase64()));
        clientSignature.setSignatureType("2");
        clientSignature.setIdentiType("1");
        clientSignature.setSignaturevalue(signedBase64);
        clientSignature.setCreateTime(dateVp);
        clientSignature.setEvidenceSn(sn);
        objs.add(clientSignature);
        clientSignature = null;
        // 密钥别名定义
        String alias = null;
        // 判断是否需要签名或时间戳
        if (evidenceSaveService.getFixationWay() != null && evidenceSaveService.getFixationWay() != 1) {
            // 判断是否需要签名
            if (evidenceSaveService.getFixationWay() == 2 || evidenceSaveService.getFixationWay() == 4) {
                // 定义签名参数
                Map<String, Object> param = new HashMap<String, Object>();
                String url = null;
                // 判断签名类型配置是否为空
                if (StringUtils.isNotBlank(serviceConfiguration.getSignatureType())) {
                    // 得到配置证书
                    EvidenceCertificate evidenceCertificate = null;
                    evidenceCertificate = CacheCustomer.getEVIDENCE_CERTIFICATE_MAP().get((long) serviceConfiguration.getSignatureCertificate());
                    if (evidenceCertificate == null) {
                        evidenceCertificate = certificateService.selectById((long) serviceConfiguration.getSignatureCertificate());
                    }
                    // 得到服务配置的签名证书的密钥别名
                    alias = CacheCustomer.getMAP_COMFIG().get((long) serviceConfiguration.getSignatureCertificate());
                    if (StringUtils.isEmpty(alias)) {
                        alias = secretKeyService.getAliasByCertId((long) serviceConfiguration.getSignatureCertificate());
                    }
                    // 配置签名url 和 参数   1.裸签名  2.p7分离式签名  3.p7非分离式签名  (本期只做2)
                    switch(Integer.parseInt(serviceConfiguration.getSignatureType())) {
                        case 1:
                            param.put("alias", alias);
                            param.put("hashAlg", serviceConfiguration.getArithmetic());
                            param.put("contentType", "CT_HASH");
                            param.put("content", HMACSHA1.getDigest(serviceConfiguration.getArithmetic(), evidencePackage));
                            url = realNameAuthentication.getRealNameddress() + SIGNATURE_SIGN;
                            break;
                        case 2:
                            param.put("alias", alias);
                            param.put("hashAlg", serviceConfiguration.getArithmetic());
                            param.put("detached", true);
                            param.put("contentType", "CT_HASH");
                            param.put("content", HMACSHA1.getDigest(serviceConfiguration.getArithmetic(), evidencePackage));
                            url = realNameAuthentication.getRealNameddress() + P7_SIGN;
                            break;
                        case 3:
                            param.put("alias", alias);
                            param.put("hashAlg", serviceConfiguration.getArithmetic());
                            param.put("detached", false);
                            param.put("contentType", "CT_HASH");
                            param.put("content", HMACSHA1.getDigest(serviceConfiguration.getArithmetic(), evidencePackage));
                            url = realNameAuthentication.getRealNameddress() + P7_SIGN;
                            break;
                    }
                    // 异步处理p7签名
                    // HttpAsyncClientUtil.getInstance().execute(
                    // url,
                    // AuthService.getHeader(),
                    // param,
                    // new EvidenceSignTask(
                    // url,
                    // param,
                    // sn,
                    // Long.parseLong(evidenceCertificate.getCert())));
                    // 异步处理p7签名
                    // OkHttpClientManagerSign.postAsyn(
                    // url,
                    // AuthService.getHeader().get("Authorization").toString(),
                    // param,
                    // new EvidenceSignTask(
                    // url,
                    // param,
                    // sn,
                    // Long.parseLong(evidenceCertificate.getCert())));
                    String strP7 = null;
                    try {
                        long p7Sign = System.currentTimeMillis();
                        strP7 = OkHttpClientManagerSign.post(url, AuthService.getHeader().get("Authorization").toString(), param);
                        log.error("p7Sign time is [" + (System.currentTimeMillis() - p7Sign) + "]");
                    } catch (Exception e) {
                        e.printStackTrace();
                        LogUtil.evidencelog(sqlSession, sn, "存证接口_天威签名", "天威签名失败,证据编号:" + sn + ", 请求参数:" + param.toString() + ", 请求地址:" + url + ", 返回结果:" + strP7 + ", 失败原因:" + e.toString());
                        result.put("status", 0);
                        result.put("message", "天威签名失败");
                        return result;
                    }
                    JSONObject jsonRepP7Sign = JSONObject.parseObject(strP7);
                    if (jsonRepP7Sign.getIntValue("code") != 0) {
                        // 天威签名失败
                        LogUtil.evidencelog(sqlSession, sn, "存证接口_天威签名", "天威签名失败,证据编号:" + sn + ", 请求参数:" + param.toString() + ", 请求地址:" + url + ", 返回结果:" + strP7 + ", 失败原因:" + jsonRepP7Sign);
                        result.put("status", 0);
                        result.put("message", "天威签名失败");
                        return result;
                    } else {
                        // 天威签名服务记录入库
                        EvidenceClientSignature signature = new EvidenceClientSignature();
                        signature.setHashAlgorithm(param.get("hashAlg").toString());
                        signature.setName("1");
                        signature.setEvidenceSn(sn);
                        signature.setSignatureType("2");
                        signature.setCertId(Long.parseLong(evidenceCertificate.getCert()));
                        signature.setHashvalue(param.get("content").toString());
                        signature.setSignaturevalue(jsonRepP7Sign.getString("signedData"));
                        signature.setCreateTime(new Date());
                        objs.add(signature);
                    }
                    evidenceCertificate = null;
                }
            }
            // 判断是否需要签名时间戳
            if (evidenceSaveService.getFixationWay() == 3 || evidenceSaveService.getFixationWay() == 4) {
                // 对证据包HASH
                String plainHash = HMACSHA1.getDigest(serviceConfiguration.getArithmetic(), evidencePackage);
                // 异步处理时间戳   ---  本期是实现新版本接口
                long timeSign = System.currentTimeMillis();
                Map<String, Object> retTime = EvidenceSaveServiceApi.genTimeStamp(realNameAuthenticationTime, plainHash, serviceConfiguration.getArithmetic(), sn, null);
                log.error("timeSign time is [" + (System.currentTimeMillis() - timeSign) + "]");
                if (!(boolean) retTime.get("retStatus") || retTime.get("obj") == null) {
                    result.put("status", 0);
                    result.put("message", "天威时间戳签名失败");
                    return result;
                }
                objs.add(retTime.get("obj"));
            }
        }
        alias = null;
        Map<String, Object> retSaveMap = new HashMap<String, Object>();
        // 判断证据编号是否为空   true -> 证据编码为空 代表第一次存证   ,false ->证据编码不为空 代表不是第一次存证
        if (StringUtils.isEmpty(evidenceSn)) {
            basicInformation = new EvidenceBasicInformation();
            basicInformation.setReceiptStatus(0);
            basicInformation.setStatus(0);
            basicInformation.setIsCallback(0);
            basicInformation.setCreateTime(new Date());
            basicInformation.setEndTime(EvidenceSaveServiceApi.convertDate(evidenceSaveService.getSaveTime()));
            basicInformation.setEvidenceSize(fileSize);
            basicInformation.setEvidenceSn(genSn);
            basicInformation.setAppService(appService.getId());
            basicInformation.setEvidenceStatus(1);
            basicInformation.setApplicationInfo(applicationInfo.getId());
            basicInformation.setOutAppService(evidenceSaveService.getAppServiceName());
            basicInformation.setSaveServiceNmae(appService.getAppServiceName());
            basicInformation.setServicePlatformName(applicationInfo.getName());
            basicInformation.setServiceClientName(applicationInfo.getServiceClientName());
            basicInformation.setServiceClientId(applicationInfo.getServiceClientId());
            if (StringUtils.isNotEmpty(failureReason)) {
                basicInformation.setFailureReason(failureReason);
                basicInformation.setEvidenceStatus(0);
                result.put("status", 0);
            }
            // 对要素 (接收 核验 必填) 操作进行处理
            long saveFactorTime = System.currentTimeMillis();
            retSaveMap = saveFactor(retSaveMap, evidenceSaveService, genSn, jsonEvidenceContent, basicInformation, realNameAuthentication, realNameAuthenticationOss, serviceConfiguration, true, applyDate.getTime());
            log.error("saveFactorTime time is [" + (System.currentTimeMillis() - saveFactorTime) + "]");
        } else {
            result.put("status", 0);
            result.put("message", "提交证据失败,系统暂不支持补交功能。");
            return result;
        }
        if (retSaveMap.get("status") != null) {
            result.put("status", retSaveMap.get("status"));
            result.put("message", retSaveMap.get("message"));
            return result;
        } else {
            List<Object> lists = (List<Object>) retSaveMap.get("objs");
            for (Object obj : lists) {
                objs.add(obj);
            }
        }
        basicInformation = (EvidenceBasicInformation) retSaveMap.get("basicInformation");
        if (basicInformation.getEvidenceStatus() != null && basicInformation.getEvidenceStatus() == 0) {
            result.put("status", 0);
            result.put("message", basicInformation.getEvidenceStatus());
            return result;
        }
        // 得到加密证书别名
        alias = CacheCustomer.getMAP_COMFIG().get((long) serviceConfiguration.getEncryptionCertificate());
        if (StringUtils.isEmpty(alias)) {
            alias = secretKeyService.getAliasByCertId((long) serviceConfiguration.getEncryptionCertificate());
        }
        // 内部加密存储证据包
        String urlSave = realNameAuthentication.getRealNameddress() + "/storage/save";
        Map<String, Object> mapSave = new HashMap<String, Object>();
        mapSave.put("type", "ST_E");
        mapSave.put("bucketName", realNameAuthenticationOss.getKeyCode());
        mapSave.put("objectName", applicationInfo.getServiceClientId() + "/" + sn + (count + 1));
        mapSave.put("contentType", "CT_BASE64_DATA");
        mapSave.put("content", Base64.encode(evidencePackage.getBytes("utf-8")));
        mapSave.put("alias", alias);
        mapSave.put("digestZValue", false);
        mapSave.put("encAlg", serviceConfiguration.getEncryptionAlgorithm());
        String saveFactor = null;
        if (retSaveMap.get("saveFactor") != null) {
            saveFactor = retSaveMap.get("saveFactor").toString();
        }
        // 异步处理存储
        // long saveTime = System.currentTimeMillis();
        // HttpAsyncClientUtil.getInstance().execute(
        // urlSave,
        // AuthService.getHeader(),
        // mapSave,
        // new EvidenceSavePackageTask(
        // urlSave,
        // mapSave,
        // null,
        // (StringUtils.isEmpty(evidenceSn) ? genSn : evidenceSn),
        // fileSize,
        // null,
        // applyDate,
        // Integer.toString(evidenceSaveService.getSaveTime()),
        // saveFactor));
        // log.error("saveTime time is [" + (System.currentTimeMillis() - saveTime) + "]");
        log.error("save is " + (!(evidenceSaveService.getEncryptionWay() == null || evidenceSaveService.getEncryptionWay() == 0)));
        if (!(evidenceSaveService.getEncryptionWay() == null || evidenceSaveService.getEncryptionWay() == 0)) {
            // String retSave = null;
            // try {
            // long saveTime = System.currentTimeMillis();
            // retSave = OkHttpClientManagerSave.post(urlSave, AuthService.getHeader().get("Authorization").toString(), mapSave);
            // log.error("saveTime time is [" + (System.currentTimeMillis() - saveTime) + "]");
            // } catch (Exception e) {
            // e.printStackTrace();
            // LogUtil.evidencelog(sqlSession, sn, "存证接口_存储数据包", "存储数据包失败,证据编号:"
            // + sn +  ", 请求地址:"
            // + urlSave + ",返回结果" + retSave + ", 失败原因:" +e.toString());
            // 
            // result.put("status", 0);
            // result.put("message", "证据存储失败");
            // return result;
            // }
            // JSONObject jsonSave = JSONObject.parseObject(retSave);
            // if(jsonSave.getIntValue("code") != 0) {//天威签名失败
            // LogUtil.evidencelog(sqlSession, sn, "存证接口_存储数据包", "存储数据包失败,证据编号:"
            // + sn + ", 请求地址:" + urlSave
            // + ",返回结果" + retSave + ", 失败原因:" + jsonSave.getString("message"));
            // 
            // result.put("status", 0);
            // result.put("message", "证据存储失败");
            // return result;
            // 
            // } else {
            // EvidenceEnclosure enclosure = new EvidenceEnclosure();
            // enclosure.setBuid(jsonSave.getString("buid"));
            // enclosure.setEvidenceSn(sn);
            // enclosure.setFilesize(Integer.toString(fileSize));
            // enclosure.setPdfType("1");
            // enclosure.setApplicationTime(applyDate);
            // enclosure.setCreateTime(new Date());
            // enclosure.setSaveTime(Integer.toString(evidenceSaveService.getSaveTime()));
            // if(mapSave.get("type") != null)
            // enclosure.setType(mapSave.get("type").toString());
            // if(mapSave.get("contentType") != null)
            // enclosure.setContentType(mapSave.get("contentType").toString());
            // if(mapSave.get("bucketName") != null)
            // enclosure.setBucketName(mapSave.get("bucketName").toString());
            // if(mapSave.get("objectName") != null)
            // enclosure.setObjectName(mapSave.get("objectName").toString());
            // if(mapSave.get("alias") != null)
            // enclosure.setAlias(mapSave.get("alias").toString());
            // enclosure.setFixationTime(new Date());
            // if(saveFactor != null){
            // enclosure.setSaveFactor(saveFactor);
            // }
            // objs.add(enclosure);
            // }
            long saveTime = System.currentTimeMillis();
            OkHttpClientManagerSave.postAsyn(urlSave, AuthService.getHeader().get("Authorization").toString(), mapSave, new EvidenceSavePackageTask(urlSave, mapSave, null, sn, fileSize, null, applyDate, Integer.toString(evidenceSaveService.getSaveTime()), saveFactor));
            log.error("saveTime time is [" + (System.currentTimeMillis() - saveTime) + "]");
        }
        if ((int) result.get("status") == 1) {
        } else {
            basicInformation.setEvidenceStatus(0);
            if (StringUtils.isEmpty(basicInformation.getFailureReason())) {
                if (result.get("message") != null) {
                    basicInformation.setFailureReason(result.get("message").toString());
                }
            } else {
                if (result.get("message") != null) {
                    basicInformation.setFailureReason(basicInformation.getFailureReason() + "," + result.get("message").toString());
                }
            }
        }
        objs.add(basicInformation);
        // 记录计费流水
        if ((int) mapCharging.get("retCode") == 1) {
            Map<String, Object> mapStoreCg = storeChargingService.storeCharging(appService.getServiceConfigName(), appService.getServiceConfigId(), applicationInfo, appService, null, "EvidenceBasicInformation", evidenceSaveService.getBaseSpace(), EvidenceSaveServiceApi.getSize(fileSize), StringUtils.isBlank(evidenceSn), sn);
            // + ",totalSize__ : " + EvidenceSaveServiceApi.getSize(fileSize));
            if ((int) mapStoreCg.get("retCode") != 1) {
                result.put("status", -4);
                result.put("message", "服务计费失败");
                return result;
            }
        }
        boolean l = false;
        for (Object o : objs) {
            if (o == null)
                l = true;
        }
        log.error("objs count is [" + objs.size() + "]" + ", objsIncNull is" + l);
        queueThread.putListQueue(objs);
    } catch (Exception e) {
        e.printStackTrace();
        if (null == info) {
            info = "系统处理异常!";
        }
        LogUtil.evidencelog(sqlSession, sn, "存证接口", "存证失败,证据编号:" + sn + ", 失败原因:" + e.toString());
        result.put("status", -5);
        result.put("message", "系统服务错误,请联系管理员");
        return result;
    } finally {
        result.remove("saveFactor");
        result.remove("basicInformation");
    }
    return result;
}
Also used : AppService(com.itrus.portal.db.AppService) EvidenceBasicInformation(com.itrus.portal.db.EvidenceBasicInformation) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) ApplicationInfo(com.itrus.portal.db.ApplicationInfo) ArrayList(java.util.ArrayList) EvidenceSavePackageTask(com.itrus.portal.evidence.controller.threeAppAPIService.EvidenceSavePackageTask) Date(java.util.Date) EvidenceServiceConfiguration(com.itrus.portal.db.EvidenceServiceConfiguration) JSONObject(com.alibaba.fastjson.JSONObject) EvidenceCertificate(com.itrus.portal.db.EvidenceCertificate) JSONObject(com.alibaba.fastjson.JSONObject) List(java.util.List) ArrayList(java.util.ArrayList) EvidenceClientSignature(com.itrus.portal.db.EvidenceClientSignature)

Aggregations

EvidenceCertificate (com.itrus.portal.db.EvidenceCertificate)13 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)10 HashMap (java.util.HashMap)6 EvidenceSecretKey (com.itrus.portal.db.EvidenceSecretKey)5 JSONObject (com.alibaba.fastjson.JSONObject)4 EvidenceServiceConfiguration (com.itrus.portal.db.EvidenceServiceConfiguration)4 Date (java.util.Date)4 EvidenceBasicInformation (com.itrus.portal.db.EvidenceBasicInformation)3 EvidenceSignetPlaceConfig (com.itrus.portal.db.EvidenceSignetPlaceConfig)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 AppService (com.itrus.portal.db.AppService)2 EvidenceCertificateExample (com.itrus.portal.db.EvidenceCertificateExample)2 EvidenceClientSignature (com.itrus.portal.db.EvidenceClientSignature)2 EvidenceEnclosure (com.itrus.portal.db.EvidenceEnclosure)2 EvidenceEnclosureExample (com.itrus.portal.db.EvidenceEnclosureExample)2 EvidenceOutTemplate (com.itrus.portal.db.EvidenceOutTemplate)2 RaAccount (com.itrus.portal.db.RaAccount)2 EvidenceCertificationChargingHandler (com.itrus.portal.evidence.service.EvidenceCertificationChargingHandler)2