From 23c53ee06896639dd51daeb1b5a0809c07610e59 Mon Sep 17 00:00:00 2001 From: liux <963924687@qq.com> Date: Tue, 11 Jun 2024 10:36:28 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E4=BA=8C=E6=AC=A1=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DecodePwdAuthenticationProvider.java | 42 ++++++++ src/main/resources/static/js/public.js | 6 +- src/main/resources/static/js/publicJs.js | 101 +++++++----------- 3 files changed, 83 insertions(+), 66 deletions(-) create mode 100644 src/main/java/com/bonus/nxdt/energy/manager/config/DecodePwdAuthenticationProvider.java diff --git a/src/main/java/com/bonus/nxdt/energy/manager/config/DecodePwdAuthenticationProvider.java b/src/main/java/com/bonus/nxdt/energy/manager/config/DecodePwdAuthenticationProvider.java new file mode 100644 index 0000000..7f0502f --- /dev/null +++ b/src/main/java/com/bonus/nxdt/energy/manager/config/DecodePwdAuthenticationProvider.java @@ -0,0 +1,42 @@ +package com.bonus.nxdt.energy.manager.config; + +import com.bonus.nxdt.energy.manager.service.impl.UserDetailsServiceImpl; +import com.bonus.nxdt.energy.manager.utils.AesCbcUtils; +import lombok.extern.slf4j.Slf4j; +import org.springframework.security.authentication.BadCredentialsException; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.authentication.dao.DaoAuthenticationProvider; +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; + +/** + * 密码自定义校验 + */ +@Slf4j +public class DecodePwdAuthenticationProvider extends DaoAuthenticationProvider { + + + + public DecodePwdAuthenticationProvider(UserDetailsServiceImpl userDetailsService){ + setUserDetailsService(userDetailsService); + } + + + @Override + protected void additionalAuthenticationChecks(UserDetails userDetails, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException { + if (authentication.getCredentials() == null) { + this.logger.debug("Authentication failed: no credentials provided"); + throw new BadCredentialsException(this.messages.getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials")); + } else { + String presentedPassword = authentication.getCredentials().toString(); + presentedPassword= AesCbcUtils.decrypt(presentedPassword); + BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); + if (!passwordEncoder.matches(presentedPassword, userDetails.getPassword())) { + this.logger.debug("Authentication failed: password does not match stored value"); + throw new BadCredentialsException(this.messages.getMessage("AbstractUserDetailsAuthenticationProvider.badCredentials", "Bad credentials")); + } + } + } + +} diff --git a/src/main/resources/static/js/public.js b/src/main/resources/static/js/public.js index cfd4293..223b28f 100644 --- a/src/main/resources/static/js/public.js +++ b/src/main/resources/static/js/public.js @@ -1,6 +1,6 @@ -// var dataUrl ="http://218.21.27.6:1930/nxnyback/"; -// var dataUrl ="http://127.0.0.1:1930/nxnyback/"; -var dataUrl = "http://192.168.0.14:1930/nxnyback"; +// var dataUrl ="http://140.210.195.210:1918/gzrbmw/"; +// var dataUrl ="http://140.210.195.210:1920/gzrbmw/"; +var dataUrl ="http://218.21.27.6:1930/nxnyback"; var token=localStorage.getItem('token'); $(function() { var headHTML = document.getElementsByTagName('head')[0].innerHTML; diff --git a/src/main/resources/static/js/publicJs.js b/src/main/resources/static/js/publicJs.js index d155d06..eef2348 100644 --- a/src/main/resources/static/js/publicJs.js +++ b/src/main/resources/static/js/publicJs.js @@ -1,28 +1,29 @@ var ctxPath = getContextPath(); -var dataPath = "http://192.168.0.14:1930/nxnyback"; -// var dataUrl ="http://218.21.27.6:1930/nxnyback/"; -// var dataUrl ="http://127.0.0.1:1930/nxnyback/"; +// var dataPath = "http://192.168.0.176:1930/nxnyback"; +var dataUrl ="http://218.21.27.6:1930/nxnyback/"; +var aqEnnable = true; //查看图片的路径 -// var lookFile = "http://218.21.27.6:1999/nxnyback/statics"; //文件路径 -var lookFile = "http://192.168.0.14:1930/nxnyback/statics"; //文件路径 +var lookFile = "http://218.21.27.6:1999/nxnyback/statics"; //文件路径 +//var lookFile = "http://192.168.0.14:1930/nxenergyweb/statics"; //文件路径 //kk file 测试环境地址 -var filePreviewPathAll = "http://192.168.0.14:8012/onlinePreview?url="; -// var filePreviewPathAll = "http://218.21.27.6:8012/onlinePreview?url="; +//var filePreviewPathAll = "http://192.168.0.14:8012/onlinePreview?url="; +var filePreviewPathAll = "http://218.21.27.6:8012/onlinePreview?url="; function getContextPath() { var pathName = document.location.pathname; var index = pathName.substr(1).indexOf("/"); - return pathName.substr(0, index + 1); + var result = pathName.substr(0, index + 1); + return result; } var disphoto = ctxPath + '/statics/'; var filePath = ctxPath + '/statics'; function isNotEmpty(str) { - if (str != null && str !== 'null' && str !== '') { + if (str != null && str != 'null' && str != '') { return true; } else { return false; @@ -36,7 +37,11 @@ function openFileWindows(url) { } function isEmpty(str) { - return str == null || str === 'null' || str === ''; + if (str == null || str == 'null' || str == '') { + return true; + } else { + return false; + } } function choseType(str) { @@ -46,9 +51,13 @@ function choseType(str) { return true; } else if (str.indexOf("jpeg") > 0) { return true; - } else return str.indexOf("gif") > 0; + } else if (str.indexOf("gif") > 0) { + return true; + } else { + return false; + } -} +}; function getTypeImg(str) { if (str.toLowerCase().indexOf("xlsx") > 0 || str.toLowerCase().indexOf("xls") > 0) { @@ -155,12 +164,12 @@ function addSvg(svgId,addDivId) { } function getFirst(str) { - if(str ==null | str ==='null' | str === undefined | str ==='undefined' || str.length<1){ + if(str ==null | str =='null' | str ==undefined | str=='undefined' | str.length<1){ return; } var x = str.substring(0,1); var y = str.substring(1,str.length); - if(x === "/"){ + if(x == "/"){ // str.substring(1,str.length); console.log("str111=="+y) return y; @@ -275,8 +284,10 @@ function checkPsidno(value) } // 不能是2月30号、4月31号、5月32号出生的吧 const date = new Date(year, month, 0) // 获取当月的最后一天 - return !(day < 1 || day > date.getDate()); - + if (day < 1 || day > date.getDate()) { + return false + } + return true } // 4.18位号码校验生成的校验码 @@ -301,8 +312,10 @@ function checkPsidno(value) // 验证手机号码的正则 const phone_reg = function(num){ var num_reg = /^13[0-9]{1}[0-9]{8}$|15[0-9]{1}[0-9]{8}$|16[0-9]{1}[0-9]{8}$|18[0-9]{1}[0-9]{8}|17[0-9]{1}[0-9]{8}$|19[0-9]{1}[0-9]{8}$|14[0-9]{1}[0-9]{8}/; - return num_reg.test(num); - + if(!num_reg.test(num)){ + return false; + } + return true; } @@ -320,7 +333,7 @@ function changeDivHeightById(divId,num) { var height = $("#"+divId).outerHeight() var lineNum = Math.ceil(num/6); var ss = height*lineNum; - $('#'+divId).css("height", ss+"px"); + $("#"+divId).css("height", ss+"px"); } @@ -335,57 +348,19 @@ function changeDivHeightByIdAndLine(divId,num,lineNum,type) { if(num <= 0){ num =1; } - let lineNum1; - const height = 160; - if(type ===1){ - lineNum1 = Math.ceil((num+1)/lineNum); + var height = 160; + if(type ==1){ + var lineNum = Math.ceil((num+1)/lineNum); }else{ - lineNum1 = Math.ceil(num/lineNum); + var lineNum = Math.ceil(num/lineNum); } - const ss = height * lineNum1; + var ss = height*lineNum; $("#"+divId).css("height", ss+"px"); } -const provinces = { - 11: "北京", - 12: "天津", - 13: "河北", - 14: "山西", - 15: "内蒙古", - 21: "辽宁", - 22: "吉林", - 23: "黑龙江", - 31: "上海", - 32: "江苏", - 33: "浙江", - 34: "安徽", - 35: "福建", - 36: "江西", - 37: "山东", - 41: "河南", - 42: "湖北", - 43: "湖南", - 44: "广东", - 45: "广西", - 46: "海南", - 50: "重庆", - 51: "四川", - 52: "贵州", - 53: "云南", - 54: "西藏", - 61: "陕西", - 62: "甘肃", - 63: "青海", - 64: "宁夏", - 65: "新疆", - 71: "台湾", - 81: "香港", - 82: "澳门", - 91: "国外" -}; - +var provinces = { 11: "北京", 12: "天津", 13: "河北", 14: "山西", 15: "内蒙古", 21: "辽宁", 22: "吉林", 23: "黑龙江", 31: "上海", 32: "江苏", 33: "浙江", 34: "安徽", 35: "福建", 36: "江西", 37: "山东", 41: "河南", 42: "湖北", 43: "湖南", 44: "广东", 45: "广西", 46: "海南", 50: "重庆", 51: "四川", 52: "贵州", 53: "云南", 54: "西藏", 61: "陕西", 62: "甘肃", 63: "青海", 64: "宁夏", 65: "新疆", 71: "台湾", 81: "香港", 82: "澳门", 91: "国外" }; function getProvince(idNumber){ return provinces[parseInt(idNumber.substr(0, 2))]; } \ No newline at end of file