This is an automated email from the ASF dual-hosted git repository. solomax pushed a commit to branch quickstart-fix-10 in repository https://gitbox.apache.org/repos/asf/wicket.git
commit e2d431b698c2253379f40a6823d258a73cb36fb7 Author: Maxim Solodovnik <[email protected]> AuthorDate: Sat Aug 26 13:52:30 2023 +0700 [WICKET-7070] quickstart should be fixed --- .../src/main/resources/archetype-resources/pom.xml | 17 ++++++++++ .../archetype-resources/src/test/java/Start.java | 36 +++++++++++++++++++--- .../src/test/jetty/jetty-http.xml | 2 +- .../src/test/jetty/jetty-https.xml | 2 +- .../src/test/jetty/jetty-ssl.xml | 2 +- .../archetype-resources/src/test/jetty/jetty.xml | 2 +- .../org/apache/wicket/examples/StartExamples.java | 4 ++- 7 files changed, 56 insertions(+), 9 deletions(-) diff --git a/archetypes/quickstart/src/main/resources/archetype-resources/pom.xml b/archetypes/quickstart/src/main/resources/archetype-resources/pom.xml index dd63abeb0e..059cfdca84 100644 --- a/archetypes/quickstart/src/main/resources/archetype-resources/pom.xml +++ b/archetypes/quickstart/src/main/resources/archetype-resources/pom.xml @@ -57,6 +57,11 @@ <artifactId>wicket-core</artifactId> <version>${wicket.version}</version> </dependency> + <dependency> + <groupId>org.apache.wicket</groupId> + <artifactId>wicket-native-websocket-javax</artifactId> + <version>${wicket.version}</version> + </dependency> <!-- OPTIONAL DEPENDENCY <dependency> <groupId>org.apache.wicket</groupId> @@ -81,6 +86,12 @@ </dependency> <!-- JETTY DEPENDENCIES FOR TESTING --> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-server</artifactId> + <scope>test</scope> + <version>${jetty.version}</version> + </dependency> <dependency> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-webapp</artifactId> @@ -90,8 +101,14 @@ <dependency> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-jmx</artifactId> + <scope>test</scope> <version>${jetty.version}</version> + </dependency> + <dependency> + <groupId>org.eclipse.jetty.websocket</groupId> + <artifactId>websocket-jakarta-server</artifactId> <scope>test</scope> + <version>${jetty.version}</version> </dependency> <!-- uncomment if WebSocket support is needed diff --git a/archetypes/quickstart/src/main/resources/archetype-resources/src/test/java/Start.java b/archetypes/quickstart/src/main/resources/archetype-resources/src/test/java/Start.java index 37d546a9a8..f40a28a3bc 100644 --- a/archetypes/quickstart/src/main/resources/archetype-resources/src/test/java/Start.java +++ b/archetypes/quickstart/src/main/resources/archetype-resources/src/test/java/Start.java @@ -1,9 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ${package}; import java.lang.management.ManagementFactory; import javax.management.MBeanServer; +import org.apache.wicket.protocol.ws.javax.WicketServerEndpointConfig; import org.eclipse.jetty.jmx.MBeanContainer; import org.eclipse.jetty.server.HttpConfiguration; import org.eclipse.jetty.server.HttpConnectionFactory; @@ -11,9 +28,13 @@ import org.eclipse.jetty.server.SecureRequestCustomizer; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.server.SslConnectionFactory; +import org.eclipse.jetty.server.session.DefaultSessionCache; +import org.eclipse.jetty.server.session.FileSessionDataStore; +import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.util.resource.Resource; import org.eclipse.jetty.util.ssl.SslContextFactory; import org.eclipse.jetty.webapp.WebAppContext; +import org.eclipse.jetty.websocket.jakarta.server.config.JakartaWebSocketServletContainerInitializer; /** * Separate startup class for people that want to run the examples directly. Use parameter @@ -26,7 +47,7 @@ public class Start * * @param args */ - public static void main(String[] args) + public static void main(String[] args) throws Exception { System.setProperty("wicket.configuration", "development"); @@ -43,7 +64,7 @@ public class Start server.addConnector(http); - Resource keystore = Resource.newClassPathResource("/keystore.p12"); + Resource keystore = Resource.newClassPathResource("/keystore"); if (keystore != null && keystore.exists()) { // if a keystore for a SSL certificate is available, start a SSL @@ -53,13 +74,15 @@ public class Start // use this certificate anywhere important as the passwords are // available in the source. - SslContextFactory sslContextFactory = new SslContextFactory(); + SslContextFactory.Server sslContextFactory = new SslContextFactory.Server(); sslContextFactory.setKeyStoreResource(keystore); sslContextFactory.setKeyStorePassword("wicket"); sslContextFactory.setKeyManagerPassword("wicket"); HttpConfiguration https_config = new HttpConfiguration(http_config); - https_config.addCustomizer(new SecureRequestCustomizer()); + SecureRequestCustomizer src = new SecureRequestCustomizer(); + src.setSniHostCheck(false); + https_config.addCustomizer(src); ServerConnector https = new ServerConnector(server, new SslConnectionFactory( sslContextFactory, "http/1.1"), new HttpConnectionFactory(https_config)); @@ -83,6 +106,11 @@ public class Start // ServerContainer serverContainer = WebSocketServerContainerInitializer.configureContext(bb); // serverContainer.addEndpoint(new WicketServerEndpointConfig()); +// bb.getSessionHandler().setSessionCache(sessionCache); + + ServletContextHandler contextHandler = ServletContextHandler.getServletContextHandler(bb.getServletContext()); + JakartaWebSocketServletContainerInitializer.configure(contextHandler, + (servletContext, container) -> container.addEndpoint(new WicketServerEndpointConfig())); // uncomment next line if you want to test with JSESSIONID encoded in the urls // ((AbstractSessionManager) // bb.getSessionHandler().getSessionManager()).setUsingCookies(false); diff --git a/archetypes/quickstart/src/main/resources/archetype-resources/src/test/jetty/jetty-http.xml b/archetypes/quickstart/src/main/resources/archetype-resources/src/test/jetty/jetty-http.xml index 7b39acb61c..9b8048ec45 100644 --- a/archetypes/quickstart/src/main/resources/archetype-resources/src/test/jetty/jetty-http.xml +++ b/archetypes/quickstart/src/main/resources/archetype-resources/src/test/jetty/jetty-http.xml @@ -1,5 +1,5 @@ <?xml version="1.0"?> -<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd"> +<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://www.eclipse.org/jetty/configure_10_0.dtd"> <!-- ============================================================= --> <!-- Configure the Jetty Server instance with an ID "Server" --> <!-- by adding a HTTP connector. --> diff --git a/archetypes/quickstart/src/main/resources/archetype-resources/src/test/jetty/jetty-https.xml b/archetypes/quickstart/src/main/resources/archetype-resources/src/test/jetty/jetty-https.xml index 35100e7c5d..3425d0f11a 100644 --- a/archetypes/quickstart/src/main/resources/archetype-resources/src/test/jetty/jetty-https.xml +++ b/archetypes/quickstart/src/main/resources/archetype-resources/src/test/jetty/jetty-https.xml @@ -1,5 +1,5 @@ <?xml version="1.0"?> -<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd"> +<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://www.eclipse.org/jetty/configure_10_0.dtd"> <!-- ============================================================= --> <!-- Configure a HTTPS connector. --> <!-- This configuration must be used in conjunction with jetty.xml --> diff --git a/archetypes/quickstart/src/main/resources/archetype-resources/src/test/jetty/jetty-ssl.xml b/archetypes/quickstart/src/main/resources/archetype-resources/src/test/jetty/jetty-ssl.xml index f23231bd72..6065fd02a6 100644 --- a/archetypes/quickstart/src/main/resources/archetype-resources/src/test/jetty/jetty-ssl.xml +++ b/archetypes/quickstart/src/main/resources/archetype-resources/src/test/jetty/jetty-ssl.xml @@ -1,5 +1,5 @@ <?xml version="1.0"?> -<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd"> +<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://www.eclipse.org/jetty/configure_10_0.dtd"> <!-- ============================================================= --> <!-- Configure a TLS (SSL) Context Factory --> <!-- This configuration must be used in conjunction with jetty.xml --> diff --git a/archetypes/quickstart/src/main/resources/archetype-resources/src/test/jetty/jetty.xml b/archetypes/quickstart/src/main/resources/archetype-resources/src/test/jetty/jetty.xml index fca91396f9..f606b20ed7 100644 --- a/archetypes/quickstart/src/main/resources/archetype-resources/src/test/jetty/jetty.xml +++ b/archetypes/quickstart/src/main/resources/archetype-resources/src/test/jetty/jetty.xml @@ -1,5 +1,5 @@ <?xml version="1.0"?> -<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd"> +<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://www.eclipse.org/jetty/configure_10_0.dtd"> <!-- ============================================================= --> <!-- Configure a HTTP connector. --> <!-- ============================================================= --> diff --git a/wicket-examples/src/test/java/org/apache/wicket/examples/StartExamples.java b/wicket-examples/src/test/java/org/apache/wicket/examples/StartExamples.java index d687d790a7..1064e89e5f 100644 --- a/wicket-examples/src/test/java/org/apache/wicket/examples/StartExamples.java +++ b/wicket-examples/src/test/java/org/apache/wicket/examples/StartExamples.java @@ -80,7 +80,9 @@ public class StartExamples sslContextFactory.setKeyManagerPassword("wicket"); HttpConfiguration https_config = new HttpConfiguration(http_config); - https_config.addCustomizer(new SecureRequestCustomizer()); + SecureRequestCustomizer src = new SecureRequestCustomizer(); + src.setSniHostCheck(false); + https_config.addCustomizer(src); ServerConnector https = new ServerConnector(server, new SslConnectionFactory( sslContextFactory, "http/1.1"), new HttpConnectionFactory(https_config));
