Index: ssts-web/src/main/webapp/disinfectsystem/config/gdszyy/interfaces/mybatis/queryAndWriteVerificationCode_Mapper.xml
===================================================================
diff -u
--- ssts-web/src/main/webapp/disinfectsystem/config/gdszyy/interfaces/mybatis/queryAndWriteVerificationCode_Mapper.xml (revision 0)
+++ ssts-web/src/main/webapp/disinfectsystem/config/gdszyy/interfaces/mybatis/queryAndWriteVerificationCode_Mapper.xml (revision 31653)
@@ -0,0 +1,37 @@
+
+
+
+
+
+ (SISMSID,EXTCODE,DESTADDR,MESSAGECONTENT,REQDELIVERYREPORT,MSGFMT,SENDMETHOD,REQUESTTIME,APPLICATIONID)
+
+
+
+
+
+ values(
+ #{SISMSID,jdbcType=VARCHAR},
+ #{EXTCODE,jdbcType=VARCHAR},
+ #{DESTADDR,jdbcType=VARCHAR},
+ #{MESSAGECONTENT,jdbcType=VARCHAR},
+ #{REQDELIVERYREPORT},
+ #{MSGFMT},
+ #{SENDMETHOD,jdbcType=VARCHAR},
+ #{REQUESTTIME},
+ #{APPLICATIONID,jdbcType=VARCHAR}
+ )
+
+
+
+
+
+
\ No newline at end of file
Index: ssts-datasync/src/main/java/com/forgon/disinfectsystem/verification/service/VerificationCodeManager.java
===================================================================
diff -u
--- ssts-datasync/src/main/java/com/forgon/disinfectsystem/verification/service/VerificationCodeManager.java (revision 0)
+++ ssts-datasync/src/main/java/com/forgon/disinfectsystem/verification/service/VerificationCodeManager.java (revision 31653)
@@ -0,0 +1,35 @@
+package com.forgon.disinfectsystem.verification.service;
+
+import net.sf.json.JSONObject;
+
+public interface VerificationCodeManager {
+
+ /**
+ * 生成验证码
+ * @param 验证码
+ * @return
+ */
+ public JSONObject generateverificationCode(String userName);
+
+ /**
+ * 获取用户联系电话
+ * @param userName
+ * @return
+ */
+ public String getPhoneNumberByLoginName(String userName);
+
+ /**
+ * 修改密码
+ * @param loginName
+ * @param newPassword
+ */
+ public void modifyPassword(String loginName, String newPassword);
+
+ /**
+ * 根据消息UUID获取验证码提示信息
+ * @param messageId
+ * @return
+ */
+ public String getVerificationCodeByMessageId(String messageId);
+
+}
Index: ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/verification/VerificationCodeManagerImpl.java
===================================================================
diff -u
--- ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/verification/VerificationCodeManagerImpl.java (revision 0)
+++ ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/verification/VerificationCodeManagerImpl.java (revision 31653)
@@ -0,0 +1,158 @@
+package com.forgon.disinfectsystem.verification;
+
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.security.authentication.encoding.Md5PasswordEncoder;
+import org.springframework.security.authentication.encoding.PasswordEncoder;
+import net.sf.json.JSONObject;
+import com.forgon.directory.acegi.tools.AcegiHelper;
+import com.forgon.directory.mailremotemanager.service.RemoteManagerClient;
+import com.forgon.disinfectsystem.verification.dao.VerificationCodeDao;
+import com.forgon.disinfectsystem.verification.model.VerificationCode;
+import com.forgon.disinfectsystem.verification.service.VerificationCodeManager;
+import com.forgon.exception.SystemException;
+import com.forgon.security.model.User;
+import com.forgon.security.service.UserManager;
+import com.forgon.tools.StrutsParamUtils;
+import com.forgon.tools.StrutsResponseUtils;
+import com.forgon.tools.json.JSONUtil;
+
+public class VerificationCodeManagerImpl implements VerificationCodeManager {
+
+ private UserManager userManager;
+
+ private VerificationCodeDao verificationCodeDaoMybatis;
+
+ private RemoteManagerClient remoteManagerClient;
+
+ public void setRemoteManagerClient(RemoteManagerClient remoteManagerClient) {
+ this.remoteManagerClient = remoteManagerClient;
+ }
+
+ public void setUserManager(UserManager userManager) {
+ this.userManager = userManager;
+ }
+
+ public void setVerificationCodeDaoMybatis(
+ VerificationCodeDao verificationCodeDaoMybatis) {
+ this.verificationCodeDaoMybatis = verificationCodeDaoMybatis;
+ }
+
+ @Override
+ public JSONObject generateverificationCode(String userName) {
+ if(StringUtils.isBlank(userName)){
+ throw new SystemException("登录名不能为空!");
+ }
+
+ List userList = userManager.getByProperty("name", userName);
+ if(CollectionUtils.isEmpty(userList)){
+ throw new SystemException("用户不存在!");
+ }
+
+ User user = userList.get(0);
+ if(StringUtils.isBlank(user.getSmsMumber())){
+ throw new SystemException("该用户没有绑定手机号,请联系管理员绑定手机号!");
+ }
+ Pattern p = Pattern.compile("^(1)[0-9]{10}$");
+ Matcher m = p.matcher(user.getSmsMumber());
+ if(!m.matches()){
+ throw new SystemException("该用户绑定手机号无效,请联系管理员更改手机号!");
+ }
+
+ Integer num = (int)((Math.random()*9+1)*1000);
+ String variables = num.toString();
+
+ String messageContent = generateMessageContent(variables);
+ VerificationCode verificationCode = new VerificationCode();
+ verificationCode.setMessageContent(messageContent);
+ verificationCode.setDestAddr(user.getSmsMumber());
+
+ String messageId = UUID.randomUUID().toString();
+
+ // 广东省中医院短信平台接口写入验证码,短信平台再把验证码发给用户
+ verificationCodeDaoMybatis.generateverificationCode(messageId, VerificationCode.EXTCODE,
+ user.getSmsMumber(), messageContent,
+ VerificationCode.REQDELIVERYREPORT, VerificationCode.MSGFORMAT, VerificationCode.SENDMETHOD,
+ new Date(), VerificationCode.APPLICATIONID);
+
+ JSONObject result = JSONUtil.buildJsonObject(true);
+ result.put("verificationCode", variables);
+ result.put("messageId", messageId);
+ return result;
+ }
+
+
+ /**
+ * 生成随机验证码
+ * 【丁香软件】验证码:1234,用于追溯系统重置登录密码。验证码请勿泄露给他人,谨防账号被盗。
+ * @return
+ */
+ private String generateMessageContent(String variables) {
+ String messageContent = "【丁香软件】验证码:" + variables + ",用于追溯系统重置登录密码。验证码请勿泄露给他人,谨防账号被盗。";
+ return messageContent;
+ }
+
+
+ @Override
+ public String getPhoneNumberByLoginName(String userName) {
+ List userList = userManager.getByProperty("name", userName);
+ if(CollectionUtils.isEmpty(userList)){
+ throw new SystemException("用户不存在!");
+ }
+
+ User user = userList.get(0);
+ if(StringUtils.isBlank(user.getSmsMumber())){
+ throw new SystemException("该用户没有绑定手机号,请联系管理员绑定手机号!");
+ }
+ return user.getSmsMumber();
+ }
+
+ @Override
+ public void modifyPassword(String loginName, String newPassword) {
+
+ List userList = userManager.getByProperty("name", loginName);
+ if(CollectionUtils.isEmpty(userList)){
+ throw new SystemException("用户不存在!");
+ }
+
+ User user = userList.get(0);
+ boolean meetPwdComplexityReq = userManager.forceUserChangePwdWhenNotMeetPwdComplexityReq(loginName, loginName, newPassword);
+ if(!meetPwdComplexityReq){
+ throw new SystemException("密码不符合复杂度要求!");
+ }
+ if (remoteManagerClient != null) {
+ remoteManagerClient.setPassword(user.getName(), user.getPasswd());
+ }
+ user.setModifiedPwd(true); //已修改
+ user.setPasswd(newPassword);
+ userManager.save(user);
+ }
+
+ @Override
+ public String getVerificationCodeByMessageId(String messageId) {
+ if(StringUtils.isBlank(messageId)){
+ throw new SystemException("消息UUID不能为空!");
+ }
+ VerificationCode verificationCode = verificationCodeDaoMybatis.getVerificationCodeByMessageId(messageId);
+ if(verificationCode == null){
+ throw new SystemException("验证码查询失败!");
+ }
+ // 【丁香软件】验证码:1234,用于追溯系统重置登录密码。验证码请勿泄露给他人,谨防账号被盗。
+ String messageContent = verificationCode.getMessageContent();
+ if(StringUtils.isBlank(messageContent)){
+ throw new SystemException("验证码查询失败,消息内容为空!");
+ }
+ int startIndex = messageContent.indexOf(":");
+ int endIndex = messageContent.indexOf(",");
+ if(startIndex == -1 || endIndex == -1){
+ throw new SystemException("验证码查询失败,消息格式错误!");
+ }
+ return messageContent.substring(startIndex + 1, endIndex);
+ }
+
+}
Index: ssts-datasync/src/main/java/com/forgon/disinfectsystem/verification/dao/VerificationCodeDao.java
===================================================================
diff -u
--- ssts-datasync/src/main/java/com/forgon/disinfectsystem/verification/dao/VerificationCodeDao.java (revision 0)
+++ ssts-datasync/src/main/java/com/forgon/disinfectsystem/verification/dao/VerificationCodeDao.java (revision 31653)
@@ -0,0 +1,37 @@
+package com.forgon.disinfectsystem.verification.dao;
+
+import java.util.Date;
+import org.apache.ibatis.annotations.Param;
+import com.forgon.disinfectsystem.verification.model.VerificationCode;
+
+/**
+ * 验证码dao
+ * @author ZhouPeiMian
+ * @since 2021-07-15
+ */
+public interface VerificationCodeDao {
+
+ /**
+ * 生成验证码提示信息
+ * @param messageId
+ * @param extCode
+ * @param destAddr
+ * @param messageContent
+ * @param reqDeliveryReport
+ * @param msgFormat
+ * @param sendMethod
+ * @param requestDateTime
+ * @param applicationId
+ */
+ public void generateverificationCode(@Param("SISMSID") String messageId, @Param("EXTCODE") String extCode, @Param("DESTADDR") String destAddr,
+ @Param("MESSAGECONTENT") String messageContent, @Param("REQDELIVERYREPORT") Integer reqDeliveryReport, @Param("MSGFMT") Integer msgFormat,
+ @Param("SENDMETHOD") Integer sendMethod, @Param("REQUESTTIME") Date requestDateTime, @Param("APPLICATIONID") String applicationId);
+
+ /**
+ * 根据消息UUID获取验证码提示信息
+ * @param projCode
+ * @return
+ */
+ public VerificationCode getVerificationCodeByMessageId(@Param("messageId") String messageId);
+
+}
Index: ssts-datasync/src/main/java/com/forgon/disinfectsystem/verification/model/VerificationCode.java
===================================================================
diff -u
--- ssts-datasync/src/main/java/com/forgon/disinfectsystem/verification/model/VerificationCode.java (revision 0)
+++ ssts-datasync/src/main/java/com/forgon/disinfectsystem/verification/model/VerificationCode.java (revision 31653)
@@ -0,0 +1,151 @@
+package com.forgon.disinfectsystem.verification.model;
+
+import java.util.Date;
+
+/**
+ * 验证码
+ * @author ZhouPeiMian
+ * @since 2021-07-15
+ */
+public class VerificationCode {
+
+ /**
+ * 消息UUID
+ */
+ private String messageId;
+
+ /**
+ * 扩展号码
+ */
+ private String extCode;
+
+ /**
+ * 接受手机MISSONID(手机号码),多个用“;”分割
+ */
+ private String destAddr;
+
+ /**
+ * 短信内容(包含验证码)
+ */
+ private String messageContent;
+
+ /**
+ * 是否需要状态报告 (1)
+ */
+ private Integer reqDeliveryReport;
+
+ /**
+ * 消息类型(8)
+ */
+ private Integer msgFormat;
+
+ /**
+ * 普通短信(2)
+ */
+ private Integer sendMethod;
+
+ /**
+ * 入库时间(短信发送请求时间)
+ */
+ private Date requestDateTime;
+
+ /**
+ * EC/SI应用的ID(P000000000000073)
+ */
+ private String applicationId;
+
+ /**
+ * 扩展号码 默认值
+ */
+ public final static String EXTCODE = "DXRJ";
+ /**
+ * 扩展号码 默认值
+ */
+ public final static Integer REQDELIVERYREPORT = 1;
+ /**
+ * 扩展号码 默认值
+ */
+ public final static Integer MSGFORMAT = 8;
+ /**
+ * 扩展号码 默认值
+ */
+ public final static Integer SENDMETHOD = 2;
+ /**
+ * 扩展号码 默认值
+ */
+ public final static String APPLICATIONID = "P000000000000073";
+
+
+ public String getMessageId() {
+ return messageId;
+ }
+
+ public void setMessageId(String messageId) {
+ this.messageId = messageId;
+ }
+
+ public String getExtCode() {
+ return extCode;
+ }
+
+ public void setExtCode(String extCode) {
+ this.extCode = extCode;
+ }
+
+ public String getDestAddr() {
+ return destAddr;
+ }
+
+ public void setDestAddr(String destAddr) {
+ this.destAddr = destAddr;
+ }
+
+ public String getMessageContent() {
+ return messageContent;
+ }
+
+ public void setMessageContent(String messageContent) {
+ this.messageContent = messageContent;
+ }
+
+ public Integer getReqDeliveryReport() {
+ return reqDeliveryReport;
+ }
+
+ public void setReqDeliveryReport(Integer reqDeliveryReport) {
+ this.reqDeliveryReport = reqDeliveryReport;
+ }
+
+ public Integer getMsgFormat() {
+ return msgFormat;
+ }
+
+ public void setMsgFormat(Integer msgFormat) {
+ this.msgFormat = msgFormat;
+ }
+
+ public Integer getSendMethod() {
+ return sendMethod;
+ }
+
+ public void setSendMethod(Integer sendMethod) {
+ this.sendMethod = sendMethod;
+ }
+
+ public Date getRequestDateTime() {
+ return requestDateTime;
+ }
+
+ public void setRequestDateTime(Date requestDateTime) {
+ this.requestDateTime = requestDateTime;
+ }
+
+ public String getApplicationId() {
+ return applicationId;
+ }
+
+ public void setApplicationId(String applicationId) {
+ this.applicationId = applicationId;
+ }
+
+}
Index: ssts-datasync/src/main/java/com/forgon/disinfectsystem/verification/action/VerificationCodeAction.java
===================================================================
diff -u
--- ssts-datasync/src/main/java/com/forgon/disinfectsystem/verification/action/VerificationCodeAction.java (revision 0)
+++ ssts-datasync/src/main/java/com/forgon/disinfectsystem/verification/action/VerificationCodeAction.java (revision 31653)
@@ -0,0 +1,114 @@
+package com.forgon.disinfectsystem.verification.action;
+
+import java.util.List;
+import net.sf.json.JSONObject;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.struts2.convention.annotation.Action;
+import org.apache.struts2.convention.annotation.Namespace;
+import org.apache.struts2.convention.annotation.ParentPackage;
+import com.forgon.disinfectsystem.verification.service.VerificationCodeManager;
+import com.forgon.exception.SystemException;
+import com.forgon.security.model.User;
+import com.forgon.security.service.UserManager;
+import com.forgon.tools.StrutsParamUtils;
+import com.forgon.tools.StrutsResponseUtils;
+import com.forgon.tools.json.JSONUtil;
+
+/**
+ * 验证码接口
+ * @author ZhouPeiMian
+ * @since 2021-07-15
+ */
+@ParentPackage(value = "default")
+@Namespace(value = "/disinfectSystem/verification")
+@Action(value = "verificationCodeAction")
+public class VerificationCodeAction {
+
+ private VerificationCodeManager verificationCodeManager;
+
+ private UserManager userManager;
+
+ public void setUserManager(UserManager userManager) {
+ this.userManager = userManager;
+ }
+
+ public void setVerificationCodeManager(
+ VerificationCodeManager verificationCodeManager) {
+ this.verificationCodeManager = verificationCodeManager;
+ }
+
+ /**
+ * 生成验证码的接口
+ */
+ public void generateverificationCode(){
+ JSONObject result = JSONUtil.buildJsonObject(true);
+ String loginName = StrutsParamUtils.getPraramValue("loginName", "");
+
+ try {
+ result = verificationCodeManager.generateverificationCode(loginName);
+ } catch (Exception e) {
+ e.printStackTrace();
+ result = JSONUtil.buildJsonObject(false, e.getMessage());
+ }
+
+ StrutsResponseUtils.output(result);
+ }
+
+ /**
+ * 获取用户联系电话
+ */
+ public void getPhoneNumberByLoginName(){
+ JSONObject result = JSONUtil.buildJsonObject(true);
+ String loginName = StrutsParamUtils.getPraramValue("loginName", "");
+ try {
+ List userList = userManager.getByProperty("name", loginName);
+ if(CollectionUtils.isEmpty(userList)){
+ throw new SystemException("用户不存在!");
+ }
+
+ User user = userList.get(0);
+ if(StringUtils.isBlank(user.getSmsMumber())){
+ throw new SystemException("该用户没有绑定手机号,请联系管理员绑定手机号!");
+ }
+
+ result.put("phoneNumber", user.getSmsMumber());
+
+ } catch (Exception e) {
+ result = JSONUtil.buildJsonObject(false, e.getMessage());
+ }
+ StrutsResponseUtils.output(result);
+ }
+
+ /**
+ * 根据消息UUID获取验证码
+ */
+ public void getVerificationCodeByMessageId(){
+ String messageId = StrutsParamUtils.getPraramValue("messageId", "");
+ JSONObject result = JSONUtil.buildJsonObject(true, "成功返回验证码");
+ String verificationCode = "";
+ try {
+ verificationCode = verificationCodeManager.getVerificationCodeByMessageId(messageId);
+ } catch (Exception e) {
+ e.printStackTrace();
+ result = JSONUtil.buildJsonObject(false, "验证码查询失败:" + e.getMessage());
+ }
+ result.put("verificationCode", verificationCode);
+ StrutsResponseUtils.output(result);
+ }
+
+ /**
+ * 修改用户密码
+ */
+ public void modifyPassword() {
+ String loginName = StrutsParamUtils.getPraramValue("loginName", "");
+ String newPassword = StrutsParamUtils.getPraramValue("newPassword", "");
+ JSONObject result = JSONUtil.buildJsonObject(true, "密码修改成功!");
+ try {
+ verificationCodeManager.modifyPassword(loginName, newPassword);
+ } catch (Exception e) {
+ result = JSONUtil.buildJsonObject(false, e.getMessage());
+ }
+ StrutsResponseUtils.output(result);
+ }
+}
Index: forgon-core/src/main/java/com/forgon/security/service/UserManagerImpl.java
===================================================================
diff -u -r31478 -r31653
--- forgon-core/src/main/java/com/forgon/security/service/UserManagerImpl.java (.../UserManagerImpl.java) (revision 31478)
+++ forgon-core/src/main/java/com/forgon/security/service/UserManagerImpl.java (.../UserManagerImpl.java) (revision 31653)
@@ -784,14 +784,14 @@
}
@Override
- public boolean forceUserChangePwdWhenNotMeetPwdComplexityReq(String userName, String loginName, String password) {
+ public boolean forceUserChangePwdWhenNotMeetPwdComplexityReq(String userName, String barcode, String password) {
Boolean forceUserChangePwdWhenNotMeetPwdComplexityReq =
ConfigUtils.getSystemSetConfigByNameBool("forceUserChangePwdWhenNotMeetPwdComplexityReq");
if(!forceUserChangePwdWhenNotMeetPwdComplexityReq){
return true;
}
// 条码登录的不检查密码复杂度,也不需要修改密码
- if(loginName.matches("^01[0-9]{7,10}$")){
+ if(StringUtils.isNotBlank(barcode) && barcode.matches("^01[0-9]{7,10}$")){
return true;
}
String needBeStrongPwdWhenModifyPwd = ConfigUtils.getSystemSetConfigByName("needBeStrongPwdWhenModifyPwd");
Index: ssts-web/src/main/webapp/disinfectsystem/config/gdszyy/spring/verification.xml
===================================================================
diff -u
--- ssts-web/src/main/webapp/disinfectsystem/config/gdszyy/spring/verification.xml (revision 0)
+++ ssts-web/src/main/webapp/disinfectsystem/config/gdszyy/spring/verification.xml (revision 31653)
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
Index: ssts-web/src/main/webapp/WEB-INF/spring/security-standard/applicationContext-acegi-security.xml
===================================================================
diff -u -r31538 -r31653
--- ssts-web/src/main/webapp/WEB-INF/spring/security-standard/applicationContext-acegi-security.xml (.../applicationContext-acegi-security.xml) (revision 31538)
+++ ssts-web/src/main/webapp/WEB-INF/spring/security-standard/applicationContext-acegi-security.xml (.../applicationContext-acegi-security.xml) (revision 31653)
@@ -73,6 +73,9 @@
+
+
+