Search in sources :

Example 1 with ResourceUrlProviderExposingInterceptor

use of org.springframework.web.servlet.resource.ResourceUrlProviderExposingInterceptor in project spring-framework by spring-projects.

the class WebMvcConfigurationSupport method getInterceptors.

/**
	 * Provide access to the shared handler interceptors used to configure
	 * {@link HandlerMapping} instances with. This method cannot be overridden,
	 * use {@link #addInterceptors(InterceptorRegistry)} instead.
	 */
protected final Object[] getInterceptors() {
    if (this.interceptors == null) {
        InterceptorRegistry registry = new InterceptorRegistry();
        addInterceptors(registry);
        registry.addInterceptor(new ConversionServiceExposingInterceptor(mvcConversionService()));
        registry.addInterceptor(new ResourceUrlProviderExposingInterceptor(mvcResourceUrlProvider()));
        this.interceptors = registry.getInterceptors();
    }
    return this.interceptors.toArray();
}
Also used : ResourceUrlProviderExposingInterceptor(org.springframework.web.servlet.resource.ResourceUrlProviderExposingInterceptor) ConversionServiceExposingInterceptor(org.springframework.web.servlet.handler.ConversionServiceExposingInterceptor)

Example 2 with ResourceUrlProviderExposingInterceptor

use of org.springframework.web.servlet.resource.ResourceUrlProviderExposingInterceptor in project spring-framework by spring-projects.

the class WebMvcConfigurationSupport method resourceHandlerMapping.

/**
	 * Return a handler mapping ordered at Integer.MAX_VALUE-1 with mapped
	 * resource handlers. To configure resource handling, override
	 * {@link #addResourceHandlers}.
	 */
@Bean
public HandlerMapping resourceHandlerMapping() {
    ResourceHandlerRegistry registry = new ResourceHandlerRegistry(this.applicationContext, this.servletContext, mvcContentNegotiationManager());
    addResourceHandlers(registry);
    AbstractHandlerMapping handlerMapping = registry.getHandlerMapping();
    if (handlerMapping != null) {
        handlerMapping.setPathMatcher(mvcPathMatcher());
        handlerMapping.setUrlPathHelper(mvcUrlPathHelper());
        handlerMapping.setInterceptors(new ResourceUrlProviderExposingInterceptor(mvcResourceUrlProvider()));
        handlerMapping.setCorsConfigurations(getCorsConfigurations());
    } else {
        handlerMapping = new EmptyHandlerMapping();
    }
    return handlerMapping;
}
Also used : ResourceUrlProviderExposingInterceptor(org.springframework.web.servlet.resource.ResourceUrlProviderExposingInterceptor) AbstractHandlerMapping(org.springframework.web.servlet.handler.AbstractHandlerMapping) Bean(org.springframework.context.annotation.Bean)

Example 3 with ResourceUrlProviderExposingInterceptor

use of org.springframework.web.servlet.resource.ResourceUrlProviderExposingInterceptor in project spring-framework by spring-projects.

the class WebMvcConfigurationSupport method getInterceptors.

/**
 * Provide access to the shared handler interceptors used to configure
 * {@link HandlerMapping} instances with.
 * <p>This method cannot be overridden; use {@link #addInterceptors} instead.
 */
protected final Object[] getInterceptors(FormattingConversionService mvcConversionService, ResourceUrlProvider mvcResourceUrlProvider) {
    if (this.interceptors == null) {
        InterceptorRegistry registry = new InterceptorRegistry();
        addInterceptors(registry);
        registry.addInterceptor(new ConversionServiceExposingInterceptor(mvcConversionService));
        registry.addInterceptor(new ResourceUrlProviderExposingInterceptor(mvcResourceUrlProvider));
        this.interceptors = registry.getInterceptors();
    }
    return this.interceptors.toArray();
}
Also used : ResourceUrlProviderExposingInterceptor(org.springframework.web.servlet.resource.ResourceUrlProviderExposingInterceptor) ConversionServiceExposingInterceptor(org.springframework.web.servlet.handler.ConversionServiceExposingInterceptor)

Example 4 with ResourceUrlProviderExposingInterceptor

use of org.springframework.web.servlet.resource.ResourceUrlProviderExposingInterceptor in project dhis2-core by dhis2.

the class MvcTestConfig method requestMappingHandlerMapping.

@Bean
public CustomRequestMappingHandlerMapping requestMappingHandlerMapping(FormattingConversionService mvcConversionService, ResourceUrlProvider mvcResourceUrlProvider) {
    CustomPathExtensionContentNegotiationStrategy pathExtensionNegotiationStrategy = new CustomPathExtensionContentNegotiationStrategy(mediaTypeMap);
    pathExtensionNegotiationStrategy.setUseRegisteredExtensionsOnly(true);
    ContentNegotiationManager manager = new ContentNegotiationManager(Arrays.asList(pathExtensionNegotiationStrategy, new HeaderContentNegotiationStrategy(), new FixedContentNegotiationStrategy(MediaType.APPLICATION_JSON)));
    CustomRequestMappingHandlerMapping mapping = new CustomRequestMappingHandlerMapping();
    mapping.setOrder(0);
    mapping.setContentNegotiationManager(manager);
    TestInterceptorRegistry registry = new TestInterceptorRegistry();
    addInterceptors(registry);
    registry.addInterceptor(new ConversionServiceExposingInterceptor(mvcConversionService));
    registry.addInterceptor(new ResourceUrlProviderExposingInterceptor(mvcResourceUrlProvider));
    mapping.setInterceptors(registry.getInterceptors().toArray());
    return mapping;
}
Also used : ContentNegotiationManager(org.springframework.web.accept.ContentNegotiationManager) ResourceUrlProviderExposingInterceptor(org.springframework.web.servlet.resource.ResourceUrlProviderExposingInterceptor) ConversionServiceExposingInterceptor(org.springframework.web.servlet.handler.ConversionServiceExposingInterceptor) CustomRequestMappingHandlerMapping(org.hisp.dhis.webapi.mvc.CustomRequestMappingHandlerMapping) FixedContentNegotiationStrategy(org.springframework.web.accept.FixedContentNegotiationStrategy) HeaderContentNegotiationStrategy(org.springframework.web.accept.HeaderContentNegotiationStrategy) CustomPathExtensionContentNegotiationStrategy(org.hisp.dhis.webapi.view.CustomPathExtensionContentNegotiationStrategy) Bean(org.springframework.context.annotation.Bean)

Example 5 with ResourceUrlProviderExposingInterceptor

use of org.springframework.web.servlet.resource.ResourceUrlProviderExposingInterceptor in project cas by apereo.

the class DefaultLoginWebflowConfigurerTests method verifyOperation.

@Test
public void verifyOperation() {
    assertFalse(casWebflowExecutionPlan.getWebflowConfigurers().isEmpty());
    val interceptors = casWebflowExecutionPlan.getWebflowInterceptors();
    assertEquals(2, interceptors.size());
    assertTrue(interceptors.stream().anyMatch(interceptor -> interceptor instanceof CasLocaleChangeInterceptor));
    assertTrue(interceptors.stream().anyMatch(interceptor -> interceptor instanceof ResourceUrlProviderExposingInterceptor));
    val flow = (Flow) this.loginFlowDefinitionRegistry.getFlowDefinition(CasWebflowConfigurer.FLOW_ID_LOGIN);
    assertNotNull(flow);
    assertTrue(flow.containsState(CasWebflowConstants.STATE_ID_VIEW_LOGIN_FORM));
    assertTrue(flow.containsState(CasWebflowConstants.STATE_ID_INIT_LOGIN_FORM));
    assertTrue(flow.containsState(CasWebflowConstants.STATE_ID_CREATE_TICKET_GRANTING_TICKET));
    assertTrue(flow.containsState(CasWebflowConstants.STATE_ID_SEND_TICKET_GRANTING_TICKET));
    assertTrue(flow.containsState(CasWebflowConstants.STATE_ID_GENERATE_SERVICE_TICKET));
    assertTrue(flow.containsState(CasWebflowConstants.STATE_ID_HANDLE_AUTHN_FAILURE));
    assertTrue(flow.containsState(CasWebflowConstants.STATE_ID_POST_VIEW));
    assertTrue(flow.containsState(CasWebflowConstants.STATE_ID_REDIRECT));
    assertTrue(flow.containsState(CasWebflowConstants.STATE_ID_SERVICE_AUTHZ_CHECK));
    assertTrue(flow.containsState(CasWebflowConstants.STATE_ID_VIEW_GENERIC_LOGIN_SUCCESS));
    assertTrue(flow.containsState(CasWebflowConstants.STATE_ID_VIEW_REDIR_UNAUTHZ_URL));
    assertTrue(flow.containsState(CasWebflowConstants.STATE_ID_VIEW_SERVICE_ERROR));
    assertTrue(flow.containsState(CasWebflowConstants.STATE_ID_GATEWAY_REQUEST_CHECK));
    assertTrue(flow.containsState(CasWebflowConstants.STATE_ID_VIEW_GENERIC_LOGIN_SUCCESS));
}
Also used : lombok.val(lombok.val) CasLocaleChangeInterceptor(org.apereo.cas.web.support.CasLocaleChangeInterceptor) ResourceUrlProviderExposingInterceptor(org.springframework.web.servlet.resource.ResourceUrlProviderExposingInterceptor) MockRequestContext(org.springframework.webflow.test.MockRequestContext) ViewFactory(org.springframework.webflow.execution.ViewFactory) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) ServletExternalContext(org.springframework.webflow.context.servlet.ServletExternalContext) Map(java.util.Map) Tag(org.junit.jupiter.api.Tag) MockServletContext(org.springframework.mock.web.MockServletContext) MockRequestControlContext(org.springframework.webflow.test.MockRequestControlContext) ExternalContextHolder(org.springframework.webflow.context.ExternalContextHolder) lombok.val(lombok.val) Expression(org.springframework.binding.expression.Expression) TestPropertySource(org.springframework.test.context.TestPropertySource) Flow(org.springframework.webflow.engine.Flow) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Action(org.springframework.webflow.execution.Action) Transition(org.springframework.webflow.engine.Transition) Test(org.junit.jupiter.api.Test) Mockito(org.mockito.Mockito) EndState(org.springframework.webflow.engine.EndState) ViewState(org.springframework.webflow.engine.ViewState) Executable(org.junit.jupiter.api.function.Executable) RequestContextHolder(org.springframework.webflow.execution.RequestContextHolder) Assertions(org.junit.jupiter.api.Assertions) ResourceUrlProviderExposingInterceptor(org.springframework.web.servlet.resource.ResourceUrlProviderExposingInterceptor) CasLocaleChangeInterceptor(org.apereo.cas.web.support.CasLocaleChangeInterceptor) Flow(org.springframework.webflow.engine.Flow) Test(org.junit.jupiter.api.Test)

Aggregations

ResourceUrlProviderExposingInterceptor (org.springframework.web.servlet.resource.ResourceUrlProviderExposingInterceptor)6 ConversionServiceExposingInterceptor (org.springframework.web.servlet.handler.ConversionServiceExposingInterceptor)3 lombok.val (lombok.val)2 CasLocaleChangeInterceptor (org.apereo.cas.web.support.CasLocaleChangeInterceptor)2 Assertions (org.junit.jupiter.api.Assertions)2 Tag (org.junit.jupiter.api.Tag)2 Test (org.junit.jupiter.api.Test)2 Bean (org.springframework.context.annotation.Bean)2 Flow (org.springframework.webflow.engine.Flow)2 Map (java.util.Map)1 CustomRequestMappingHandlerMapping (org.hisp.dhis.webapi.mvc.CustomRequestMappingHandlerMapping)1 CustomPathExtensionContentNegotiationStrategy (org.hisp.dhis.webapi.view.CustomPathExtensionContentNegotiationStrategy)1 Executable (org.junit.jupiter.api.function.Executable)1 Mockito (org.mockito.Mockito)1 Expression (org.springframework.binding.expression.Expression)1 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)1 MockServletContext (org.springframework.mock.web.MockServletContext)1 TestPropertySource (org.springframework.test.context.TestPropertySource)1 ContentNegotiationManager (org.springframework.web.accept.ContentNegotiationManager)1