[英]Why does principal returns as type Object in spring security?
I have added blocking user functionality on the site. 我在网站上添加了阻止用户功能。
I add isBlocked
to my UserModel
. 我将
isBlocked
添加到我的UserModel
。 When I user try to login - this fields checks. 当我尝试登录时-此字段会检查。
Problem retains for already logged user. 问题保留给已登录的用户。 I want to force log out it when admin block user.
我想在管理员阻止用户时强制注销它。
I have read following topic: 我已阅读以下主题:
How do you log out all logged in users in spring-security? 如何在spring-security中注销所有已登录的用户?
But I have not ideas how to check that principal( java.lang.Object
actually) related with user. 但是我不知道如何检查与用户相关的主体(实际上是
java.lang.Object
)。
The principal is the object that you have to use in order to identify a user. 委托人是您用来识别用户的对象。 Once identified you can expired the session of that user.
确定后,您可以使该用户的会话过期。 Here you will find a nice explanation on what a Principal is in Spring.
在这里,您将找到关于春季校长的很好的解释。
You can cast the principal to the appropriate Class, but you have to know it before. 您可以将主体转换为适当的类,但是您必须事先知道。 The Class of the principal could be
org.springframework.security.core.userdetails.User
or whatever, it depends on how you are using SpringSecurity. 主体的类可以是
org.springframework.security.core.userdetails.User
或其他任何类,这取决于您如何使用SpringSecurity。
A quick way to know what is the correct Class is debugging the solution commented in the link you provided. 知道什么是正确的类的快速方法是调试您提供的链接中注释的解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.