Subversion Repositories SmartDukaan

Rev

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
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
        
        @Autowired
        private MyBasicAuthenticationEntryPoint myBasicAuthenticationEntryPoint;

        @Override
        public void configure(WebSecurity web) throws Exception {
                web.ignoring().anyRequest();
        }

        @Override
        protected 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
        }

        @Override
        protected void configure(AuthenticationManagerBuilder auth) throws Exception {
                auth.inMemoryAuthentication()
                        .withUser("hdfcuser").password("sd123$%^aGg").roles("hdfc").and()
                        .withUser("hdfctestuser").password("test").roles("hdfctest");
        }

}