| | |
| | | package com.vci.frameworkcore.compatibility.impl; |
| | | |
| | | import com.vci.dto.SmUserDTO; |
| | | import com.vci.common.util.ThreeDES; |
| | | import com.vci.corba.common.PLException; |
| | | import com.vci.corba.common.data.UserEntityInfo; |
| | |
| | | import com.vci.frameworkcore.compatibility.SmPwdStrategyQueryServiceI; |
| | | import com.vci.frameworkcore.compatibility.SmRoleQueryServiceI; |
| | | import com.vci.frameworkcore.compatibility.SmUserQueryServiceI; |
| | | import com.vci.frameworkcore.model.dto.SmUserDTO; |
| | | import com.vci.frameworkcore.model.SmUserDO; |
| | | import com.vci.frameworkcore.model.po.SmUserPO; |
| | | import com.vci.frameworkcore.pagemodel.OrgDepartmentVO; |
| | | import com.vci.frameworkcore.pagemodel.SmPasswordStrategyVO; |
| | | import com.vci.frameworkcore.pagemodel.SmRoleVO; |
| | | import com.vci.frameworkcore.pagemodel.SmUserVO; |
| | | import com.vci.model.SmUserDO; |
| | | import com.vci.pagemodel.SmUserVO; |
| | | import com.vci.po.SmUserPO; |
| | | import com.vci.pagemodel.OrgDepartmentVO; |
| | | import com.vci.pagemodel.SmPasswordStrategyVO; |
| | | import com.vci.pagemodel.SmRoleVO; |
| | | import com.vci.frameworkcore.properties.ConfigReader; |
| | | import com.vci.omd.utils.ObjectTool; |
| | | import com.vci.starter.poi.bo.ReadExcelOption; |
| | |
| | | * @return 用户的信息 |
| | | * @throws VciBaseException 查询出错的时候会抛出异常 |
| | | */ |
| | | private SmUserVO getUserByField(String queryField,String queryValue) throws VciBaseException{ |
| | | private SmUserVO getUserByField(String queryField, String queryValue) throws VciBaseException{ |
| | | VciQueryWrapperForDO queryWrapper = new VciQueryWrapperForDO(null, SmUserDO.class,null,true); |
| | | queryWrapper.eq(queryWrapper.getTableNick() + "." +queryField,queryValue); |
| | | queryWrapper.setDistinct(true); |
| | |
| | | /** |
| | | * 修改密码 |
| | | * @param userOid 用户主键 |
| | | * @param oldPassword 旧的密码 |
| | | * @param password 新的密码 |
| | | * @param confirmPassword 确认密码 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void changePassword(String userOid, String password, |
| | | String confirmPassword) throws VciBaseException { |
| | | WebUtil.alertNotNull(userOid,"用户主键",password,"密码",confirmPassword,"确认密码"); |
| | | public boolean changePassword(String userOid,String oldPassword, String password, |
| | | String confirmPassword) throws Exception { |
| | | WebUtil.alertNotNull(userOid,"用户主键",oldPassword,"登录密码",password,"密码",confirmPassword,"确认密码"); |
| | | if(!password.equals(confirmPassword)){ |
| | | throw new VciBaseException("密码和确认密码不相等"); |
| | | } |
| | | //对旧密码和密码进行解密,便于比对密码用 |
| | | oldPassword = Func.decryptAes(oldPassword,"daliantan0v0vcip"); |
| | | password = Func.decryptAes(password,"daliantan0v0vcip"); |
| | | //对比旧密码 |
| | | boolean b = this.checkPasswordEqual(oldPassword, userOid); |
| | | if(!b){ |
| | | throw new PLException("500", new String[] { "您输入的密码与登录密码不一致,请重新输入!"}); |
| | | } |
| | | SmUserVO smUserVO = getUserByUserOid(userOid); |
| | | if(Func.isEmpty(smUserVO)){ |
| | | throw new VciBaseException("当前修改的用户不存在!"); |
| | | } |
| | | //TODO:校验密码是否符合策略 |
| | | String error = platformClientUtil.getFrameworkService().checkPasswordStrategyByUserId(smUserVO.getId(), password,null); |
| | | if (!StringUtils.isBlank(error)) { |
| | | throw new VciBaseException("当前设置的密码,密码策略校验未通过!"); |
| | | } |
| | | |
| | | //TODO:考虑是否需要将修改方式改成直接调用平台的接口,因为现在的修改方式没能正确的更新缓存 |
| | | /*UserInfo userInfo = new UserInfo(); |
| | | userInfo.id = userOid.trim(); |
| | | userInfo.pwd = password; |
| | | userInfo.pwdUpdateTime = System.currentTimeMillis(); |
| | | boolean updateBoolean = platformClientUtil.getFrameworkService().updateUser(userInfo, new UserEntityInfo(WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId(), null)); |
| | | return updateBoolean;*/ |
| | | |
| | | ThreeDES des = new ThreeDES();// 实例化一个对�? |
| | | des.getKey("daliantan0v0");// 生成密匙 |
| | | String encPassword = des.getEncString(password); |
| | | String sql = "update pluser set plpassword = '" + encPassword + "' where pluid = '" + userOid.trim() + "'"; |
| | | //修改密码的同时需要将密码修改时间也更新 |
| | | String sql = "update pluser set plpassword = '" + encPassword + "', plpwdupdatetime = TO_DATE('" |
| | | + Func.format(new Date(),"yyyy-MM-dd HH:mm:ss") +"','yyyy-MM-dd hh24:mi:ss') where pluid = '" + userOid.trim() + "'"; |
| | | try { |
| | | platformClientUtil.getBOFactoryService().executeUpdateSql(sql); |
| | | return platformClientUtil.getBOFactoryService().executeUpdateSql(sql); |
| | | } catch (PLException vciError) { |
| | | throw WebUtil.getVciBaseException(vciError); |
| | | } |
| | |
| | | } |
| | | //根据当前创建这个用户的人所绑定密码策略来进行密码校验 |
| | | try { |
| | | String userName = WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId(); |
| | | String error = platformClientUtil.getFrameworkService().checkPasswordStrategyByUserId(userName, smUserDTO.getPassword(),null); |
| | | String userId = WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId(); |
| | | String error = platformClientUtil.getFrameworkService().checkPasswordStrategyByUserId(userId, smUserDTO.getPassword(),null); |
| | | if (!StringUtils.isBlank(error)) { |
| | | throw new VciBaseException("当前设置的密码,密码策略校验未通过"); |
| | | } |