I am unable to find how the java.security.Principal in HttpServletRequest is created - who is responsible? How it is done? Is it necessarily kept in Session?
How it is connected to Spring Security?
Are there any alternatives to Spring Security which uses Principal for User authorization/authentication?
How would one implement own user authorization/authentication so that Principal would contain the current user?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
- typically, Principal object putting in the session after successful login.See documentation.
- Springs
Authentication
interface extendsPrincipal
interface - Alternatively you can use Apache Shiro
- Implement own
UserDetailsService
which wil return your User object(it must implement UserDetails interface) See docs.
回答2:
The Principal will be set by Spring Security based upon your Spring Security configuration.
To implement this, please see http://static.springsource.org/spring-security/site/docs/3.1.x/reference/springsecurity.html