use of jakarta.servlet.Filter in project spring-security by spring-projects.
the class WebSecurity method getRequestMatcherPrivilegeEvaluatorsEntry.
private RequestMatcherEntry<List<WebInvocationPrivilegeEvaluator>> getRequestMatcherPrivilegeEvaluatorsEntry(SecurityFilterChain securityFilterChain) {
List<WebInvocationPrivilegeEvaluator> privilegeEvaluators = new ArrayList<>();
for (Filter filter : securityFilterChain.getFilters()) {
if (filter instanceof FilterSecurityInterceptor) {
DefaultWebInvocationPrivilegeEvaluator defaultWebInvocationPrivilegeEvaluator = new DefaultWebInvocationPrivilegeEvaluator((FilterSecurityInterceptor) filter);
defaultWebInvocationPrivilegeEvaluator.setServletContext(this.servletContext);
privilegeEvaluators.add(defaultWebInvocationPrivilegeEvaluator);
continue;
}
if (filter instanceof AuthorizationFilter) {
AuthorizationManager<HttpServletRequest> authorizationManager = ((AuthorizationFilter) filter).getAuthorizationManager();
privilegeEvaluators.add(new AuthorizationManagerWebInvocationPrivilegeEvaluator(authorizationManager));
}
}
return new RequestMatcherEntry<>(securityFilterChain::matches, privilegeEvaluators);
}
use of jakarta.servlet.Filter in project atmosphere by Atmosphere.
the class MeteorServlet method init.
@Override
public void init(final ServletConfig sc) throws ServletException {
if (!framework().isInit) {
super.init(sc);
if (delegate == null) {
loadDelegateViaConfig(sc);
} else {
ReflectorServletProcessor r = new ReflectorServletProcessor(delegate);
for (Filter f : filters) {
r.addFilter(f);
}
framework().getBroadcasterFactory().remove(delegateMapping);
framework().addAtmosphereHandler(delegateMapping, r);
framework().checkWebSocketSupportState();
}
}
}
use of jakarta.servlet.Filter in project atmosphere by Atmosphere.
the class ReflectorServletProcessor method loadFilterInstances.
private void loadFilterInstances(ServletConfig sc) {
for (Filter f : filters) {
FilterConfigImpl fc = new FilterConfigImpl(sc);
fc.setFilter(f);
fc.setFilterName(f.getClass().getSimpleName());
filterChain.addFilter(fc);
logger.info("Installing Filter {}", f.getClass().getSimpleName());
}
}
use of jakarta.servlet.Filter in project atmosphere by Atmosphere.
the class AtmosphereFilterChain method doFilter.
/**
* Invoke the next filter in this chain, passing the specified request
* and response. If there are no more filters in this chain, invoke
* the <code>service()</code> method of the servlet itself.
*
* @param request The servlet request we are processing
* @param response The servlet response we are creating
* @throws IOException if an input/output error occurs
* @throws ServletException if a servlet exception occurs
*/
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
// Call the next filter if there is one
AtomicInteger pos = ((AtomicInteger) request.getAttribute("pos"));
if (pos.get() < n) {
FilterConfigImpl filterConfig = filters[pos.getAndIncrement()];
Filter filter = null;
try {
filter = filterConfig.getFilter();
filter.doFilter(request, response, this);
} catch (IOException e) {
throw e;
} catch (ServletException e) {
throw e;
} catch (RuntimeException e) {
throw e;
} catch (Throwable e) {
throw new ServletException("Throwable", e);
}
return;
}
try {
if (servlet != null) {
servlet.service(request, response);
} else {
RequestDispatcher rd = configImpl.getServletContext().getNamedDispatcher("default");
if (rd == null) {
throw new ServletException("No Servlet Found");
}
rd.forward(request, response);
}
} catch (IOException e) {
throw e;
} catch (ServletException e) {
throw e;
} catch (RuntimeException e) {
throw e;
} catch (Throwable e) {
throw new ServletException("Throwable", e);
}
}
use of jakarta.servlet.Filter in project spring-security by spring-projects.
the class HttpInterceptUrlTests method loadConfig.
private void loadConfig(String... configLocations) {
for (int i = 0; i < configLocations.length; i++) {
configLocations[i] = getClass().getName().replaceAll("\\.", "/") + "-" + configLocations[i];
}
XmlWebApplicationContext context = new XmlWebApplicationContext();
context.setConfigLocations(configLocations);
context.setServletContext(new MockServletContext());
context.refresh();
this.context = context;
context.getAutowireCapableBeanFactory().autowireBean(this);
Filter springSecurityFilterChain = context.getBean("springSecurityFilterChain", Filter.class);
this.mockMvc = MockMvcBuilders.standaloneSetup(new FooController()).addFilters(springSecurityFilterChain).build();
}
Aggregations