Merge branch '1.5.x'

This commit is contained in:
Phillip Webb 2017-04-04 10:07:38 -07:00
commit 2de7e9c310
17 changed files with 115 additions and 94 deletions

View File

@ -169,7 +169,8 @@ public class ManagementServerProperties implements SecurityPrerequisite {
/** /**
* Comma-separated list of roles that can access the management endpoint. * Comma-separated list of roles that can access the management endpoint.
*/ */
private List<String> roles = new ArrayList<String>(Collections.singletonList("ACTUATOR")); private List<String> roles = new ArrayList<String>(
Collections.singletonList("ACTUATOR"));
/** /**
* Session creating policy for security use (always, never, if_required, * Session creating policy for security use (always, never, if_required,

View File

@ -61,7 +61,8 @@ public class EnvironmentEndpoint extends AbstractEndpoint<Map<String, Object>> {
Map<String, Object> result = new LinkedHashMap<>(); Map<String, Object> result = new LinkedHashMap<>();
result.put("profiles", getEnvironment().getActiveProfiles()); result.put("profiles", getEnvironment().getActiveProfiles());
PropertyResolver resolver = getResolver(); PropertyResolver resolver = getResolver();
for (Entry<String, PropertySource<?>> entry : getPropertySourcesAsMap().entrySet()) { for (Entry<String, PropertySource<?>> entry : getPropertySourcesAsMap()
.entrySet()) {
PropertySource<?> source = entry.getValue(); PropertySource<?> source = entry.getValue();
String sourceName = entry.getKey(); String sourceName = entry.getKey();
if (source instanceof EnumerablePropertySource) { if (source instanceof EnumerablePropertySource) {
@ -88,8 +89,7 @@ public class EnvironmentEndpoint extends AbstractEndpoint<Map<String, Object>> {
private Map<String, PropertySource<?>> getPropertySourcesAsMap() { private Map<String, PropertySource<?>> getPropertySourcesAsMap() {
Map<String, PropertySource<?>> map = new LinkedHashMap<String, PropertySource<?>>(); Map<String, PropertySource<?>> map = new LinkedHashMap<String, PropertySource<?>>();
MutablePropertySources sources = getPropertySources(); for (PropertySource<?> source : getPropertySources()) {
for (PropertySource<?> source : sources) {
extract("", map, source); extract("", map, source);
} }
return map; return map;
@ -138,12 +138,11 @@ public class EnvironmentEndpoint extends AbstractEndpoint<Map<String, Object>> {
} }
/** /**
* {@link PropertySourcesPropertyResolver} that sanitizes sensitive placeholders * {@link PropertySourcesPropertyResolver} that sanitizes sensitive placeholders if
* if present. * present.
*
* @author Madhura Bhave
*/ */
private class PlaceholderSanitizingPropertyResolver extends PropertySourcesPropertyResolver { private class PlaceholderSanitizingPropertyResolver
extends PropertySourcesPropertyResolver {
private final Sanitizer sanitizer; private final Sanitizer sanitizer;
@ -152,8 +151,8 @@ public class EnvironmentEndpoint extends AbstractEndpoint<Map<String, Object>> {
* @param propertySources the set of {@link PropertySource} objects to use * @param propertySources the set of {@link PropertySource} objects to use
* @param sanitizer the sanitizer used to sanitize sensitive values * @param sanitizer the sanitizer used to sanitize sensitive values
*/ */
PlaceholderSanitizingPropertyResolver(PropertySources PlaceholderSanitizingPropertyResolver(PropertySources propertySources,
propertySources, Sanitizer sanitizer) { Sanitizer sanitizer) {
super(propertySources); super(propertySources);
this.sanitizer = sanitizer; this.sanitizer = sanitizer;
} }
@ -163,6 +162,7 @@ public class EnvironmentEndpoint extends AbstractEndpoint<Map<String, Object>> {
String value = super.getPropertyAsRawString(key); String value = super.getPropertyAsRawString(key);
return (String) this.sanitizer.sanitize(key, value); return (String) this.sanitizer.sanitize(key, value);
} }
} }
} }

View File

@ -25,6 +25,7 @@ import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.TimeUnit;
import javax.servlet.Filter; import javax.servlet.Filter;
import javax.servlet.FilterChain; import javax.servlet.FilterChain;
@ -97,13 +98,11 @@ public class WebRequestTraceFilter extends OncePerRequestFilter implements Order
this.order = order; this.order = order;
} }
@Override @Override
protected void doFilterInternal(HttpServletRequest request, protected void doFilterInternal(HttpServletRequest request,
HttpServletResponse response, FilterChain filterChain) HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException { throws ServletException, IOException {
long startTime = System.currentTimeMillis(); long startTime = System.nanoTime();
Map<String, Object> trace = getTrace(request); Map<String, Object> trace = getTrace(request);
logTrace(request, trace); logTrace(request, trace);
int status = HttpStatus.INTERNAL_SERVER_ERROR.value(); int status = HttpStatus.INTERNAL_SERVER_ERROR.value();
@ -112,8 +111,7 @@ public class WebRequestTraceFilter extends OncePerRequestFilter implements Order
status = response.getStatus(); status = response.getStatus();
} }
finally { finally {
long endTime = System.currentTimeMillis(); addTimeTaken(trace, startTime);
addTimeTaken(startTime, endTime, trace);
enhanceTrace(trace, status == response.getStatus() ? response enhanceTrace(trace, status == response.getStatus() ? response
: new CustomStatusResponseWrapper(response, status)); : new CustomStatusResponseWrapper(response, status));
this.repository.add(trace); this.repository.add(trace);
@ -200,9 +198,10 @@ public class WebRequestTraceFilter extends OncePerRequestFilter implements Order
protected void postProcessRequestHeaders(Map<String, Object> headers) { protected void postProcessRequestHeaders(Map<String, Object> headers) {
} }
private void addTimeTaken(long startTime, long endTime, Map<String, Object> trace) { private void addTimeTaken(Map<String, Object> trace, long startTime) {
long timeTaken = endTime - startTime; long timeTaken = System.nanoTime() - startTime;
add(trace, Include.TIME_TAKEN, "timeTaken", String.valueOf(timeTaken)); add(trace, Include.TIME_TAKEN, "timeTaken",
"" + TimeUnit.NANOSECONDS.toMillis(timeTaken));
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")

View File

@ -138,7 +138,8 @@ public class EnvironmentMvcEndpointTests {
} }
@Test @Test
public void nestedPathWhenPlaceholderCannotBeResolvedShouldReturnUnresolvedProperty() throws Exception { public void nestedPathWhenPlaceholderCannotBeResolvedShouldReturnUnresolvedProperty()
throws Exception {
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
map.put("my.foo", "${my.bar}"); map.put("my.foo", "${my.bar}");
((ConfigurableEnvironment) this.context.getEnvironment()).getPropertySources() ((ConfigurableEnvironment) this.context.getEnvironment()).getPropertySources()

View File

@ -250,8 +250,8 @@ public class WebRequestTraceFilterTests {
MockHttpServletResponse response = new MockHttpServletResponse(); MockHttpServletResponse response = new MockHttpServletResponse();
MockFilterChain chain = new MockFilterChain(); MockFilterChain chain = new MockFilterChain();
this.filter.doFilter(request, response, chain); this.filter.doFilter(request, response, chain);
String timeTaken = (String) this.repository.findAll() String timeTaken = (String) this.repository.findAll().iterator().next().getInfo()
.iterator().next().getInfo().get("timeTaken"); .get("timeTaken");
assertThat(timeTaken).isNotNull(); assertThat(timeTaken).isNotNull();
} }

View File

@ -40,8 +40,7 @@ class HazelcastJCacheCustomizationConfiguration {
@Bean @Bean
public HazelcastPropertiesCustomizer hazelcastPropertiesCustomizer( public HazelcastPropertiesCustomizer hazelcastPropertiesCustomizer(
ObjectProvider<HazelcastInstance> hazelcastInstance) { ObjectProvider<HazelcastInstance> hazelcastInstance) {
return new HazelcastPropertiesCustomizer( return new HazelcastPropertiesCustomizer(hazelcastInstance.getIfUnique());
hazelcastInstance.getIfUnique());
} }
private static class HazelcastPropertiesCustomizer private static class HazelcastPropertiesCustomizer
@ -72,8 +71,8 @@ class HazelcastJCacheCustomizationConfiguration {
return config.getURI(); return config.getURI();
} }
catch (IOException ex) { catch (IOException ex) {
throw new IllegalArgumentException( throw new IllegalArgumentException("Could not get URI from " + config,
"Could not get URI from " + config, ex); ex);
} }
} }

View File

@ -499,7 +499,8 @@ public class CacheAutoConfigurationTests {
load(DefaultCacheConfiguration.class, "spring.cache.type=jcache", load(DefaultCacheConfiguration.class, "spring.cache.type=jcache",
"spring.cache.jcache.provider=" + cachingProviderFqn, "spring.cache.jcache.provider=" + cachingProviderFqn,
"spring.cache.jcache.config=" + configLocation); "spring.cache.jcache.config=" + configLocation);
JCacheCacheManager cacheManager = validateCacheManager(JCacheCacheManager.class); JCacheCacheManager cacheManager = validateCacheManager(
JCacheCacheManager.class);
Resource configResource = new ClassPathResource(configLocation); Resource configResource = new ClassPathResource(configLocation);
assertThat(cacheManager.getCacheManager().getURI()) assertThat(cacheManager.getCacheManager().getURI())
@ -519,10 +520,11 @@ public class CacheAutoConfigurationTests {
"spring.cache.jcache.provider=" + cachingProviderFqn); "spring.cache.jcache.provider=" + cachingProviderFqn);
JCacheCacheManager cacheManager = validateCacheManager(JCacheCacheManager.class); JCacheCacheManager cacheManager = validateCacheManager(JCacheCacheManager.class);
javax.cache.CacheManager jCacheManager = cacheManager.getCacheManager(); javax.cache.CacheManager jCacheManager = cacheManager.getCacheManager();
assertThat(jCacheManager).isInstanceOf( assertThat(jCacheManager)
com.hazelcast.cache.HazelcastCacheManager.class); .isInstanceOf(com.hazelcast.cache.HazelcastCacheManager.class);
assertThat(this.context.getBeansOfType(HazelcastInstance.class)).hasSize(1); 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) assertThat(((com.hazelcast.cache.HazelcastCacheManager) jCacheManager)
.getHazelcastInstance()).isSameAs(hazelcastInstance); .getHazelcastInstance()).isSameAs(hazelcastInstance);
assertThat(hazelcastInstance.getName()).isEqualTo("default-instance"); assertThat(hazelcastInstance.getName()).isEqualTo("default-instance");
@ -596,7 +598,8 @@ public class CacheAutoConfigurationTests {
load(JCacheWithCustomizerConfiguration.class, "spring.cache.type=jcache", load(JCacheWithCustomizerConfiguration.class, "spring.cache.type=jcache",
"spring.cache.jcache.provider=" + cachingProviderFqn, "spring.cache.jcache.provider=" + cachingProviderFqn,
"spring.cache.cacheNames[0]=foo", "spring.cache.cacheNames[1]=bar"); "spring.cache.cacheNames[0]=foo", "spring.cache.cacheNames[1]=bar");
JCacheCacheManager cacheManager = validateCacheManager(JCacheCacheManager.class); JCacheCacheManager cacheManager = validateCacheManager(
JCacheCacheManager.class);
// see customizer // see customizer
assertThat(cacheManager.getCacheNames()).containsOnly("foo", "custom1"); assertThat(cacheManager.getCacheNames()).containsOnly("foo", "custom1");
} }

View File

@ -104,29 +104,31 @@ public class TransactionAutoConfigurationTests {
assertThat(field).hasSize(1).first().isInstanceOf(TransactionProperties.class); assertThat(field).hasSize(1).first().isInstanceOf(TransactionProperties.class);
} }
@Test @Test
public void transactionNotManagedWithNoTransactionManager() { public void transactionNotManagedWithNoTransactionManager() {
load(BaseConfiguration.class); load(BaseConfiguration.class);
assertThat(this.context.getBean(TransactionalService.class) assertThat(this.context.getBean(TransactionalService.class).isTransactionActive())
.isTransactionActive()).isFalse(); .isFalse();
} }
@Test @Test
public void transactionManagerUsesCglibByDefault() { public void transactionManagerUsesCglibByDefault() {
load(TransactionManagersConfiguration.class); load(TransactionManagersConfiguration.class);
assertThat(this.context.getBean(AnotherServiceImpl.class) assertThat(this.context.getBean(AnotherServiceImpl.class).isTransactionActive())
.isTransactionActive()).isTrue(); .isTrue();
assertThat(this.context.getBeansOfType(TransactionalServiceImpl.class)).hasSize(1); assertThat(this.context.getBeansOfType(TransactionalServiceImpl.class))
.hasSize(1);
} }
@Test @Test
public void transactionManagerCanBeConfiguredToJdkProxy() { public void transactionManagerCanBeConfiguredToJdkProxy() {
load(TransactionManagersConfiguration.class, "spring.aop.proxy-target-class=false"); load(TransactionManagersConfiguration.class,
assertThat(this.context.getBean(AnotherService.class) "spring.aop.proxy-target-class=false");
.isTransactionActive()).isTrue(); assertThat(this.context.getBean(AnotherService.class).isTransactionActive())
.isTrue();
assertThat(this.context.getBeansOfType(AnotherServiceImpl.class)).hasSize(0); 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 @Test
@ -134,10 +136,11 @@ public class TransactionAutoConfigurationTests {
load(new Class<?>[] { CustomTransactionManagementConfiguration.class, load(new Class<?>[] { CustomTransactionManagementConfiguration.class,
TransactionManagersConfiguration.class }, TransactionManagersConfiguration.class },
"spring.aop.proxy-target-class=true"); "spring.aop.proxy-target-class=true");
assertThat(this.context.getBean(AnotherService.class) assertThat(this.context.getBean(AnotherService.class).isTransactionActive())
.isTransactionActive()).isTrue(); .isTrue();
assertThat(this.context.getBeansOfType(AnotherServiceImpl.class)).hasSize(0); 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) { private void load(Class<?> config, String... environment) {
@ -235,11 +238,11 @@ public class TransactionAutoConfigurationTests {
static class TransactionalServiceImpl implements TransactionalService { static class TransactionalServiceImpl implements TransactionalService {
@Override @Override
public boolean isTransactionActive() { public boolean isTransactionActive() {
return TransactionSynchronizationManager.isActualTransactionActive(); return TransactionSynchronizationManager.isActualTransactionActive();
} }
} }
interface AnotherService { interface AnotherService {
@ -250,12 +253,12 @@ public class TransactionAutoConfigurationTests {
static class AnotherServiceImpl implements AnotherService { static class AnotherServiceImpl implements AnotherService {
@Override @Override
@Transactional @Transactional
public boolean isTransactionActive() { public boolean isTransactionActive() {
return TransactionSynchronizationManager.isActualTransactionActive(); return TransactionSynchronizationManager.isActualTransactionActive();
} }
} }
} }

View File

@ -1,17 +1,12 @@
<hazelcast <hazelcast
xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-3.7.xsd" xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-3.7.xsd"
xmlns="http://www.hazelcast.com/schema/config" xmlns="http://www.hazelcast.com/schema/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<instance-name>default-instance</instance-name> <instance-name>default-instance</instance-name>
<map name="defaultCache" /> <map name="defaultCache" />
<network> <network>
<join> <join>
<tcp-ip enabled="false"/> <tcp-ip enabled="false" />
<multicast enabled="false"/> <multicast enabled="false" />
</join> </join>
</network> </network>
</hazelcast> </hazelcast>

View File

@ -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 the location of the `/health` endpoint to `/ping/me` you can set
`endpoints.health.path=/ping/me`. `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, 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. and default it to `/{id}` if you want your code to behave like the standard MVC endpoints.

View File

@ -46,6 +46,7 @@ public class UnauthenticatedAccessExample {
protected void configure(HttpSecurity http) throws Exception { protected void configure(HttpSecurity http) throws Exception {
http.antMatcher("/**").authorizeRequests().anyRequest().authenticated(); http.antMatcher("/**").authorizeRequests().anyRequest().authenticated();
} }
} }
// end::configuration[] // end::configuration[]

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -260,7 +260,7 @@ public class LogbackLoggingSystem extends Slf4JLoggingSystem {
return new ShutdownHandler(); return new ShutdownHandler();
} }
ch.qos.logback.classic.Logger getLogger(String name) { private ch.qos.logback.classic.Logger getLogger(String name) {
LoggerContext factory = getLoggerContext(); LoggerContext factory = getLoggerContext();
if (StringUtils.isEmpty(name) || ROOT_LOGGER_NAME.equals(name)) { if (StringUtils.isEmpty(name) || ROOT_LOGGER_NAME.equals(name)) {
name = Logger.ROOT_LOGGER_NAME; name = Logger.ROOT_LOGGER_NAME;

View File

@ -315,18 +315,20 @@ public class UndertowServletWebServerFactory extends AbstractServletWebServerFac
keyPassword = ssl.getKeyStorePassword().toCharArray(); keyPassword = ssl.getKeyStorePassword().toCharArray();
} }
keyManagerFactory.init(keyStore, keyPassword); keyManagerFactory.init(keyStore, keyPassword);
return getConfigurableAliasKeyManagers(ssl, keyManagerFactory.getKeyManagers()); return getConfigurableAliasKeyManagers(ssl,
keyManagerFactory.getKeyManagers());
} }
catch (Exception ex) { catch (Exception ex) {
throw new IllegalStateException(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++) { for (int i = 0; i < keyManagers.length; i++) {
if (keyManagers[i] instanceof X509ExtendedKeyManager) { if (keyManagers[i] instanceof X509ExtendedKeyManager) {
keyManagers[i] = new ConfigurableAliasKeyManager((X509ExtendedKeyManager) keyManagers[i], keyManagers[i] = new ConfigurableAliasKeyManager(
ssl.getKeyAlias()); (X509ExtendedKeyManager) keyManagers[i], ssl.getKeyAlias());
} }
} }
return keyManagers; 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 static class ConfigurableAliasKeyManager extends X509ExtendedKeyManager {
private final X509ExtendedKeyManager sourceKeyManager; private final X509ExtendedKeyManager keyManager;
private final String alias; private final String alias;
ConfigurableAliasKeyManager(X509ExtendedKeyManager keyManager, String alias) { ConfigurableAliasKeyManager(X509ExtendedKeyManager keyManager, String alias) {
this.sourceKeyManager = keyManager; this.keyManager = keyManager;
this.alias = alias; this.alias = alias;
} }
@Override @Override
public String chooseEngineClientAlias(String[] strings, Principal[] principals, SSLEngine sslEngine) { public String chooseEngineClientAlias(String[] strings, Principal[] principals,
return this.sourceKeyManager.chooseEngineClientAlias(strings, principals, sslEngine); SSLEngine sslEngine) {
return this.keyManager.chooseEngineClientAlias(strings, principals,
sslEngine);
} }
@Override @Override
public String chooseEngineServerAlias(String s, Principal[] principals, SSLEngine sslEngine) { public String chooseEngineServerAlias(String s, Principal[] principals,
SSLEngine sslEngine) {
if (this.alias == null) { if (this.alias == null) {
return this.sourceKeyManager.chooseEngineServerAlias(s, principals, sslEngine); return this.keyManager.chooseEngineServerAlias(s, principals, sslEngine);
} }
return this.alias; return this.alias;
} }
@Override
public String chooseClientAlias(String[] keyType, Principal[] issuers, public String chooseClientAlias(String[] keyType, Principal[] issuers,
Socket socket) { Socket socket) {
return this.sourceKeyManager.chooseClientAlias(keyType, issuers, socket); return this.keyManager.chooseClientAlias(keyType, issuers, socket);
} }
@Override
public String chooseServerAlias(String keyType, Principal[] issuers, public String chooseServerAlias(String keyType, Principal[] issuers,
Socket socket) { Socket socket) {
return this.sourceKeyManager.chooseServerAlias(keyType, issuers, socket); return this.keyManager.chooseServerAlias(keyType, issuers, socket);
} }
@Override
public X509Certificate[] getCertificateChain(String alias) { public X509Certificate[] getCertificateChain(String alias) {
return this.sourceKeyManager.getCertificateChain(alias); return this.keyManager.getCertificateChain(alias);
} }
@Override
public String[] getClientAliases(String keyType, Principal[] issuers) { 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) { public PrivateKey getPrivateKey(String alias) {
return this.sourceKeyManager.getPrivateKey(alias); return this.keyManager.getPrivateKey(alias);
} }
@Override
public String[] getServerAliases(String keyType, Principal[] issuers) { public String[] getServerAliases(String keyType, Principal[] issuers) {
return this.sourceKeyManager.getServerAliases(keyType, issuers); return this.keyManager.getServerAliases(keyType, issuers);
} }
} }

View File

@ -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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 { public void getLoggingConfigurationForALL() throws Exception {
this.loggingSystem.beforeInitialize(); this.loggingSystem.beforeInitialize();
this.loggingSystem.initialize(this.initializationContext, null, null); 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); logger.setLevel(Level.ALL);
LoggerConfiguration configuration = this.loggingSystem LoggerConfiguration configuration = this.loggingSystem
.getLoggerConfiguration(getClass().getName()); .getLoggerConfiguration(getClass().getName());
@ -224,7 +225,8 @@ public class LogbackLoggingSystemTests extends AbstractLoggingSystemTests {
this.loggingSystem.beforeInitialize(); this.loggingSystem.beforeInitialize();
this.loggingSystem.initialize(this.initializationContext, null, null); this.loggingSystem.initialize(this.initializationContext, null, null);
this.loggingSystem.setLogLevel(getClass().getName(), LogLevel.TRACE); 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); assertThat(logger.getLevel()).isEqualTo(Level.TRACE);
} }

View File

@ -49,6 +49,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import java.util.zip.GZIPInputStream; import java.util.zip.GZIPInputStream;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLException; import javax.net.ssl.SSLException;
import javax.servlet.GenericServlet; import javax.servlet.GenericServlet;
import javax.servlet.ServletContext; 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.impl.client.HttpClients;
import org.apache.http.protocol.HttpContext; import org.apache.http.protocol.HttpContext;
import org.apache.http.ssl.SSLContextBuilder; import org.apache.http.ssl.SSLContextBuilder;
import org.apache.http.ssl.TrustStrategy;
import org.apache.jasper.EmbeddedServletOptions; import org.apache.jasper.EmbeddedServletOptions;
import org.apache.jasper.servlet.JspServlet; import org.apache.jasper.servlet.JspServlet;
import org.junit.After; import org.junit.After;
@ -436,21 +438,21 @@ public abstract class AbstractServletWebServerFactoryTests {
@Test @Test
public void sslKeyAlias() throws Exception { public void sslKeyAlias() throws Exception {
AbstractServletWebServerFactory factory = getFactory(); AbstractServletWebServerFactory factory = getFactory();
factory.setSsl( Ssl ssl = getSsl(null, "password", "test-alias", "src/test/resources/test.jks");
getSsl(null, "password", "test-alias", "src/test/resources/test.jks")); factory.setSsl(ssl);
this.webServer = factory.getWebServer( ServletRegistrationBean<ExampleServlet> registration = new ServletRegistrationBean<>(
new ServletRegistrationBean<>(new ExampleServlet(true, false), "/hello")); new ExampleServlet(true, false), "/hello");
this.webServer = factory.getWebServer(registration);
this.webServer.start(); this.webServer.start();
SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory( TrustStrategy trustStrategy = new SerialNumberValidatingTrustSelfSignedStrategy(
new SSLContextBuilder().loadTrustMaterial(null, "77e7c302");
new SerialNumberValidatingTrustSelfSignedStrategy("77e7c302")) SSLContext sslContext = new SSLContextBuilder()
.build()); .loadTrustMaterial(null, trustStrategy).build();
HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory) HttpClient httpClient = HttpClients.custom()
.build(); .setSSLSocketFactory(new SSLConnectionSocketFactory(sslContext)).build();
HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory( String response = getResponse(getLocalUrl("https", "/hello"),
httpClient); new HttpComponentsClientHttpRequestFactory(httpClient));
assertThat(getResponse(getLocalUrl("https", "/hello"), requestFactory)) assertThat(response).contains("scheme=https");
.contains("scheme=https");
} }
@Test @Test