[bs-140] Extract framework-provided @ConfigurationProperties into @Bean

Allows @ConfigurationProperties beans to be declared explicitly (to set default values)

[#50804109]
This commit is contained in:
Dave Syer
2013-05-30 14:20:24 +01:00
parent cf201ffd80
commit 6c22e0ab6e
3 changed files with 29 additions and 8 deletions

View File

@@ -40,9 +40,15 @@ public class ActuatorAutoConfiguration {
* ServerProperties has to be declared in a non-conditional bean, so that it gets
* added to the context early enough
*/
@EnableConfigurationProperties(ManagementServerProperties.class)
@EnableConfigurationProperties
public static class ServerPropertiesConfiguration {
@ConditionalOnMissingBean(ManagementServerProperties.class)
@Bean(name = "org.springframework.bootstrap.actuate.properties.ManagementServerProperties")
public ManagementServerProperties managementServerProperties() {
return new ManagementServerProperties();
}
@Bean
@ConditionalOnMissingBean(EndpointsProperties.class)
public EndpointsProperties endpointsProperties() {

View File

@@ -42,9 +42,15 @@ import org.springframework.security.web.authentication.www.BasicAuthenticationEn
@Configuration
@ConditionalOnClass({ EnableWebSecurity.class })
@EnableWebSecurity
@EnableConfigurationProperties(SecurityProperties.class)
@EnableConfigurationProperties
public class SecurityAutoConfiguration {
@ConditionalOnMissingBean(SecurityProperties.class)
@Bean(name = "org.springframework.bootstrap.actuate.properties.SecurityProperties")
public SecurityProperties securityProperties() {
return new SecurityProperties();
}
@Bean
@ConditionalOnMissingBean({ AuthenticationEventPublisher.class })
public AuthenticationEventPublisher authenticationEventPublisher() {
@@ -74,11 +80,12 @@ public class SecurityAutoConfiguration {
http.requiresChannel().antMatchers("/**").requiresSecure();
}
if (this.security.getBasic().isEnabled()) {
http.authenticationEntryPoint(entryPoint())
.antMatcher(this.security.getBasic().getPath()).httpBasic()
.authenticationEntryPoint(entryPoint()).and().anonymous()
.disable();
http.authorizeUrls().antMatchers("/**")
HttpConfiguration matcher = http.antMatcher(this.security.getBasic()
.getPath());
matcher.authenticationEntryPoint(entryPoint()).antMatcher("/**")
.httpBasic().authenticationEntryPoint(entryPoint()).and()
.anonymous().disable();
matcher.authorizeUrls().antMatchers("/**")
.hasRole(this.security.getBasic().getRole());
}
// No cookies for service endpoints by default