1.商家申请入驻的密码要使用BCrypt算法进行加密存储,修改SellerController.java的add方法
1 /** 2 * 增加 3 * @param seller 4 * @return 5 */ 6 @RequestMapping("/add") 7 public Result add(@RequestBody TbSeller seller){ 8 //密码加密 9 BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); 10 String password = passwordEncoder.encode(seller.getPassword()); 11 seller.setPassword(password); 12 try { 13 sellerService.add(seller); 14 return new Result(true, "增加成功"); 15 } catch (Exception e) { 16 e.printStackTrace(); 17 return new Result(false, "增加失败"); 18 } 19 }
Cookie Sessoin 会话跟踪技术(自动登录功能)
Cookie 是客户端的对象
Session是服务器端的对象
Cookie不能存中文
String str = URLEncoder.encoder(“张三”,”utf-8”);%E0%B3%D5
URLDecoder.decoder(str,”utf-8”);
2.加密配置
2.1 修改y-shop-web的spring-security.xml ,添加如下配置
<beans:bean id="bcryptEncoder"
class="org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder" />
2.2 修改认证管理器的配置
<!-- 认证管理器 -->
<authentication-manager alias="authenticationManager">
<authentication-provider user-service-ref='userDetailService'>
<password-encoder ref="bcryptEncoder"></password-encoder>
</authentication-provider>
</authentication-manager>
浙公网安备 33010602011771号