Reorganized classes according to the last pull request's comments.

This commit is contained in:
oreva 2016-11-19 21:14:40 +02:00
parent 7e0bf584a1
commit 858d14baf3
2 changed files with 17 additions and 18 deletions

View File

@ -1,9 +1,8 @@
package org.baeldung.spring;
package org.baeldung.security.filter.configuration;
import org.baeldung.security.basic.MyBasicAuthenticationEntryPoint;
import org.baeldung.security.filter.CustomFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
@ -13,28 +12,29 @@ import org.springframework.security.web.authentication.www.BasicAuthenticationFi
@Configuration
@EnableWebSecurity
@ComponentScan("org.baeldung.security")
public class SecSecurityConfigJava extends WebSecurityConfigurerAdapter {
public class CustomWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter {
@Autowired
private MyBasicAuthenticationEntryPoint authenticationEntryPoint;
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
public void configureGlobal(AuthenticationManagerBuilder auth)
throws Exception {
auth
.inMemoryAuthentication()
.withUser("user1").password("user1Pass").authorities("ROLE_USER");
.inMemoryAuthentication()
.withUser("user1").password("user1Pass")
.authorities("ROLE_USER");
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/securityNone").permitAll()
.anyRequest().authenticated()
.and()
.antMatchers("/securityNone").permitAll()
.anyRequest().authenticated()
.and()
.httpBasic()
.authenticationEntryPoint(authenticationEntryPoint);
.authenticationEntryPoint(authenticationEntryPoint);
http.addFilterAfter(new CustomFilter(), BasicAuthenticationFilter.class);
http.addFilterAfter(new CustomFilter(),
BasicAuthenticationFilter.class);
}
}

View File

@ -2,14 +2,13 @@ package org.baeldung.spring;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
//@Configuration
@Configuration
@ComponentScan("org.baeldung.security")
//@ImportResource({ "classpath:webSecurityConfig.xml" })
//@ComponentScan("org.baeldung.security")
public class SecSecurityConfigXML {
public class SecSecurityConfig {
public SecSecurityConfigXML() {
public SecSecurityConfig() {
super();
}