In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Xiaobian to share with you how Apache shiro single sign-in, I believe most people still do not know how, so share this article for your reference, I hope you have a lot of harvest after reading this article, let's go to understand it together!
1. Assuming that you are using Apache shrio and that the project requires that only one user can exist on an account at a time, you should add the following code to your shiro configuration file:
Next, you should add the following code to your realm, which is mainly to determine whether the user logged in to the account has already logged in.
@Autowired private SessionDAO sessionDAO; ...............
Next, you should get all the logged in accounts in the cache of shiro in realm to determine whether the current user has logged in.
//apache shiro Get all online users Collection sessions = sessionDAO.getActiveSessions(); for(Session session:sessions){ String loginUsername = String.valueOf(session.getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY));//Get the name of the logged in user in the session if(username.equals(loginUsername)){ //username here is the username of the current login session.setTimeout(0); //This clears the session, } }
2.SessionManager
Here is a possible bug that can be resolved by configuring the sessionId Cookie property to override the session ID in the cookie by the server
That's all for "Apache shiro how to single sign-on", thanks for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.