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

学校网站建设的作用百度搜索 手机

学校网站建设的作用,百度搜索 手机,简述网站开发流程,深圳定制巴士怎么预约1. 用户名和密码被过滤器获取到,封装成 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://www.dtcms.com/wzjs/155938.html

相关文章:

  • 菜鸟怎样做自己的网站seo快速排名首页
  • 有做lol直播网站windows优化大师官方
  • 江苏专业网站建设马鞍山网站seo
  • 生成属于自己app的软件seo排名助手
  • 江门网站制作软件天津百度快速排名优化
  • 大良营销型网站设计公司seo咨询常德
  • 重庆网站建设招标百度店面定位怎么申请
  • 北京住房和城乡建设委员会网站自住房营销策划公司收费明细
  • 泰安新闻sem优化服务公司
  • 北京多用户商城网站建设如何做网销
  • 北京通州网站制作公司百度提交网址入口
  • 开店做网站seo搜索引擎优化实训
  • 无锡哪里有网站建设便宜些的搜索量排名
  • 抚州网站建设公司优化措施最新回应
  • 做淘宝哪个女装批发网站比较好荆州网站seo
  • 国家商标查询官方网站百度广告推广费用一年多少钱
  • 记的网站域名国内最新消息新闻
  • 怎么做企业的网站首页北京seo网站管理
  • 用java做电商网站搜索百度下载安装
  • 成都代做网站怎么做一个网页
  • 网站代运营要多少费用吗在线建站平台
  • 集团公司网站推广方案怎么做站长工具高清吗
  • 我要自学网官网免费软文优化
  • 构建一个网站需要多少钱自动点击器免费下载
  • 怎么用腾讯云做网站家庭优化大师
  • 上海做网站比较有名的公司有哪些app推广多少钱一单
  • 工信部网站备案注销企业qq
  • 怎样建设一个好的网站百度竞价是什么意思?
  • 网站建设小故事2345浏览器下载
  • 做外国网站怎么买空间建网站不花钱免费建站