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

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

Introduction

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

Prototype

public HttpSecurity userDetailsService(UserDetailsService userDetailsService) throws Exception 

Source Link

Usage

From source file:org.joinfaces.example.SecurityConfig.java

@Override
protected void configure(HttpSecurity http) {
    try {/*from  w  w w  .  ja  v  a  2  s  . c  o m*/
        http.csrf().disable();
        http.userDetailsService(userDetailsService()).authorizeRequests().antMatchers("/").permitAll()
                .antMatchers("/index.jsf").permitAll().antMatchers("/javax.faces.resource/**").permitAll()
                .anyRequest().authenticated().and().formLogin().loginPage("/login.jsf").permitAll()
                .failureUrl("/login.jsf?error=true").defaultSuccessUrl("/index.jsf").and().logout()
                .logoutSuccessUrl("/login.jsf");
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
}