use of cn.topca.tca.ra.service.CertInfo in project portal by ixinportal.
the class EnrolCertTest method topcaCert.
public static void topcaCert(String accountOrgUnit, String accountOrganization, String serviceUrl, String accountHash, String csr) throws Exception {
String json = "{\"certValidity\":" + 60 + "}";
json = "{'certKmcReq2':'','certValidity':'12'}";
UserAPIService service = new UserAPIService(new URL(serviceUrl));
UserAPIServicePortType client = service.getUserAPIServicePort();
// 用户信息
UserInfo userInfo = new UserInfo();
userInfo.setUserEmail("test@itrus.com.cn");
userInfo.setUserName("cceshi");
userInfo.setUserOrgunit(accountOrgUnit);
userInfo.setUserOrganization(accountOrganization);
userInfo.setUserAdditionalField1("123");
CertInfo certInfo = client.enrollCertAA(userInfo, csr, accountHash, "itrusyes", "", json);
System.out.println(certInfo.getCertSerialNumber());
}
use of cn.topca.tca.ra.service.CertInfo in project portal by ixinportal.
the class RenewUserServiceImpl method applyCert.
/**
* 申请指定产品下的证书
*
* @param product
* @return
* @throws Exception
* @throws EncDecException
*/
public CertInfo applyCert(String csr, Product product, String oldCertDn, Integer certValidity) throws EncDecException, Exception {
// 解析项目产品中,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());
// 获取产品、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);
logger.error("********************************************certValidity=" + certValidity);
// 设置userInfo信息
for (int i = 0; i < certinfo.size(); i++) {
JSONObject obj = certinfo.getJSONObject(i);
String raParaName = obj.getString("raParaName");
if (raParaName == null)
continue;
String certName = obj.getString("certName");
String constValue = obj.getString("constValue");
String val = null;
if (constValue != null) {
val = constValue;
} else if (certName != null) {
val = uidutils.getCertSubjectInfo(certName, obj.getString("certNamePrefix"), oldCertDn);
}
certutil.setUserInfoVal(rauserinfo, raParaName, val);
}
logger.error("--------------------------------------certValidity=" + certValidity);
if (null == certValidity) {
certValidity = 5;
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;
}
}
// 调用RA
CertInfo racertinfo = null;
if (ra.getAaPassword() != null)
ra.setAaPassword(AESencrp.decrypt(ra.getAaPassword(), dbEncKey));
racertinfo = certutil.enrollCertByWS(csr, ra, rauserinfo, certValidity);
return racertinfo;
}
use of cn.topca.tca.ra.service.CertInfo in project portal by ixinportal.
the class MobileCertApplyService method execute.
/**
* service:certApply 申请证书移动端需要传过来的参数
* 1.设备信息 device
* equipmentCategory String 设备型号
* appId Long 应用的名称
* operatingSystem String 操作系统
* userId Long 和用户关联的字段
* createTime date 创建时间
* updateTime date 修改时间
* deviceSerialNumber string 设备序列号 唯一标识
* 2.用户信息 即 注册信息 user
* name String 用户姓名
* phone String 手机号
* idNumber String 身份证号
* appId Long 和应用关联的字段
* email String 电子邮件
* registrationTime date 注册时间
* createTime date 创建时间
* updateTime date 修改时间
* userCode String 用户编码
*
* 最后保存 用户信息 设备信息 证书信息 // TODO: 2017/12/8
* @param content
* @return
*/
@Override
public Map<String, Object> execute(String content) {
Map<String, Object> result = new HashMap<String, Object>(5);
// webSocket日志记录
// MobileWebSocketLogService webSocketLogService=new MobileWebSocketLogService();
// webSocketLogService.execute(content);
result.put(" status", 0);
try {
JSONObject param = JSON.parseObject(content);
// 通过appId获取 应用配置 // TODO: 2017/12/8
String appId = param.getString("appId");
String Alias = param.getString("alias");
// String p=param.getString("p2");
// System.out.println(p);
System.out.println(Alias);
MobileApplyConfigManage mobileApplyConfig = mobileApplyConfigService.selectByappId(appId);
ApplicationInfo applicationInfo = applicationInfoService.getApplicationInfo(appId);
CertUtlis certutil = new CertUtlis();
JSONObject jsonUser = param.getJSONObject("user");
// 根据证书信息项设置 rauserinfo对象 // TODO: 2017/12/8
UserInfo rauserinfo = new UserInfo();
rauserinfo.setUserName(jsonUser.getString("name"));
rauserinfo.setUserEmail(jsonUser.getString("email"));
rauserinfo.setUserAdditionalField1(applicationInfo.getName());
rauserinfo.setUserAdditionalField4(jsonUser.getString("userCode"));
JSONObject jsondevice = param.getJSONObject("device");
JSONObject jsonuser = param.getJSONObject("user");
MobileUser mobileUser = new MobileUser();
mobileUser.setName(jsonuser.getString("name"));
mobileUser.setPhone(jsonuser.getString("phone"));
mobileUser.setIdNumber(jsonuser.getString("idNumber"));
mobileUser.setAppId(applicationInfo.getId());
mobileUser.setUid(jsonuser.getString("userCode"));
mobileUser.setCreateTime(new Date());
mobileUser.setEmail(jsonuser.getString("email"));
mobileUser.setRegistrationTime(new Date());
sqlSession.insert("com.itrus.portal.db.MobileUserMapper.insertSelective", mobileUser);
String user_id = UniqueIDUtils.genMobileUserUID(mobileUser);
System.out.println("user_id :" + user_id);
mobileUser.setUserId(user_id);
// mobileUser.setUid(mobileUser.getId().toString());
mobileLogmanagementLogService.update(mobileUser);
MobileEquipment equipment = new MobileEquipment();
equipment.setAppId(param.getString("appId"));
equipment.setCreateTime(new Date());
equipment.setDeviceSerialNumber(jsondevice.getString("deviceSerialNumber"));
equipment.setEquipmentType(jsondevice.getString("equipmentCategory"));
equipment.setUpdateTime(jsondevice.getDate("updateTime"));
equipment.setUserId(mobileUser.getId());
equipment.setOperatingSystem(jsondevice.getString("operatingSystem"));
mobileEquipmentService.insert(equipment);
// 根据证书信息项设置 证书有效期 // TODO: 2017/12/8
Integer certValidity = 7;
if (mobileApplyConfig.getCertificatedeadline() == null || "0".equals(mobileApplyConfig.getCertificatedeadline())) {
certValidity = null;
} else if (1 == mobileApplyConfig.getCertificatedeadline()) {
certValidity = 365 * 1 + 1;
} else if (2 == mobileApplyConfig.getCertificatedeadline()) {
certValidity = 365 * 2 + 1;
} else if (3 == mobileApplyConfig.getCertificatedeadline()) {
certValidity = 365 * 3 + 1;
} else if (4 == mobileApplyConfig.getCertificatedeadline()) {
certValidity = 365 * 5 + 2;
} else if (5 == mobileApplyConfig.getCertificatedeadline()) {
certValidity = 365 * 10 + 2;
}
RaAccount ra = raAccountService.getRaAccount(mobileApplyConfig.getRaaccountId());
// ra.setAccountHash(accountHash);
if (ra.getAaPassword() != null) {
ra.setAaPassword(AESencrp.decrypt(ra.getAaPassword(), dbEncKey));
}
CertInfo racertinfo = certutil.enrollCertByWS(param.getString("csr"), ra, rauserinfo, certValidity);
Map<String, Object> data = new HashMap<String, Object>(8);
data.put("certSignBuf", racertinfo.getCertSignBuf());
data.put("certChain", racertinfo.getCertSignBufP7());
data.put("certDn", racertinfo.getCertSubjectDn());
data.put("certSn", racertinfo.getCertSerialNumber());
data.put("issuerDn", racertinfo.getCertIssuerDn());
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss");
data.put("startTime", sdf.parse(racertinfo.getCertNotBefore()));
data.put("endTime", sdf.parse(racertinfo.getCertNotAfter()));
data.put("certKmcRep1", racertinfo.getCertKmcRep1());
data.put("certKmcRep2", racertinfo.getCertKmcRep2());
result.put("data", data);
result.put("status", 1);
result.put("message", "制作证书成功");
MobileCertificate certificate = new MobileCertificate();
certificate.setAppId(appId);
certificate.setApplyConfigId(mobileApplyConfig.getId());
certificate.setUserId(mobileUser.getId());
certificate.setCertificateStatus(0);
certificate.setCreateTime(new Date());
// certificate.setEquipmentId(equipment.getId());
certificate.setEquipmentNumber(equipment.getDeviceSerialNumber());
certificate.setIssueTime((Date) data.get("startTime"));
certificate.setLoseefficacyTime((Date) data.get("endTime"));
certificate.setCertificateCn(EvidenceSaveServiceApi.getCertCn(data.get("certDn").toString()));
certificate.setLockStatus(0);
certificate.setSequenceNumber(data.get("certSn").toString());
certificate.setSubject(data.get("certDn").toString());
certificate.setCertSignBuf(data.get("certSignBuf").toString());
System.out.println(Alias);
certificate.setAlias(Alias);
// System.out.println("certSignBuf: " + data.get("certSignBuf").toString());
System.out.println("certSignBuf: " + data.get("certSignBuf").toString());
certificateService.insert(certificate);
// 更新设备信息
equipment.setCertificate(certificate.getId());
mobileEquipmentService.update(equipment);
// 业务记录日志
// System.out.println("certSignBuf: " + data.get("certSignBuf").toString());
MobileLogmanagementLog log = new MobileLogmanagementLog();
ApplicationInfo info = applicationInfoService.getApplicationInfo(appId);
result.put("infoName", info.getName());
result.put("userId", mobileUser.getUserId());
log.setAppName(info.getName());
log.setContenu("注册成功");
log.setCreateTime(new Date());
log.setServiceType("注册");
log.setUserName(mobileUser.getUserId());
mobileLogmanagementLogService.insertMobileLogmanagementLog(log);
} catch (Exception e) {
e.printStackTrace();
result.put("message", e.toString());
MobileLogmanagementLog log = new MobileLogmanagementLog();
// ApplicationInfo info=applicationInfoService.getApplicationInfo(appId);
log.setAppName(result.get("infoName").toString());
log.setContenu("注册失败");
log.setCreateTime(new Date());
log.setServiceType("注册");
log.setUserName(result.get("userId").toString());
mobileLogmanagementLogService.insertMobileLogmanagementLog(log);
// String oper = "RA调用失败";
// String info = "错误原因:" + e.toString();
// com.itrus.portal.evidence.utils.LogUtil.evidencelog(sqlSession, oper, info);
}
return result;
}
use of cn.topca.tca.ra.service.CertInfo in project portal by ixinportal.
the class MobileCertRenewService method execute.
/**
* service:certApply 申请证书移动端需要传过来的参数
* 1.设备信息 device
* equipmentCategory String 设备型号
* appId Long 应用的名称
* operatingSystem String 操作系统
* userId Long 和用户关联的字段
* createTime date 创建时间
* updateTime date 修改时间
* deviceSerialNumber string 设备序列号 唯一标识
* 2.用户信息 即 注册信息 user
* name String 用户姓名
* phone String 手机号
* idNumber String 身份证号
* appId Long 和应用关联的字段
* email String 电子邮件
* registrationTime date 注册时间
* createTime date 创建时间
* updateTime date 修改时间
* userCode String 用户编码
*
* 最后保存 用户信息 设备信息 证书信息 // TODO: 2017/12/8
* @param content
* @return
*/
@Override
public Map<String, Object> execute(String content) {
Map<String, Object> result = new HashMap<String, Object>(5);
// webSocket日志记录
// MobileWebSocketLogService webSocketLogService=new MobileWebSocketLogService();
// webSocketLogService.execute(content);
result.put(" status", 0);
try {
JSONObject param = JSON.parseObject(content);
// 通过appId获取 应用配置 // TODO: 2017/12/8
String appId = param.getString("appId");
String Alias = param.getString("alias");
// String p=param.getString("p2");
// System.out.println(p);
System.out.println(Alias);
MobileApplyConfigManage mobileApplyConfig = mobileApplyConfigService.selectByappId(appId);
ApplicationInfo applicationInfo = applicationInfoService.getApplicationInfo(appId);
// 获取旧证书
String deviceSerialNumber = param.get("oldCertSn").toString();
System.out.println(deviceSerialNumber);
MobileCertificateExample certificateExample = new MobileCertificateExample();
MobileCertificateExample.Criteria criteria = certificateExample.createCriteria();
criteria.andSequenceNumberEqualTo(deviceSerialNumber);
MobileCertificate certificateOld = certificateService.selectByExample(certificateExample);
// 获取有效期
int valDay = certificateOld == null ? 0 : getCertValidityDays(certificateOld.getLoseefficacyTime());
if (valDay > 0) {
MobileUserExample muExample = new MobileUserExample();
MobileUserExample.Criteria criteria1 = muExample.createCriteria();
MobileUser mobileUser = null;
MobileEquipment equipment = null;
if (param.getString("userId") != null) {
criteria1.andUserIdEqualTo(param.getString("userId"));
mobileUser = sqlSession.selectOne("com.itrus.portal.db.MobileUserMapper.selectByExample", muExample);
equipment = mobileEquipmentService.selectByUser(mobileUser.getId());
}
CertUtlis certutil = new CertUtlis();
// 根据证书信息项设置 rauserinfo对象 // TODO: 2017/12/8
UserInfo rauserinfo = new UserInfo();
rauserinfo.setUserName(mobileUser.getName());
rauserinfo.setUserEmail(mobileUser.getEmail());
rauserinfo.setUserAdditionalField1(applicationInfo.getName());
rauserinfo.setUserAdditionalField4(mobileUser.getUid());
// JSONObject jsondevice = param.getJSONObject("device");
// JSONObject jsonuser = param.getJSONObject("user");
/* MobileUser mobileUser=new MobileUser();
mobileUser.setName(jsonuser.getString("name"));
mobileUser.setPhone(jsonuser.getString("phone"));
mobileUser.setIdNumber(jsonuser.getString("idNumber"));
mobileUser.setAppId(applicationInfo.getId());
mobileUser.setUid(jsonuser.getString("userCode"));
mobileUser.setCreateTime(new Date());
mobileUser.setEmail(jsonuser.getString("email"));
mobileUser.setRegistrationTime(new Date());
sqlSession.insert("com.itrus.portal.db.MobileUserMapper.insertSelective",mobileUser);
String user_id=UniqueIDUtils.genMobileUserUID(mobileUser);*/
System.out.println("user_id :" + mobileUser.getUserId());
// mobileUser.setUserId(user_id);
// mobileUser.setUid(mobileUser.getId().toString());
// mobileLogmanagementLogService.update(mobileUser);
/* MobileEquipment equipment=new MobileEquipment();
equipment.setAppId(param.getString("appId"));
equipment.setCreateTime(new Date());
equipment.setDeviceSerialNumber(jsondevice.getString("deviceSerialNumber"));
equipment.setEquipmentType(jsondevice.getString("equipmentCategory"));
equipment.setUpdateTime(jsondevice.getDate("updateTime"));
equipment.setUserId(mobileUser.getId());
equipment.setOperatingSystem(jsondevice.getString("operatingSystem"));
mobileEquipmentService.insert(equipment);*/
// 根据证书信息项设置 证书有效期 // TODO: 2017/12/8
Integer certValidity = 7;
if (mobileApplyConfig.getCertificatedeadline() == null || "0".equals(mobileApplyConfig.getCertificatedeadline())) {
certValidity = 0;
} else if (1 == mobileApplyConfig.getCertificatedeadline()) {
certValidity = 365 * 1 + 1;
} else if (2 == mobileApplyConfig.getCertificatedeadline()) {
certValidity = 365 * 2 + 1;
} else if (3 == mobileApplyConfig.getCertificatedeadline()) {
certValidity = 365 * 3 + 1;
} else if (4 == mobileApplyConfig.getCertificatedeadline()) {
certValidity = 365 * 5 + 2;
} else if (5 == mobileApplyConfig.getCertificatedeadline()) {
certValidity = 365 * 10 + 2;
}
RaAccount ra = raAccountService.getRaAccount(mobileApplyConfig.getRaaccountId());
// ra.setAccountHash(accountHash);
if (ra.getAaPassword() != null) {
ra.setAaPassword(AESencrp.decrypt(ra.getAaPassword(), dbEncKey));
}
CertInfo racertinfo = certutil.enrollCertByWS(param.getString("csr"), ra, rauserinfo, valDay + certValidity);
Map<String, Object> data = new HashMap<String, Object>(8);
data.put("certSignBuf", racertinfo.getCertSignBuf());
data.put("certChain", racertinfo.getCertSignBufP7());
data.put("certDn", racertinfo.getCertSubjectDn());
data.put("certSn", racertinfo.getCertSerialNumber());
data.put("issuerDn", racertinfo.getCertIssuerDn());
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss");
data.put("startTime", sdf.parse(racertinfo.getCertNotBefore()));
data.put("endTime", sdf.parse(racertinfo.getCertNotAfter()));
data.put("certKmcRep1", racertinfo.getCertKmcRep1());
data.put("certKmcRep2", racertinfo.getCertKmcRep2());
result.put("data", data);
result.put("status", 1);
result.put("message", "制作证书成功");
MobileCertificate certificate = new MobileCertificate();
certificate.setAppId(appId);
certificate.setApplyConfigId(mobileApplyConfig.getId());
certificate.setUserId(mobileUser.getId());
certificate.setCertificateStatus(0);
certificate.setCreateTime(new Date());
// certificate.setEquipmentId(equipment.getId());
certificate.setEquipmentNumber(equipment.getDeviceSerialNumber());
certificate.setIssueTime((Date) data.get("startTime"));
certificate.setLoseefficacyTime((Date) data.get("endTime"));
certificate.setCertificateCn(EvidenceSaveServiceApi.getCertCn(data.get("certDn").toString()));
certificate.setLockStatus(0);
certificate.setSequenceNumber(data.get("certSn").toString());
certificate.setSubject(data.get("certDn").toString());
certificate.setCertSignBuf(data.get("certSignBuf").toString());
System.out.println(Alias);
certificate.setAlias(Alias);
// System.out.println("certSignBuf: " + data.get("certSignBuf").toString());
System.out.println("certSignBuf: " + data.get("certSignBuf").toString());
certificateService.insert(certificate);
// 更新设备信息
if (null != equipment) {
equipment.setCertificate(certificate.getId());
mobileEquipmentService.update(equipment);
}
// 业务记录日志
// System.out.println("certSignBuf: " + data.get("certSignBuf").toString());
MobileLogmanagementLog log = new MobileLogmanagementLog();
ApplicationInfo info = applicationInfoService.getApplicationInfo(appId);
result.put("infoName", info.getName());
result.put("userId", mobileUser.getUserId());
log.setAppName(info.getName());
log.setContenu("更新成功");
log.setCreateTime(new Date());
log.setServiceType("更新");
log.setUserName(mobileUser.getUserId());
mobileLogmanagementLogService.insertMobileLogmanagementLog(log);
} else {
result.put("message", "有效期小于1天");
}
} catch (Exception e) {
e.printStackTrace();
result.put("message", e.toString());
MobileLogmanagementLog log = new MobileLogmanagementLog();
// ApplicationInfo info=applicationInfoService.getApplicationInfo(appId);
log.setAppName(result.get("infoName").toString());
log.setContenu("更新失败");
log.setCreateTime(new Date());
log.setServiceType("更新");
log.setUserName(result.get("userId").toString());
mobileLogmanagementLogService.insertMobileLogmanagementLog(log);
// String oper = "RA调用失败";
// String info = "错误原因:" + e.toString();
// com.itrus.portal.evidence.utils.LogUtil.evidencelog(sqlSession, oper, info);
}
return result;
}
use of cn.topca.tca.ra.service.CertInfo in project portal by ixinportal.
the class DownLoadCertServiceImpl method downLoadCert.
/**
* 下载证书
*
* @param product
* @param ra
* @param bill
* @param digitalcert
* @param uidIdx
* @param csr
* @return
* @throws Exception
*/
public CertInfo downLoadCert(Product product, RaAccount ra, Bill bill, DigitalCert digitalcert, Integer uidIdx, String csr, String autoidType, Integer autoidValue) throws Exception {
CertInfo racertinfo = null;
// 解析项目产品中,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());
com.itrus.portal.utils.CertUtlis certutil = new com.itrus.portal.utils.CertUtlis();
// 组织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);
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 (hasProductSpec) {
Integer day = Integer.parseInt(productSpec.getProductValid());
if (day == 100) {
// TODO 测试时候,配置年限为100年,则有效期为10天
certValidity = 10;
} 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;
}
}
if (ra.getAaPassword() != null)
ra.setAaPassword(AESencrp.decrypt(ra.getAaPassword(), dbEncKey));
racertinfo = certutil.enrollCertByWS(csr, ra, rauserinfo, certValidity);
return racertinfo;
}
Aggregations