Search in sources :

Example 1 with AppAuthConfigExample

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

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

the class AppServiceImpl method getAppByAppId.

/**
 * 通过appId获取对应的应用
 */
public AppAuthConfig getAppByAppId(String appId) {
    AppAuthConfigExample appAuthConfigExample = new AppAuthConfigExample();
    AppAuthConfigExample.Criteria criteria = appAuthConfigExample.createCriteria();
    if (appId != null) {
        criteria.andAppIdEqualTo(appId);
    }
    AppAuthConfig appAuthConfig = sqlSession.selectOne("com.itrus.portal.db.AppAuthConfigMapper.selectByExample", appAuthConfigExample);
    return appAuthConfig;
}
Also used : AppAuthConfigExample(com.itrus.portal.db.AppAuthConfigExample) AppAuthConfig(com.itrus.portal.db.AppAuthConfig)

Example 3 with AppAuthConfigExample

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

the class AppAuthConfigController method show.

// 详情页面
@RequestMapping(produces = "text/html")
public String show(Model uiModel) {
    AppAuthConfig appAuthConfig = appAuthConfigService.getAppAuthConfig(new AppAuthConfigExample());
    // uiModel.addAttribute("projects", getProjectMapOfAdmin().values());
    if (null == appAuthConfig) {
        return "appauthconfig/create";
    }
    uiModel.addAttribute("appAuthConfig", appAuthConfig);
    // uiModel.addAttribute("projectMap",getProjectMapOfAdmin());
    return "appauthconfig/show";
}
Also used : AppAuthConfig(com.itrus.portal.db.AppAuthConfig) AppAuthConfigExample(com.itrus.portal.db.AppAuthConfigExample) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with AppAuthConfigExample

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

the class AppAuthConfigServiceImpl method getConfigByProjectId.

/**
 * 根据项目ID获取应用认证配置
 *
 * @param projectId
 * @return
 */
public AppAuthConfig getConfigByProjectId(Long projectId) {
    AppAuthConfigExample example = new AppAuthConfigExample();
    AppAuthConfigExample.Criteria criteria = example.or();
    criteria.andProjectEqualTo(projectId);
    AppAuthConfig appAuthConfig = sqlSession.selectOne("com.itrus.portal.db.AppAuthConfigMapper.selectByExample", example);
    return appAuthConfig;
}
Also used : AppAuthConfigExample(com.itrus.portal.db.AppAuthConfigExample) AppAuthConfig(com.itrus.portal.db.AppAuthConfig)

Aggregations

AppAuthConfig (com.itrus.portal.db.AppAuthConfig)4 AppAuthConfigExample (com.itrus.portal.db.AppAuthConfigExample)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 SigningServerException (com.itrus.cryptorole.SigningServerException)1 EvidenceCert (com.itrus.portal.db.EvidenceCert)1 UserCert (com.itrus.portal.db.UserCert)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 CertificateException (java.security.cert.CertificateException)1 Date (java.util.Date)1