Rev 26310 | Go to most recent revision | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed
package com.spice.profitmandi.web.config;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.beans.factory.annotation.Value;import org.springframework.context.annotation.Configuration;import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;import org.springframework.security.config.annotation.web.builders.HttpSecurity;import org.springframework.security.config.annotation.web.builders.WebSecurity;import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;@Configuration@EnableWebSecuritypublic class WebSecurityConfig extends WebSecurityConfigurerAdapter {@Autowiredprivate MyBasicAuthenticationEntryPoint myBasicAuthenticationEntryPoint;@Overridepublic void configure(WebSecurity web) throws Exception {web.ignoring().anyRequest();}@Overrideprotected void configure(HttpSecurity http) throws Exception {http.authorizeRequests().antMatchers("/hdfc/**").hasRole("hdfc").antMatchers("/hdfctest/**").hasRole("hdfctest").and()// Possibly more configuration ....httpBasic().authenticationEntryPoint(myBasicAuthenticationEntryPoint);// set permitAll for all URLs associated with Form Login}@Overrideprotected void configure(AuthenticationManagerBuilder auth) throws Exception {auth.inMemoryAuthentication().withUser("hdfcuser").password("sd123$%^aGg").roles("hdfc").and().withUser("hdfctestuser").password("test").roles("hdfctest");}}