diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/ManagementServerProperties.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/ManagementServerProperties.java index 899cd2d12e1..a78a9e45f55 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/ManagementServerProperties.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/ManagementServerProperties.java @@ -169,7 +169,8 @@ public class ManagementServerProperties implements SecurityPrerequisite { /** * Comma-separated list of roles that can access the management endpoint. */ - private List roles = new ArrayList(Collections.singletonList("ACTUATOR")); + private List roles = new ArrayList( + Collections.singletonList("ACTUATOR")); /** * Session creating policy for security use (always, never, if_required, diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/EnvironmentEndpoint.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/EnvironmentEndpoint.java index 71dd7288d74..99fd74d29ec 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/EnvironmentEndpoint.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/EnvironmentEndpoint.java @@ -61,7 +61,8 @@ public class EnvironmentEndpoint extends AbstractEndpoint> { Map result = new LinkedHashMap<>(); result.put("profiles", getEnvironment().getActiveProfiles()); PropertyResolver resolver = getResolver(); - for (Entry> entry : getPropertySourcesAsMap().entrySet()) { + for (Entry> entry : getPropertySourcesAsMap() + .entrySet()) { PropertySource source = entry.getValue(); String sourceName = entry.getKey(); if (source instanceof EnumerablePropertySource) { @@ -88,8 +89,7 @@ public class EnvironmentEndpoint extends AbstractEndpoint> { private Map> getPropertySourcesAsMap() { Map> map = new LinkedHashMap>(); - MutablePropertySources sources = getPropertySources(); - for (PropertySource source : sources) { + for (PropertySource source : getPropertySources()) { extract("", map, source); } return map; @@ -138,12 +138,11 @@ public class EnvironmentEndpoint extends AbstractEndpoint> { } /** - * {@link PropertySourcesPropertyResolver} that sanitizes sensitive placeholders - * if present. - * - * @author Madhura Bhave + * {@link PropertySourcesPropertyResolver} that sanitizes sensitive placeholders if + * present. */ - private class PlaceholderSanitizingPropertyResolver extends PropertySourcesPropertyResolver { + private class PlaceholderSanitizingPropertyResolver + extends PropertySourcesPropertyResolver { private final Sanitizer sanitizer; @@ -152,8 +151,8 @@ public class EnvironmentEndpoint extends AbstractEndpoint> { * @param propertySources the set of {@link PropertySource} objects to use * @param sanitizer the sanitizer used to sanitize sensitive values */ - PlaceholderSanitizingPropertyResolver(PropertySources - propertySources, Sanitizer sanitizer) { + PlaceholderSanitizingPropertyResolver(PropertySources propertySources, + Sanitizer sanitizer) { super(propertySources); this.sanitizer = sanitizer; } @@ -163,6 +162,7 @@ public class EnvironmentEndpoint extends AbstractEndpoint> { String value = super.getPropertyAsRawString(key); return (String) this.sanitizer.sanitize(key, value); } + } } diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/WebRequestTraceFilter.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/WebRequestTraceFilter.java index ac74a476377..1f4ba8104a9 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/WebRequestTraceFilter.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/WebRequestTraceFilter.java @@ -25,6 +25,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.concurrent.TimeUnit; import javax.servlet.Filter; import javax.servlet.FilterChain; @@ -97,13 +98,11 @@ public class WebRequestTraceFilter extends OncePerRequestFilter implements Order this.order = order; } - - @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { - long startTime = System.currentTimeMillis(); + long startTime = System.nanoTime(); Map trace = getTrace(request); logTrace(request, trace); int status = HttpStatus.INTERNAL_SERVER_ERROR.value(); @@ -112,8 +111,7 @@ public class WebRequestTraceFilter extends OncePerRequestFilter implements Order status = response.getStatus(); } finally { - long endTime = System.currentTimeMillis(); - addTimeTaken(startTime, endTime, trace); + addTimeTaken(trace, startTime); enhanceTrace(trace, status == response.getStatus() ? response : new CustomStatusResponseWrapper(response, status)); this.repository.add(trace); @@ -200,9 +198,10 @@ public class WebRequestTraceFilter extends OncePerRequestFilter implements Order protected void postProcessRequestHeaders(Map headers) { } - private void addTimeTaken(long startTime, long endTime, Map trace) { - long timeTaken = endTime - startTime; - add(trace, Include.TIME_TAKEN, "timeTaken", String.valueOf(timeTaken)); + private void addTimeTaken(Map trace, long startTime) { + long timeTaken = System.nanoTime() - startTime; + add(trace, Include.TIME_TAKEN, "timeTaken", + "" + TimeUnit.NANOSECONDS.toMillis(timeTaken)); } @SuppressWarnings("unchecked") diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/EnvironmentMvcEndpointTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/EnvironmentMvcEndpointTests.java index 41558077e25..25222f621cd 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/EnvironmentMvcEndpointTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/EnvironmentMvcEndpointTests.java @@ -138,7 +138,8 @@ public class EnvironmentMvcEndpointTests { } @Test - public void nestedPathWhenPlaceholderCannotBeResolvedShouldReturnUnresolvedProperty() throws Exception { + public void nestedPathWhenPlaceholderCannotBeResolvedShouldReturnUnresolvedProperty() + throws Exception { Map map = new HashMap(); map.put("my.foo", "${my.bar}"); ((ConfigurableEnvironment) this.context.getEnvironment()).getPropertySources() diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/trace/WebRequestTraceFilterTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/trace/WebRequestTraceFilterTests.java index 6dad5101c9c..7000c4b205c 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/trace/WebRequestTraceFilterTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/trace/WebRequestTraceFilterTests.java @@ -250,8 +250,8 @@ public class WebRequestTraceFilterTests { MockHttpServletResponse response = new MockHttpServletResponse(); MockFilterChain chain = new MockFilterChain(); this.filter.doFilter(request, response, chain); - String timeTaken = (String) this.repository.findAll() - .iterator().next().getInfo().get("timeTaken"); + String timeTaken = (String) this.repository.findAll().iterator().next().getInfo() + .get("timeTaken"); assertThat(timeTaken).isNotNull(); } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/HazelcastJCacheCustomizationConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/HazelcastJCacheCustomizationConfiguration.java index 0b3deba443a..b36cbdf204c 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/HazelcastJCacheCustomizationConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/HazelcastJCacheCustomizationConfiguration.java @@ -40,8 +40,7 @@ class HazelcastJCacheCustomizationConfiguration { @Bean public HazelcastPropertiesCustomizer hazelcastPropertiesCustomizer( ObjectProvider hazelcastInstance) { - return new HazelcastPropertiesCustomizer( - hazelcastInstance.getIfUnique()); + return new HazelcastPropertiesCustomizer(hazelcastInstance.getIfUnique()); } private static class HazelcastPropertiesCustomizer @@ -72,8 +71,8 @@ class HazelcastJCacheCustomizationConfiguration { return config.getURI(); } catch (IOException ex) { - throw new IllegalArgumentException( - "Could not get URI from " + config, ex); + throw new IllegalArgumentException("Could not get URI from " + config, + ex); } } diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfigurationTests.java index e1353749334..bfa41792246 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfigurationTests.java @@ -499,7 +499,8 @@ public class CacheAutoConfigurationTests { load(DefaultCacheConfiguration.class, "spring.cache.type=jcache", "spring.cache.jcache.provider=" + cachingProviderFqn, "spring.cache.jcache.config=" + configLocation); - JCacheCacheManager cacheManager = validateCacheManager(JCacheCacheManager.class); + JCacheCacheManager cacheManager = validateCacheManager( + JCacheCacheManager.class); Resource configResource = new ClassPathResource(configLocation); assertThat(cacheManager.getCacheManager().getURI()) @@ -515,14 +516,15 @@ public class CacheAutoConfigurationTests { public void hazelcastAsJCacheWithExistingHazelcastInstance() throws IOException { String cachingProviderFqn = HazelcastCachingProvider.class.getName(); load(new Class[] { HazelcastAutoConfiguration.class, - DefaultCacheConfiguration.class }, "spring.cache.type=jcache", + DefaultCacheConfiguration.class }, "spring.cache.type=jcache", "spring.cache.jcache.provider=" + cachingProviderFqn); JCacheCacheManager cacheManager = validateCacheManager(JCacheCacheManager.class); javax.cache.CacheManager jCacheManager = cacheManager.getCacheManager(); - assertThat(jCacheManager).isInstanceOf( - com.hazelcast.cache.HazelcastCacheManager.class); + assertThat(jCacheManager) + .isInstanceOf(com.hazelcast.cache.HazelcastCacheManager.class); assertThat(this.context.getBeansOfType(HazelcastInstance.class)).hasSize(1); - HazelcastInstance hazelcastInstance = this.context.getBean(HazelcastInstance.class); + HazelcastInstance hazelcastInstance = this.context + .getBean(HazelcastInstance.class); assertThat(((com.hazelcast.cache.HazelcastCacheManager) jCacheManager) .getHazelcastInstance()).isSameAs(hazelcastInstance); assertThat(hazelcastInstance.getName()).isEqualTo("default-instance"); @@ -596,7 +598,8 @@ public class CacheAutoConfigurationTests { load(JCacheWithCustomizerConfiguration.class, "spring.cache.type=jcache", "spring.cache.jcache.provider=" + cachingProviderFqn, "spring.cache.cacheNames[0]=foo", "spring.cache.cacheNames[1]=bar"); - JCacheCacheManager cacheManager = validateCacheManager(JCacheCacheManager.class); + JCacheCacheManager cacheManager = validateCacheManager( + JCacheCacheManager.class); // see customizer assertThat(cacheManager.getCacheNames()).containsOnly("foo", "custom1"); } diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/transaction/TransactionAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/transaction/TransactionAutoConfigurationTests.java index 4177c099294..e453f65b2cb 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/transaction/TransactionAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/transaction/TransactionAutoConfigurationTests.java @@ -104,40 +104,43 @@ public class TransactionAutoConfigurationTests { assertThat(field).hasSize(1).first().isInstanceOf(TransactionProperties.class); } - @Test public void transactionNotManagedWithNoTransactionManager() { load(BaseConfiguration.class); - assertThat(this.context.getBean(TransactionalService.class) - .isTransactionActive()).isFalse(); + assertThat(this.context.getBean(TransactionalService.class).isTransactionActive()) + .isFalse(); } @Test public void transactionManagerUsesCglibByDefault() { load(TransactionManagersConfiguration.class); - assertThat(this.context.getBean(AnotherServiceImpl.class) - .isTransactionActive()).isTrue(); - assertThat(this.context.getBeansOfType(TransactionalServiceImpl.class)).hasSize(1); + assertThat(this.context.getBean(AnotherServiceImpl.class).isTransactionActive()) + .isTrue(); + assertThat(this.context.getBeansOfType(TransactionalServiceImpl.class)) + .hasSize(1); } @Test public void transactionManagerCanBeConfiguredToJdkProxy() { - load(TransactionManagersConfiguration.class, "spring.aop.proxy-target-class=false"); - assertThat(this.context.getBean(AnotherService.class) - .isTransactionActive()).isTrue(); + load(TransactionManagersConfiguration.class, + "spring.aop.proxy-target-class=false"); + assertThat(this.context.getBean(AnotherService.class).isTransactionActive()) + .isTrue(); assertThat(this.context.getBeansOfType(AnotherServiceImpl.class)).hasSize(0); - assertThat(this.context.getBeansOfType(TransactionalServiceImpl.class)).hasSize(0); + assertThat(this.context.getBeansOfType(TransactionalServiceImpl.class)) + .hasSize(0); } @Test public void customEnableTransactionManagementTakesPrecedence() { load(new Class[] { CustomTransactionManagementConfiguration.class, - TransactionManagersConfiguration.class }, + TransactionManagersConfiguration.class }, "spring.aop.proxy-target-class=true"); - assertThat(this.context.getBean(AnotherService.class) - .isTransactionActive()).isTrue(); + assertThat(this.context.getBean(AnotherService.class).isTransactionActive()) + .isTrue(); assertThat(this.context.getBeansOfType(AnotherServiceImpl.class)).hasSize(0); - assertThat(this.context.getBeansOfType(TransactionalServiceImpl.class)).hasSize(0); + assertThat(this.context.getBeansOfType(TransactionalServiceImpl.class)) + .hasSize(0); } private void load(Class config, String... environment) { @@ -235,11 +238,11 @@ public class TransactionAutoConfigurationTests { static class TransactionalServiceImpl implements TransactionalService { - @Override public boolean isTransactionActive() { return TransactionSynchronizationManager.isActualTransactionActive(); } + } interface AnotherService { @@ -250,12 +253,12 @@ public class TransactionAutoConfigurationTests { static class AnotherServiceImpl implements AnotherService { - @Override @Transactional public boolean isTransactionActive() { return TransactionSynchronizationManager.isActualTransactionActive(); } + } } diff --git a/spring-boot-autoconfigure/src/test/resources/hazelcast.xml b/spring-boot-autoconfigure/src/test/resources/hazelcast.xml index c59ae8a4631..7d175c2177e 100644 --- a/spring-boot-autoconfigure/src/test/resources/hazelcast.xml +++ b/spring-boot-autoconfigure/src/test/resources/hazelcast.xml @@ -1,17 +1,12 @@ - + xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-3.7.xsd" + xmlns="http://www.hazelcast.com/schema/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> default-instance - - - - + + - diff --git a/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc b/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc index b2cba56d554..2f91174a5d8 100644 --- a/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc +++ b/spring-boot-docs/src/main/asciidoc/production-ready-features.adoc @@ -602,7 +602,8 @@ those values (so you can use anything that is legal in a URL path). For example, the location of the `/health` endpoint to `/ping/me` you can set `endpoints.health.path=/ping/me`. -NOTE: Even if an endpoint path is configured separately, it is still relative to the `management.context-path`. +NOTE: Even if an endpoint path is configured separately, it is still relative to the +`management.context-path`. TIP: If you provide a custom `MvcEndpoint` remember to include a settable `path` property, and default it to `/{id}` if you want your code to behave like the standard MVC endpoints. diff --git a/spring-boot-docs/src/main/java/org/springframework/boot/web/security/UnauthenticatedAccessExample.java b/spring-boot-docs/src/main/java/org/springframework/boot/web/security/UnauthenticatedAccessExample.java index 43917375e93..494c2ff095e 100644 --- a/spring-boot-docs/src/main/java/org/springframework/boot/web/security/UnauthenticatedAccessExample.java +++ b/spring-boot-docs/src/main/java/org/springframework/boot/web/security/UnauthenticatedAccessExample.java @@ -46,6 +46,7 @@ public class UnauthenticatedAccessExample { protected void configure(HttpSecurity http) throws Exception { http.antMatcher("/**").authorizeRequests().anyRequest().authenticated(); } + } // end::configuration[] diff --git a/spring-boot-samples/spring-boot-sample-actuator/src/main/java/sample/actuator/SampleActuatorApplication.java b/spring-boot-samples/spring-boot-sample-actuator/src/main/java/sample/actuator/SampleActuatorApplication.java index 80f14beeae9..f0a111839c3 100644 --- a/spring-boot-samples/spring-boot-sample-actuator/src/main/java/sample/actuator/SampleActuatorApplication.java +++ b/spring-boot-samples/spring-boot-sample-actuator/src/main/java/sample/actuator/SampleActuatorApplication.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTypeExcludeFilterTests.java b/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTypeExcludeFilterTests.java index 0981aa50216..2fbde812557 100644 --- a/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTypeExcludeFilterTests.java +++ b/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTypeExcludeFilterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java b/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java index a2d90e2d9e1..c4a3f956603 100644 --- a/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java +++ b/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java @@ -260,7 +260,7 @@ public class LogbackLoggingSystem extends Slf4JLoggingSystem { return new ShutdownHandler(); } - ch.qos.logback.classic.Logger getLogger(String name) { + private ch.qos.logback.classic.Logger getLogger(String name) { LoggerContext factory = getLoggerContext(); if (StringUtils.isEmpty(name) || ROOT_LOGGER_NAME.equals(name)) { name = Logger.ROOT_LOGGER_NAME; diff --git a/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java b/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java index 16b706284aa..25d5b6d4876 100644 --- a/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java +++ b/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java @@ -315,18 +315,20 @@ public class UndertowServletWebServerFactory extends AbstractServletWebServerFac keyPassword = ssl.getKeyStorePassword().toCharArray(); } keyManagerFactory.init(keyStore, keyPassword); - return getConfigurableAliasKeyManagers(ssl, keyManagerFactory.getKeyManagers()); + return getConfigurableAliasKeyManagers(ssl, + keyManagerFactory.getKeyManagers()); } catch (Exception ex) { throw new IllegalStateException(ex); } } - private KeyManager[] getConfigurableAliasKeyManagers(Ssl ssl, KeyManager[] keyManagers) { + private KeyManager[] getConfigurableAliasKeyManagers(Ssl ssl, + KeyManager[] keyManagers) { for (int i = 0; i < keyManagers.length; i++) { if (keyManagers[i] instanceof X509ExtendedKeyManager) { - keyManagers[i] = new ConfigurableAliasKeyManager((X509ExtendedKeyManager) keyManagers[i], - ssl.getKeyAlias()); + keyManagers[i] = new ConfigurableAliasKeyManager( + (X509ExtendedKeyManager) keyManagers[i], ssl.getKeyAlias()); } } return keyManagers; @@ -709,54 +711,66 @@ public class UndertowServletWebServerFactory extends AbstractServletWebServerFac } } + /** + * {@link X509ExtendedKeyManager} that supports custom alias configuration. + */ private static class ConfigurableAliasKeyManager extends X509ExtendedKeyManager { - private final X509ExtendedKeyManager sourceKeyManager; + private final X509ExtendedKeyManager keyManager; private final String alias; ConfigurableAliasKeyManager(X509ExtendedKeyManager keyManager, String alias) { - this.sourceKeyManager = keyManager; + this.keyManager = keyManager; this.alias = alias; } @Override - public String chooseEngineClientAlias(String[] strings, Principal[] principals, SSLEngine sslEngine) { - return this.sourceKeyManager.chooseEngineClientAlias(strings, principals, sslEngine); + public String chooseEngineClientAlias(String[] strings, Principal[] principals, + SSLEngine sslEngine) { + return this.keyManager.chooseEngineClientAlias(strings, principals, + sslEngine); } @Override - public String chooseEngineServerAlias(String s, Principal[] principals, SSLEngine sslEngine) { + public String chooseEngineServerAlias(String s, Principal[] principals, + SSLEngine sslEngine) { if (this.alias == null) { - return this.sourceKeyManager.chooseEngineServerAlias(s, principals, sslEngine); + return this.keyManager.chooseEngineServerAlias(s, principals, sslEngine); } return this.alias; } + @Override public String chooseClientAlias(String[] keyType, Principal[] issuers, Socket socket) { - return this.sourceKeyManager.chooseClientAlias(keyType, issuers, socket); + return this.keyManager.chooseClientAlias(keyType, issuers, socket); } + @Override public String chooseServerAlias(String keyType, Principal[] issuers, Socket socket) { - return this.sourceKeyManager.chooseServerAlias(keyType, issuers, socket); + return this.keyManager.chooseServerAlias(keyType, issuers, socket); } + @Override public X509Certificate[] getCertificateChain(String alias) { - return this.sourceKeyManager.getCertificateChain(alias); + return this.keyManager.getCertificateChain(alias); } + @Override public String[] getClientAliases(String keyType, Principal[] issuers) { - return this.sourceKeyManager.getClientAliases(keyType, issuers); + return this.keyManager.getClientAliases(keyType, issuers); } + @Override public PrivateKey getPrivateKey(String alias) { - return this.sourceKeyManager.getPrivateKey(alias); + return this.keyManager.getPrivateKey(alias); } + @Override public String[] getServerAliases(String keyType, Principal[] issuers) { - return this.sourceKeyManager.getServerAliases(keyType, issuers); + return this.keyManager.getServerAliases(keyType, issuers); } } diff --git a/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java b/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java index 0d4aacde0f1..e1230eb98dc 100644 --- a/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -211,7 +211,8 @@ public class LogbackLoggingSystemTests extends AbstractLoggingSystemTests { public void getLoggingConfigurationForALL() throws Exception { this.loggingSystem.beforeInitialize(); this.loggingSystem.initialize(this.initializationContext, null, null); - Logger logger = this.loggingSystem.getLogger(getClass().getName()); + Logger logger = (Logger) StaticLoggerBinder.getSingleton().getLoggerFactory() + .getLogger(getClass().getName()); logger.setLevel(Level.ALL); LoggerConfiguration configuration = this.loggingSystem .getLoggerConfiguration(getClass().getName()); @@ -224,7 +225,8 @@ public class LogbackLoggingSystemTests extends AbstractLoggingSystemTests { this.loggingSystem.beforeInitialize(); this.loggingSystem.initialize(this.initializationContext, null, null); this.loggingSystem.setLogLevel(getClass().getName(), LogLevel.TRACE); - Logger logger = this.loggingSystem.getLogger(getClass().getName()); + Logger logger = (Logger) StaticLoggerBinder.getSingleton().getLoggerFactory() + .getLogger(getClass().getName()); assertThat(logger.getLevel()).isEqualTo(Level.TRACE); } diff --git a/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java b/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java index bac2cca8db1..0594f6b46eb 100644 --- a/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java @@ -49,6 +49,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; import java.util.zip.GZIPInputStream; +import javax.net.ssl.SSLContext; import javax.net.ssl.SSLException; import javax.servlet.GenericServlet; import javax.servlet.ServletContext; @@ -68,6 +69,7 @@ import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.client.HttpClients; import org.apache.http.protocol.HttpContext; import org.apache.http.ssl.SSLContextBuilder; +import org.apache.http.ssl.TrustStrategy; import org.apache.jasper.EmbeddedServletOptions; import org.apache.jasper.servlet.JspServlet; import org.junit.After; @@ -436,21 +438,21 @@ public abstract class AbstractServletWebServerFactoryTests { @Test public void sslKeyAlias() throws Exception { AbstractServletWebServerFactory factory = getFactory(); - factory.setSsl( - getSsl(null, "password", "test-alias", "src/test/resources/test.jks")); - this.webServer = factory.getWebServer( - new ServletRegistrationBean<>(new ExampleServlet(true, false), "/hello")); + Ssl ssl = getSsl(null, "password", "test-alias", "src/test/resources/test.jks"); + factory.setSsl(ssl); + ServletRegistrationBean registration = new ServletRegistrationBean<>( + new ExampleServlet(true, false), "/hello"); + this.webServer = factory.getWebServer(registration); this.webServer.start(); - SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory( - new SSLContextBuilder().loadTrustMaterial(null, - new SerialNumberValidatingTrustSelfSignedStrategy("77e7c302")) - .build()); - HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory) - .build(); - HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory( - httpClient); - assertThat(getResponse(getLocalUrl("https", "/hello"), requestFactory)) - .contains("scheme=https"); + TrustStrategy trustStrategy = new SerialNumberValidatingTrustSelfSignedStrategy( + "77e7c302"); + SSLContext sslContext = new SSLContextBuilder() + .loadTrustMaterial(null, trustStrategy).build(); + HttpClient httpClient = HttpClients.custom() + .setSSLSocketFactory(new SSLConnectionSocketFactory(sslContext)).build(); + String response = getResponse(getLocalUrl("https", "/hello"), + new HttpComponentsClientHttpRequestFactory(httpClient)); + assertThat(response).contains("scheme=https"); } @Test