spring-security(六)

spring-security(六)

摘自《pro spring security》基于spring security 4.2.2.RELEASE

认证对象(The Authentication Object)

Authentication object就是登陆到系统的对象的一种抽象。大体来讲,像用户(user),通常只有用户需要认证。Authentication object在spring security框架中有一些默认的实现类。

这里写图片描述

一般的,在创建认证请求的时候就会使用到Authentication object,携带了不同层次和类的在这框架中的请求数据,当校验通过,这个Authentication object又包含了已经认证过实体的信息,并且将它存储在SecurityContext上下文中。通常情况下,当你登陆到一个应用的时候,这个Authentication object会被创建,并且存储了你的username,passwordpermissions,用技术的角度上讲熟悉的称为Principal,CredentialsAuthorities:

public interface Authentication extends Principal, Serializable {

    Collection<? extends GrantedAuthority> getAuthorities();

    Object getCredentials();

    Object getDetails();

    Object getPrincipal();

    boolean isAuthenticated();

    void setAuthenticated(boolean isAuthenticated) throws IllegalArgumentException;
}
  • UsernamePasswordAuthenticationToken.:: 一种简单的实现,顾名思义,这个类包含了用户名和密码,也是系统中最普遍的Authentication接口的实现,像AuthenticationProvider大多是直接依赖这个类
  • PreAuthenticatedAuthenticationToken: 这个是为了预认证Authentication objects而存在的。预认证的过程实际上是外部系统认证的过程,spring security仅仅是给外部系统提供解析用户身份(Principal)信息
  • RunAsUserToken: 通常是在Security Interceptor中的RunAsManager才会使用到,是因为访问资源所包含的ConfigAttribute中是RUN_AS_为前缀的,如果确实包含了这个值,RunAsManager会根据RUN_AS的值给认证的用户创建GrantedAuthorities
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值