| | |
| | | |
| | | @Value("${password-free.secret-key:9fbd170bd83eb869}") |
| | | private String secretKey;//应用秘钥 |
| | | |
| | | @Autowired |
| | | private BladeRedis bladeRedis; |
| | | |
| | |
| | | |
| | | /** |
| | | * 单点登录 |
| | | * @param servletRequest |
| | | * @param empCode |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public String ssoFreeLogin(ServletRequest servletRequest) throws Exception { |
| | | HttpServletRequest request = (HttpServletRequest) servletRequest; |
| | | // String content = request.getHeader("empCode"); |
| | | String content = "test"; |
| | | // if(Func.isBlank(content)){ |
| | | // throw new ServiceException("未获取到empCode参数"); |
| | | // } |
| | | //加密 |
| | | String str1 = aesEncrypt(content, clientId); |
| | | String str2 = aesEncrypt(str1, secretKey); |
| | | |
| | | String enStr1 = aesDecrypt(str2, secretKey); |
| | | String enStr2 = aesDecrypt(enStr1, clientId); |
| | | public String ssoFreeLogin(String empCode) throws Exception { |
| | | if(Func.isBlank(empCode)){ |
| | | throw new ServiceException("未获取到empCode参数"); |
| | | } |
| | | String enStr2; |
| | | try { |
| | | String enStr1 = aesDecrypt(empCode, secretKey); |
| | | enStr2 = aesDecrypt(enStr1, clientId); |
| | | }catch (Exception e){ |
| | | throw new ServiceException("empCode参数解密失败!原因:"+e.getMessage()); |
| | | } |
| | | // 解密 |
| | | log.debug("单点登录参数解密后:"+enStr2); |
| | | String token = this.passwordFreeLogin("pwdfree"); |
| | | String token = this.passwordFreeLogin(enStr2); |
| | | return token; |
| | | } |
| | | |