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";
}
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";
}
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;
}
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) {
}
}
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;
}
Aggregations