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.