Search in sources :

Example 1 with SecurityRequestFilterChain

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);
}
Also used : Response(com.yahoo.application.container.handler.Response) SecurityRequestFilter(com.yahoo.jdisc.http.filter.SecurityRequestFilter) SecurityRequestFilterChain(com.yahoo.jdisc.http.filter.SecurityRequestFilterChain) FilterChainRepository(com.yahoo.container.http.filter.FilterChainRepository)

Aggregations

Response (com.yahoo.application.container.handler.Response)1 FilterChainRepository (com.yahoo.container.http.filter.FilterChainRepository)1 SecurityRequestFilter (com.yahoo.jdisc.http.filter.SecurityRequestFilter)1 SecurityRequestFilterChain (com.yahoo.jdisc.http.filter.SecurityRequestFilterChain)1