Skip to content

Commit 5881c9c

Browse files
committed
Polish
1 parent 43256ee commit 5881c9c

File tree

27 files changed

+100
-99
lines changed

27 files changed

+100
-99
lines changed

Diff for: spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/CrshAutoConfiguration.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@
9393
* <p>
9494
* If a Spring Security {@link AuthenticationManager} is detected, this configuration will
9595
* create a {@link CRaSHPlugin} to forward shell authentication requests to Spring
96-
* Security. This authentication method will get enabled if {@code management.shell.auth.type}
97-
* is set to {@code spring} or if no explicit {@code management.shell.auth} is provided
98-
* and a {@link AuthenticationManager} is available. In the latter case shell access will
99-
* be restricted to users having roles that match those configured in
100-
* {@link ManagementServerProperties}. Required roles can be overridden by
101-
* {@code management.shell.auth.spring.roles}.
96+
* Security. This authentication method will get enabled if
97+
* {@code management.shell.auth.type} is set to {@code spring} or if no explicit
98+
* {@code management.shell.auth} is provided and a {@link AuthenticationManager} is
99+
* available. In the latter case shell access will be restricted to users having roles
100+
* that match those configured in {@link ManagementServerProperties}. Required roles can
101+
* be overridden by {@code management.shell.auth.spring.roles}.
102102
* <p>
103103
* To add customizations to the shell simply define beans of type {@link CRaSHPlugin} in
104104
* the application context. Those beans will get auto detected during startup and

Diff for: spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/LocalManagementPort.java

+1
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,5 @@
3838
@Documented
3939
@Value("${local.management.port}")
4040
public @interface LocalManagementPort {
41+
4142
}

Diff for: spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/ShellProperties.java

+8-4
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,8 @@ public Integer getPort() {
375375
/**
376376
* Auth specific properties for JAAS authentication.
377377
*/
378-
@ConfigurationProperties(prefix = SHELL_PREFIX + ".auth.jaas", ignoreUnknownFields = false)
378+
@ConfigurationProperties(prefix = SHELL_PREFIX
379+
+ ".auth.jaas", ignoreUnknownFields = false)
379380
public static class JaasAuthenticationProperties
380381
extends CrshShellAuthenticationProperties {
381382

@@ -404,7 +405,8 @@ public String getDomain() {
404405
/**
405406
* Auth specific properties for key authentication.
406407
*/
407-
@ConfigurationProperties(prefix = SHELL_PREFIX + ".auth.key", ignoreUnknownFields = false)
408+
@ConfigurationProperties(prefix = SHELL_PREFIX
409+
+ ".auth.key", ignoreUnknownFields = false)
408410
public static class KeyAuthenticationProperties
409411
extends CrshShellAuthenticationProperties {
410412

@@ -435,7 +437,8 @@ public String getPath() {
435437
/**
436438
* Auth specific properties for simple authentication.
437439
*/
438-
@ConfigurationProperties(prefix = SHELL_PREFIX + ".auth.simple", ignoreUnknownFields = false)
440+
@ConfigurationProperties(prefix = SHELL_PREFIX
441+
+ ".auth.simple", ignoreUnknownFields = false)
439442
public static class SimpleAuthenticationProperties
440443
extends CrshShellAuthenticationProperties {
441444

@@ -511,7 +514,8 @@ public void setPassword(String password) {
511514
/**
512515
* Auth specific properties for Spring authentication.
513516
*/
514-
@ConfigurationProperties(prefix = SHELL_PREFIX + ".auth.spring", ignoreUnknownFields = false)
517+
@ConfigurationProperties(prefix = SHELL_PREFIX
518+
+ ".auth.spring", ignoreUnknownFields = false)
515519
public static class SpringAuthenticationProperties
516520
extends CrshShellAuthenticationProperties {
517521

Diff for: spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/CrshAutoConfigurationTests.java

+3-6
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ public void close() {
8181

8282
@Test
8383
public void testDisabledPlugins() throws Exception {
84-
load("management.shell.disabled_plugins=" +
85-
"termIOHandler, org.crsh.auth.AuthenticationPlugin, javaLanguage");
84+
load("management.shell.disabled_plugins="
85+
+ "termIOHandler, org.crsh.auth.AuthenticationPlugin, javaLanguage");
8686
PluginLifeCycle lifeCycle = this.context.getBean(PluginLifeCycle.class);
8787
assertThat(lifeCycle).isNotNull();
8888
assertThat(lifeCycle.getContext().getPlugins(TermIOHandler.class))
@@ -109,8 +109,7 @@ public void testAttributes() throws Exception {
109109

110110
@Test
111111
public void testSshConfiguration() {
112-
load("management.shell.ssh.enabled=true",
113-
"management.shell.ssh.port=3333");
112+
load("management.shell.ssh.enabled=true", "management.shell.ssh.port=3333");
114113
PluginLifeCycle lifeCycle = this.context.getBean(PluginLifeCycle.class);
115114
assertThat(lifeCycle.getConfig().getProperty("crash.ssh.port")).isEqualTo("3333");
116115
assertThat(lifeCycle.getConfig().getProperty("crash.ssh.auth_timeout"))
@@ -140,7 +139,6 @@ public void testSshConfigurationCustomTimeouts() {
140139
.isEqualTo("400000");
141140
}
142141

143-
144142
@Test
145143
public void testCommandResolution() {
146144
load();
@@ -329,7 +327,6 @@ private void load(String... environment) {
329327
this.context.refresh();
330328
}
331329

332-
333330
@Configuration
334331
public static class SecurityConfiguration {
335332

Diff for: spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/ShellPropertiesTests.java

+14-12
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ public void close() {
6565

6666
@Test
6767
public void testBindingAuth() {
68-
ShellProperties props = load(ShellProperties.class, "management.shell.auth.type=spring");
68+
ShellProperties props = load(ShellProperties.class,
69+
"management.shell.auth.type=spring");
6970
assertThat(props.getAuth().getType()).isEqualTo("spring");
7071
}
7172

@@ -78,7 +79,8 @@ public void testBindingAuthIfEmpty() {
7879

7980
@Test
8081
public void testBindingCommandRefreshInterval() {
81-
ShellProperties props = load(ShellProperties.class, "management.shell.command-refresh-interval=1");
82+
ShellProperties props = load(ShellProperties.class,
83+
"management.shell.command-refresh-interval=1");
8284
assertThat(props.getCommandRefreshInterval()).isEqualTo(1);
8385
}
8486

@@ -87,7 +89,7 @@ public void testBindingCommandPathPatterns() {
8789
ShellProperties props = load(ShellProperties.class,
8890
"management.shell.command-path-patterns=pattern1, pattern2");
8991
assertThat(props.getCommandPathPatterns().length).isEqualTo(2);
90-
Assert.assertArrayEquals(new String[] {"pattern1", "pattern2"},
92+
Assert.assertArrayEquals(new String[] { "pattern1", "pattern2" },
9193
props.getCommandPathPatterns());
9294
}
9395

@@ -96,7 +98,7 @@ public void testBindingConfigPathPatterns() {
9698
ShellProperties props = load(ShellProperties.class,
9799
"management.shell.config-path-patterns=pattern1, pattern2");
98100
assertThat(props.getConfigPathPatterns().length).isEqualTo(2);
99-
Assert.assertArrayEquals(new String[] {"pattern1", "pattern2"},
101+
Assert.assertArrayEquals(new String[] { "pattern1", "pattern2" },
100102
props.getConfigPathPatterns());
101103
}
102104

@@ -118,8 +120,7 @@ public void testBindingDisabledCommands() {
118120
@Test
119121
public void testBindingSsh() {
120122
ShellProperties props = load(ShellProperties.class,
121-
"management.shell.ssh.enabled=true",
122-
"management.shell.ssh.port=2222",
123+
"management.shell.ssh.enabled=true", "management.shell.ssh.port=2222",
123124
"management.shell.ssh.key-path=~/.ssh/test.pem");
124125
Properties p = props.asCrshShellConfig();
125126
assertThat(p.get("crash.ssh.port")).isEqualTo("2222");
@@ -129,8 +130,7 @@ public void testBindingSsh() {
129130
@Test
130131
public void testBindingSshIgnored() {
131132
ShellProperties props = load(ShellProperties.class,
132-
"management.shell.ssh.enabled=false",
133-
"management.shell.ssh.port=2222",
133+
"management.shell.ssh.enabled=false", "management.shell.ssh.port=2222",
134134
"management.shell.ssh.key-path=~/.ssh/test.pem");
135135
Properties p = props.asCrshShellConfig();
136136
assertThat(p.get("crash.ssh.port")).isNull();
@@ -194,14 +194,16 @@ public void testBindingSimple() {
194194

195195
@Test
196196
public void testDefaultPasswordAutoGeneratedIfUnresolvedPlaceholder() {
197-
SimpleAuthenticationProperties security = load(SimpleAuthenticationProperties.class,
197+
SimpleAuthenticationProperties security = load(
198+
SimpleAuthenticationProperties.class,
198199
"management.shell.auth.simple.user.password=${ADMIN_PASSWORD}");
199200
assertThat(security.getUser().isDefaultPassword()).isTrue();
200201
}
201202

202203
@Test
203204
public void testDefaultPasswordAutoGeneratedIfEmpty() {
204-
SimpleAuthenticationProperties security = load(SimpleAuthenticationProperties.class,
205+
SimpleAuthenticationProperties security = load(
206+
SimpleAuthenticationProperties.class,
205207
"management.shell.auth.simple.user.password=");
206208
assertThat(security.getUser().isDefaultPassword()).isTrue();
207209
}
@@ -242,9 +244,9 @@ private <T> T load(Class<T> type, String... environment) {
242244
}
243245

244246
@Configuration
245-
@EnableConfigurationProperties({ShellProperties.class,
247+
@EnableConfigurationProperties({ ShellProperties.class,
246248
JaasAuthenticationProperties.class, KeyAuthenticationProperties.class,
247-
SimpleAuthenticationProperties.class, SpringAuthenticationProperties.class})
249+
SimpleAuthenticationProperties.class, SpringAuthenticationProperties.class })
248250
static class TestConfiguration {
249251

250252
}

Diff for: spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ws/WsAutoConfiguration.java renamed to spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/webservices/WebServicesAutoConfiguration.java

+9-8
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.autoconfigure.ws;
17+
package org.springframework.boot.autoconfigure.webservices;
1818

1919
import java.util.Map;
2020

@@ -44,13 +44,13 @@
4444
@ConditionalOnWebApplication
4545
@ConditionalOnClass(MessageDispatcherServlet.class)
4646
@ConditionalOnMissingBean(WsConfigurationSupport.class)
47-
@EnableConfigurationProperties(WsProperties.class)
47+
@EnableConfigurationProperties(WebServicesProperties.class)
4848
@AutoConfigureAfter(EmbeddedServletContainerAutoConfiguration.class)
49-
public class WsAutoConfiguration {
49+
public class WebServicesAutoConfiguration {
5050

51-
private final WsProperties properties;
51+
private final WebServicesProperties properties;
5252

53-
public WsAutoConfiguration(WsProperties properties) {
53+
public WebServicesAutoConfiguration(WebServicesProperties properties) {
5454
this.properties = properties;
5555
}
5656

@@ -61,9 +61,9 @@ public ServletRegistrationBean messageDispatcherServlet(
6161
servlet.setApplicationContext(applicationContext);
6262
String path = this.properties.getPath();
6363
String urlMapping = (path.endsWith("/") ? path + "*" : path + "/*");
64-
ServletRegistrationBean registration = new ServletRegistrationBean(
65-
servlet, urlMapping);
66-
WsProperties.Servlet servletProperties = this.properties.getServlet();
64+
ServletRegistrationBean registration = new ServletRegistrationBean(servlet,
65+
urlMapping);
66+
WebServicesProperties.Servlet servletProperties = this.properties.getServlet();
6767
registration.setLoadOnStartup(servletProperties.getLoadOnStartup());
6868
for (Map.Entry<String, String> entry : servletProperties.getInit().entrySet()) {
6969
registration.addInitParameter(entry.getKey(), entry.getValue());
@@ -74,6 +74,7 @@ public ServletRegistrationBean messageDispatcherServlet(
7474
@Configuration
7575
@EnableWs
7676
protected static class WsConfiguration {
77+
7778
}
7879

7980
}

Diff for: spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ws/WsProperties.java renamed to spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/webservices/WebServicesProperties.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.autoconfigure.ws;
17+
package org.springframework.boot.autoconfigure.webservices;
1818

1919
import java.util.HashMap;
2020
import java.util.Map;
@@ -31,8 +31,8 @@
3131
* @author Stephane Nicoll
3232
* @since 1.4.0
3333
*/
34-
@ConfigurationProperties("spring.ws")
35-
public class WsProperties {
34+
@ConfigurationProperties("spring.webservices")
35+
public class WebServicesProperties {
3636

3737
/**
3838
* Path that serves as the base URI for the services.
@@ -55,7 +55,6 @@ public Servlet getServlet() {
5555
return this.servlet;
5656
}
5757

58-
5958
public static class Servlet {
6059

6160
/**

Diff for: spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ws/package-info.java renamed to spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/webservices/package-info.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
/**
1818
* Auto-configuration for Spring Web Services.
1919
*/
20-
package org.springframework.boot.autoconfigure.ws;
20+
package org.springframework.boot.autoconfigure.webservices;

Diff for: spring-boot-autoconfigure/src/main/resources/META-INF/spring.factories

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration,\
9797
org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration,\
9898
org.springframework.boot.autoconfigure.websocket.WebSocketAutoConfiguration,\
9999
org.springframework.boot.autoconfigure.websocket.WebSocketMessagingAutoConfiguration,\
100-
org.springframework.boot.autoconfigure.ws.WsAutoConfiguration
100+
org.springframework.boot.autoconfigure.webservices.WebServicesAutoConfiguration
101101

102102
# Template availability providers
103103
org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider=\

Diff for: spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/ws/WsAutoConfigurationTests.java renamed to spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/webservices/WebServicesAutoConfigurationTests.java

+18-17
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.autoconfigure.ws;
17+
package org.springframework.boot.autoconfigure.webservices;
1818

1919
import org.junit.After;
2020
import org.junit.Rule;
@@ -31,12 +31,12 @@
3131
import static org.assertj.core.api.Assertions.assertThat;
3232

3333
/**
34-
* Tests for {@link WsAutoConfiguration}.
34+
* Tests for {@link WebServicesAutoConfiguration}.
3535
*
3636
* @author Vedran Pavic
3737
* @author Stephane Nicoll
3838
*/
39-
public class WsAutoConfigurationTests {
39+
public class WebServicesAutoConfigurationTests {
4040

4141
@Rule
4242
public ExpectedException thrown = ExpectedException.none();
@@ -52,36 +52,36 @@ public void close() {
5252

5353
@Test
5454
public void defaultConfiguration() {
55-
load(WsAutoConfiguration.class);
56-
55+
load(WebServicesAutoConfiguration.class);
5756
assertThat(this.context.getBeansOfType(ServletRegistrationBean.class)).hasSize(1);
5857
}
5958

6059
@Test
6160
public void customPathMustBeginWithASlash() {
6261
this.thrown.expect(BeanCreationException.class);
6362
this.thrown.expectMessage("Path must start with /");
64-
load(WsAutoConfiguration.class, "spring.ws.path=invalid");
63+
load(WebServicesAutoConfiguration.class, "spring.webservices.path=invalid");
6564
}
6665

6766
@Test
6867
public void customPathWithTrailingSlash() {
69-
load(WsAutoConfiguration.class, "spring.ws.path=/valid/");
68+
load(WebServicesAutoConfiguration.class, "spring.webservices.path=/valid/");
7069
assertThat(this.context.getBean(ServletRegistrationBean.class).getUrlMappings())
7170
.contains("/valid/*");
7271
}
7372

7473
@Test
7574
public void customPath() {
76-
load(WsAutoConfiguration.class, "spring.ws.path=/valid");
75+
load(WebServicesAutoConfiguration.class, "spring.webservices.path=/valid");
7776
assertThat(this.context.getBeansOfType(ServletRegistrationBean.class)).hasSize(1);
7877
assertThat(this.context.getBean(ServletRegistrationBean.class).getUrlMappings())
7978
.contains("/valid/*");
8079
}
8180

8281
@Test
8382
public void customLoadOnStartup() {
84-
load(WsAutoConfiguration.class, "spring.ws.servlet.load-on-startup=1");
83+
load(WebServicesAutoConfiguration.class,
84+
"spring.webservices.servlet.load-on-startup=1");
8585
ServletRegistrationBean registrationBean = this.context
8686
.getBean(ServletRegistrationBean.class);
8787
assertThat(ReflectionTestUtils.getField(registrationBean, "loadOnStartup"))
@@ -90,21 +90,22 @@ public void customLoadOnStartup() {
9090

9191
@Test
9292
public void customInitParameters() {
93-
load(WsAutoConfiguration.class, "spring.ws.servlet.init.key1=value1",
94-
"spring.ws.servlet.init.key2=value2");
93+
load(WebServicesAutoConfiguration.class,
94+
"spring.webservices.servlet.init.key1=value1",
95+
"spring.webservices.servlet.init.key2=value2");
9596
ServletRegistrationBean registrationBean = this.context
9697
.getBean(ServletRegistrationBean.class);
9798
assertThat(registrationBean.getInitParameters()).containsEntry("key1", "value1");
9899
assertThat(registrationBean.getInitParameters()).containsEntry("key2", "value2");
99100
}
100101

101102
private void load(Class<?> config, String... environment) {
102-
AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
103-
ctx.setServletContext(new MockServletContext());
104-
EnvironmentTestUtils.addEnvironment(ctx, environment);
105-
ctx.register(config);
106-
ctx.refresh();
107-
this.context = ctx;
103+
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
104+
context.setServletContext(new MockServletContext());
105+
EnvironmentTestUtils.addEnvironment(context, environment);
106+
context.register(config);
107+
context.refresh();
108+
this.context = context;
108109
}
109110

110111
}

0 commit comments

Comments
 (0)