Subversion Repositories SmartDukaan

Rev

Rev 30227 | 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.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
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

        @Autowired
        private MyBasicAuthenticationEntryPoint myBasicAuthenticationEntryPoint;

        @Override
        public void configure(WebSecurity web) throws Exception {
                web.ignoring().antMatchers("/resources/**").antMatchers("/spicemoney/callback");
        }

        @Override
        protected void configure(HttpSecurity http) throws Exception {
                http.logout().logoutUrl("logmeout").and().cors().disable().csrf().disable().authorizeRequests()
                                // .antMatchers("/**").hasRole("hdfc")
                                .antMatchers("/hdfc/**").hasRole("hdfc").antMatchers("/imei/validate").hasRole("paytail")
                                .antMatchers("/spicemoney/callback").hasRole("spicemoney").antMatchers("/hdfctest/**")
                                .hasRole("hdfctest").antMatchers("/**").permitAll().and().httpBasic()
                                .authenticationEntryPoint(myBasicAuthenticationEntryPoint);
        }

        @Autowired
        protected void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
                auth.inMemoryAuthentication().withUser("hdfcuser").password("sd123$%^aGg").roles("hdfc").and()
                                .withUser("hdfctestuser").password("test").roles("hdfctest").and().withUser("spicemoney")
                                .password("$SMT123MONEY").roles("spicemoney").and().withUser("paytail").password("$SDP@yTa!l")
                                .roles("paytail");
        }

}