Polish
This commit is contained in:
@@ -93,12 +93,12 @@ import org.springframework.util.StringUtils;
|
||||
* <p>
|
||||
* If a Spring Security {@link AuthenticationManager} is detected, this configuration will
|
||||
* create a {@link CRaSHPlugin} to forward shell authentication requests to Spring
|
||||
* Security. This authentication method will get enabled if {@code management.shell.auth.type}
|
||||
* is set to {@code spring} or if no explicit {@code management.shell.auth} is provided
|
||||
* and a {@link AuthenticationManager} is available. In the latter case shell access will
|
||||
* be restricted to users having roles that match those configured in
|
||||
* {@link ManagementServerProperties}. Required roles can be overridden by
|
||||
* {@code management.shell.auth.spring.roles}.
|
||||
* Security. This authentication method will get enabled if
|
||||
* {@code management.shell.auth.type} is set to {@code spring} or if no explicit
|
||||
* {@code management.shell.auth} is provided and a {@link AuthenticationManager} is
|
||||
* available. In the latter case shell access will be restricted to users having roles
|
||||
* that match those configured in {@link ManagementServerProperties}. Required roles can
|
||||
* be overridden by {@code management.shell.auth.spring.roles}.
|
||||
* <p>
|
||||
* To add customizations to the shell simply define beans of type {@link CRaSHPlugin} in
|
||||
* the application context. Those beans will get auto detected during startup and
|
||||
|
||||
@@ -38,4 +38,5 @@ import org.springframework.beans.factory.annotation.Value;
|
||||
@Documented
|
||||
@Value("${local.management.port}")
|
||||
public @interface LocalManagementPort {
|
||||
|
||||
}
|
||||
|
||||
@@ -375,7 +375,8 @@ public class ShellProperties {
|
||||
/**
|
||||
* Auth specific properties for JAAS authentication.
|
||||
*/
|
||||
@ConfigurationProperties(prefix = SHELL_PREFIX + ".auth.jaas", ignoreUnknownFields = false)
|
||||
@ConfigurationProperties(prefix = SHELL_PREFIX
|
||||
+ ".auth.jaas", ignoreUnknownFields = false)
|
||||
public static class JaasAuthenticationProperties
|
||||
extends CrshShellAuthenticationProperties {
|
||||
|
||||
@@ -404,7 +405,8 @@ public class ShellProperties {
|
||||
/**
|
||||
* Auth specific properties for key authentication.
|
||||
*/
|
||||
@ConfigurationProperties(prefix = SHELL_PREFIX + ".auth.key", ignoreUnknownFields = false)
|
||||
@ConfigurationProperties(prefix = SHELL_PREFIX
|
||||
+ ".auth.key", ignoreUnknownFields = false)
|
||||
public static class KeyAuthenticationProperties
|
||||
extends CrshShellAuthenticationProperties {
|
||||
|
||||
@@ -435,7 +437,8 @@ public class ShellProperties {
|
||||
/**
|
||||
* Auth specific properties for simple authentication.
|
||||
*/
|
||||
@ConfigurationProperties(prefix = SHELL_PREFIX + ".auth.simple", ignoreUnknownFields = false)
|
||||
@ConfigurationProperties(prefix = SHELL_PREFIX
|
||||
+ ".auth.simple", ignoreUnknownFields = false)
|
||||
public static class SimpleAuthenticationProperties
|
||||
extends CrshShellAuthenticationProperties {
|
||||
|
||||
@@ -511,7 +514,8 @@ public class ShellProperties {
|
||||
/**
|
||||
* Auth specific properties for Spring authentication.
|
||||
*/
|
||||
@ConfigurationProperties(prefix = SHELL_PREFIX + ".auth.spring", ignoreUnknownFields = false)
|
||||
@ConfigurationProperties(prefix = SHELL_PREFIX
|
||||
+ ".auth.spring", ignoreUnknownFields = false)
|
||||
public static class SpringAuthenticationProperties
|
||||
extends CrshShellAuthenticationProperties {
|
||||
|
||||
|
||||
@@ -81,8 +81,8 @@ public class CrshAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void testDisabledPlugins() throws Exception {
|
||||
load("management.shell.disabled_plugins=" +
|
||||
"termIOHandler, org.crsh.auth.AuthenticationPlugin, javaLanguage");
|
||||
load("management.shell.disabled_plugins="
|
||||
+ "termIOHandler, org.crsh.auth.AuthenticationPlugin, javaLanguage");
|
||||
PluginLifeCycle lifeCycle = this.context.getBean(PluginLifeCycle.class);
|
||||
assertThat(lifeCycle).isNotNull();
|
||||
assertThat(lifeCycle.getContext().getPlugins(TermIOHandler.class))
|
||||
@@ -109,8 +109,7 @@ public class CrshAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void testSshConfiguration() {
|
||||
load("management.shell.ssh.enabled=true",
|
||||
"management.shell.ssh.port=3333");
|
||||
load("management.shell.ssh.enabled=true", "management.shell.ssh.port=3333");
|
||||
PluginLifeCycle lifeCycle = this.context.getBean(PluginLifeCycle.class);
|
||||
assertThat(lifeCycle.getConfig().getProperty("crash.ssh.port")).isEqualTo("3333");
|
||||
assertThat(lifeCycle.getConfig().getProperty("crash.ssh.auth_timeout"))
|
||||
@@ -140,7 +139,6 @@ public class CrshAutoConfigurationTests {
|
||||
.isEqualTo("400000");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCommandResolution() {
|
||||
load();
|
||||
@@ -329,7 +327,6 @@ public class CrshAutoConfigurationTests {
|
||||
this.context.refresh();
|
||||
}
|
||||
|
||||
|
||||
@Configuration
|
||||
public static class SecurityConfiguration {
|
||||
|
||||
|
||||
@@ -65,7 +65,8 @@ public class ShellPropertiesTests {
|
||||
|
||||
@Test
|
||||
public void testBindingAuth() {
|
||||
ShellProperties props = load(ShellProperties.class, "management.shell.auth.type=spring");
|
||||
ShellProperties props = load(ShellProperties.class,
|
||||
"management.shell.auth.type=spring");
|
||||
assertThat(props.getAuth().getType()).isEqualTo("spring");
|
||||
}
|
||||
|
||||
@@ -78,7 +79,8 @@ public class ShellPropertiesTests {
|
||||
|
||||
@Test
|
||||
public void testBindingCommandRefreshInterval() {
|
||||
ShellProperties props = load(ShellProperties.class, "management.shell.command-refresh-interval=1");
|
||||
ShellProperties props = load(ShellProperties.class,
|
||||
"management.shell.command-refresh-interval=1");
|
||||
assertThat(props.getCommandRefreshInterval()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@@ -87,7 +89,7 @@ public class ShellPropertiesTests {
|
||||
ShellProperties props = load(ShellProperties.class,
|
||||
"management.shell.command-path-patterns=pattern1, pattern2");
|
||||
assertThat(props.getCommandPathPatterns().length).isEqualTo(2);
|
||||
Assert.assertArrayEquals(new String[] {"pattern1", "pattern2"},
|
||||
Assert.assertArrayEquals(new String[] { "pattern1", "pattern2" },
|
||||
props.getCommandPathPatterns());
|
||||
}
|
||||
|
||||
@@ -96,7 +98,7 @@ public class ShellPropertiesTests {
|
||||
ShellProperties props = load(ShellProperties.class,
|
||||
"management.shell.config-path-patterns=pattern1, pattern2");
|
||||
assertThat(props.getConfigPathPatterns().length).isEqualTo(2);
|
||||
Assert.assertArrayEquals(new String[] {"pattern1", "pattern2"},
|
||||
Assert.assertArrayEquals(new String[] { "pattern1", "pattern2" },
|
||||
props.getConfigPathPatterns());
|
||||
}
|
||||
|
||||
@@ -118,8 +120,7 @@ public class ShellPropertiesTests {
|
||||
@Test
|
||||
public void testBindingSsh() {
|
||||
ShellProperties props = load(ShellProperties.class,
|
||||
"management.shell.ssh.enabled=true",
|
||||
"management.shell.ssh.port=2222",
|
||||
"management.shell.ssh.enabled=true", "management.shell.ssh.port=2222",
|
||||
"management.shell.ssh.key-path=~/.ssh/test.pem");
|
||||
Properties p = props.asCrshShellConfig();
|
||||
assertThat(p.get("crash.ssh.port")).isEqualTo("2222");
|
||||
@@ -129,8 +130,7 @@ public class ShellPropertiesTests {
|
||||
@Test
|
||||
public void testBindingSshIgnored() {
|
||||
ShellProperties props = load(ShellProperties.class,
|
||||
"management.shell.ssh.enabled=false",
|
||||
"management.shell.ssh.port=2222",
|
||||
"management.shell.ssh.enabled=false", "management.shell.ssh.port=2222",
|
||||
"management.shell.ssh.key-path=~/.ssh/test.pem");
|
||||
Properties p = props.asCrshShellConfig();
|
||||
assertThat(p.get("crash.ssh.port")).isNull();
|
||||
@@ -194,14 +194,16 @@ public class ShellPropertiesTests {
|
||||
|
||||
@Test
|
||||
public void testDefaultPasswordAutoGeneratedIfUnresolvedPlaceholder() {
|
||||
SimpleAuthenticationProperties security = load(SimpleAuthenticationProperties.class,
|
||||
SimpleAuthenticationProperties security = load(
|
||||
SimpleAuthenticationProperties.class,
|
||||
"management.shell.auth.simple.user.password=${ADMIN_PASSWORD}");
|
||||
assertThat(security.getUser().isDefaultPassword()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDefaultPasswordAutoGeneratedIfEmpty() {
|
||||
SimpleAuthenticationProperties security = load(SimpleAuthenticationProperties.class,
|
||||
SimpleAuthenticationProperties security = load(
|
||||
SimpleAuthenticationProperties.class,
|
||||
"management.shell.auth.simple.user.password=");
|
||||
assertThat(security.getUser().isDefaultPassword()).isTrue();
|
||||
}
|
||||
@@ -242,9 +244,9 @@ public class ShellPropertiesTests {
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EnableConfigurationProperties({ShellProperties.class,
|
||||
@EnableConfigurationProperties({ ShellProperties.class,
|
||||
JaasAuthenticationProperties.class, KeyAuthenticationProperties.class,
|
||||
SimpleAuthenticationProperties.class, SpringAuthenticationProperties.class})
|
||||
SimpleAuthenticationProperties.class, SpringAuthenticationProperties.class })
|
||||
static class TestConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.ws;
|
||||
package org.springframework.boot.autoconfigure.webservices;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -44,13 +44,13 @@ import org.springframework.ws.transport.http.MessageDispatcherServlet;
|
||||
@ConditionalOnWebApplication
|
||||
@ConditionalOnClass(MessageDispatcherServlet.class)
|
||||
@ConditionalOnMissingBean(WsConfigurationSupport.class)
|
||||
@EnableConfigurationProperties(WsProperties.class)
|
||||
@EnableConfigurationProperties(WebServicesProperties.class)
|
||||
@AutoConfigureAfter(EmbeddedServletContainerAutoConfiguration.class)
|
||||
public class WsAutoConfiguration {
|
||||
public class WebServicesAutoConfiguration {
|
||||
|
||||
private final WsProperties properties;
|
||||
private final WebServicesProperties properties;
|
||||
|
||||
public WsAutoConfiguration(WsProperties properties) {
|
||||
public WebServicesAutoConfiguration(WebServicesProperties properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@@ -61,9 +61,9 @@ public class WsAutoConfiguration {
|
||||
servlet.setApplicationContext(applicationContext);
|
||||
String path = this.properties.getPath();
|
||||
String urlMapping = (path.endsWith("/") ? path + "*" : path + "/*");
|
||||
ServletRegistrationBean registration = new ServletRegistrationBean(
|
||||
servlet, urlMapping);
|
||||
WsProperties.Servlet servletProperties = this.properties.getServlet();
|
||||
ServletRegistrationBean registration = new ServletRegistrationBean(servlet,
|
||||
urlMapping);
|
||||
WebServicesProperties.Servlet servletProperties = this.properties.getServlet();
|
||||
registration.setLoadOnStartup(servletProperties.getLoadOnStartup());
|
||||
for (Map.Entry<String, String> entry : servletProperties.getInit().entrySet()) {
|
||||
registration.addInitParameter(entry.getKey(), entry.getValue());
|
||||
@@ -74,6 +74,7 @@ public class WsAutoConfiguration {
|
||||
@Configuration
|
||||
@EnableWs
|
||||
protected static class WsConfiguration {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.ws;
|
||||
package org.springframework.boot.autoconfigure.webservices;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -31,8 +31,8 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
* @author Stephane Nicoll
|
||||
* @since 1.4.0
|
||||
*/
|
||||
@ConfigurationProperties("spring.ws")
|
||||
public class WsProperties {
|
||||
@ConfigurationProperties("spring.webservices")
|
||||
public class WebServicesProperties {
|
||||
|
||||
/**
|
||||
* Path that serves as the base URI for the services.
|
||||
@@ -55,7 +55,6 @@ public class WsProperties {
|
||||
return this.servlet;
|
||||
}
|
||||
|
||||
|
||||
public static class Servlet {
|
||||
|
||||
/**
|
||||
@@ -17,4 +17,4 @@
|
||||
/**
|
||||
* Auto-configuration for Spring Web Services.
|
||||
*/
|
||||
package org.springframework.boot.autoconfigure.ws;
|
||||
package org.springframework.boot.autoconfigure.webservices;
|
||||
@@ -97,7 +97,7 @@ org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration,\
|
||||
org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration,\
|
||||
org.springframework.boot.autoconfigure.websocket.WebSocketAutoConfiguration,\
|
||||
org.springframework.boot.autoconfigure.websocket.WebSocketMessagingAutoConfiguration,\
|
||||
org.springframework.boot.autoconfigure.ws.WsAutoConfiguration
|
||||
org.springframework.boot.autoconfigure.webservices.WebServicesAutoConfiguration
|
||||
|
||||
# Template availability providers
|
||||
org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider=\
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.autoconfigure.ws;
|
||||
package org.springframework.boot.autoconfigure.webservices;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Rule;
|
||||
@@ -31,12 +31,12 @@ import org.springframework.web.context.support.AnnotationConfigWebApplicationCon
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link WsAutoConfiguration}.
|
||||
* Tests for {@link WebServicesAutoConfiguration}.
|
||||
*
|
||||
* @author Vedran Pavic
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class WsAutoConfigurationTests {
|
||||
public class WebServicesAutoConfigurationTests {
|
||||
|
||||
@Rule
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
@@ -52,8 +52,7 @@ public class WsAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void defaultConfiguration() {
|
||||
load(WsAutoConfiguration.class);
|
||||
|
||||
load(WebServicesAutoConfiguration.class);
|
||||
assertThat(this.context.getBeansOfType(ServletRegistrationBean.class)).hasSize(1);
|
||||
}
|
||||
|
||||
@@ -61,19 +60,19 @@ public class WsAutoConfigurationTests {
|
||||
public void customPathMustBeginWithASlash() {
|
||||
this.thrown.expect(BeanCreationException.class);
|
||||
this.thrown.expectMessage("Path must start with /");
|
||||
load(WsAutoConfiguration.class, "spring.ws.path=invalid");
|
||||
load(WebServicesAutoConfiguration.class, "spring.webservices.path=invalid");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customPathWithTrailingSlash() {
|
||||
load(WsAutoConfiguration.class, "spring.ws.path=/valid/");
|
||||
load(WebServicesAutoConfiguration.class, "spring.webservices.path=/valid/");
|
||||
assertThat(this.context.getBean(ServletRegistrationBean.class).getUrlMappings())
|
||||
.contains("/valid/*");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customPath() {
|
||||
load(WsAutoConfiguration.class, "spring.ws.path=/valid");
|
||||
load(WebServicesAutoConfiguration.class, "spring.webservices.path=/valid");
|
||||
assertThat(this.context.getBeansOfType(ServletRegistrationBean.class)).hasSize(1);
|
||||
assertThat(this.context.getBean(ServletRegistrationBean.class).getUrlMappings())
|
||||
.contains("/valid/*");
|
||||
@@ -81,7 +80,8 @@ public class WsAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void customLoadOnStartup() {
|
||||
load(WsAutoConfiguration.class, "spring.ws.servlet.load-on-startup=1");
|
||||
load(WebServicesAutoConfiguration.class,
|
||||
"spring.webservices.servlet.load-on-startup=1");
|
||||
ServletRegistrationBean registrationBean = this.context
|
||||
.getBean(ServletRegistrationBean.class);
|
||||
assertThat(ReflectionTestUtils.getField(registrationBean, "loadOnStartup"))
|
||||
@@ -90,8 +90,9 @@ public class WsAutoConfigurationTests {
|
||||
|
||||
@Test
|
||||
public void customInitParameters() {
|
||||
load(WsAutoConfiguration.class, "spring.ws.servlet.init.key1=value1",
|
||||
"spring.ws.servlet.init.key2=value2");
|
||||
load(WebServicesAutoConfiguration.class,
|
||||
"spring.webservices.servlet.init.key1=value1",
|
||||
"spring.webservices.servlet.init.key2=value2");
|
||||
ServletRegistrationBean registrationBean = this.context
|
||||
.getBean(ServletRegistrationBean.class);
|
||||
assertThat(registrationBean.getInitParameters()).containsEntry("key1", "value1");
|
||||
@@ -99,12 +100,12 @@ public class WsAutoConfigurationTests {
|
||||
}
|
||||
|
||||
private void load(Class<?> config, String... environment) {
|
||||
AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext();
|
||||
ctx.setServletContext(new MockServletContext());
|
||||
EnvironmentTestUtils.addEnvironment(ctx, environment);
|
||||
ctx.register(config);
|
||||
ctx.refresh();
|
||||
this.context = ctx;
|
||||
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
|
||||
context.setServletContext(new MockServletContext());
|
||||
EnvironmentTestUtils.addEnvironment(context, environment);
|
||||
context.register(config);
|
||||
context.refresh();
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -160,7 +160,7 @@
|
||||
<spring-social-facebook.version>2.0.3.RELEASE</spring-social-facebook.version>
|
||||
<spring-social-linkedin.version>1.0.2.RELEASE</spring-social-linkedin.version>
|
||||
<spring-social-twitter.version>1.1.2.RELEASE</spring-social-twitter.version>
|
||||
<spring-ws.version>2.3.0.RELEASE</spring-ws.version>
|
||||
<spring-webservices.version>2.3.0.RELEASE</spring-webservices.version>
|
||||
<sqlite-jdbc.version>3.8.11.2</sqlite-jdbc.version>
|
||||
<statsd-client.version>3.1.0</statsd-client.version>
|
||||
<sun-mail.version>${javax-mail.version}</sun-mail.version>
|
||||
@@ -505,7 +505,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-ws</artifactId>
|
||||
<artifactId>spring-boot-starter-webservices</artifactId>
|
||||
<version>1.4.0.BUILD-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
@@ -2179,7 +2179,7 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.ws</groupId>
|
||||
<artifactId>spring-ws-core</artifactId>
|
||||
<version>${spring-ws.version}</version>
|
||||
<version>${spring-webservices.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>commons-logging</groupId>
|
||||
@@ -2190,7 +2190,7 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.ws</groupId>
|
||||
<artifactId>spring-ws-security</artifactId>
|
||||
<version>${spring-ws.version}</version>
|
||||
<version>${spring-webservices.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>commons-logging</groupId>
|
||||
@@ -2201,7 +2201,7 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.ws</groupId>
|
||||
<artifactId>spring-ws-support</artifactId>
|
||||
<version>${spring-ws.version}</version>
|
||||
<version>${spring-webservices.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>commons-logging</groupId>
|
||||
@@ -2212,7 +2212,7 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.ws</groupId>
|
||||
<artifactId>spring-ws-test</artifactId>
|
||||
<version>${spring-ws.version}</version>
|
||||
<version>${spring-webservices.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>commons-logging</groupId>
|
||||
|
||||
@@ -406,10 +406,10 @@ content into your application; rather pick only the properties that you need.
|
||||
spring.velocity.toolbox-config-location= # Velocity Toolbox config location. For instance `/WEB-INF/toolbox.xml`
|
||||
spring.velocity.view-names= # White list of view names that can be resolved.
|
||||
|
||||
# WEB SERVICES ({sc-spring-boot-autoconfigure}/ws/WsProperties.{sc-ext}[WsProperties])
|
||||
spring.ws.path=/services # Path that serves as the base URI for the services.
|
||||
spring.ws.servlet.init= # Servlet init parameters to pass to Spring Web Services.
|
||||
spring.ws.servlet.load-on-startup=-1 # Load on startup priority of the Spring Web Services servlet.
|
||||
# WEB SERVICES ({sc-spring-boot-autoconfigure}/webservices/WebServicesProperties.{sc-ext}[WebServicesProperties])
|
||||
spring.webservices.path=/services # Path that serves as the base URI for the services.
|
||||
spring.webservices.servlet.init= # Servlet init parameters to pass to Spring Web Services.
|
||||
spring.webservices.servlet.load-on-startup=-1 # Load on startup priority of the Spring Web Services servlet.
|
||||
|
||||
|
||||
[[common-application-properties-security]]
|
||||
|
||||
@@ -37,7 +37,7 @@ Phillip Webb; Dave Syer; Josh Long; Stéphane Nicoll; Rob Winch; Andy Wilkinson;
|
||||
:spring-boot-maven-plugin-site: http://docs.spring.io/spring-boot/docs/{spring-boot-docs-version}/maven-plugin
|
||||
:spring-reference: http://docs.spring.io/spring/docs/{spring-docs-version}/spring-framework-reference/htmlsingle
|
||||
:spring-security-reference: http://docs.spring.io/spring-security/site/docs/{spring-security-docs-version}/reference/htmlsingle
|
||||
:spring-ws-reference: http://docs.spring.io/spring-ws/docs/{spring-ws-docs-version}/reference/htmlsingle
|
||||
:spring-webservices-reference: http://docs.spring.io/spring-ws/docs/{spring-webservices-docs-version}/reference/htmlsingle
|
||||
:spring-javadoc: http://docs.spring.io/spring/docs/{spring-docs-version}/javadoc-api/org/springframework
|
||||
:spring-amqp-javadoc: http://docs.spring.io/spring-amqp/docs/current/api/org/springframework/amqp
|
||||
:spring-data-javadoc: http://docs.spring.io/spring-data/jpa/docs/current/api/org/springframework/data/jpa
|
||||
|
||||
@@ -5002,13 +5002,13 @@ be easily accessed via the `spring-boot-starter-websocket` module.
|
||||
|
||||
|
||||
|
||||
[[boot-features-ws]]
|
||||
[[boot-features-webservices]]
|
||||
== Web Services
|
||||
Spring Boot provides Web Services auto-configuration so that all is required is defining
|
||||
your `Endpoints`.
|
||||
|
||||
The {spring-ws-reference}[Spring Web Services features] can be easily accessed via the
|
||||
`spring-boot-starter-ws` module.
|
||||
The {spring-webservices-reference}[Spring Web Services features] can be easily accessed
|
||||
via the `spring-boot-starter-webservices` module.
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@
|
||||
<module>spring-boot-sample-websocket-jetty</module>
|
||||
<module>spring-boot-sample-websocket-tomcat</module>
|
||||
<module>spring-boot-sample-websocket-undertow</module>
|
||||
<module>spring-boot-sample-ws</module>
|
||||
<module>spring-boot-sample-webservices</module>
|
||||
<module>spring-boot-sample-xml</module>
|
||||
</modules>
|
||||
<!-- No dependencies - otherwise the samples won't work if you change the
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<version>1.4.0.BUILD-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>spring-boot-sample-ws</artifactId>
|
||||
<artifactId>spring-boot-sample-webservices</artifactId>
|
||||
<name>Spring Boot Web Services Sample</name>
|
||||
<description>Spring Boot Web Services Sample</description>
|
||||
<url>http://projects.spring.io/spring-boot/</url>
|
||||
@@ -26,7 +26,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-ws</artifactId>
|
||||
<artifactId>spring-boot-starter-webservices</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jaxen</groupId>
|
||||
@@ -14,16 +14,16 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package sample.ws;
|
||||
package sample.webservices;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class SampleWsApplication {
|
||||
public class SampleWebServicesApplication {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
SpringApplication.run(SampleWsApplication.class, args);
|
||||
SpringApplication.run(SampleWebServicesApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package sample.ws;
|
||||
package sample.webservices;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
@@ -29,12 +29,12 @@ public class WebServiceConfig extends WsConfigurerAdapter {
|
||||
|
||||
@Bean(name = "holiday")
|
||||
public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema countriesSchema) {
|
||||
DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
|
||||
wsdl11Definition.setPortTypeName("HumanResource");
|
||||
wsdl11Definition.setLocationUri("/holidayService/");
|
||||
wsdl11Definition.setTargetNamespace("http://mycompany.com/hr/definitions");
|
||||
wsdl11Definition.setSchema(countriesSchema);
|
||||
return wsdl11Definition;
|
||||
DefaultWsdl11Definition wsdl = new DefaultWsdl11Definition();
|
||||
wsdl.setPortTypeName("HumanResource");
|
||||
wsdl.setLocationUri("/holidayService/");
|
||||
wsdl.setTargetNamespace("http://mycompany.com/hr/definitions");
|
||||
wsdl.setSchema(countriesSchema);
|
||||
return wsdl;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package sample.ws.endpoint;
|
||||
package sample.webservices.endpoint;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
@@ -28,7 +28,7 @@ import org.jdom2.Namespace;
|
||||
import org.jdom2.filter.Filters;
|
||||
import org.jdom2.xpath.XPathExpression;
|
||||
import org.jdom2.xpath.XPathFactory;
|
||||
import sample.ws.service.HumanResourceService;
|
||||
import sample.webservices.service.HumanResourceService;
|
||||
|
||||
import org.springframework.ws.server.endpoint.annotation.Endpoint;
|
||||
import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
|
||||
@@ -40,7 +40,9 @@ public class HolidayEndpoint {
|
||||
private static final String NAMESPACE_URI = "http://mycompany.com/hr/schemas";
|
||||
|
||||
private XPathExpression<Element> startDateExpression;
|
||||
|
||||
private XPathExpression<Element> endDateExpression;
|
||||
|
||||
private XPathExpression<String> nameExpression;
|
||||
|
||||
private HumanResourceService humanResourceService;
|
||||
@@ -49,11 +51,8 @@ public class HolidayEndpoint {
|
||||
throws JDOMException, XPathFactoryConfigurationException,
|
||||
XPathExpressionException {
|
||||
this.humanResourceService = humanResourceService;
|
||||
|
||||
Namespace namespace = Namespace.getNamespace("hr", NAMESPACE_URI);
|
||||
|
||||
XPathFactory xPathFactory = XPathFactory.instance();
|
||||
|
||||
this.startDateExpression = xPathFactory.compile("//hr:StartDate",
|
||||
Filters.element(), null, namespace);
|
||||
this.endDateExpression = xPathFactory.compile("//hr:EndDate", Filters.element(),
|
||||
@@ -72,7 +71,6 @@ public class HolidayEndpoint {
|
||||
Date endDate = dateFormat
|
||||
.parse(this.endDateExpression.evaluateFirst(holidayRequest).getText());
|
||||
String name = this.nameExpression.evaluateFirst(holidayRequest);
|
||||
|
||||
this.humanResourceService.bookHoliday(startDate, endDate, name);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package sample.ws.service;
|
||||
package sample.webservices.service;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package sample.ws.service;
|
||||
package sample.webservices.service;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package sample.ws;
|
||||
package sample.webservices;
|
||||
|
||||
import java.io.StringReader;
|
||||
|
||||
@@ -62,10 +62,8 @@ public class SampleWsApplicationTests {
|
||||
+ " <hr:FirstName>John</hr:FirstName>"
|
||||
+ " <hr:LastName>Doe</hr:LastName>" + " </hr:Employee>"
|
||||
+ "</hr:HolidayRequest>";
|
||||
|
||||
StreamSource source = new StreamSource(new StringReader(request));
|
||||
StreamResult result = new StreamResult(System.out);
|
||||
|
||||
this.webServiceTemplate.sendSourceAndReceiveToResult(source, result);
|
||||
assertThat(this.output.toString()).contains("Booking holiday for");
|
||||
}
|
||||
@@ -69,7 +69,7 @@
|
||||
<module>spring-boot-starter-velocity</module>
|
||||
<module>spring-boot-starter-web</module>
|
||||
<module>spring-boot-starter-websocket</module>
|
||||
<module>spring-boot-starter-ws</module>
|
||||
<module>spring-boot-starter-webservices</module>
|
||||
</modules>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<artifactId>spring-boot-starters</artifactId>
|
||||
<version>1.4.0.BUILD-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>spring-boot-starter-ws</artifactId>
|
||||
<artifactId>spring-boot-starter-webservices</artifactId>
|
||||
<name>Spring Boot Web Services Starter</name>
|
||||
<description>Starter for using Spring Web Services</description>
|
||||
<url>http://projects.spring.io/spring-boot/</url>
|
||||
Reference in New Issue
Block a user