Home > Java > javaTutorial > Examples to explain shiro login authentication and permission control

Examples to explain shiro login authentication and permission control

怪我咯
Release: 2017-06-23 11:59:21
Original
1688 people have browsed it

1. The implementation class inherits AuthorizingRealm

1. Implement the method doGetAuthenticationInfo and fill in map, realmPrincipals with the defined user entity class;

2. Implement the method doGetAuthorizationInfo and fill in roles and Permissions;

Second, create subject

Provide SecurityUtils getSubject method to create, securityManager.createSubject, and confirm in SubjectContext that securityManager, session and PrincipalCollection already exist in the map. Finally, DefaultWebSubjectFactory creates webDelegatingSubject and saves it in session.

3. Login verification

Login creation, the DelegatingSubject login method executes securityManager login, and the creation is the same as the second step.

4. Logout

The DelegatingSubject logout method executes the securityManager logout, deletes the subject in the session, and stops the session.

5. About ModularRealmAuthenticator

The ModularRealmAuthenticator class is setRealms when the project starts (defined in the first step, is not clear why is injected when the project starts), and the doSingleRealmAuthentication method calls realm doGetAuthorizationInfo

The above is the detailed content of Examples to explain shiro login authentication and permission control. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template