Search in sources :

Example 6 with MobileApplyConfigManage

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

the class MobileWebSocketLogService 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>(3);
    result.put("status", 0);
    try {
        JSONObject param = JSON.parseObject(content);
        String appId = param.getString("appId");
        ApplicationInfo applicationInfo = applicationInfoService.getApplicationInfo(appId);
        MobileApplyConfigManage mobileApplyConfig = mobileApplyConfigService.selectByappId(appId);
        CertUtlis certutil = new CertUtlis();
        JSONObject jsonUser = param.getJSONObject("user");
        // 根据证书信息项设置 rauserinfo对象 // TODO: 2017/12/26
        UserInfo rauserinfo = new UserInfo();
        rauserinfo.setUserName(jsonUser.getString("name"));
        rauserinfo.setUserEmail(jsonUser.getString("email"));
        rauserinfo.setUserAdditionalField1(applicationInfo.getName());
        rauserinfo.setUserAdditionalField4(jsonUser.getString("userCode"));
        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());
        if (ra.getAaPassword() != null) {
            ra.setAaPassword(AESencrp.decrypt(ra.getAaPassword(), dbEncKey));
        }
        CertInfo racertinfo = certutil.enrollCertByWS(param.getString("csr"), ra, rauserinfo, certValidity);
        result.put("status", 1);
        result.put("message", "制作证书成功");
    } catch (Exception e) {
        result.put("message", e.toString());
    }
    return result;
}
Also used : CertInfo(cn.topca.tca.ra.service.CertInfo) HashMap(java.util.HashMap) ApplicationInfo(com.itrus.portal.db.ApplicationInfo) UserInfo(cn.topca.tca.ra.service.UserInfo) MobileApplyConfigManage(com.itrus.portal.db.MobileApplyConfigManage) CertUtlis(com.itrus.portal.utils.CertUtlis) JSONObject(com.alibaba.fastjson.JSONObject) RaAccount(com.itrus.portal.db.RaAccount) JSONObject(com.alibaba.fastjson.JSONObject)

Example 7 with MobileApplyConfigManage

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

the class MobileApplyConfigService method selectByappId.

/*
	根据应用配置里的appid获得对应的应用配置
    */
public MobileApplyConfigManage selectByappId(String appId) {
    MobileApplyConfigManageExample applyConfigManageExample = new MobileApplyConfigManageExample();
    MobileApplyConfigManageExample.Criteria criteria = applyConfigManageExample.createCriteria();
    if (appId != null) {
        criteria.andApIdEqualTo(appId);
        MobileApplyConfigManage applyConfigManage = sqlSession.selectOne("com.itrus.portal.db.MobileApplyConfigManageMapper.selectByExample", applyConfigManageExample);
        return applyConfigManage;
    }
    return null;
}
Also used : MobileApplyConfigManageExample(com.itrus.portal.db.MobileApplyConfigManageExample) MobileApplyConfigManage(com.itrus.portal.db.MobileApplyConfigManage)

Aggregations

MobileApplyConfigManage (com.itrus.portal.db.MobileApplyConfigManage)7 ApplicationInfo (com.itrus.portal.db.ApplicationInfo)3 RaAccount (com.itrus.portal.db.RaAccount)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 MobileApplyConfigManageExample (com.itrus.portal.db.MobileApplyConfigManageExample)2 MobileCertificate (com.itrus.portal.db.MobileCertificate)2 Date (java.util.Date)2 CertInfo (cn.topca.tca.ra.service.CertInfo)1 UserInfo (cn.topca.tca.ra.service.UserInfo)1 JSONObject (com.alibaba.fastjson.JSONObject)1 ApplicationInfoExample (com.itrus.portal.db.ApplicationInfoExample)1 MobileUser (com.itrus.portal.db.MobileUser)1 CertUtlis (com.itrus.portal.utils.CertUtlis)1 HashMap (java.util.HashMap)1