Search in sources :

Example 6 with ProjectKeyInfo

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

the class ProjectKeyInfoController method updateForm.

// 返回修改页面
@RequestMapping(value = "/{id}", params = "form", produces = "text/html")
public String updateForm(@PathVariable("id") Long id, Model uiModel) throws Exception {
    ProjectKeyInfo projectkeyinfo = sqlSession.selectOne("com.itrus.portal.db.ProjectKeyInfoMapper.selectByPrimaryKey", id);
    // 检查是否有权限操作
    Long[] projects = getProjectLongIdsOfAdmin();
    List<Long> list = Arrays.asList(projects);
    Long adminProject = getProjectOfAdmin();
    if (list != null && !list.contains(projectkeyinfo.getProject())) {
        return "status403";
    }
    // 解密adminPinValue信息
    if (projectkeyinfo.getAdminPinValue() != null && !projectkeyinfo.getAdminPinValue().equals("")) {
        String unlockCipher = "AES";
        SecretKeySpec skeySpec = new SecretKeySpec(this.adminPinEncKey.substring(0, 16).getBytes(), unlockCipher);
        IvParameterSpec ivSpec = new IvParameterSpec(this.adminPinEncKey.substring(16, 32).getBytes());
        Cipher cipher = Cipher.getInstance(unlockCipher + "/CBC/PKCS5Padding");
        cipher.init(Cipher.DECRYPT_MODE, skeySpec, ivSpec, null);
        byte[] decadminpin = cipher.doFinal(Base64.decode(projectkeyinfo.getAdminPinValue().getBytes()));
        String sdecadminpin = new String(decadminpin);
        projectkeyinfo.setAdminPinValue(sdecadminpin);
    }
    uiModel.addAttribute("projectkeyinfo", projectkeyinfo);
    uiModel.addAttribute("projects", getProjectMapOfAdmin().values());
    return "projectkeyinfos/update";
}
Also used : ProjectKeyInfo(com.itrus.portal.db.ProjectKeyInfo) SecretKeySpec(javax.crypto.spec.SecretKeySpec) IvParameterSpec(javax.crypto.spec.IvParameterSpec) Cipher(javax.crypto.Cipher) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with ProjectKeyInfo

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

the class ProjectKeyInfoController method show.

// 显示详情
@RequestMapping(value = "/{id}", produces = "text/html")
public String show(@PathVariable("id") Long id, Model uiModel) {
    ProjectKeyInfo projectkeyinfo = sqlSession.selectOne("com.itrus.portal.db.ProjectKeyInfoMapper.selectByPrimaryKey", id);
    // 检查是否有权限操作
    Long[] projects = getProjectLongIdsOfAdmin();
    List<Long> list = Arrays.asList(projects);
    if (list != null && !list.contains(projectkeyinfo.getProject())) {
        return "status403";
    }
    Project project = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.selectByPrimaryKey", projectkeyinfo.getProject());
    uiModel.addAttribute("project", project);
    uiModel.addAttribute("projectkeyinfo", projectkeyinfo);
    return "projectkeyinfos/show";
}
Also used : Project(com.itrus.portal.db.Project) ProjectKeyInfo(com.itrus.portal.db.ProjectKeyInfo) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with ProjectKeyInfo

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

the class ProjectKeyInfoController method delete.

// 删除
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE, produces = "text/html")
public String delete(@PathVariable("id") Long id, HttpServletRequest request, Model uiModel) {
    String retPath = getReferer(request, "redirect:/projectkeyinfos", true);
    ProjectKeyInfo projectkeyinfo = sqlSession.selectOne("com.itrus.portal.db.ProjectKeyInfoMapper.selectByPrimaryKey", id);
    // 检查是否有权限操作
    Long[] projects = getProjectLongIdsOfAdmin();
    List<Long> list = Arrays.asList(projects);
    if (list != null && !list.contains(projectkeyinfo.getProject())) {
        return "status403";
    }
    Project project = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.selectByPrimaryKey", projectkeyinfo.getProject());
    sqlSession.delete("com.itrus.portal.db.ProjectKeyInfoMapper.deleteByPrimaryKey", id);
    String oper = "删除序列号";
    String info = "项目名称: " + project.getName() + ", 序列号1: " + projectkeyinfo.getSn1() + ", 序列号2: " + projectkeyinfo.getSn2();
    LogUtil.adminlog(sqlSession, oper, info);
    cacheCustomer.initProjectKeyInfos();
    return retPath;
}
Also used : Project(com.itrus.portal.db.Project) ProjectKeyInfo(com.itrus.portal.db.ProjectKeyInfo) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 9 with ProjectKeyInfo

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

the class ActMsgCollectService method recordMsg.

/**
 * PC端软件活动信息记录
 *
 * @param keySn
 * @param certSn
 * @param threadId
 * @param lifeTime
 * @param runStatus
 * @param activityParam
 * @return
 */
public void recordMsg(String keySn, String certSn, String threadId, String lifeTime, String runStatus, ActivityParam activityParam) {
    ProjectKeyInfo pkInfo = cacheCustomer.findProjectByKey(keySn.trim());
    // 若找不到相关项目信息,则使用默认项目
    ActivityMsgTemp am = new ActivityMsgTemp();
    if (null != pkInfo && !"".equals(certSn)) {
        am.setProject(pkInfo.getProject());
        am.setHostId(activityParam.getHostId());
        am.setUkeyVersion(activityParam.getUkeyVersion());
        am.setKeySn(keySn);
        am.setCertCn(certSn);
        am.setProcessId(activityParam.getProcessId());
        am.setThreadId(activityParam.getWinId());
        am.setOsType(ComNames.OS_WINDOWS);
    }
    try {
        setAmTimes(am, runStatus, Long.parseLong(lifeTime));
        // 将活动信息添加到消息队列中
        queueThread.putObjectQueue(am);
    } catch (ServiceNullException e) {
    }
}
Also used : ProjectKeyInfo(com.itrus.portal.db.ProjectKeyInfo) ActivityMsgTemp(com.itrus.portal.db.ActivityMsgTemp) ServiceNullException(com.itrus.portal.exception.ServiceNullException)

Example 10 with ProjectKeyInfo

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

the class UnlockKeyBillController method verifyAndRegister.

/**
 * 解锁订单提交,用户输入手机号时进行校验
 * @param has_userInfo
 * @param mPhone
 * @param code
 * @param password
 * @param keySn
 * @param enterprise
 * @param session
 * @return
 */
@RequestMapping("/verifyAndRegister")
@ResponseBody
public Map<String, Object> verifyAndRegister(@RequestParam(value = "has_userInfo", required = true) Integer has_userInfo, @RequestParam(value = "keySn", required = true) String keySn, @RequestParam(value = "mPhone", required = true) String mPhone, @RequestParam(value = "code", required = true) String code, @RequestParam(value = "password", required = false) String password, HttpSession session) {
    Map<String, Object> retMap = new HashMap<String, Object>();
    // 错误
    retMap.put("retCode", 0);
    ProjectKeyInfo projectKeyInfo = cacheCustomer.findProjectByKey(keySn);
    if (null == projectKeyInfo) {
        retMap.put("retMsg", "无法识别Key序列号:" + keySn + ",所属的项目,请联系系统管理员配置");
        return retMap;
    }
    Project project = projectService.selectByPrimaryKey(projectKeyInfo.getProject());
    // 验证动态码,
    if (!dynamicCodeService.verifyCode(mPhone, code)) {
        retMap.put("retMsg", "动态码验证失败");
        return retMap;
    }
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    TransactionStatus status = transactionManager.getTransaction(def);
    try {
        UserInfo userInfo = userInfoService.getUserInfoByMphone(mPhone);
        if (null != has_userInfo && has_userInfo.equals(0)) {
            // 绑定用户和证书
            if (null == userInfo) {
                if (StringUtils.isBlank(password)) {
                    retMap.put("retMsg", "请先设置登录口令");
                    return retMap;
                }
                if (project != null) {
                    // 先自动创建用户
                    userInfo = userInfoService.registerUserInfo(mPhone, password, project.getId());
                    // 记录系统日志
                    String info = mPhone + "注册成功";
                    LogUtil.syslog(sqlSession, "注册用户", info);
                }
            }
        }
        // // 获取证书
        // UserCert userCert = userCertService.getUserCert(certBase64);
        // // key序列号
        // if (StringUtils.isNotBlank(keySn)){
        // userCert.setKeySn(keySn);
        // }
        transactionManager.commit(status);
        // 返回绑定成功
        retMap.put("retCode", 1);
    } catch (UserInfoServiceException e) {
        if (!status.isCompleted())
            transactionManager.rollback(status);
        retMap.put("retMsg", e.getMessage());
        return retMap;
    } catch (Exception e) {
        if (!status.isCompleted())
            transactionManager.rollback(status);
        retMap.put("retMsg", "服务端出现未知异常,请联系管理员");
        String info = mPhone + "校验和注册用户失败,原因:" + e.getMessage();
        LogUtil.syslog(sqlSession, "解锁校验", info);
        return retMap;
    } finally {
        if (!status.isCompleted())
            transactionManager.rollback(status);
    }
    return retMap;
}
Also used : Project(com.itrus.portal.db.Project) DefaultTransactionDefinition(org.springframework.transaction.support.DefaultTransactionDefinition) HashMap(java.util.HashMap) ProjectKeyInfo(com.itrus.portal.db.ProjectKeyInfo) TransactionStatus(org.springframework.transaction.TransactionStatus) UserInfo(com.itrus.portal.db.UserInfo) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IOException(java.io.IOException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

ProjectKeyInfo (com.itrus.portal.db.ProjectKeyInfo)19 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)17 Project (com.itrus.portal.db.Project)12 UserInfo (com.itrus.portal.db.UserInfo)9 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)7 HashMap (java.util.HashMap)6 UserCert (com.itrus.portal.db.UserCert)5 UserInfoServiceException (com.itrus.portal.exception.UserInfoServiceException)5 Enterprise (com.itrus.portal.db.Enterprise)4 ProjectKeyInfoExample (com.itrus.portal.db.ProjectKeyInfoExample)4 UserinfoEnterprise (com.itrus.portal.db.UserinfoEnterprise)3 Cipher (javax.crypto.Cipher)3 IvParameterSpec (javax.crypto.spec.IvParameterSpec)3 SecretKeySpec (javax.crypto.spec.SecretKeySpec)3 Ereceipt (com.itrus.portal.db.Ereceipt)2 Product (com.itrus.portal.db.Product)2 IOException (java.io.IOException)2 Date (java.util.Date)2 ActivityMsgTemp (com.itrus.portal.db.ActivityMsgTemp)1 Bill (com.itrus.portal.db.Bill)1