测试stand库修改-文档库

This commit is contained in:
xiejunyu
2022-06-08 21:21:42 +08:00
parent 5f1428d3fd
commit 5cb0eca94a
3 changed files with 47 additions and 25 deletions
@@ -50,6 +50,9 @@ public class ShiroRealm extends AuthorizingRealm {
@Resource
private RedisUtil redisUtil;
@Autowired
private HttpServletResponse response;
// @Autowired
// private HttpServletResponse response;
@@ -105,6 +108,25 @@ public class ShiroRealm extends AuthorizingRealm {
String token = (String) auth.getCredentials();
if (token == null) {
log.info("————————身份认证失败——————————IP地址: "+ oConvertUtils.getIpAddrByRequest(SpringContextUtils.getHttpServletRequest()));
String reponseJson = new Gson().toJson(Result.error(401,"token为空,请重新登录!"));
response.setContentType("application/json; charset=utf-8");
response.setCharacterEncoding("utf-8");
OutputStream out = null;
try {
out = response.getOutputStream();
out.write(reponseJson.getBytes());
}catch (IOException ex){
ex.printStackTrace();
}finally {
if(out != null){
try {
out.close();
out.flush();
} catch (IOException e) {
e.printStackTrace();
}
}
}
LoginException.loginException(401,"token为空");
//throw new JeroBootException("token为空!");
}