Business logic: Five, complete authentication user's dynamic authorization function vi. complete Shiro integration Ehcache cache permissions Data

Source: Internet
Author: User

One complete the dynamic authorization function for authenticated users

Tip: According to the current authenticated user query database, get their corresponding permissions, for their authorization

Operation Steps:

    1. In realm 's authorization method , get to the currently logged-in user by using the Principals object
    2. Create an authorization information object
    3. List of roles based on user query and traverse list of roles
    4. Add role keywords to the role properties of the authorization information object in the loop body
    5. According to the user query permission list, and traverse the permission list
    6. Add a permission keyword to the permission property of an authorization information object in the loop body
    7. Determine whether a user is a system administrator based on the user query role and permissions method in the role and Permissions service class
    8. If the system administrator queries out all roles and permissions
    9. If not, the corresponding roles and permissions are based on the user's query

One complete S Hiro Integration E Hcache Cache Permission Data

hint: introduce Ehcache dependency, provide ehcache core configuration file, configure Cache Manager object and inject to Security Manager object

Operation Steps:

    1. introducing The coordinates of Ehcache in Pom.xml
    2. provides core configuration files for Ehcache
    3. registering a Ehcache Cache Manager object in the spring configuration file, injecting the Ehcache core profile path to the Cache manager Object
    4. in the Configure the Cache Manager property for the Ehcache cache Manager object in the Shiro security Manager

Business logic: Five, complete authentication user's dynamic authorization function vi. complete Shiro integration Ehcache cache permissions Data

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.