Polish
This commit is contained in:
@@ -46,7 +46,8 @@ import org.springframework.http.converter.support.AllEncompassingFormHttpMessage
|
||||
public class BackgroundPreinitializer
|
||||
implements ApplicationListener<SpringApplicationEvent> {
|
||||
|
||||
private static final AtomicBoolean preinitializationStarted = new AtomicBoolean(false);
|
||||
private static final AtomicBoolean preinitializationStarted = new AtomicBoolean(
|
||||
false);
|
||||
|
||||
private static final CountDownLatch preinitializationComplete = new CountDownLatch(1);
|
||||
|
||||
|
||||
@@ -40,7 +40,8 @@ import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
||||
* @see EnableAspectJAutoProxy
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnClass({ EnableAspectJAutoProxy.class, Aspect.class, Advice.class, AnnotatedElement.class })
|
||||
@ConditionalOnClass({ EnableAspectJAutoProxy.class, Aspect.class, Advice.class,
|
||||
AnnotatedElement.class })
|
||||
@ConditionalOnProperty(prefix = "spring.aop", name = "auto", havingValue = "true", matchIfMissing = true)
|
||||
public class AopAutoConfiguration {
|
||||
|
||||
|
||||
@@ -92,8 +92,8 @@ class DataSourceInitializedPublisher implements BeanPostProcessor {
|
||||
}
|
||||
String defaultDdlAuto = (EmbeddedDatabaseConnection.isEmbedded(dataSource)
|
||||
? "create-drop" : "none");
|
||||
Map<String, String> hibernate = this.properties.getHibernateProperties(
|
||||
defaultDdlAuto);
|
||||
Map<String, String> hibernate = this.properties
|
||||
.getHibernateProperties(defaultDdlAuto);
|
||||
if (hibernate.containsKey("hibernate.hbm2ddl.auto")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -109,8 +109,8 @@ public class HibernateJpaAutoConfiguration extends JpaBaseConfiguration {
|
||||
@Override
|
||||
protected Map<String, Object> getVendorProperties() {
|
||||
Map<String, Object> vendorProperties = new LinkedHashMap<>();
|
||||
String defaultDdlMode = this.defaultDdlAutoProvider.getDefaultDdlAuto(
|
||||
getDataSource());
|
||||
String defaultDdlMode = this.defaultDdlAutoProvider
|
||||
.getDefaultDdlAuto(getDataSource());
|
||||
vendorProperties.putAll(getProperties().getHibernateProperties(defaultDdlMode));
|
||||
return vendorProperties;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.springframework.boot.autoconfigure.security;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
@@ -79,10 +78,8 @@ public class AuthenticationManagerConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public static SpringBootAuthenticationConfigurerAdapter springBootAuthenticationConfigurerAdapter(
|
||||
SecurityProperties securityProperties,
|
||||
List<SecurityPrerequisite> dependencies) {
|
||||
return new SpringBootAuthenticationConfigurerAdapter(securityProperties);
|
||||
public static SpringBootAuthenticationConfigurerAdapter springBootAuthenticationConfigurerAdapter() {
|
||||
return new SpringBootAuthenticationConfigurerAdapter();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -118,16 +115,9 @@ public class AuthenticationManagerConfiguration {
|
||||
private static class SpringBootAuthenticationConfigurerAdapter
|
||||
extends GlobalAuthenticationConfigurerAdapter {
|
||||
|
||||
private final SecurityProperties securityProperties;
|
||||
|
||||
SpringBootAuthenticationConfigurerAdapter(SecurityProperties securityProperties) {
|
||||
this.securityProperties = securityProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(AuthenticationManagerBuilder auth) throws Exception {
|
||||
auth.apply(new DefaultInMemoryUserDetailsManagerConfigurer(
|
||||
this.securityProperties));
|
||||
auth.apply(new DefaultInMemoryUserDetailsManagerConfigurer());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -156,13 +146,6 @@ public class AuthenticationManagerConfiguration {
|
||||
private static class DefaultInMemoryUserDetailsManagerConfigurer
|
||||
extends InMemoryUserDetailsManagerConfigurer<AuthenticationManagerBuilder> {
|
||||
|
||||
private final SecurityProperties securityProperties;
|
||||
|
||||
DefaultInMemoryUserDetailsManagerConfigurer(
|
||||
SecurityProperties securityProperties) {
|
||||
this.securityProperties = securityProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure(AuthenticationManagerBuilder auth) throws Exception {
|
||||
if (auth.isConfigured()) {
|
||||
|
||||
@@ -81,7 +81,7 @@ public final class SpringBootSecurity {
|
||||
*/
|
||||
public RequestMatcher endpoints(Class<?>... endpoints) {
|
||||
Assert.notEmpty(endpoints, "At least one endpoint must be specified.");
|
||||
List<String> paths = Arrays.stream(endpoints).map(e -> {
|
||||
List<String> paths = Arrays.stream(endpoints).map((e) -> {
|
||||
if (e.isAnnotationPresent(Endpoint.class)) {
|
||||
return e.getAnnotation(Endpoint.class).id();
|
||||
}
|
||||
|
||||
@@ -40,12 +40,8 @@ public class OAuth2SsoDefaultConfiguration extends WebSecurityConfigurerAdapter
|
||||
|
||||
private final ApplicationContext applicationContext;
|
||||
|
||||
private final OAuth2SsoProperties sso;
|
||||
|
||||
public OAuth2SsoDefaultConfiguration(ApplicationContext applicationContext,
|
||||
OAuth2SsoProperties sso) {
|
||||
public OAuth2SsoDefaultConfiguration(ApplicationContext applicationContext) {
|
||||
this.applicationContext = applicationContext;
|
||||
this.sso = sso;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -120,12 +120,14 @@ public class FlywayAutoConfigurationTests {
|
||||
registerAndRefresh(FlywayDataSourceConfiguration.class,
|
||||
EmbeddedDataSourceConfiguration.class, FlywayAutoConfiguration.class,
|
||||
PropertyPlaceholderAutoConfiguration.class);
|
||||
FlywaySchemaManagementProvider schemaManagementProvider = this.context.getBean(
|
||||
FlywaySchemaManagementProvider.class);
|
||||
assertThat(schemaManagementProvider.getSchemaManagement(this.context.getBean(
|
||||
DataSource.class))).isEqualTo(SchemaManagement.UNMANAGED);
|
||||
assertThat(schemaManagementProvider.getSchemaManagement(this.context.getBean(
|
||||
"flywayDataSource", DataSource.class))).isEqualTo(SchemaManagement.MANAGED);
|
||||
FlywaySchemaManagementProvider schemaManagementProvider = this.context
|
||||
.getBean(FlywaySchemaManagementProvider.class);
|
||||
assertThat(schemaManagementProvider
|
||||
.getSchemaManagement(this.context.getBean(DataSource.class)))
|
||||
.isEqualTo(SchemaManagement.UNMANAGED);
|
||||
assertThat(schemaManagementProvider.getSchemaManagement(
|
||||
this.context.getBean("flywayDataSource", DataSource.class)))
|
||||
.isEqualTo(SchemaManagement.MANAGED);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -61,15 +61,16 @@ public class H2ConsoleAutoConfigurationIntegrationTests {
|
||||
public void noPrincipal() throws Exception {
|
||||
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
|
||||
.apply(springSecurity()).build();
|
||||
mockMvc.perform(get("/h2-console/").accept(MediaType.APPLICATION_JSON)).andExpect(status().isUnauthorized());
|
||||
mockMvc.perform(get("/h2-console/").accept(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isUnauthorized());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void userPrincipal() throws Exception {
|
||||
MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
|
||||
.apply(springSecurity()).build();
|
||||
mockMvc.perform(get("/h2-console/").accept(MediaType.APPLICATION_JSON).with(user("test").roles("USER")))
|
||||
.andExpect(status().isOk())
|
||||
mockMvc.perform(get("/h2-console/").accept(MediaType.APPLICATION_JSON)
|
||||
.with(user("test").roles("USER"))).andExpect(status().isOk())
|
||||
.andExpect(header().string("X-Frame-Options", "SAMEORIGIN"));
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,8 @@ public class CustomHibernateJpaAutoConfigurationTests {
|
||||
HibernateJpaAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
JpaProperties bean = this.context.getBean(JpaProperties.class);
|
||||
Map<String, String> hibernateProperties = bean.getHibernateProperties("create-drop");
|
||||
Map<String, String> hibernateProperties = bean
|
||||
.getHibernateProperties("create-drop");
|
||||
assertThat(hibernateProperties.get("hibernate.ejb.naming_strategy")).isNull();
|
||||
}
|
||||
|
||||
|
||||
@@ -53,14 +53,14 @@ public class HibernateDefaultDdlAutoProviderTests {
|
||||
+ org.apache.tomcat.jdbc.pool.DataSource.class.getName(),
|
||||
"spring.datasource.database:mysql",
|
||||
"spring.datasource.url:jdbc:mysql://localhost/nonexistent",
|
||||
"spring.jpa.database:MYSQL"
|
||||
).run((context) -> {
|
||||
HibernateDefaultDdlAutoProvider ddlAutoProvider = new HibernateDefaultDdlAutoProvider(
|
||||
Collections.emptyList());
|
||||
assertThat(ddlAutoProvider.getDefaultDdlAuto(
|
||||
context.getBean(DataSource.class))).isEqualTo("none");
|
||||
"spring.jpa.database:MYSQL").run((context) -> {
|
||||
HibernateDefaultDdlAutoProvider ddlAutoProvider = new HibernateDefaultDdlAutoProvider(
|
||||
Collections.emptyList());
|
||||
assertThat(ddlAutoProvider
|
||||
.getDefaultDdlAuto(context.getBean(DataSource.class)))
|
||||
.isEqualTo("none");
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -68,8 +68,9 @@ public class HibernateDefaultDdlAutoProviderTests {
|
||||
this.contextRunner.run((context) -> {
|
||||
HibernateDefaultDdlAutoProvider ddlAutoProvider = new HibernateDefaultDdlAutoProvider(
|
||||
Collections.emptyList());
|
||||
assertThat(ddlAutoProvider.getDefaultDdlAuto(
|
||||
context.getBean(DataSource.class))).isEqualTo("create-drop");
|
||||
assertThat(
|
||||
ddlAutoProvider.getDefaultDdlAuto(context.getBean(DataSource.class)))
|
||||
.isEqualTo("create-drop");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -82,8 +83,7 @@ public class HibernateDefaultDdlAutoProviderTests {
|
||||
.willReturn(SchemaManagement.MANAGED);
|
||||
HibernateDefaultDdlAutoProvider ddlAutoProvider = new HibernateDefaultDdlAutoProvider(
|
||||
Collections.singletonList(provider));
|
||||
assertThat(ddlAutoProvider.getDefaultDdlAuto(
|
||||
dataSource)).isEqualTo("none");
|
||||
assertThat(ddlAutoProvider.getDefaultDdlAuto(dataSource)).isEqualTo("none");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -96,8 +96,8 @@ public class HibernateDefaultDdlAutoProviderTests {
|
||||
.willReturn(SchemaManagement.UNMANAGED);
|
||||
HibernateDefaultDdlAutoProvider ddlAutoProvider = new HibernateDefaultDdlAutoProvider(
|
||||
Collections.singletonList(provider));
|
||||
assertThat(ddlAutoProvider.getDefaultDdlAuto(
|
||||
dataSource)).isEqualTo("create-drop");
|
||||
assertThat(ddlAutoProvider.getDefaultDdlAuto(dataSource))
|
||||
.isEqualTo("create-drop");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user