`
zsjg13
  • 浏览: 138923 次
  • 性别: Icon_minigender_1
  • 来自: 安徽
社区版块
存档分类
最新评论

用户凭据是在哪里进行验证的(Where do the user's credentials get validate?)

 
阅读更多

<authentication-manager alias="authenticationManager">
    <authentication-provider>
        <user-service>
            <user authorities="ROLE_USER" name="guest"     password="guest"/>
        </user-service>
    </authentication-provider>
</authentication-manager>

 

我们并没有显式地为这个AuthenticationProvider装配任何实现,并且我们再一次看到 security namespace handler完成了大量死记硬背的配置工作。请记住AuthenticationManager的默认实现支持配置一到多个AuthenticationProvider实现。<authentication-provider>声明将默认实例化out of the box实现(就是o.s.s.authentication.dao.DaoAuthenticationProvider),并自动装配到AuthenticationManager中去。

 

DaoAuthenticationProvider提供了一个瘦包装器(a thin wrapper)来实现AuthenticationProvider接口,然后委托给o.s.s.core.userdetails.UserDetailsService接口的实现类。UserDetailsService负责返回一个o.s.s.core.userdetails.UserDetails的实现。

 

 

如果你查看一下UserDetails的Javadoc,你将注意到它和Authentication接口很相似。不要困惑,尽管它们有很多重叠的地方(在方法名称上和功能上),但目的相当的不一样。

 

<user-service>触发了对o.s.s.core.userdetails.memory.InMemoryDaoImpl(它是UserDetailsService的一个实现)的配置。正如你预期的,该实现将XML安全配置文件中的配置的用户存储在驻留于内存的数据存储中。该service的配置支持其他属性以便允许账户被禁用或锁住。

 

大多数Spring Security例子要么是使用in-memory user credentials store或JDBC(也就是数据库)credential store.

0
1
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics