试着分析一下 仅供参考
public void authResult() {
//获得包含请求信息的一个自定义请求对象
MiRequest req = new MiRequest(getRequest());
//获得安全上下文对象
SecurityContext securityContext = SecurityContextHolder.getContext();
//获得验证处理过滤器(应该是一个bean)
AuthenticationProcessingFilter authenticationProcessingFilter = (AuthenticationProcessingFilter)SpringContextHolder.getBean("authenticationProcessingFilter");
//通过过滤器对请求进行试验证 获得一个验证对象
Authentication authentication = authenticationProcessingFilter.attemptAuthentication(getRequest());
//构造一个自定义响应对象 类似于构造请求对象
MiResponse res = new MiResponse(getResponse());
//如果验证通过
if (authentication.isAuthenticated()){
//在安全上下文对象中置域值(验证对象)
securityContext.setAuthentication(authentication);
Result result = new Result();
//在result对象中放sessionid的一个entry
result.put("JSESSIONID", getRequest().getSession().getId());
//通过响应对象发送这个附带附加参数DS_OUTPUT_ID的result
res.send(result, Constants.DS_OUTPUT_ID);
} else {
//置错 登录失败
res.error("-2000", "login fail");
}
}
public void authResult() {
//获得包含请求信息的一个自定义请求对象
MiRequest req = new MiRequest(getRequest());
//获得安全上下文对象
SecurityContext securityContext = SecurityContextHolder.getContext();
//获得验证处理过滤器(应该是一个bean)
AuthenticationProcessingFilter authenticationProcessingFilter = (AuthenticationProcessingFilter)SpringContextHolder.getBean("authenticationProcessingFilter");
//通过过滤器对请求进行试验证 获得一个验证对象
Authentication authentication = authenticationProcessingFilter.attemptAuthentication(getRequest());
//构造一个自定义响应对象 类似于构造请求对象
MiResponse res = new MiResponse(getResponse());
//如果验证通过
if (authentication.isAuthenticated()){
//在安全上下文对象中置域值(验证对象)
securityContext.setAuthentication(authentication);
Result result = new Result();
//在result对象中放sessionid的一个entry
result.put("JSESSIONID", getRequest().getSession().getId());
//通过响应对象发送这个附带附加参数DS_OUTPUT_ID的result
res.send(result, Constants.DS_OUTPUT_ID);
} else {
//置错 登录失败
res.error("-2000", "login fail");
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货