Example usage for org.springframework.security.web.savedrequest HttpSessionRequestCache setRequestMatcher

List of usage examples for org.springframework.security.web.savedrequest HttpSessionRequestCache setRequestMatcher

Introduction

In this page you can find the example usage for org.springframework.security.web.savedrequest HttpSessionRequestCache setRequestMatcher.

Prototype

public void setRequestMatcher(RequestMatcher requestMatcher) 

Source Link

Document

Allows selective use of saved requests for a subset of requests.

Usage

From source file:com.hp.autonomy.frontend.find.core.beanconfiguration.SecurityConfiguration.java

@SuppressWarnings("ProhibitedExceptionDeclared")
@Override//from w ww.  j  a  v  a  2  s  .c o m
protected void configure(final HttpSecurity http) throws Exception {
    final HttpSessionRequestCache requestCache = new HttpSessionRequestCache();
    requestCache.setRequestMatcher(new AntPathRequestMatcher(FindController.APP_PATH));

    http.authorizeRequests().antMatchers("/api/public/**").hasRole(FindRole.USER.name())
            .antMatchers("/api/admin/**").hasRole(FindRole.ADMIN.name()).antMatchers("/api/config/**")
            .hasRole(FindRole.CONFIG.name()).antMatchers("/api/bi/**").hasRole(FindRole.BI.name()).and()
            .requestCache().requestCache(requestCache).and().csrf().disable().headers().defaultsDisabled()
            .frameOptions().sameOrigin();
}

From source file:com.hp.autonomy.frontend.find.hod.beanconfiguration.InMemoryHodSecurity.java

@SuppressWarnings("ProhibitedExceptionDeclared")
@Override//from  ww w  .j a  v a  2  s.c  o  m
protected void configure(final HttpSecurity http) throws Exception {
    final AuthenticationSuccessHandler loginSuccessHandler = new LoginSuccessHandler(FindRole.CONFIG.toString(),
            FindController.CONFIG_PATH, "/p/");
    final HttpSessionRequestCache requestCache = new HttpSessionRequestCache();

    requestCache.setRequestMatcher(new OrRequestMatcher(new AntPathRequestMatcher("/p/**"),
            new AntPathRequestMatcher(FindController.CONFIG_PATH)));

    http.regexMatcher("/p/.*|/config/.*|/authenticate|/logout").authorizeRequests().antMatchers("/p/**")
            .hasRole(FindRole.ADMIN.name()).antMatchers(FindController.CONFIG_PATH)
            .hasRole(FindRole.CONFIG.name()).and().requestCache().requestCache(requestCache).and().formLogin()
            .loginPage(FindController.DEFAULT_LOGIN_PAGE).loginProcessingUrl("/authenticate")
            .successHandler(loginSuccessHandler).failureUrl(FindController.DEFAULT_LOGIN_PAGE + "?error=auth")
            .and().logout()
            .logoutSuccessHandler(new HodLogoutSuccessHandler(
                    new HodTokenLogoutSuccessHandler(SsoController.SSO_LOGOUT_PAGE, tokenRepository),
                    FindController.APP_PATH))
            .and().csrf().disable();
}

From source file:architecture.user.spring.config.SecurityConfig.java

@Bean(name = "authenticationRequestCache")
public HttpSessionRequestCache authenticationRequestCache() {
    HttpSessionRequestCache authenticationRequestCache = new HttpSessionRequestCache();
    authenticationRequestCache.setRequestMatcher(nonAjaxRequestMatcher());
    return authenticationRequestCache;
}