[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