Java 类org.springframework.web.filter.GenericFilterBean 实例源码

项目:whisper    文件:FilterConfiguration.java   
@Bean
public Filter security(){
    return new GenericFilterBean() {

        @Override
        public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {

            HttpServletRequest servletRequest = (HttpServletRequest) request;
            HttpServletResponse servletResponse = (HttpServletResponse) response;

            if (!servletRequest.getRequestURI().startsWith("/ui/")){
                chain.doFilter(request , response);
                return;
            }

            String sessionId = servletRequest.getSession(true).getId();

            if (!usersManager.findUserBySessionId(sessionId).isPresent()){
                servletResponse.sendError(401);
            }else{
                chain.doFilter(request , response);
            }
        }

    };
}
项目:superfly    文件:InsufficientAuthenticationAccessDecisionManagerTest.java   
private GenericFilterBean createFilter() {
    return new GenericFilterBean() {
        public void doFilter(ServletRequest request, ServletResponse response,
                FilterChain chain) throws IOException, ServletException {
        }
    };
}
项目:cloudbreak    文件:AppConfig.java   
@Bean
public FilterRegistrationBean turnOnStackUnderOperationService() {
    FilterRegistrationBean registration = new FilterRegistrationBean();
    registration.setFilter(new GenericFilterBean() {
        @Override
        public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
            stackUnderOperationService.on();
            chain.doFilter(request, response);
            stackUnderOperationService.off();
        }
    });
    registration.addUrlPatterns("/*");
    return registration;
}