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
91a7bf92
Commit
91a7bf92
authored
Mar 06, 2017
by
Phillip Webb
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.5.x'
parents
dcf7e11d
fedd7b95
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
43 additions
and
27 deletions
+43
-27
CloudFoundryHealthMvcEndpoint.java
...t/actuate/cloudfoundry/CloudFoundryHealthMvcEndpoint.java
+2
-1
HealthMvcEndpoint.java
...ramework/boot/actuate/endpoint/mvc/HealthMvcEndpoint.java
+4
-3
MvcEndpointSecurityInterceptor.java
.../actuate/endpoint/mvc/MvcEndpointSecurityInterceptor.java
+1
-1
CloudFoundryHealthMvcEndpointTests.java
...uate/cloudfoundry/CloudFoundryHealthMvcEndpointTests.java
+1
-1
HealthMvcEndpointTests.java
...ork/boot/actuate/endpoint/mvc/HealthMvcEndpointTests.java
+2
-1
NoSpringSecurityHealthMvcEndpointIntegrationTests.java
...vc/NoSpringSecurityHealthMvcEndpointIntegrationTests.java
+9
-3
MongoProperties.java
...ngframework/boot/autoconfigure/mongo/MongoProperties.java
+3
-0
EmbeddedServletContainerAutoConfiguration.java
...figure/web/EmbeddedServletContainerAutoConfiguration.java
+13
-17
EmbeddedServletContainerCustomizerBeanPostProcessor.java
.../EmbeddedServletContainerCustomizerBeanPostProcessor.java
+4
-0
ErrorPageRegistrarBeanPostProcessor.java
...boot/web/servlet/ErrorPageRegistrarBeanPostProcessor.java
+4
-0
No files found.
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cloudfoundry/CloudFoundryHealthMvcEndpoint.java
View file @
91a7bf92
...
...
@@ -38,7 +38,8 @@ class CloudFoundryHealthMvcEndpoint extends HealthMvcEndpoint {
}
@Override
protected
boolean
exposeHealthDetails
(
HttpServletRequest
request
,
Principal
principal
)
{
protected
boolean
exposeHealthDetails
(
HttpServletRequest
request
,
Principal
principal
)
{
return
true
;
}
...
...
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/HealthMvcEndpoint.java
View file @
91a7bf92
...
...
@@ -183,7 +183,8 @@ public class HealthMvcEndpoint extends AbstractEndpointMvcAdapter<HealthEndpoint
return
(
accessTime
-
this
.
lastAccess
)
>=
getDelegate
().
getTimeToLive
();
}
protected
boolean
exposeHealthDetails
(
HttpServletRequest
request
,
Principal
principal
)
{
protected
boolean
exposeHealthDetails
(
HttpServletRequest
request
,
Principal
principal
)
{
if
(!
this
.
secure
)
{
return
true
;
}
...
...
@@ -192,7 +193,7 @@ public class HealthMvcEndpoint extends AbstractEndpointMvcAdapter<HealthEndpoint
if
(
request
.
isUserInRole
(
role
))
{
return
true
;
}
if
(
isSpringSecurityAuthentication
(
principal
))
{
if
(
isSpringSecurityAuthentication
(
principal
))
{
Authentication
authentication
=
(
Authentication
)
principal
;
for
(
GrantedAuthority
authority
:
authentication
.
getAuthorities
())
{
String
name
=
authority
.
getAuthority
();
...
...
@@ -217,7 +218,7 @@ public class HealthMvcEndpoint extends AbstractEndpointMvcAdapter<HealthEndpoint
private
boolean
isSpringSecurityAuthentication
(
Principal
principal
)
{
return
ClassUtils
.
isPresent
(
"org.springframework.security.core.Authentication"
,
null
)
&&
(
principal
instanceof
Authentication
)
;
null
)
&&
principal
instanceof
Authentication
;
}
}
spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/MvcEndpointSecurityInterceptor.java
View file @
91a7bf92
/*
* 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-actuator/src/test/java/org/springframework/boot/actuate/cloudfoundry/CloudFoundryHealthMvcEndpointTests.java
View file @
91a7bf92
/*
* 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-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HealthMvcEndpointTests.java
View file @
91a7bf92
...
...
@@ -167,7 +167,8 @@ public class HealthMvcEndpointTests {
public
void
rightAuthorityPresentShouldExposeDetails
()
throws
Exception
{
this
.
environment
.
getPropertySources
().
addLast
(
SECURITY_ROLES
);
Authentication
principal
=
mock
(
Authentication
.
class
);
Set
<
SimpleGrantedAuthority
>
authorities
=
Collections
.
singleton
(
new
SimpleGrantedAuthority
(
"HERO"
));
Set
<
SimpleGrantedAuthority
>
authorities
=
Collections
.
singleton
(
new
SimpleGrantedAuthority
(
"HERO"
));
doReturn
(
authorities
).
when
(
principal
).
getAuthorities
();
given
(
this
.
endpoint
.
invoke
())
.
willReturn
(
new
Health
.
Builder
().
up
().
withDetail
(
"foo"
,
"bar"
).
build
());
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/NoSpringSecurityHealthMvcEndpointIntegrationTests.java
View file @
91a7bf92
...
...
@@ -67,13 +67,15 @@ public class NoSpringSecurityHealthMvcEndpointIntegrationTests {
}
@Test
public
void
healthWhenRightRoleNotPresentShouldExposeHealthDetails
()
throws
Exception
{
public
void
healthWhenRightRoleNotPresentShouldExposeHealthDetails
()
throws
Exception
{
this
.
context
=
new
AnnotationConfigWebApplicationContext
();
this
.
context
.
setServletContext
(
new
MockServletContext
());
this
.
context
.
register
(
TestConfiguration
.
class
);
this
.
context
.
refresh
();
MockMvc
mockMvc
=
MockMvcBuilders
.
webAppContextSetup
(
this
.
context
).
build
();
mockMvc
.
perform
(
get
(
"/health"
).
with
(
getRequestPostProcessor
())).
andExpect
(
status
().
isOk
())
mockMvc
.
perform
(
get
(
"/health"
).
with
(
getRequestPostProcessor
()))
.
andExpect
(
status
().
isOk
())
.
andExpect
(
content
().
string
(
containsString
(
"\"status\":\"UP\""
)));
}
...
...
@@ -93,12 +95,15 @@ public class NoSpringSecurityHealthMvcEndpointIntegrationTests {
private
RequestPostProcessor
getRequestPostProcessor
()
{
return
new
RequestPostProcessor
()
{
@Override
public
MockHttpServletRequest
postProcessRequest
(
MockHttpServletRequest
request
)
{
public
MockHttpServletRequest
postProcessRequest
(
MockHttpServletRequest
request
)
{
Principal
principal
=
mock
(
Principal
.
class
);
request
.
setUserPrincipal
(
principal
);
return
request
;
}
};
}
...
...
@@ -117,6 +122,7 @@ public class NoSpringSecurityHealthMvcEndpointIntegrationTests {
public
Health
health
()
{
return
Health
.
up
().
withDetail
(
"hello"
,
"world"
).
build
();
}
};
}
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoProperties.java
View file @
91a7bf92
...
...
@@ -40,6 +40,9 @@ public class MongoProperties {
*/
public
static
final
int
DEFAULT_PORT
=
27017
;
/**
* Default URI used when the configured URI is {@code null}.
*/
public
static
final
String
DEFAULT_URI
=
"mongodb://localhost/test"
;
/**
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/EmbeddedServletContainerAutoConfiguration.java
View file @
91a7bf92
...
...
@@ -145,25 +145,21 @@ public class EmbeddedServletContainerAutoConfiguration {
if
(
this
.
beanFactory
==
null
)
{
return
;
}
if
(
ObjectUtils
.
isEmpty
(
this
.
beanFactory
.
getBeanNamesForType
(
EmbeddedServletContainerCustomizerBeanPostProcessor
.
class
,
true
,
false
)))
{
RootBeanDefinition
beanDefinition
=
new
RootBeanDefinition
(
EmbeddedServletContainerCustomizerBeanPostProcessor
.
class
);
beanDefinition
.
setSynthetic
(
true
);
registry
.
registerBeanDefinition
(
"embeddedServletContainerCustomizerBeanPostProcessor"
,
beanDefinition
);
registerSyntheticBeanIfMissing
(
registry
,
"embeddedServletContainerCustomizerBeanPostProcessor"
,
EmbeddedServletContainerCustomizerBeanPostProcessor
.
class
);
registerSyntheticBeanIfMissing
(
registry
,
"errorPageRegistrarBeanPostProcessor"
,
ErrorPageRegistrarBeanPostProcessor
.
class
);
}
}
if
(
ObjectUtils
.
isEmpty
(
this
.
beanFactory
.
getBeanNamesForType
(
ErrorPageRegistrarBeanPostProcessor
.
class
,
true
,
false
)))
{
RootBeanDefinition
beanDefinition
=
new
RootBeanDefinition
(
ErrorPageRegistrarBeanPostProcessor
.
c
lass
);
private
void
registerSyntheticBeanIfMissing
(
BeanDefinitionRegistry
registry
,
String
name
,
Class
<?>
beanClass
)
{
if
(
ObjectUtils
.
isEmpty
(
this
.
beanFactory
.
getBeanNamesForType
(
beanClass
,
true
,
false
)))
{
RootBeanDefinition
beanDefinition
=
new
RootBeanDefinition
(
beanC
lass
);
beanDefinition
.
setSynthetic
(
true
);
registry
.
registerBeanDefinition
(
"errorPageRegistrarBeanPostProcessor"
,
beanDefinition
);
registry
.
registerBeanDefinition
(
name
,
beanDefinition
);
}
}
...
...
spring-boot/src/main/java/org/springframework/boot/context/embedded/EmbeddedServletContainerCustomizerBeanPostProcessor.java
View file @
91a7bf92
...
...
@@ -27,6 +27,7 @@ import org.springframework.beans.factory.BeanFactoryAware;
import
org.springframework.beans.factory.ListableBeanFactory
;
import
org.springframework.beans.factory.config.BeanPostProcessor
;
import
org.springframework.core.annotation.AnnotationAwareOrderComparator
;
import
org.springframework.util.Assert
;
/**
* {@link BeanPostProcessor} that applies all {@link EmbeddedServletContainerCustomizer}s
...
...
@@ -45,6 +46,9 @@ public class EmbeddedServletContainerCustomizerBeanPostProcessor
@Override
public
void
setBeanFactory
(
BeanFactory
beanFactory
)
{
Assert
.
isInstanceOf
(
ListableBeanFactory
.
class
,
beanFactory
,
"EmbeddedServletContainerCustomizerBeanPostProcessor can only be used "
+
"with a ListableBeanFactory"
);
this
.
beanFactory
=
(
ListableBeanFactory
)
beanFactory
;
}
...
...
spring-boot/src/main/java/org/springframework/boot/web/servlet/ErrorPageRegistrarBeanPostProcessor.java
View file @
91a7bf92
...
...
@@ -27,6 +27,7 @@ import org.springframework.beans.factory.BeanFactoryAware;
import
org.springframework.beans.factory.ListableBeanFactory
;
import
org.springframework.beans.factory.config.BeanPostProcessor
;
import
org.springframework.core.annotation.AnnotationAwareOrderComparator
;
import
org.springframework.util.Assert
;
/**
* {@link BeanPostProcessor} that applies all {@link ErrorPageRegistrar}s from the bean
...
...
@@ -45,6 +46,9 @@ public class ErrorPageRegistrarBeanPostProcessor
@Override
public
void
setBeanFactory
(
BeanFactory
beanFactory
)
{
Assert
.
isInstanceOf
(
ListableBeanFactory
.
class
,
beanFactory
,
"ErrorPageRegistrarBeanPostProcessor can only be used "
+
"with a ListableBeanFactory"
);
this
.
beanFactory
=
(
ListableBeanFactory
)
beanFactory
;
}
...
...
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