package ameba.security.shiro.filters;

import org.apache.shiro.util.ThreadContext;

import javax.annotation.Priority;
import javax.inject.Singleton;
import javax.ws.rs.Priorities;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.PreMatching;

/**
 * @author icode
 */
@Priority(Priorities.AUTHENTICATION)
@PreMatching
@Singleton
public class ShiroContainerFilter extends OncePerContainerFilter {

    @Override
    public void doFilter(ContainerRequestContext containerRequestContext) {
        ThreadContext.bind(createSubject());
    }
}
@@ -256,27 +256,110 @@
 ntainer.
-PreMatching
+ContainerResponseContext;%0Aimport javax.ws.rs.container.PreMatching;%0Aimport java.io.IOException
 ;%0A%0A/**%0A 
@@ -647,10 +647,191 @@
 );%0A    %7D
+%0A%0A    @Override%0A    public void doFilter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException %7B%0A        ThreadContext.remove();%0A    %7D
 %0A%7D

整合 session