Springsecurity之UserDetails

    先上一张图,以下图1所示:spring

                                       

                                                                       图1 UserDetails的类图this

    UserDetails这个类的目的,《Pro Spring Security》的chapter3中,原文,"The interface org.springframework.security.core.userdetails.UserDetails object is the main abstraction in the system, and it’s used to represent a full user in the context of Spring Security. It is also made available to be accessed later in the system from any point that has access to SecurityContext. Normally, developers create their own implementation of this interface to store particular user details they need or want (like email, telephone, address, and so on). Later, they can access this information, which will be encapsulated in the Authentication object, and they can be obtained by calling the getPrincipal method on it"orm

    咱们能够本身实现这个Userdetails接口,保存咱们想要的用户信息,以后将这个UserDetails的实现类放在Authentication中,经过Authentication.getPrincipal()得到。blog

相关文章
相关标签/搜索