当前位置: 首页 > wzjs >正文

黑龙江网站备案管理局重庆装修

黑龙江网站备案管理局,重庆装修,传媒公司网站建设方案,wordpress login_head1. 用户名和密码被过滤器获取到,封装成 Authentication ,通常情况下是 UsernamePasswordAuthenticationToken 这个实现类。 2. AuthenticationManager 身份管理器负责验证这个 Authentication 3. 认证成功后, AuthenticationManager 身份管理器返回一…

1. 用户名和密码被过滤器获取到,封装成 Authentication ,通常情况下是 UsernamePasswordAuthenticationToken 这个实现类。

2. AuthenticationManager 身份管理器负责验证这个 Authentication

3. 认证成功后, AuthenticationManager 身份管理器返回一个被填充满了信息的(包括上面提到的 权限信息,身份信息,细节信息,但密码通常会被移除) Authentication 实例。

4. SecurityContextHolder 安全上下文容器将第3步填充了信息的 Authentication ,通过 SecurityContextHolder.getContext().setAuthentication(…)方法,设置到其中。

public class AuthenticationExample {
private static AuthenticationManager am = new SampleAuthenticationManager();
public static void main(String[] args) throws Exception {
BufferedReader in = new BufferedReader(new
InputStreamReader(System.in));
测试
while (true) {
System.out.println("Please enter your username:");
String name = in.readLine();
System.out.println("Please enter your password:");
String password = in.readLine();
try {
// 封装认证信息,未认证通过
Authentication request = new
UsernamePasswordAuthenticationToken(name, password);
// 认证逻辑
Authentication result = am.authenticate(request);
//当前线程绑定认证信息
SecurityContextHolder.getContext().setAuthentication(result);
break;
} catch (AuthenticationException e) {
System.out.println("Authentication failed: " + e.getMessage());
}
}
System.out.println("Successfully authenticated. Security context
contains: " +
SecurityContextHolder.getContext().getAuthentication());
}
}
class SampleAuthenticationManager implements AuthenticationManager {
static final List<GrantedAuthority> AUTHORITIES = new
ArrayList<GrantedAuthority>();
static {
AUTHORITIES.add(new SimpleGrantedAuthority("ROLE_USER"));
}
@Override
public Authentication authenticate(Authentication auth) throws
AuthenticationException {
// 判断条件,用户名和密码是否相同
if (auth.getName().equals(auth.getCredentials())) {
// 封装认证信息,认证已通过
return new UsernamePasswordAuthenticationToken(auth.getName(),
auth.getCredentials(), AUTHORITIES);
}
throw new BadCredentialsException("Bad Credentials");
}
}
认证流程

推荐阅读

技术总体方案设计思路

如何评价代码的质量-CSDN博客

领域分解识别服务


文章转载自:

http://jQimAsKi.wdqhg.cn
http://gMSvTLeb.wdqhg.cn
http://ZsHZWnca.wdqhg.cn
http://3OF5cd3X.wdqhg.cn
http://XfqNOBk3.wdqhg.cn
http://l9wvImt5.wdqhg.cn
http://wcIyI5r2.wdqhg.cn
http://8Bnxrwgu.wdqhg.cn
http://PRNmzUPp.wdqhg.cn
http://a0RMjzS9.wdqhg.cn
http://fmU3rq8n.wdqhg.cn
http://AfDgCc8Z.wdqhg.cn
http://Yvazy0Mu.wdqhg.cn
http://FZXCJ8SC.wdqhg.cn
http://zaY4JdyK.wdqhg.cn
http://5UV2dG6a.wdqhg.cn
http://Sgv4HYMl.wdqhg.cn
http://zbipLcat.wdqhg.cn
http://kUFflKVg.wdqhg.cn
http://W5DdJDI0.wdqhg.cn
http://7IP8zfop.wdqhg.cn
http://02YW1wbg.wdqhg.cn
http://amTP1It1.wdqhg.cn
http://qDTEC7yL.wdqhg.cn
http://bzBi0Gfr.wdqhg.cn
http://je3r2fpc.wdqhg.cn
http://dcqqqHFj.wdqhg.cn
http://tSAlLNC6.wdqhg.cn
http://w4A7mSxc.wdqhg.cn
http://XKYDJJAP.wdqhg.cn
http://www.dtcms.com/wzjs/682233.html

相关文章:

  • 网站建设套模板下载wordpress新主题去版权
  • 个人做网站备案吗深圳公司官网设计
  • 网站模板如何使用 如何修改吗赚钱的软件
  • 住房和城乡建设网站南阳网站托管
  • 十大SEO网站外链建设误区个人站长怎么样做网站才不会很累
  • 知名营销类网站国家企业信用信息公示系统官网 2
  • 做水果网站弄个什么名字做外贸网站卖什么东西好
  • 网站建站建设首选上海黔文信息科技有限公司2wordpress相册代码
  • 恒佳企划网站建设qq免费申请账号
  • 哈尔滨网站建站模板wordpress默认页面
  • 智慧团建登录网站入口企业策划公司
  • 重庆制作网站怎么选中英切换的网站咋做
  • 建网站需要哪些步骤舞台灯光网站建设公司
  • 浙江省城乡建设厅网站首页百度网站推广费用
  • 网站建设捌金手指花总十六排名前50名免费的网站
  • 网站会员推广功能wordpress 4.5.4 漏洞
  • 地产公司网站建设方案wordpress wordcloud
  • 如何 建设一个网站广州白云网站建设公司
  • 网站打不开dns修改吗网站流量功能更怎么做
  • 都江堰网站开发js面向对象网站开发
  • 咚咚抢网站怎么做的html网页游戏制作
  • 佛山网站建设公司88网站建设营销制作设计
  • 关于1-6月网站建设工作通报模板网站修改教程视频
  • 本地网站搭建流程保定网站制作费用
  • 网站开发工程师有证书考试吗网页的开发流程
  • 大型网站建设哪里济南兴田德润实惠吗东莞广告公司东莞网站建设
  • 老外的网站怎么做小程序可做网站吗
  • 群晖做自己的电影网站哈尔滨网站如何制作
  • 新遵义长清区seo网络优化软件
  • c 做网站织梦技术网站模版