Rev 230 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 216 | espaco | 1 | package br.com.ec.controller.seguranca; |
| 2 | |||
| 3 | import org.springframework.beans.factory.annotation.Autowired; |
||
| 4 | import org.springframework.context.annotation.Bean; |
||
| 5 | import org.springframework.context.annotation.Configuration; |
||
| 242 | espaco | 6 | //import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; |
| 7 | //import org.springframework.security.config.annotation.web.builders.HttpSecurity; |
||
| 8 | //import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; |
||
| 9 | //import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; |
||
| 216 | espaco | 10 | import org.springframework.security.core.userdetails.UserDetailsService; |
| 242 | espaco | 11 | //import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; |
| 12 | //import org.springframework.security.crypto.password.PasswordEncoder; |
||
| 216 | espaco | 13 | |
| 242 | espaco | 14 | //@Configuration |
| 15 | //@EnableWebSecurity |
||
| 16 | public class SecurityConfig /*extends WebSecurityConfigurerAdapter */{ |
||
| 216 | espaco | 17 | |
| 218 | espaco | 18 | // @Autowired |
| 19 | // private UserDetailsService userDetailsService; |
||
| 20 | |||
| 21 | // @Autowired |
||
| 22 | // private SistemaAuthenticationProvider sistemaAuthenticationProvider; |
||
| 216 | espaco | 23 | |
| 218 | espaco | 24 | // @Override |
| 25 | // protected void configure(AuthenticationManagerBuilder auth) throws Exception { |
||
| 26 | // auth.authenticationProvider(sistemaAuthenticationProvider); |
||
| 27 | // auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder()); |
||
| 28 | /* |
||
| 216 | espaco | 29 | auth.inMemoryAuthentication() |
| 30 | .passwordEncoder(passwordEncoder()) |
||
| 31 | .withUser("user").password(passwordEncoder().encode("123456")).roles("USER") |
||
| 32 | .and() |
||
| 33 | .withUser("admin").password(passwordEncoder().encode("123456")).roles("USER", "ADMIN") |
||
| 34 | .and() |
||
| 35 | .withUser("bruno").password(passwordEncoder().encode("brunolp0910")).roles("USER", "ADMIN"); |
||
| 218 | espaco | 36 | */ |
| 37 | // } |
||
| 242 | espaco | 38 | |
| 39 | /* |
||
| 216 | espaco | 40 | @Bean |
| 41 | public PasswordEncoder passwordEncoder() { |
||
| 42 | return new BCryptPasswordEncoder(); |
||
| 43 | } |
||
| 44 | |||
| 45 | @Override |
||
| 46 | protected void configure(HttpSecurity http) throws Exception { |
||
| 47 | http.authorizeRequests() |
||
| 218 | espaco | 48 | .antMatchers("/sistema/login**").permitAll() |
| 49 | .antMatchers("/sistema/**").authenticated() |
||
| 216 | espaco | 50 | .and().authorizeRequests() |
| 51 | .and() |
||
| 52 | .formLogin() |
||
| 53 | .loginPage("/sistema/login.xhtml") |
||
| 224 | espaco | 54 | .defaultSuccessUrl("/sistema/pagina_inicial.xhtml") |
| 55 | .failureUrl("/sistema/login.xhtml?login_error=1") |
||
| 226 | espaco | 56 | .loginProcessingUrl("/login").permitAll() |
| 216 | espaco | 57 | .and() |
| 218 | espaco | 58 | .logout().logoutUrl("/sistema_security_logout").logoutSuccessUrl("/sistema/login.xhtml?logout=true").invalidateHttpSession(true).permitAll() |
| 216 | espaco | 59 | .and().csrf().disable(); |
| 60 | } |
||
| 242 | espaco | 61 | */ |
| 216 | espaco | 62 | } |