| | |
| | | package com.ruoyi.common.security.utils; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | import com.ruoyi.system.api.model.AppUser; |
| | | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; |
| | | import com.ruoyi.common.core.constant.SecurityConstants; |
| | | import com.ruoyi.common.core.constant.TokenConstants; |
| | |
| | | { |
| | | return SecurityContextHolder.get(SecurityConstants.LOGIN_USER, LoginUser.class); |
| | | } |
| | | |
| | | public static AppUser getAppLoginUser() |
| | | { |
| | | return SecurityContextHolder.get(SecurityConstants.COMPANY_LOGIN_USER, AppUser.class); |
| | | } |
| | | |
| | | /** |
| | | * 获取企业用户信息 |
| | | */ |
| | | public static AppUser getCompanyLoginUser() |
| | | { |
| | | return SecurityContextHolder.get(SecurityConstants.COMPANY_LOGIN_USER, AppUser.class); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取请求token |
| | |
| | | BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); |
| | | return passwordEncoder.matches(rawPassword, encodedPassword); |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | String password1 = "$2a$10$qB8arbbFx4mevJzCOoChhebLS/ULjY7BCBNMNk9CoSJHAUM/Ixr2K"; |
| | | for (int i = 0; i < 5; i++) { |
| | | String password = encryptPassword("123"); |
| | | System.out.println(matchesPassword("123",password1)); |
| | | } |
| | | } |
| | | } |