Example usage for org.springframework.security.config.annotation.web.configurers DefaultLoginPageConfigurer DefaultLoginPageConfigurer

List of usage examples for org.springframework.security.config.annotation.web.configurers DefaultLoginPageConfigurer DefaultLoginPageConfigurer

Introduction

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

Prototype

DefaultLoginPageConfigurer

Source Link

Usage

From source file:cn.timeoff.config.hackspring.WebSecurityConfigurerAdapter.java

/**
 * Creates the {@link HttpSecurity} or returns the current instance
 *
 * @return the {@link HttpSecurity}/*www  . j  a v  a2 s .co m*/
 * @throws Exception
 */
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);
    http = new HttpSecurity(objectPostProcessor, authenticationBuilder,
            localConfigureAuthenticationBldr.getSharedObjects());
    http.setSharedObject(UserDetailsService.class, userDetailsService());
    http.setSharedObject(ApplicationContext.class, context);
    http.setSharedObject(ContentNegotiationStrategy.class, contentNegotiationStrategy);
    http.setSharedObject(AuthenticationTrustResolver.class, trustResolver);
    if (!disableDefaults) {
        http.csrf().and().addFilter(new WebAsyncManagerIntegrationFilter()).exceptionHandling().and().headers()
                .and().sessionManagement().and().securityContext().and().requestCache().and().anonymous().and()
                .servletApi().and().apply(new DefaultLoginPageConfigurer<HttpSecurity>()).and().logout();
    }
    configure(http);
    return http;
}

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 w w  w .  j  av a 2  s .  c  om*/
 * @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;
}