Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
2de7e9c3
Commit
2de7e9c3
authored
Apr 04, 2017
by
Phillip Webb
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.5.x'
parents
5cb1f320
3b93bb46
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
115 additions
and
94 deletions
+115
-94
ManagementServerProperties.java
...oot/actuate/autoconfigure/ManagementServerProperties.java
+2
-1
EnvironmentEndpoint.java
...gframework/boot/actuate/endpoint/EnvironmentEndpoint.java
+10
-10
WebRequestTraceFilter.java
...ngframework/boot/actuate/trace/WebRequestTraceFilter.java
+7
-8
EnvironmentMvcEndpointTests.java
...oot/actuate/endpoint/mvc/EnvironmentMvcEndpointTests.java
+2
-1
WebRequestTraceFilterTests.java
...mework/boot/actuate/trace/WebRequestTraceFilterTests.java
+2
-2
HazelcastJCacheCustomizationConfiguration.java
...gure/cache/HazelcastJCacheCustomizationConfiguration.java
+3
-4
CacheAutoConfigurationTests.java
...boot/autoconfigure/cache/CacheAutoConfigurationTests.java
+9
-6
TransactionAutoConfigurationTests.java
...figure/transaction/TransactionAutoConfigurationTests.java
+19
-16
hazelcast.xml
spring-boot-autoconfigure/src/test/resources/hazelcast.xml
+4
-9
production-ready-features.adoc
...oot-docs/src/main/asciidoc/production-ready-features.adoc
+2
-1
UnauthenticatedAccessExample.java
...ework/boot/web/security/UnauthenticatedAccessExample.java
+1
-0
SampleActuatorApplication.java
.../main/java/sample/actuator/SampleActuatorApplication.java
+1
-1
WebMvcTypeExcludeFilterTests.java
...toconfigure/web/servlet/WebMvcTypeExcludeFilterTests.java
+1
-1
LogbackLoggingSystem.java
...gframework/boot/logging/logback/LogbackLoggingSystem.java
+1
-1
UndertowServletWebServerFactory.java
...eb/embedded/undertow/UndertowServletWebServerFactory.java
+30
-16
LogbackLoggingSystemTests.java
...ework/boot/logging/logback/LogbackLoggingSystemTests.java
+5
-3
AbstractServletWebServerFactoryTests.java
.../servlet/server/AbstractServletWebServerFactoryTests.java
+16
-14
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/ManagementServerProperties.java
View file @
2de7e9c3
...
...
@@ -169,7 +169,8 @@ public class ManagementServerProperties implements SecurityPrerequisite {
/**
* 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,
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/EnvironmentEndpoint.java
View file @
2de7e9c3
...
...
@@ -61,7 +61,8 @@ public class EnvironmentEndpoint extends AbstractEndpoint<Map<String, Object>> {
Map
<
String
,
Object
>
result
=
new
LinkedHashMap
<>();
result
.
put
(
"profiles"
,
getEnvironment
().
getActiveProfiles
());
PropertyResolver
resolver
=
getResolver
();
for
(
Entry
<
String
,
PropertySource
<?>>
entry
:
getPropertySourcesAsMap
().
entrySet
())
{
for
(
Entry
<
String
,
PropertySource
<?>>
entry
:
getPropertySourcesAsMap
()
.
entrySet
())
{
PropertySource
<?>
source
=
entry
.
getValue
();
String
sourceName
=
entry
.
getKey
();
if
(
source
instanceof
EnumerablePropertySource
)
{
...
...
@@ -88,8 +89,7 @@ public class EnvironmentEndpoint extends AbstractEndpoint<Map<String, Object>> {
private
Map
<
String
,
PropertySource
<?>>
getPropertySourcesAsMap
()
{
Map
<
String
,
PropertySource
<?>>
map
=
new
LinkedHashMap
<
String
,
PropertySource
<?>>();
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<Map<String, Object>> {
}
/**
* {@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<Map<String, Object>> {
* @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<Map<String, Object>> {
String
value
=
super
.
getPropertyAsRawString
(
key
);
return
(
String
)
this
.
sanitizer
.
sanitize
(
key
,
value
);
}
}
}
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/WebRequestTraceFilter.java
View file @
2de7e9c3
...
...
@@ -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
<
String
,
Object
>
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
<
String
,
Object
>
headers
)
{
}
private
void
addTimeTaken
(
long
startTime
,
long
endTime
,
Map
<
String
,
Object
>
trace
)
{
long
timeTaken
=
endTime
-
startTime
;
add
(
trace
,
Include
.
TIME_TAKEN
,
"timeTaken"
,
String
.
valueOf
(
timeTaken
));
private
void
addTimeTaken
(
Map
<
String
,
Object
>
trace
,
long
startTime
)
{
long
timeTaken
=
System
.
nanoTime
()
-
startTime
;
add
(
trace
,
Include
.
TIME_TAKEN
,
"timeTaken"
,
""
+
TimeUnit
.
NANOSECONDS
.
toMillis
(
timeTaken
));
}
@SuppressWarnings
(
"unchecked"
)
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/EnvironmentMvcEndpointTests.java
View file @
2de7e9c3
...
...
@@ -138,7 +138,8 @@ public class EnvironmentMvcEndpointTests {
}
@Test
public
void
nestedPathWhenPlaceholderCannotBeResolvedShouldReturnUnresolvedProperty
()
throws
Exception
{
public
void
nestedPathWhenPlaceholderCannotBeResolvedShouldReturnUnresolvedProperty
()
throws
Exception
{
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
map
.
put
(
"my.foo"
,
"${my.bar}"
);
((
ConfigurableEnvironment
)
this
.
context
.
getEnvironment
()).
getPropertySources
()
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/trace/WebRequestTraceFilterTests.java
View file @
2de7e9c3
...
...
@@ -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
();
}
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/HazelcastJCacheCustomizationConfiguration.java
View file @
2de7e9c3
...
...
@@ -40,8 +40,7 @@ class HazelcastJCacheCustomizationConfiguration {
@Bean
public
HazelcastPropertiesCustomizer
hazelcastPropertiesCustomizer
(
ObjectProvider
<
HazelcastInstance
>
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
);
}
}
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfigurationTests.java
View file @
2de7e9c3
...
...
@@ -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"
);
}
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/transaction/TransactionAutoConfigurationTests.java
View file @
2de7e9c3
...
...
@@ -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
)
.
is
TransactionActive
()).
is
False
();
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
)
.
isTr
ansactionActive
()).
isTr
ue
();
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
();
}
}
}
spring-boot-autoconfigure/src/test/resources/hazelcast.xml
View file @
2de7e9c3
<hazelcast
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"
>
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"
>
<instance-name>
default-instance
</instance-name>
<map
name=
"defaultCache"
/>
<network>
<join>
<tcp-ip
enabled=
"false"
/>
<multicast
enabled=
"false"
/>
<tcp-ip
enabled=
"false"
/>
<multicast
enabled=
"false"
/>
</join>
</network>
</hazelcast>
spring-boot-docs/src/main/asciidoc/production-ready-features.adoc
View file @
2de7e9c3
...
...
@@ -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.
...
...
spring-boot-docs/src/main/java/org/springframework/boot/web/security/UnauthenticatedAccessExample.java
View file @
2de7e9c3
...
...
@@ -46,6 +46,7 @@ public class UnauthenticatedAccessExample {
protected
void
configure
(
HttpSecurity
http
)
throws
Exception
{
http
.
antMatcher
(
"/**"
).
authorizeRequests
().
anyRequest
().
authenticated
();
}
}
// end::configuration[]
...
...
spring-boot-samples/spring-boot-sample-actuator/src/main/java/sample/actuator/SampleActuatorApplication.java
View file @
2de7e9c3
/*
* Copyright 2012-201
6
the original author or authors.
* Copyright 2012-201
7
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.
...
...
spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/WebMvcTypeExcludeFilterTests.java
View file @
2de7e9c3
/*
* Copyright 2012-201
6
the original author or authors.
* Copyright 2012-201
7
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.
...
...
spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java
View file @
2de7e9c3
...
...
@@ -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
;
...
...
spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java
View file @
2de7e9c3
...
...
@@ -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
sourceK
eyManager
;
private
final
X509ExtendedKeyManager
k
eyManager
;
private
final
String
alias
;
ConfigurableAliasKeyManager
(
X509ExtendedKeyManager
keyManager
,
String
alias
)
{
this
.
sourceK
eyManager
=
keyManager
;
this
.
k
eyManager
=
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
.
sourceK
eyManager
.
chooseEngineServerAlias
(
s
,
principals
,
sslEngine
);
return
this
.
k
eyManager
.
chooseEngineServerAlias
(
s
,
principals
,
sslEngine
);
}
return
this
.
alias
;
}
@Override
public
String
chooseClientAlias
(
String
[]
keyType
,
Principal
[]
issuers
,
Socket
socket
)
{
return
this
.
sourceK
eyManager
.
chooseClientAlias
(
keyType
,
issuers
,
socket
);
return
this
.
k
eyManager
.
chooseClientAlias
(
keyType
,
issuers
,
socket
);
}
@Override
public
String
chooseServerAlias
(
String
keyType
,
Principal
[]
issuers
,
Socket
socket
)
{
return
this
.
sourceK
eyManager
.
chooseServerAlias
(
keyType
,
issuers
,
socket
);
return
this
.
k
eyManager
.
chooseServerAlias
(
keyType
,
issuers
,
socket
);
}
@Override
public
X509Certificate
[]
getCertificateChain
(
String
alias
)
{
return
this
.
sourceK
eyManager
.
getCertificateChain
(
alias
);
return
this
.
k
eyManager
.
getCertificateChain
(
alias
);
}
@Override
public
String
[]
getClientAliases
(
String
keyType
,
Principal
[]
issuers
)
{
return
this
.
sourceK
eyManager
.
getClientAliases
(
keyType
,
issuers
);
return
this
.
k
eyManager
.
getClientAliases
(
keyType
,
issuers
);
}
@Override
public
PrivateKey
getPrivateKey
(
String
alias
)
{
return
this
.
sourceK
eyManager
.
getPrivateKey
(
alias
);
return
this
.
k
eyManager
.
getPrivateKey
(
alias
);
}
@Override
public
String
[]
getServerAliases
(
String
keyType
,
Principal
[]
issuers
)
{
return
this
.
sourceK
eyManager
.
getServerAliases
(
keyType
,
issuers
);
return
this
.
k
eyManager
.
getServerAliases
(
keyType
,
issuers
);
}
}
...
...
spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java
View file @
2de7e9c3
/*
* Copyright 2012-201
6
the original author or authors.
* Copyright 2012-201
7
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
);
}
...
...
spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java
View file @
2de7e9c3
...
...
@@ -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
<
ExampleServlet
>
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment