注意:AuthenticationProvider与Authentication紧密联系,关于Authentication,看个人这篇博客。ide
先上一张图,以下图1.net
图1 AuthenticationProvider的类图blog
AuthenticationProvider是个接口,经过实现这个接口,实现拓展,此图来自于《Pro Spring Security》的Chapter3:继承
图2 AuthenticationProvider的继承图接口
来看个例子,DaoAuthenticationProvider,它的类图以下图3,使用了Template pattern,在AbstractUserDetilsAuthenticationProvider中定义执行逻辑,而在DaoAuthenticationProvider中有具体实现。Template pattern能够在必定程度上理解为父类调用子类。get
图3 DaoAuthenticationProvider的类图博客
参考:it
1. Carlo Scarioni, Pro Spring Security.io