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
6de479fe
Commit
6de479fe
authored
May 04, 2018
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
93046d05
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
21 deletions
+35
-21
EndpointRequest.java
...tuate/autoconfigure/security/servlet/EndpointRequest.java
+24
-13
WebMvcEndpointChildContextConfigurationTests.java
...servlet/WebMvcEndpointChildContextConfigurationTests.java
+5
-3
DispatcherServletAutoConfiguration.java
...igure/web/servlet/DispatcherServletAutoConfiguration.java
+4
-2
DispatcherServletPathProvider.java
...oconfigure/web/servlet/DispatcherServletPathProvider.java
+2
-3
No files found.
spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/security/servlet/EndpointRequest.java
View file @
6de479fe
...
@@ -165,7 +165,8 @@ public final class EndpointRequest {
...
@@ -165,7 +165,8 @@ public final class EndpointRequest {
}
}
@Override
@Override
protected
void
initialized
(
Supplier
<
WebApplicationContext
>
webApplicationContext
)
{
protected
void
initialized
(
Supplier
<
WebApplicationContext
>
webApplicationContext
)
{
this
.
delegate
=
createDelegate
(
webApplicationContext
);
this
.
delegate
=
createDelegate
(
webApplicationContext
);
}
}
...
@@ -173,8 +174,10 @@ public final class EndpointRequest {
...
@@ -173,8 +174,10 @@ public final class EndpointRequest {
Supplier
<
WebApplicationContext
>
webApplicationContext
)
{
Supplier
<
WebApplicationContext
>
webApplicationContext
)
{
try
{
try
{
WebApplicationContext
context
=
webApplicationContext
.
get
();
WebApplicationContext
context
=
webApplicationContext
.
get
();
PathMappedEndpoints
pathMappedEndpoints
=
context
.
getBean
(
PathMappedEndpoints
.
class
);
PathMappedEndpoints
pathMappedEndpoints
=
context
DispatcherServletPathProvider
pathProvider
=
context
.
getBean
(
DispatcherServletPathProvider
.
class
);
.
getBean
(
PathMappedEndpoints
.
class
);
DispatcherServletPathProvider
pathProvider
=
context
.
getBean
(
DispatcherServletPathProvider
.
class
);
return
createDelegate
(
pathMappedEndpoints
,
pathProvider
.
getServletPath
());
return
createDelegate
(
pathMappedEndpoints
,
pathProvider
.
getServletPath
());
}
}
catch
(
NoSuchBeanDefinitionException
ex
)
{
catch
(
NoSuchBeanDefinitionException
ex
)
{
...
@@ -182,18 +185,20 @@ public final class EndpointRequest {
...
@@ -182,18 +185,20 @@ public final class EndpointRequest {
}
}
}
}
private
RequestMatcher
createDelegate
(
PathMappedEndpoints
pathMappedEndpoints
,
String
servletPath
)
{
private
RequestMatcher
createDelegate
(
PathMappedEndpoints
pathMappedEndpoints
,
String
servletPath
)
{
Set
<
String
>
paths
=
new
LinkedHashSet
<>();
Set
<
String
>
paths
=
new
LinkedHashSet
<>();
if
(
this
.
includes
.
isEmpty
())
{
if
(
this
.
includes
.
isEmpty
())
{
paths
.
addAll
(
pathMappedEndpoints
.
getAllPaths
());
paths
.
addAll
(
pathMappedEndpoints
.
getAllPaths
());
}
}
streamPaths
(
this
.
includes
,
pathMappedEndpoints
).
forEach
(
paths:
:
add
);
streamPaths
(
this
.
includes
,
pathMappedEndpoints
).
forEach
(
paths:
:
add
);
streamPaths
(
this
.
excludes
,
pathMappedEndpoints
).
forEach
(
paths:
:
remove
);
streamPaths
(
this
.
excludes
,
pathMappedEndpoints
).
forEach
(
paths:
:
remove
);
List
<
RequestMatcher
>
delegateMatchers
=
getDelegateMatchers
(
servletPath
,
paths
);
List
<
RequestMatcher
>
delegateMatchers
=
getDelegateMatchers
(
servletPath
,
paths
);
if
(
this
.
includeLinks
if
(
this
.
includeLinks
&&
StringUtils
.
hasText
(
pathMappedEndpoints
.
getBasePath
()))
{
&&
StringUtils
.
hasText
(
pathMappedEndpoints
.
getBasePath
()))
{
delegateMatchers
.
add
(
delegateMatchers
.
add
(
new
AntPathRequestMatcher
(
new
AntPathRequestMatcher
(
servletPath
+
pathMappedEndpoints
.
getBasePath
()));
servletPath
+
pathMappedEndpoints
.
getBasePath
()));
}
}
return
new
OrRequestMatcher
(
delegateMatchers
);
return
new
OrRequestMatcher
(
delegateMatchers
);
}
}
...
@@ -221,8 +226,10 @@ public final class EndpointRequest {
...
@@ -221,8 +226,10 @@ public final class EndpointRequest {
return
annotation
.
id
();
return
annotation
.
id
();
}
}
private
List
<
RequestMatcher
>
getDelegateMatchers
(
String
servletPath
,
Set
<
String
>
paths
)
{
private
List
<
RequestMatcher
>
getDelegateMatchers
(
String
servletPath
,
return
paths
.
stream
().
map
((
path
)
->
new
AntPathRequestMatcher
(
servletPath
+
path
+
"/**"
))
Set
<
String
>
paths
)
{
return
paths
.
stream
()
.
map
((
path
)
->
new
AntPathRequestMatcher
(
servletPath
+
path
+
"/**"
))
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
}
}
...
@@ -247,11 +254,14 @@ public final class EndpointRequest {
...
@@ -247,11 +254,14 @@ public final class EndpointRequest {
}
}
@Override
@Override
protected
void
initialized
(
Supplier
<
WebApplicationContext
>
webApplicationContext
)
{
protected
void
initialized
(
Supplier
<
WebApplicationContext
>
webApplicationContext
)
{
try
{
try
{
WebApplicationContext
context
=
webApplicationContext
.
get
();
WebApplicationContext
context
=
webApplicationContext
.
get
();
WebEndpointProperties
properties
=
context
.
getBean
(
WebEndpointProperties
.
class
);
WebEndpointProperties
properties
=
context
DispatcherServletPathProvider
pathProvider
=
context
.
getBean
(
DispatcherServletPathProvider
.
class
);
.
getBean
(
WebEndpointProperties
.
class
);
DispatcherServletPathProvider
pathProvider
=
context
.
getBean
(
DispatcherServletPathProvider
.
class
);
this
.
delegate
=
createDelegate
(
pathProvider
.
getServletPath
(),
properties
);
this
.
delegate
=
createDelegate
(
pathProvider
.
getServletPath
(),
properties
);
}
}
catch
(
NoSuchBeanDefinitionException
ex
)
{
catch
(
NoSuchBeanDefinitionException
ex
)
{
...
@@ -259,7 +269,8 @@ public final class EndpointRequest {
...
@@ -259,7 +269,8 @@ public final class EndpointRequest {
}
}
}
}
private
RequestMatcher
createDelegate
(
String
path
,
WebEndpointProperties
properties
)
{
private
RequestMatcher
createDelegate
(
String
path
,
WebEndpointProperties
properties
)
{
if
(
StringUtils
.
hasText
(
properties
.
getBasePath
()))
{
if
(
StringUtils
.
hasText
(
properties
.
getBasePath
()))
{
return
new
AntPathRequestMatcher
(
path
+
properties
.
getBasePath
());
return
new
AntPathRequestMatcher
(
path
+
properties
.
getBasePath
());
}
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/servlet/WebMvcEndpointChildContextConfigurationTests.java
View file @
6de479fe
...
@@ -65,9 +65,11 @@ public class WebMvcEndpointChildContextConfigurationTests {
...
@@ -65,9 +65,11 @@ public class WebMvcEndpointChildContextConfigurationTests {
@Test
@Test
public
void
contextShouldConfigureDispatcherServletPathProviderWithEmptyPath
()
{
public
void
contextShouldConfigureDispatcherServletPathProviderWithEmptyPath
()
{
this
.
contextRunner
.
withUserConfiguration
(
WebMvcEndpointChildContextConfiguration
.
class
)
this
.
contextRunner
.
run
((
context
)
->
assertThat
(
context
.
getBean
(
DispatcherServletPathProvider
.
class
)
.
withUserConfiguration
(
WebMvcEndpointChildContextConfiguration
.
class
)
.
getServletPath
()).
isEmpty
());
.
run
((
context
)
->
assertThat
(
context
.
getBean
(
DispatcherServletPathProvider
.
class
).
getServletPath
())
.
isEmpty
());
}
}
static
class
ExistingConfig
{
static
class
ExistingConfig
{
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/DispatcherServletAutoConfiguration.java
View file @
6de479fe
...
@@ -90,7 +90,8 @@ public class DispatcherServletAutoConfiguration {
...
@@ -90,7 +90,8 @@ public class DispatcherServletAutoConfiguration {
private
final
ServerProperties
serverProperties
;
private
final
ServerProperties
serverProperties
;
public
DispatcherServletConfiguration
(
WebMvcProperties
webMvcProperties
,
ServerProperties
serverProperties
)
{
public
DispatcherServletConfiguration
(
WebMvcProperties
webMvcProperties
,
ServerProperties
serverProperties
)
{
this
.
webMvcProperties
=
webMvcProperties
;
this
.
webMvcProperties
=
webMvcProperties
;
this
.
serverProperties
=
serverProperties
;
this
.
serverProperties
=
serverProperties
;
}
}
...
@@ -117,7 +118,8 @@ public class DispatcherServletAutoConfiguration {
...
@@ -117,7 +118,8 @@ public class DispatcherServletAutoConfiguration {
@Bean
@Bean
public
DispatcherServletPathProvider
mainDispatcherServletPathProvider
()
{
public
DispatcherServletPathProvider
mainDispatcherServletPathProvider
()
{
return
()
->
DispatcherServletConfiguration
.
this
.
serverProperties
.
getServlet
().
getPath
();
return
()
->
DispatcherServletConfiguration
.
this
.
serverProperties
.
getServlet
()
.
getPath
();
}
}
}
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/DispatcherServletPathProvider.java
View file @
6de479fe
...
@@ -19,8 +19,8 @@ package org.springframework.boot.autoconfigure.web.servlet;
...
@@ -19,8 +19,8 @@ package org.springframework.boot.autoconfigure.web.servlet;
import
org.springframework.web.servlet.DispatcherServlet
;
import
org.springframework.web.servlet.DispatcherServlet
;
/**
/**
* Interface that provides the path of the {@link DispatcherServlet} in
* Interface that provides the path of the {@link DispatcherServlet} in
an application
*
an application
context.
* context.
*
*
* @author Madhura Bhave
* @author Madhura Bhave
* @since 2.0.2
* @since 2.0.2
...
@@ -31,4 +31,3 @@ public interface DispatcherServletPathProvider {
...
@@ -31,4 +31,3 @@ public interface DispatcherServletPathProvider {
String
getServletPath
();
String
getServletPath
();
}
}
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