Search in sources :

Example 1 with EvidenceCertificationChargingHandler

use of com.itrus.portal.evidence.service.EvidenceCertificationChargingHandler 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 2 with EvidenceCertificationChargingHandler

use of com.itrus.portal.evidence.service.EvidenceCertificationChargingHandler in project portal by ixinportal.

the class RealNameAuthenticationController method update.

// 修改处理
@RequestMapping(method = RequestMethod.POST, produces = "text/html")
public String update(RealNameAuthentication realName, @RequestParam(value = "status", required = false) Integer status, Model uiModel) {
    if (realName.getId() == null) {
        realName.setType(status);
        try {
            realnameauthent.addRealName(realName);
        } catch (ServiceNullException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    } else {
        if (realName != null && realName.getCertificate() != null) {
            if (!"realName.certificate".equals(realName.getCertificate())) {
                String result = null;
                try {
                    sun.misc.BASE64Decoder decoder = new sun.misc.BASE64Decoder();
                    byte[] bt = decoder.decodeBuffer(realName.getCertificate());
                    result = new String(bt, "utf-8");
                    result = result.replaceAll("-----BEGIN CERTIFICATE-----", "").replaceAll("-----END CERTIFICATE-----", "").replaceAll("\r", "").replaceAll("\n", "");
                    // System.out.println(result);
                    realName.setCertificate(result);
                    UserCert usercert = CertUtil.getCertFromBase64(result);
                    ;
                    String certDn = usercert.getCertDn();
                    EvidenceCert evidenceCert = new EvidenceCert();
                    evidenceCert.setCertBase64(result);
                    evidenceCert.setCertSerialnumber(usercert.getCertSn());
                    evidenceCert.setCreateTime(new Date());
                    evidenceCert.setEndTime(usercert.getCertEndTime());
                    if (usercert.getCertBuf() != null) {
                        evidenceCert.setEvidenceBuf(usercert.getCertBuf().toString());
                    }
                    evidenceCert.setIssuerdn(usercert.getIssuerDn());
                    evidenceCert.setStartTime(usercert.getCertStartTime());
                    evidenceCert.setSubjectdn(usercert.getCertDn());
                    sqlSession.insert("com.itrus.portal.db.EvidenceCertMapper.insertSelective", evidenceCert);
                    if (evidenceCert.getId() != null) {
                        realName.setCertificateCn(evidenceCert.getId().toString());
                    }
                } 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 {
                realName.setCertificate(null);
            }
        }
        try {
            realnameauthent.updateRealName(realName);
        } catch (ServiceNullException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    // 通知其他机器,加载缓存
    EvidenceCertificationChargingHandler cch = new EvidenceCertificationChargingHandler();
    cch.setType(2);
    QueueThread.buildCertificationTask(cch);
    cacheCustomer.initEvidence(2);
    return "redirect:/realname";
}
Also used : UnsupportedEncodingException(java.io.UnsupportedEncodingException) CertificateException(java.security.cert.CertificateException) EvidenceCertificationChargingHandler(com.itrus.portal.evidence.service.EvidenceCertificationChargingHandler) ServiceNullException(com.itrus.portal.exception.ServiceNullException) IOException(java.io.IOException) ServiceNullException(com.itrus.portal.exception.ServiceNullException) IOException(java.io.IOException) CertificateException(java.security.cert.CertificateException) SigningServerException(com.itrus.cryptorole.SigningServerException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Date(java.util.Date) EvidenceCert(com.itrus.portal.db.EvidenceCert) SigningServerException(com.itrus.cryptorole.SigningServerException) UserCert(com.itrus.portal.db.UserCert) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with EvidenceCertificationChargingHandler

use of com.itrus.portal.evidence.service.EvidenceCertificationChargingHandler in project portal by ixinportal.

the class ServiceConfigurationController method create.

// 返回新建页面
@RequestMapping(params = "form", produces = "text/html")
public String create(@RequestParam(value = "id", required = false) Long id, Model uiModel) {
    if (id == null) {
        List<EvidenceCertificate> configuration = sqlSession.selectList("com.itrus.portal.db.EvidenceCertificateMapper.selectByExample");
        // System.out.println(configuration.size());
        uiModel.addAttribute("configuration", configuration);
        return "serviceconfiguration/create";
    }
    try {
        List<EvidenceCertificate> configuration = sqlSession.selectList("com.itrus.portal.db.EvidenceCertificateMapper.selectByExample");
        uiModel.addAttribute("configuration", configuration);
        EvidenceServiceConfiguration serviceconfig = sqlSession.selectOne("com.itrus.portal.db.EvidenceServiceConfigurationMapper.selectByPrimaryKey", id);
        uiModel.addAttribute("serviceconfig", serviceconfig);
    } catch (Exception e) {
        e.printStackTrace();
    }
    // 通知其他机器,加载缓存
    EvidenceCertificationChargingHandler cch = new EvidenceCertificationChargingHandler();
    cch.setType(1);
    QueueThread.buildCertificationTask(cch);
    cacheCustomer.initEvidence(1);
    return "serviceconfiguration/create";
}
Also used : EvidenceServiceConfiguration(com.itrus.portal.db.EvidenceServiceConfiguration) EvidenceCertificate(com.itrus.portal.db.EvidenceCertificate) EvidenceCertificationChargingHandler(com.itrus.portal.evidence.service.EvidenceCertificationChargingHandler) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

EvidenceCertificationChargingHandler (com.itrus.portal.evidence.service.EvidenceCertificationChargingHandler)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 EvidenceCertificate (com.itrus.portal.db.EvidenceCertificate)2 SigningServerException (com.itrus.cryptorole.SigningServerException)1 EvidenceCert (com.itrus.portal.db.EvidenceCert)1 EvidenceServiceConfiguration (com.itrus.portal.db.EvidenceServiceConfiguration)1 UserCert (com.itrus.portal.db.UserCert)1 ServiceNullException (com.itrus.portal.exception.ServiceNullException)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 CertificateException (java.security.cert.CertificateException)1 Date (java.util.Date)1