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