Search in sources :

Example 16 with UserCert

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

the class ApplicationInfoController method create.

// 新建处理
@RequestMapping(method = RequestMethod.POST, produces = "text/html")
public String create(@Valid ApplicationInfo applicationinfo, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) throws Exception {
    if (bindingResult.hasErrors()) {
        return "applicationinfo/create";
    }
    applicationinfo.setCreateTime(new Date());
    applicationinfo.setCreator(getAdmin().getId());
    applicationinfo.setAppId(UniqueIDUtils.genUUID().substring(0, 16).replaceAll("-", ""));
    applicationinfo.setSecretKey(UniqueIDUtils.genUUID().replaceAll("-", ""));
    applicationinfo.setCallback(applicationinfo.getCallback());
    EvidenceCert cert = new EvidenceCert();
    if (applicationinfo != null && applicationinfo.getCertBase64() != null) {
        if (!"applicationinfo.certBase64".equals(applicationinfo.getCertBase64())) {
            // applicationinfo.setCertBase64(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);
                String certDn = userCert.getCertDn();
                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());
                cert.setCreateTime(new Date());
                /*if(userCert.getCertBuf()!=null){
						cert.setEvidenceBuf(userCert.getCertBuf().toString());
					}*/
                sqlSession.insert("com.itrus.portal.db.EvidenceCertMapper.insert", cert);
                // applicationinfo.setCertBase64(result);
                applicationinfo.setCertBase64(cert.getId().toString());
                applicationinfo.setCertDn(certDn);
                applicationinfo.setCertCn(EvidenceSaveServiceApi.getCertCn(certDn));
            /*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);
    }
    AppAuthConfig appAuthConfig = appAuthConfigService.getAppAuthConfig(new AppAuthConfigExample());
    if (appAuthConfig != null) {
        applicationinfo.setAppId2(AESencrp.encrypt(appAuthConfig.getAppId(), applicationinfo.getSecretKey()));
        applicationinfo.setSecretKey2(AESencrp.encrypt(appAuthConfig.getSecretKey(), applicationinfo.getSecretKey()));
    }
    applicationinfo = applicationInfoService.insertByApplicationInfo(applicationinfo);
    String oper = "应用添加";
    String info = "应用名称: " + applicationinfo.getName();
    LogUtil.adminlog(sqlSession, oper, info);
    /*EvidenceCertificationChargingHandler cch = new EvidenceCertificationChargingHandler();
        cch.setType(3);
		QueueThread.buildCertificationTask(cch);
		cacheCustomer.initEvidence(3);*/
    return "redirect:applicationinfo/" + applicationinfo.getId();
}
Also used : AppAuthConfig(com.itrus.portal.db.AppAuthConfig) UnsupportedEncodingException(java.io.UnsupportedEncodingException) CertificateException(java.security.cert.CertificateException) IOException(java.io.IOException) Date(java.util.Date) EvidenceCert(com.itrus.portal.db.EvidenceCert) AppAuthConfigExample(com.itrus.portal.db.AppAuthConfigExample) SigningServerException(com.itrus.cryptorole.SigningServerException) UserCert(com.itrus.portal.db.UserCert) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 17 with UserCert

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

the class MakeCertController method userCertMakeSealStatus.

/**
 * 证书签章授权成功
 *
 * @param type
 *            make表示证书签章,authori表示证书授权
 * @param sealImage
 *            签章时候需传图片base64
 * @param enterpriseId
 * @param userCertId
 * @return
 */
@RequestMapping("/userCertMakeSealStatus")
@ResponseBody
public Map<String, Object> userCertMakeSealStatus(@RequestParam(value = "type", required = true) String type, @RequestParam(value = "sealImage", required = false) String sealImage, @RequestParam(value = "billId", required = true) Long billId, @RequestParam(value = "enterpriseId", required = false) Long enterpriseId, @RequestParam(value = "userCertId", required = true) Long userCertId) {
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("retCode", 0);
    UserCert userCert = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByPrimaryKey", userCertId);
    if ("make".equals(type)) {
        // 制章
        // if (StringUtils.isBlank(sealImage)) {
        // map.put("retMsg", "获取签章图片失败,请重试");
        // return map;
        // }
        // 0未制章,1已制章
        userCert.setMakeSealmstatus(1);
    // Enterprise enterprise = sqlSession.selectOne(
    // "com.itrus.portal.db.EnterpriseMapper.selectByPrimaryKey",
    // enterpriseId);
    // 保存图片
    // try {
    // File imgDir = filePathUtils.getEnterpriseFile(enterprise
    // .getEnterpriseSn());
    // String filename = System.currentTimeMillis() + "seal"
    // + Math.round(Math.random() * 89 + 10) + ".gif";
    // // 创建磁盘文件
    // File imgFile = new File(imgDir, filename);
    // imageByBase64.saveImage(sealImage, imgFile);
    // if (null != imgFile && imgFile.isFile()) {
    // enterprise.setSealImage(imgFile.getName());
    // sqlSession
    // .update("com.itrus.portal.db.EnterpriseMapper.updateByPrimaryKey",
    // enterprise);
    // }
    // } catch (Exception e) {
    // map.put("retMsg", e.getMessage());
    // return map;
    // }
    } else if ("authori".equals(type)) {
        // 授权
        // 0未授权,1已授权
        userCert.setMakeSealastatus(1);
    } else if ("amake".equals(type)) {
        // 0未制章,1已制章
        userCert.setMakeSealmstatus(1);
        // 0未授权,1已授权
        userCert.setMakeSealastatus(1);
    }
    sqlSession.update("com.itrus.portal.db.UserCertMapper.updateByPrimaryKey", userCert);
    // 更新订单状态
    Bill bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", billId);
    // 查询项目产品
    Product product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct());
    updateBillStatus(bill, product);
    map.put("retCode", 1);
    return map;
}
Also used : HashMap(java.util.HashMap) Bill(com.itrus.portal.db.Bill) Product(com.itrus.portal.db.Product) 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 18 with UserCert

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

the class MakeCertController method makeSealBaiRun.

/**
 * 百润制章
 *
 * @param billId
 *            订单id
 * @param csr
 *            证书base64编码
 * @param request
 * @param response
 * @return
 * @throws EncDecException
 * @throws Exception
 */
@RequestMapping(value = "/makeSealBaiRun", method = RequestMethod.POST)
public void makeSealBaiRun(@RequestParam(value = "billId", required = true) Long billId, @RequestParam(value = "sealpic", required = true) String sealpic, @RequestParam(value = "csr", required = true) String csr, @RequestParam(value = "productId", required = false) Long productId, HttpServletRequest request, HttpServletResponse response) throws EncDecException, Exception {
    // Map<String, Object> map = new HashMap<String, Object>();
    // map.put("retCode", 0);
    // 获取签章模版
    Bill bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", billId);
    // 查询项目产品
    Product product = null;
    // 如为组合产品productId不为空
    if (null == productId) {
        product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct());
    } else {
        product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", productId);
    }
    /*
		 * if (null == product.getMakeSealServer() ||
		 * product.getMakeSealServer() <= 0) { map.put("retMsg", "该产品未配置签章服务");
		 * return map; }
		 */
    MakeSealServer makeSealServer = sqlSession.selectOne("com.itrus.portal.db.MakeSealServerMapper.selectByPrimaryKey", product.getMakeSealServer());
    // 签章服务配置
    List<MakeSealConfig> makeSealConfigs = sqlSession.selectList("com.itrus.portal.db.MakeSealConfigMapper.selectByExample");
    /*
		 * if (makeSealConfigs.isEmpty()) { map.put("retMsg", "没有找到签章服务配置");
		 * return map; }
		 */
    Map<String, Object> param = new HashMap<>();
    param.put("id", bill.getId());
    UserCertExample userc = new UserCertExample();
    UserCertExample.Criteria us = userc.createCriteria();
    us.andIdNotEqualTo(bill.getId());
    userc.setOrderByClause("cert_start_time desc");
    userc.setLimit(1);
    UserCert usercert = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByExample", userc);
    CertBufExample certbuf = new CertBufExample();
    CertBufExample.Criteria cert = certbuf.createCriteria();
    cert.andIdEqualTo(usercert.getCertBuf());
    CertBuf organ = sqlSession.selectOne("com.itrus.portal.db.CertBufMapper.selectByExample", certbuf);
    if (makeSealConfigs.get(1).getName().contains(makeSealServer.getFirm())) {
        MakeSealConfig makeSealConfig = makeSealConfigs.get(0);
        // 替换-印章名称
        if (StringUtils.isNotBlank(makeSealServer.getSealName())) {
            UIDInfoUtils uidutils = new UIDInfoUtils();
            uidutils.initService(businessService, orgCodeService, taxCertService, identityCardService, userInfoService, enterpriseService);
            makeSealServer.setSealName(uidutils.getUidInfo(billId, makeSealServer.getSealName()));
        }
        try {
            log.error("request.getLocalAddr : " + request.getLocalAddr() + ",CSR:" + organ.getCertBuf());
            boolean userbool = true;
            if (usercert.getIsRegister() == null || !usercert.getIsRegister().equals(1)) {
                usercert.setIsRegister(1);
                sqlSession.update("com.itrus.portal.db.UserCertMapper.updateByPrimaryKeySelective", usercert);
                // 注册用户
                userbool = UserSDK.addUser(null, makeSealConfig.getAddressKey(), organ.getCertBuf(), makeSealServer.getAccount(), Constant.APP, Constant.Token);
                log.error("makeCertController userbool : " + userbool);
            // log.info(makeSealConfig.getAddressKey());
            // log.info(String.valueOf(userbool));
            }
            // 制作印章
            Map<String, Object> result = SealSDK.makeSeal(makeSealServer.getSealName(), organ.getCertBuf(), sealpic, "公章", Constant.APP, Constant.Token);
            if (userbool && (Boolean) result.get("state")) {
                // 制章完成后的印章数据,返回到前台用作导章
                log.error("SealSDK : context");
            } else {
                log.error("SealSDK : ");
            // map.put("retMsg", "制章异常");
            }
            response.setCharacterEncoding("GBK");
            response.setContentType("text/html");
            OutputStream out = response.getOutputStream();
            out.write(result.get("data").toString().getBytes("GBK"));
            // map.put("bairun_ret",
            // result.get("data").toString().getBytes("GBK"));
            out.flush();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
        // map.put("retMsg", e.getMessage());
        }
    } else {
        MakeSealConfig makeSealConfig = makeSealConfigs.get(1);
        // 替换-印章名称
        if (StringUtils.isNotBlank(makeSealServer.getSealName())) {
            UIDInfoUtils uidutils = new UIDInfoUtils();
            uidutils.initService(businessService, orgCodeService, taxCertService, identityCardService, userInfoService, enterpriseService);
            makeSealServer.setSealName(uidutils.getUidInfo(billId, makeSealServer.getSealName()));
        }
        try {
            log.error("request.getLocalAddr : " + request.getLocalAddr() + ",CSR:" + organ.getCertBuf());
            boolean userbool = true;
            if (usercert.getIsRegister() != null && !usercert.getIsRegister().equals(1)) {
                usercert.setIsRegister(1);
                sqlSession.update("com.itrus.portal.db.UserCertMapper.updateByPrimaryKeySelective", usercert);
                // 注册用户
                userbool = UserSDK.addUser(null, makeSealConfig.getAddressKey(), organ.getCertBuf(), Constant.TianWeiChenXin, Constant.APP, Constant.Token);
            }
            // 制作印章
            Map<String, Object> result = SealSDK.makeSeal(makeSealServer.getSealName(), organ.getCertBuf(), sealpic, "公章", Constant.APP, Constant.Token);
            String s = Constant.IP;
            if (userbool && (Boolean) result.get("state")) {
                // 制章完成后的印章数据,返回到前台用作导章
                log.error("SealSDK : " + result.get("data").toString());
            } else {
                log.error("SealSDK : ");
            // map.put("retMsg", "制章异常");
            }
            response.setCharacterEncoding("GBK");
            response.setContentType("text/html");
            OutputStream out = response.getOutputStream();
            out.write(result.get("data").toString().getBytes("GBK"));
            // map.put("bairun_ret",
            // result.get("data").toString().getBytes("GBK"));
            out.flush();
            out.close();
            System.out.println(result.get("data").toString().getBytes("GBK").toString() + ":JS");
        } catch (Exception e) {
            e.printStackTrace();
        // map.put("retMsg", e.getMessage());
        }
    }
// map.put("retCode", 1);
// return map;
}
Also used : HashMap(java.util.HashMap) UserCertExample(com.itrus.portal.db.UserCertExample) OutputStream(java.io.OutputStream) Product(com.itrus.portal.db.Product) EncDecException(com.itrus.portal.exception.EncDecException) IOException(java.io.IOException) RaServiceUnavailable_Exception(cn.topca.tca.ra.service.RaServiceUnavailable_Exception) UIDInfoUtils(com.itrus.portal.utils.UIDInfoUtils) MakeSealServer(com.itrus.portal.db.MakeSealServer) MakeSealConfig(com.itrus.portal.db.MakeSealConfig) Bill(com.itrus.portal.db.Bill) CertBuf(com.itrus.portal.db.CertBuf) JSONObject(com.alibaba.fastjson.JSONObject) CertBufExample(com.itrus.portal.db.CertBufExample) UserCert(com.itrus.portal.db.UserCert) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 19 with UserCert

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

the class MakeCertController method reMakeCert.

/**
 * 已制证的订单修改状态为待制证
 *
 * @param certId
 *            证书id
 * @return
 */
@ResponseBody
@RequestMapping("/reMakeCert")
public Map<String, Object> reMakeCert(@RequestParam(value = "certId", required = true) Long certId) {
    Map<String, Object> retMap = new HashMap<String, Object>();
    retMap.put("retCode", 0);
    UserCert userCert = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByPrimaryKey", certId);
    if (null == userCert) {
        retMap.put("msg", "该证书不存在");
        return retMap;
    }
    // 设置证书id状态为0,标识制证异常
    userCert.setCertStatus("0");
    // 设置注册用户状态(百润)为 0 未注册
    userCert.setIsRegister(0);
    // 修改对应订单状态为待制证状态5
    Bill bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", userCert.getBill());
    if (null == bill) {
        retMap.put("msg", "对应的订单不存在");
        return retMap;
    }
    bill.setBillStatus(ComNames.BILL_STATUS_5);
    // 判断证书是否为用户下载方式
    Product product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct());
    // 判断是否为组合产品
    if (product.getIsCombined() != null && product.getIsCombined().equals(1)) {
        product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct1());
    }
    DigitalCert cert = sqlSession.selectOne("com.itrus.portal.db.DigitalCertMapper.selectByPrimaryKey", product.getCert());
    // 数字证书操作方式为用户下载(2)的,订单状态设置为待下载
    if (null != cert && null != cert.getInitBuy() && "2".equals(cert.getInitBuy())) {
        bill.setBillStatus(ComNames.BILL_STATUS_13);
    }
    // 待更新
    if (ComNames.TYPE_RENEW.equals(product.getType())) {
        bill.setBillStatus(ComNames.BILL_STATUS_12);
    }
    // 更新数据库
    sqlSession.update("com.itrus.portal.db.UserCertMapper.updateByPrimaryKey", userCert);
    sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKey", bill);
    retMap.put("retCode", 1);
    return retMap;
}
Also used : DigitalCert(com.itrus.portal.db.DigitalCert) HashMap(java.util.HashMap) Bill(com.itrus.portal.db.Bill) Product(com.itrus.portal.db.Product) JSONObject(com.alibaba.fastjson.JSONObject) UserCert(com.itrus.portal.db.UserCert) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 20 with UserCert

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

the class ConditionController method detail.

/**
 * 前往详情界面
 * @param
 * @return
 */
@RequestMapping(value = "/detail")
public String detail(@RequestParam(value = "enterpriseName", required = false) String enterpriseName, @RequestParam(value = "userId", required = false) Long userId, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, 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);
    // 当月第一天
    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.ConditionRecordMapper.selectOneMonth", param);
    Map<Object, Object> monthMap = conditionRecordService.dealMonthList(monthList);
    // 前六月统计数目
    List<Map<String, Object>> sixMonthList = sqlSession.selectList("com.itrus.portal.db.ConditionRecordMapper.selectSixMonth", param);
    Map<Object, Object> sixthMap = conditionRecordService.dealSixList(sixMonthList);
    // 展示详情页面最上端信息
    Map<String, Object> signatureRecord = conditionRecordService.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("sixthMap", sixthMap);
    return "condition/detail";
}
Also used : 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