use of com.yahoo.jdisc.http.filter.SecurityRequestFilterChain in project vespa by vespa-engine.
the class ContainerTester method invokeSecurityFilters.
// Hack to run request filters as part of the request processing chain.
// Limitation: Bindings ignored, disc filter request wrapper only support limited set of methods.
private FilterResult invokeSecurityFilters(Request request) {
FilterChainRepository filterChainRepository = (FilterChainRepository) container.components().getComponent(FilterChainRepository.class.getName());
SecurityRequestFilterChain chain = (SecurityRequestFilterChain) filterChainRepository.getFilter(ComponentSpecification.fromString("default"));
for (SecurityRequestFilter securityRequestFilter : chain.getFilters()) {
ApplicationRequestToDiscFilterRequestWrapper discFilterRequest = new ApplicationRequestToDiscFilterRequestWrapper(request);
ResponseHandlerToApplicationResponseWrapper responseHandlerWrapper = new ResponseHandlerToApplicationResponseWrapper();
securityRequestFilter.filter(discFilterRequest, responseHandlerWrapper);
request = discFilterRequest.getUpdatedRequest();
Optional<Response> filterResponse = responseHandlerWrapper.toResponse();
if (filterResponse.isPresent()) {
return new FilterResult(request, filterResponse.get());
}
}
return new FilterResult(request, null);
}
Aggregations