Remove redundant bean declarations from some of the security samples

Closes gh-6740
pull/6752/head
Andy Wilkinson 8 years ago
parent d6e9ccecec
commit 46e03529fb

@ -22,7 +22,6 @@ import java.util.Map;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.SecurityProperties; import org.springframework.boot.autoconfigure.security.SecurityProperties;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order; import org.springframework.core.annotation.Order;
@ -62,11 +61,6 @@ public class SampleMethodSecurityApplication extends WebMvcConfigurerAdapter {
registry.addViewController("/access").setViewName("access"); registry.addViewController("/access").setViewName("access");
} }
@Bean
public ApplicationSecurity applicationSecurity() {
return new ApplicationSecurity();
}
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
new SpringApplicationBuilder(SampleMethodSecurityApplication.class).run(args); new SpringApplicationBuilder(SampleMethodSecurityApplication.class).run(args);
} }
@ -85,6 +79,7 @@ public class SampleMethodSecurityApplication extends WebMvcConfigurerAdapter {
} }
@Configuration
@Order(SecurityProperties.ACCESS_OVERRIDE_ORDER) @Order(SecurityProperties.ACCESS_OVERRIDE_ORDER)
protected static class ApplicationSecurity extends WebSecurityConfigurerAdapter { protected static class ApplicationSecurity extends WebSecurityConfigurerAdapter {

@ -22,7 +22,7 @@ import java.util.Map;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.SecurityProperties; import org.springframework.boot.autoconfigure.security.SecurityProperties;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order; import org.springframework.core.annotation.Order;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; 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.HttpSecurity;
@ -55,15 +55,11 @@ public class SampleWebSecureCustomApplication extends WebMvcConfigurerAdapter {
registry.addViewController("/login").setViewName("login"); registry.addViewController("/login").setViewName("login");
} }
@Bean
public ApplicationSecurity applicationSecurity() {
return new ApplicationSecurity();
}
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
new SpringApplicationBuilder(SampleWebSecureCustomApplication.class).run(args); new SpringApplicationBuilder(SampleWebSecureCustomApplication.class).run(args);
} }
@Configuration
@Order(SecurityProperties.ACCESS_OVERRIDE_ORDER) @Order(SecurityProperties.ACCESS_OVERRIDE_ORDER)
protected static class ApplicationSecurity extends WebSecurityConfigurerAdapter { protected static class ApplicationSecurity extends WebSecurityConfigurerAdapter {

@ -25,7 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.SecurityProperties; import org.springframework.boot.autoconfigure.security.SecurityProperties;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order; import org.springframework.core.annotation.Order;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; 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.HttpSecurity;
@ -38,7 +38,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
@SpringBootApplication @SpringBootApplication
@Controller @Controller
public class SampleWebSecureCustomApplication extends WebMvcConfigurerAdapter { public class SampleWebSecureJdbcApplication extends WebMvcConfigurerAdapter {
@GetMapping("/") @GetMapping("/")
public String home(Map<String, Object> model) { public String home(Map<String, Object> model) {
@ -58,15 +58,11 @@ public class SampleWebSecureCustomApplication extends WebMvcConfigurerAdapter {
registry.addViewController("/login").setViewName("login"); registry.addViewController("/login").setViewName("login");
} }
@Bean
public ApplicationSecurity applicationSecurity() {
return new ApplicationSecurity();
}
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
new SpringApplicationBuilder(SampleWebSecureCustomApplication.class).run(args); new SpringApplicationBuilder(SampleWebSecureJdbcApplication.class).run(args);
} }
@Configuration
@Order(SecurityProperties.ACCESS_OVERRIDE_ORDER) @Order(SecurityProperties.ACCESS_OVERRIDE_ORDER)
protected static class ApplicationSecurity extends WebSecurityConfigurerAdapter { protected static class ApplicationSecurity extends WebSecurityConfigurerAdapter {

@ -48,7 +48,7 @@ import static org.assertj.core.api.Assertions.assertThat;
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
@DirtiesContext @DirtiesContext
public class SampleWebSecureCustomApplicationTests { public class SampleWebSecureJdbcApplicationTests {
@LocalServerPort @LocalServerPort
private int port; private int port;
Loading…
Cancel
Save