Example usage for org.springframework.security.config.annotation.web.builders HttpSecurity HttpSecurity

List of usage examples for org.springframework.security.config.annotation.web.builders HttpSecurity HttpSecurity

Introduction

In this page you can find the example usage for org.springframework.security.config.annotation.web.builders HttpSecurity HttpSecurity.

Prototype

@SuppressWarnings("unchecked")
public HttpSecurity(ObjectPostProcessor<Object> objectPostProcessor,
        AuthenticationManagerBuilder authenticationBuilder,
        Map<Class<? extends Object>, Object> sharedObjects) 

Source Link

Document

Creates a new instance

Usage

From source file:org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter.java

/**
 * Creates the {@link HttpSecurity} or returns the current instance
 *
 * ] * @return the {@link HttpSecurity}//from   ww  w .  ja va  2s  .co  m
 * @throws Exception
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
protected final HttpSecurity getHttp() throws Exception {
    if (http != null) {
        return http;
    }

    DefaultAuthenticationEventPublisher eventPublisher = objectPostProcessor
            .postProcess(new DefaultAuthenticationEventPublisher());
    localConfigureAuthenticationBldr.authenticationEventPublisher(eventPublisher);

    AuthenticationManager authenticationManager = authenticationManager();
    authenticationBuilder.parentAuthenticationManager(authenticationManager);
    authenticationBuilder.authenticationEventPublisher(eventPublisher);
    Map<Class<? extends Object>, Object> sharedObjects = createSharedObjects();

    http = new HttpSecurity(objectPostProcessor, authenticationBuilder, sharedObjects);
    if (!disableDefaults) {
        // @formatter:off
        http.csrf().and().addFilter(new WebAsyncManagerIntegrationFilter()).exceptionHandling().and().headers()
                .and().sessionManagement().and().securityContext().and().requestCache().and().anonymous().and()
                .servletApi().and().apply(new DefaultLoginPageConfigurer<>()).and().logout();
        // @formatter:on
        ClassLoader classLoader = this.context.getClassLoader();
        List<AbstractHttpConfigurer> defaultHttpConfigurers = SpringFactoriesLoader
                .loadFactories(AbstractHttpConfigurer.class, classLoader);

        for (AbstractHttpConfigurer configurer : defaultHttpConfigurers) {
            http.apply(configurer);
        }
    }
    configure(http);
    return http;
}