Implementation Mechanism of SSH2 Permission System

Source: Internet
Author: User

[Implementation Mechanism of SSH2 permission system]

Permission control is divided into two parts: page and Background: different types of user accounts are assigned different access permissions. After a user logs on to the system using an account, only the pages with permissions can be viewed on the page, if the user directly enters the link address in the browser, the backend determines whether the user has the permission. If not, the user's request is rejected. For example, there are two modules: personal information management and transaction management. The Administrator creates an account for user a and assigns the account the permission to access the "personal information management" module, after logging on to the system, user a can only see the "personal information management" page and the "transaction management" page. Then, the user may know the path to access "personal information management" and can enter the request address in the browser. At this time, the background Spring AOP intercepts the request and determines whether the user has the permission to access this module, if no, an error message with "no permission" is thrown and then directly returned to the page through the interceptor control.

1. The method of page permission control is relatively simple: After Successful Logon, all permissions of the user are put into the session. When the user accesses the JSP page, the user obtains permissions from the session, in the onload event, traverse the page tag and compare the permission in the session to determine whether the tag is valid. If the tag is invalid, it is not displayed or set to disable. If the tag is valid, it is displayed to the user.

2. the backend implements permission control using the interceptor and AOP mechanisms: AOP filters access permissions and throws an exception if you do not have the permission. the interceptor captures exceptions and returns the corresponding error message to the page.

Spring AOP verifies whether the user has the permission to access a method before the user accesses a method of action. If the user can access the method, the user is allowed. Otherwise, a custom exception with no permission is thrown, the struts2 interceptor then captures exceptions and sends the "no access permission" error message to the page.

 

From: http://blessht.iteye.com/blog/1130679

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.