Shiro permission Verification Code record, correctly find where shiro framework has done permission identification, shiro framework

Source: Internet
Author: User

Shiro permission Verification Code record, correctly find where shiro framework has done permission identification, shiro framework

Authorization code:

Org. apache. shiro. web. servlet. AdviceFilter is the parent class of all shiro framework default permission verification instance classes.

Verification Code:

Public void doFilterInternal (ServletRequest request, ServletResponse response, FilterChain chain)
Throws ServletException, IOException {

Exception exception = null;

Try {

// The following code is used for permission verification.

    Boolean continueChain = preHandle (request, response );
If (log. isTraceEnabled ()){
Log. trace ("Invoked preHandle method. Continuing chain? : ["+ ContinueChain +"] ");
}

// Jump to the next filter after the verification is passed

If (continueChain ){
ExecuteChain (request, response, chain );
}

PostHandle (request, response );
If (log. isTraceEnabled ()){
Log. trace ("Successfully invoked postHandle method ");
}

} Catch (Exception e ){
Exception = e;
} Finally {
Cleanup (request, response, exception );
}
}

 

Default permission verification categories include:

anon -- org.apache.shiro.web.filter.authc.AnonymousFilterauthc -- org.apache.shiro.web.filter.authc.FormAuthenticationFilterauthcBasic -- org.apache.shiro.web.filter.authc.BasicHttpAuthenticationFilterperms -- org.apache.shiro.web.filter.authz.PermissionsAuthorizationFilterport -- org.apache.shiro.web.filter.authz.PortFilterrest -- org.apache.shiro.web.filter.authz.HttpMethodPermissionFilterroles -- org.apache.shiro.web.filter.authz.RolesAuthorizationFilterssl -- org.apache.shiro.web.filter.authz.SslFilteruser -- org.apache.shiro.web.filter.authc.UserFilterlogout -- org.apache.shiro.web.filter.authc.LogoutFilter

Anon: Example/admins/** = anon has no parameter, indicating that it can be used anonymously. Authc: for example,/admins/user/** = authc indicates that you need to authenticate (Log On) for use. No parameter roles: Example/admins/user/** = roles [admin], multiple parameters can be written. When multiple parameters are entered, quotation marks must be added and the parameters are separated by commas. When multiple parameters exist, for example, admins/user/** = roles ["admin, guest "]. Each passing parameter is passed, which is equivalent to the hasAllRoles () method. Perms: Example/admins/user/** = perms [user: add: *]. You can write multiple parameters. If there are multiple parameters, quotation marks must be added and the parameters are separated by commas, for example,/admins/user/** = perms ["user: add: *, user: modify: *"]. When multiple parameters exist, each parameter must pass, the isPermitedAll () method. Rest: Example/admins/user/** = rest [user]. According to the request method, it is equivalent to/admins/user/** = perms [user: method]. the method is post, get, and delete. Port: Example/admins/user/** = port [8081]. When the request url port is not 8081, It is redirected to schemal: // serverName: 8081? QueryString, where schmal is the protocol http or https, serverName is the host you visit, 8081 is the port in the url configuration, and queryString is in the url you visit? Parameters. AuthcBasic: for example,/admins/user/** = authcBasic No parameter indicates httpBasic-certified ssl: Example/admins/user/** = ssl No parameter indicates a secure url request, the Protocol is https user: for example,/admins/user/** = user. No parameter indicates that a user must exist. No check is performed during login.


 

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.