daily pastebin goal
61%
SHARE
TWEET

SecurityConfig.java

a guest May 7th, 2014 165 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @EnableWebMvcSecurity
  2. @Configuration
  3. public class SecurityConfig extends WebSecurityConfigurerAdapter
  4. {
  5.    
  6.     @Inject
  7.     private UserDetailsServiceImpl userDetailsService;
  8.  
  9.     @Override
  10.     public void configure(WebSecurity webSecurity) throws Exception {
  11.         webSecurity.ignoring().antMatchers("/static/**");
  12.     }
  13.  
  14.     @Override
  15.     protected void configure(HttpSecurity httpSecurity) throws Exception {
  16.         httpSecurity
  17.                 .formLogin()
  18.                     .loginPage("/signin")
  19.                     .loginProcessingUrl("/signin/authenticate")
  20.                     .failureUrl("/signin?error=bad_credentials")                    
  21.                 .and()
  22.                     .logout()
  23.                         .deleteCookies("JSESSIONID")
  24.                         .logoutUrl("/signout")
  25.                         .logoutSuccessUrl("/")
  26.                 .and()
  27.                     .authorizeRequests()
  28.                         .antMatchers(
  29.                                 "/",
  30.                                 "/signin/**",
  31.                                 "/signup/**",
  32.                                 "/about",
  33.                                 "/privacyPolicy",
  34.                                 "/termsConditions",
  35.                                 "/addYourChurch",
  36.                                 "/search",
  37.                                 "/contact",
  38.                                 "/church-profile/**"
  39.                         ).permitAll()
  40.                         .antMatchers("/**").hasRole("USER")
  41.                 .and()
  42.                     .apply(new SpringSocialConfigurer());
  43.     }
  44.  
  45.     @Override
  46.     protected void configure(AuthenticationManagerBuilder authenticationManager) throws Exception {
  47.         authenticationManager.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
  48.     }
  49.        
  50.     @Bean
  51.     public PasswordEncoder passwordEncoder() {
  52.         return new BCryptPasswordEncoder(10);
  53.     }
  54. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top