Shiro内置过滤器

Posted mozq

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Shiro内置过滤器相关的知识,希望对你有一定的参考价值。

Shiro内置过滤器

DefaultFilter 枚举类定义了shiro所有的默认过滤器。

package org.apache.shiro.web.filter.mgt;
public enum DefaultFilter {

    anon(AnonymousFilter.class),
    authc(FormAuthenticationFilter.class),
    authcBasic(BasicHttpAuthenticationFilter.class),
    logout(LogoutFilter.class),
    noSessionCreation(NoSessionCreationFilter.class),
    perms(PermissionsAuthorizationFilter.class),
    port(PortFilter.class),
    rest(HttpMethodPermissionFilter.class),
    roles(RolesAuthorizationFilter.class),
    ssl(SslFilter.class),
    user(UserFilter.class);

    private final Class<? extends Filter> filterClass;

    private DefaultFilter(Class<? extends Filter> filterClass) {
        this.filterClass = filterClass;
    }
}

打印枚举类:

public static void main(String[] args) {
    for(DefaultFilter filter :DefaultFilter.values()){
        System.out.println(filter.name() + ":" + filter.getFilterClass().getName());
    }
}
anon:org.apache.shiro.web.filter.authc.AnonymousFilter
authc:org.apache.shiro.web.filter.authc.FormAuthenticationFilter
authcBasic:org.apache.shiro.web.filter.authc.BasicHttpAuthenticationFilter
logout:org.apache.shiro.web.filter.authc.LogoutFilter
noSessionCreation:org.apache.shiro.web.filter.session.NoSessionCreationFilter
perms:org.apache.shiro.web.filter.authz.PermissionsAuthorizationFilter
port:org.apache.shiro.web.filter.authz.PortFilter
rest:org.apache.shiro.web.filter.authz.HttpMethodPermissionFilter
roles:org.apache.shiro.web.filter.authz.RolesAuthorizationFilter
ssl:org.apache.shiro.web.filter.authz.SslFilter
user:org.apache.shiro.web.filter.authc.UserFilter

以上是关于Shiro内置过滤器的主要内容,如果未能解决你的问题,请参考以下文章

shiro原理之过滤器

理解这9大内置过滤器,才算是精通Shiro

理解这9大内置过滤器,才算是精通Shiro

Shiro权限总结

Apache Shrio安全框架

全栈编程系列SpringBoot整合Shiro(含KickoutSessionControlFilter并发在线人数控制以及不生效问题配置启动异常No SecurityManager...)(代码片段