From 32108c1850b7426b98ea72b49b5881d6690d0981 Mon Sep 17 00:00:00 2001 From: Thomas Mortagne Date: Fri, 16 Aug 2024 09:12:42 +0200 Subject: [PATCH] XCOMMONS-2963: Upgrade to Servlet 5.0 * move to a jakarta based Jetty 12 * also modify how the custom jetty package is built to understand better what are the customizations and make upgrades a lot easier * by default, try our best to switch on anything needed to support any character in the URLs XCOMMONS-2994: Upgrade to Websocket 2.1.1 XCOMMONS-2108: Upgrade to Bean Validation 3.0.2 XCOMMONS-2109: Upgrade to Hibernate Validator 8.0.1 XCOMMONS-2475: Use Expressly instead of Apache EL XWIKI-13963: Stop relying on the application server by default to resolve relative redirect URLs XWIKI-22586: Check all redirect URLs XWIKI-21137: Impossible to install XWiki Debian tomcat packages on Debian 12+ and Ubuntu 24.04+ --- pom.xml | 12 +- xwiki-platform-core/pom.xml | 130 +++ .../pom.xml | 5 +- .../xwiki-platform-annotation-core/pom.xml | 9 +- .../xwiki-platform-annotation-io/pom.xml | 15 +- .../pom.xml | 4 +- .../xwiki-platform-annotation-rest/pom.xml | 4 +- .../xwiki-platform-attachment-api/pom.xml | 4 +- .../pom.xml | 4 +- .../pom.xml | 4 +- .../pom.xml | 4 +- .../xwiki-platform-component-wiki/pom.xml | 19 +- .../pom.xml | 4 - .../org/xwiki/container/RedirectResponse.java | 2 + .../java/org/xwiki/container/Request.java | 205 ++++- .../java/org/xwiki/container/Response.java | 116 +++ .../java/org/xwiki/container/Session.java | 65 ++ .../internal/script/ScriptRequest.java | 159 ++++ .../internal/script/ScriptResponse.java | 53 ++ .../internal/script/ScriptSession.java | 167 ++++ .../script/ContainerScriptService.java | 77 ++ .../xwiki/container/wrap/WrappingRequest.java | 100 ++ .../container/wrap/WrappingResponse.java | 112 +++ .../main/resources/META-INF/components.txt | 1 + .../xwiki-platform-container-servlet/pom.xml | 14 +- .../servlet/HttpServletRequestStub.java | 851 ++++++++++++++++++ .../servlet/HttpServletResponseStub.java | 275 ++++++ .../container/servlet/HttpServletUtils.java | 115 ++- .../servlet/ServletContainerInitializer.java | 38 +- .../container/servlet/ServletRequest.java | 100 +- .../container/servlet/ServletResponse.java | 87 +- .../container/servlet/ServletSession.java | 77 +- .../SetThreadNameServletRequestListener.java | 30 +- .../servlet/XWikiServletContextListener.java | 183 +++- .../servlet/filters/SavedRequestManager.java | 68 +- .../ResolveRelativeRedirectFilter.java | 149 +++ .../filters/internal/SafeRedirectFilter.java | 123 +++ .../internal/SavedRequestRestorerFilter.java | 29 +- .../internal/SetCharacterEncodingFilter.java | 17 +- .../filters/internal/SetHTTPHeaderFilter.java | 19 +- .../CacheControlRequestInitializer.java | 4 +- .../DefaultServletContainerInitializer.java | 61 +- .../servlet/internal/HttpSessionManager.java | 22 +- .../internal/HttpSessionManagerTest.java | 4 +- .../internal/SafeRedirectFilterTest.java} | 58 +- .../xwiki-platform-crypto-store-wiki/pom.xml | 4 +- .../xwiki-platform-csrf/pom.xml | 4 +- .../xwiki/csrf/internal/DefaultCSRFToken.java | 9 +- .../xwiki-platform-dashboard-macro/pom.xml | 9 +- .../xwiki-platform-diff-xml/pom.xml | 14 +- .../pom.xml | 5 - .../xwiki-platform-export-pdf-api/pom.xml | 4 +- .../xwiki/export/pdf/browser/BrowserTab.java | 45 +- .../pdf/macro/PDFTocMacroParameters.java | 2 +- .../pdf/browser/BrowserPDFPrinterTest.java | 4 +- .../xwiki-platform-export-pdf-default/pom.xml | 4 +- .../export/pdf/internal/chrome/ChromeTab.java | 9 +- .../pdf/internal/chrome/ChromeTabTest.java | 8 +- .../pom.xml | 4 +- .../pom.xml | 5 - .../xwiki-platform-extension-index/pom.xml | 11 - .../xwiki-platform-extension-script/pom.xml | 5 - .../pom.xml | 4 +- .../xwiki-platform-feed-api/pom.xml | 1 + .../org/xwiki/test/TestMacroParameters.java | 2 +- .../xwiki-platform-icon-default/pom.xml | 4 +- .../xwiki-platform-icon-macro/pom.xml | 14 +- .../pom.xml | 16 +- .../xwiki-platform-image-style-api/pom.xml | 4 +- .../xwiki-platform-image-style-rest/pom.xml | 4 +- .../xwiki-platform-index-default/pom.xml | 4 +- .../xwiki-platform-index-tree-api/pom.xml | 4 +- .../xwiki-platform-job-handler/pom.xml | 4 +- .../pom.xml | 4 +- .../pom.xml | 4 +- .../pom.xml | 4 +- .../pom.xml | 1 + .../pom.xml | 4 +- .../xwiki-platform-legacy-url/pom.xml | 4 +- .../xwiki-platform-lesscss-default/pom.xml | 4 +- .../xwiki-platform-lesscss-script/pom.xml | 4 +- .../xwiki-platform-like-api/pom.xml | 4 +- .../xwiki-platform-linkchecker-api/pom.xml | 4 +- .../xwiki-platform-livedata-livetable/pom.xml | 4 +- .../xwiki-platform-livedata-rest/pom.xml | 4 +- .../xwiki-platform-livetable-ui/pom.xml | 5 - .../pom.xml | 8 - .../pom.xml | 8 - .../xwiki-platform-mail-general/pom.xml | 7 - .../xwiki-platform-mail-send-default/pom.xml | 14 +- .../xwiki-platform-mail-send-storage/pom.xml | 4 +- .../xwiki-platform-mailsender/pom.xml | 2 + .../xwiki-platform-mentions/pom.xml | 4 +- .../pom.xml | 4 +- .../xwiki-platform-netflux-api/pom.xml | 15 +- .../DefaultEntityChannelStoreTest.java | 12 +- .../EntityChannelScriptAuthorBotTest.java | 20 +- .../xwiki-platform-netflux-rest/pom.xml | 5 +- .../pom.xml | 4 +- .../pom.xml | 15 +- .../pom.xml | 4 +- .../pom.xml | 5 - .../pom.xml | 4 +- .../DefaultNotificationEmailRendererTest.java | 2 +- .../pom.xml | 4 +- .../pom.xml | 4 +- .../xwiki-platform-notifications-rest/pom.xml | 5 +- .../pom.xml | 4 +- .../pom.xml | 4 +- .../xwiki-platform-oldcore/pom.xml | 19 +- .../src/main/java/com/xpn/xwiki/XWiki.java | 4 + .../main/java/com/xpn/xwiki/XWikiContext.java | 21 + .../main/java/com/xpn/xwiki/api/Context.java | 7 +- .../DefaultXWikiContextInitializer.java | 36 +- .../xwiki/internal/XWikiContextProvider.java | 6 +- .../internal/XWikiStubContextInitializer.java | 6 +- .../internal/context/RequestInitializer.java | 2 + .../xpn/xwiki/internal/web/LegacyAction.java | 24 +- .../xpn/xwiki/render/ScriptHttpSession.java | 3 + .../render/ScriptXWikiServletRequest.java | 3 + .../render/ScriptXWikiServletResponse.java} | 23 +- .../main/java/com/xpn/xwiki/util/Util.java | 1 + .../java/com/xpn/xwiki/web/ActionFilter.java | 54 +- .../com/xpn/xwiki/web/CommentAddAction.java | 1 + .../com/xpn/xwiki/web/DownloadAction.java | 1 + .../xwiki/web/HomePageRedirectServlet.java | 14 +- .../xpn/xwiki/web/LegacyActionServlet.java | 13 +- .../java/com/xpn/xwiki/web/SkinAction.java | 1 + .../main/java/com/xpn/xwiki/web/Utils.java | 3 + .../xpn/xwiki/web/WrappingXWikiRequest.java | 453 +--------- .../xpn/xwiki/web/WrappingXWikiResponse.java | 61 ++ .../java/com/xpn/xwiki/web/XWikiAction.java | 23 +- .../web/XWikiContextInitializationFilter.java | 60 +- .../java/com/xpn/xwiki/web/XWikiForm.java | 2 + .../java/com/xpn/xwiki/web/XWikiRequest.java | 8 +- .../java/com/xpn/xwiki/web/XWikiResponse.java | 5 + .../xpn/xwiki/web/XWikiServletContext.java | 7 + .../xpn/xwiki/web/XWikiServletRequest.java | 35 +- .../xwiki/web/XWikiServletRequestStub.java | 725 ++------------- .../xpn/xwiki/web/XWikiServletResponse.java | 48 +- .../xwiki/web/XWikiServletResponseStub.java | 256 +----- .../xpn/xwiki/web/XWikiServletURLFactory.java | 1 + .../script/XWikiScriptContextInitializer.java | 12 +- .../TemporaryAttachmentSessionsManager.java | 59 +- .../context/XWikiContextContextStoreTest.java | 3 +- .../AbstractBridgedComponentTestCase.java | 2 +- .../com/xpn/xwiki/test/MockitoOldcore.java | 4 +- .../com/xpn/xwiki/web/ActionFilterTest.java | 8 +- .../xwiki/web/XWikiServletURLFactoryTest.java | 205 +++-- .../xwiki-platform-ratings-api/pom.xml | 4 +- .../xwiki-platform-realtime-api/pom.xml | 4 +- .../pom.xml | 9 +- .../pom.xml | 9 +- .../pom.xml | 5 - .../pom.xml | 8 +- .../xwiki-platform-rendering-macros/pom.xml | 4 +- .../pom.xml | 8 +- .../pom.xml | 10 +- .../xwiki-platform-rendering-xwiki/pom.xml | 14 + .../xwiki-platform-resource-servlet/pom.xml | 7 +- ...stractServletResourceReferenceHandler.java | 33 +- .../ResourceReferenceHandlerServlet.java | 19 +- .../xwiki/resource/servlet/RoutingFilter.java | 42 +- .../xwiki-platform-rest-jersey/pom.xml | 13 +- .../internal/JerseyServletContainer.java | 34 +- .../jersey/internal/XWikiRESTServlet.java | 15 +- .../xwiki-platform-rest-server/pom.xml | 4 + .../xwiki-platform-scheduler-api/pom.xml | 14 +- .../xwiki-platform-search-solr-api/pom.xml | 10 +- .../pom.xml | 9 +- .../AuthenticationFailureManager.java | 82 +- .../AuthenticationFailureStrategy.java | 23 +- .../pom.xml | 6 +- .../CaptchaAuthenticationFailureStrategy.java | 12 +- .../DefaultAuthenticationFailureManager.java | 29 +- .../DisableAccountFailureStrategy.java | 4 +- ...faultAuthenticationFailureManagerTest.java | 51 +- .../DisableAccountFailureStrategyTest.java | 33 +- .../pom.xml | 4 +- .../pom.xml | 2 + .../xwiki-platform-skin-skinx/pom.xml | 4 +- .../pom.xml | 4 +- ...ultTemporaryAttachmentSessionsManager.java | 24 +- ...emporaryAttachmentSessionsManagerTest.java | 27 +- .../xwiki-platform-tag-api/pom.xml | 5 - .../xwiki-platform-test-docker/pom.xml | 4 +- .../ServletContainerExecutor.java | 5 +- .../xwiki-platform-test-integration/pom.xml | 4 +- .../xwiki-platform-test-oldcore/pom.xml | 10 +- .../xwiki-platform-test-page/pom.xml | 4 + .../java/org/xwiki/test/page/PageTest.java | 59 +- .../xwiki-platform-url-container/pom.xml | 4 +- .../xwiki-platform-url-default/pom.xml | 11 +- .../internal/DefaultURLSecurityManager.java | 67 +- .../DefaultURLSecurityManagerTest.java | 18 +- .../pom.xml | 4 +- .../xwiki-platform-user-default/pom.xml | 1 + .../xwiki-platform-user-resource/pom.xml | 4 +- .../xwiki-platform-velocity-webapp/pom.xml | 4 +- .../xwiki-platform-vfs-api/pom.xml | 4 +- .../src/main/webapp/WEB-INF/jetty-web.xml | 4 +- .../src/main/webapp/WEB-INF/web.xml | 23 + .../xwiki-platform-webjars-api/pom.xml | 4 +- .../WebJarsResourceReferenceHandlerTest.java | 46 +- .../xwiki-platform-websocket/pom.xml | 12 +- .../websocket/AbstractXWikiEndpoint.java | 9 +- .../internal/DefaultWebSocketContext.java | 29 +- .../internal/DynamicEchoEndpoint.java | 9 +- .../internal/StaticEchoEndpoint.java | 11 +- .../internal/XWikiWebSocketRequestStub.java | 14 +- .../internal/XWikiWebSocketResponseStub.java | 24 +- .../internal/DefaultWebSocketContextTest.java | 10 +- .../internal/DynamicEchoEndpointTest.java | 8 +- .../XWikiWebSocketRequestStubTest.java | 9 +- .../XWikiWebSocketResponseStubTest.java | 12 +- .../xwiki-platform-wiki-creationjob/pom.xml | 4 +- .../xwiki-platform-wiki-default/pom.xml | 4 +- .../xwiki-platform-wiki-script/pom.xml | 4 +- .../pom.xml | 4 +- .../pom.xml | 4 +- .../xwiki-platform-wiki-user-script/pom.xml | 4 +- .../pom.xml | 4 +- .../xwiki-platform-wysiwyg-api/pom.xml | 6 +- ...kartaRequestParameterConversionResult.java | 78 ++ .../RequestParameterConversionResult.java | 24 +- .../converter/RequestParameterConverter.java | 84 +- .../wysiwyg/filter/ConversionFilter.java | 16 +- .../filter/MutableJakartaServletRequest.java | 98 ++ .../wysiwyg/filter/MutableServletRequest.java | 2 + .../filter/MutableServletRequestFactory.java | 26 +- .../DefaultRequestParameterConverter.java | 43 +- ...kartaToJavaxMutableHttpServletRequest.java | 93 ++ ...vaxToJakartaMutableHttpServletRequest.java | 93 ++ .../MutableHttpServletRequestFactory.java | 13 +- ... => MutableJakartaHttpServletRequest.java} | 16 +- .../xwiki-platform-zipexplorer/pom.xml | 5 +- .../pom.xml | 18 +- .../pom.xml | 16 +- .../pom.xml | 23 +- .../src/deb/control/control | 4 +- .../src/deb/control/postinst | 2 +- .../src/deb/control/postrm | 4 +- .../xwiki-tomcat10-systemd.conf | 3 + .../resources/etc/xwiki/xwiki-tomcat10.xml} | 0 .../pom.xml | 10 +- .../src/deb/control/control | 4 +- .../src/deb/control/postinst | 14 + .../src/deb/control/postrm | 0 .../pom.xml | 10 +- .../src/deb/control/control | 4 +- .../src/deb/control/postinst | 14 + .../src/deb/control/postrm | 0 .../pom.xml | 6 +- .../src/deb/control/control | 4 +- .../src/deb/control/postinst | 14 + .../src/deb/control/postrm | 0 .../pom.xml | 67 -- .../src/deb/control/postinst | 13 - .../src/deb/control/postrm | 21 - .../deb/resources/etc/xwiki/xwiki-tomcat8.xml | 53 -- .../src/deb/control/control | 14 - .../src/deb/control/postinst | 16 - .../src/deb/control/control | 14 - .../src/deb/control/postinst | 16 - .../src/deb/control/control | 14 - .../src/deb/control/postinst | 16 - .../src/deb/control/control | 14 - .../xwiki-tomcat9-systemd.conf | 3 - .../pom.xml | 37 - .../src/deb/control/postinst | 14 - .../src/deb/control/postrm | 9 - .../pom.xml | 37 - .../src/deb/control/postinst | 14 - .../src/deb/control/postrm | 9 - .../src/deb/control/postinst | 14 - .../src/deb/control/postrm | 9 - .../pom.xml | 12 - .../pom.xml | 4 +- .../xwiki-platform-distribution-war/pom.xml | 2 +- .../src/main/resources/xwiki.properties.vm | 19 + .../README.md | 34 +- .../pom.xml | 153 ++-- .../src/main/assembly/distribution.xml | 120 +-- .../jetty/etc/jetty-bytebufferpool.xml | 35 - .../main/resources/jetty/etc/jetty-deploy.xml | 52 -- .../resources/jetty/etc/jetty-ee-webapp.xml | 44 - .../resources/jetty/etc/jetty-ee8-deploy.xml | 86 -- .../resources/jetty/etc/jetty-ee8-webapp.xml | 43 - .../jetty/etc/jetty-http-forwarded.xml | 44 - .../main/resources/jetty/etc/jetty-http.xml | 71 -- .../main/resources/jetty/etc/jetty-https.xml | 49 - .../main/resources/jetty/etc/jetty-jmx.xml | 52 -- .../resources/jetty/etc/jetty-requestlog.xml | 69 -- .../resources/jetty/etc/jetty-ssl-context.xml | 82 -- .../main/resources/jetty/etc/jetty-ssl.xml | 84 -- .../resources/jetty/etc/jetty-threadpool.xml | 53 -- .../src/main/resources/jetty/etc/jetty.xml | 119 --- .../jetty/etc/sessions/id-manager.xml | 60 -- .../resources/jetty/etc/webdefault-ee8.xml | 414 --------- .../jetty/etc/{jetty-xwiki.xml => xwiki.xml} | 0 .../jetty/modules/bytebufferpool.mod | 58 -- .../main/resources/jetty/modules/client.mod | 30 - .../jetty/modules/console-capture.mod | 51 -- .../main/resources/jetty/modules/deploy.mod | 37 - .../resources/jetty/modules/ee-webapp.mod | 51 -- .../jetty/modules/ee8-annotations.mod | 47 - .../jetty/modules/ee8-apache-jsp.mod | 37 - .../resources/jetty/modules/ee8-deploy.mod | 69 -- .../main/resources/jetty/modules/ee8-jndi.mod | 33 - .../main/resources/jetty/modules/ee8-plus.mod | 38 - .../resources/jetty/modules/ee8-security.mod | 35 - .../resources/jetty/modules/ee8-servlet.mod | 36 - .../resources/jetty/modules/ee8-webapp.mod | 61 -- .../jetty/modules/ee8-websocket-javax.mod | 44 - .../jetty/modules/ee8-websocket-jetty.mod | 42 - .../src/main/resources/jetty/modules/ext.mod | 35 - .../jetty/modules/http-forwarded.mod | 78 -- .../src/main/resources/jetty/modules/http.mod | 78 -- .../main/resources/jetty/modules/https.mod | 40 - .../src/main/resources/jetty/modules/jmx.mod | 35 - .../src/main/resources/jetty/modules/jndi.mod | 31 - .../src/main/resources/jetty/modules/jvm.mod | 47 - .../jetty/resources/jetty-logging.properties | 30 - .../resources/jetty/modules/logging/slf4j.mod | 39 - .../src/main/resources/jetty/modules/plus.mod | 30 - .../resources/jetty/modules/requestlog.mod | 64 -- .../resources/jetty/modules/resources.mod | 36 - .../main/resources/jetty/modules/security.mod | 30 - .../main/resources/jetty/modules/server.mod | 147 --- .../main/resources/jetty/modules/sessions.mod | 47 - .../src/main/resources/jetty/modules/ssl.mod | 158 ---- .../resources/jetty/modules/threadpool.mod | 61 -- .../resources/jetty/modules/xwiki-logging.mod | 43 - .../main/resources/jetty/modules/xwiki.mod | 17 +- .../src/main/resources/start.d/xwiki.ini | 10 - .../pom.xml | 4 +- .../pom.xml | 4 +- .../xwiki-platform-tool-rootwebapp/pom.xml | 4 +- .../java/com/xpn/xwiki/XWikiRootServlet.java | 8 +- .../pom.xml | 4 +- .../pom.xml | 5 +- 341 files changed, 5550 insertions(+), 6329 deletions(-) create mode 100644 xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/java/org/xwiki/container/internal/script/ScriptRequest.java create mode 100644 xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/java/org/xwiki/container/internal/script/ScriptResponse.java create mode 100644 xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/java/org/xwiki/container/internal/script/ScriptSession.java create mode 100644 xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/java/org/xwiki/container/script/ContainerScriptService.java create mode 100644 xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/java/org/xwiki/container/wrap/WrappingRequest.java create mode 100644 xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/java/org/xwiki/container/wrap/WrappingResponse.java create mode 100644 xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/HttpServletRequestStub.java create mode 100644 xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/HttpServletResponseStub.java create mode 100644 xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/filters/internal/ResolveRelativeRedirectFilter.java create mode 100644 xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/filters/internal/SafeRedirectFilter.java rename xwiki-platform-core/{xwiki-platform-oldcore/src/test/java/com/xpn/xwiki/web/XWikiServletResponseTest.java => xwiki-platform-container/xwiki-platform-container-servlet/src/test/java/org/xwiki/container/servlet/internal/SafeRedirectFilterTest.java} (64%) rename xwiki-platform-core/{xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/filter/XWikiContextInitializationFilter.java => xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/render/ScriptXWikiServletResponse.java} (59%) create mode 100644 xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/WrappingXWikiResponse.java create mode 100644 xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/converter/JakartaRequestParameterConversionResult.java create mode 100644 xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/filter/MutableJakartaServletRequest.java create mode 100644 xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/internal/filter/http/JakartaToJavaxMutableHttpServletRequest.java create mode 100644 xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/internal/filter/http/JavaxToJakartaMutableHttpServletRequest.java rename xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/internal/filter/http/{MutableHttpServletRequest.java => MutableJakartaHttpServletRequest.java} (87%) rename xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/{xwiki-platform-distribution-debian-tomcat8-mariadb => xwiki-platform-distribution-debian-tomcat10}/pom.xml (67%) rename xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/{xwiki-platform-distribution-debian-tomcat9-common => xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-common}/pom.xml (71%) rename xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/{xwiki-platform-distribution-debian-tomcat8-common => xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-common}/src/deb/control/control (79%) rename xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/{xwiki-platform-distribution-debian-tomcat9-common => xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-common}/src/deb/control/postinst (78%) rename xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/{xwiki-platform-distribution-debian-tomcat9-common => xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-common}/src/deb/control/postrm (66%) create mode 100644 xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-common/src/deb/resources/etc/systemd/system/tomcat10.service.d/xwiki-tomcat10-systemd.conf rename xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/{xwiki-platform-distribution-debian-tomcat9-common/src/deb/resources/etc/xwiki/xwiki-tomcat9.xml => xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-common/src/deb/resources/etc/xwiki/xwiki-tomcat10.xml} (100%) rename xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/{xwiki-platform-distribution-debian-tomcat8-pgsql => xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-mariadb}/pom.xml (76%) rename xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/{xwiki-platform-distribution-debian-tomcat9-mariadb => xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-mariadb}/src/deb/control/control (85%) create mode 100644 xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-mariadb/src/deb/control/postinst rename xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/{xwiki-platform-distribution-debian-tomcat8-mariadb => xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-mariadb}/src/deb/control/postrm (100%) rename xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/{xwiki-platform-distribution-debian-tomcat8-mysql => xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-mysql}/pom.xml (76%) rename xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/{xwiki-platform-distribution-debian-tomcat9-mysql => xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-mysql}/src/deb/control/control (85%) create mode 100644 xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-mysql/src/deb/control/postinst rename xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/{xwiki-platform-distribution-debian-tomcat8-mysql => xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-mysql}/src/deb/control/postrm (100%) rename xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/{xwiki-platform-distribution-debian-tomcat9-pgsql => xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-pgsql}/pom.xml (85%) rename xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/{xwiki-platform-distribution-debian-tomcat9-pgsql => xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-pgsql}/src/deb/control/control (85%) create mode 100644 xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-pgsql/src/deb/control/postinst rename xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/{xwiki-platform-distribution-debian-tomcat8-pgsql => xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-pgsql}/src/deb/control/postrm (100%) delete mode 100644 xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-common/pom.xml delete mode 100644 xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-common/src/deb/control/postinst delete mode 100644 xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-common/src/deb/control/postrm delete mode 100644 xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-common/src/deb/resources/etc/xwiki/xwiki-tomcat8.xml delete mode 100644 xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-mariadb/src/deb/control/control delete mode 100644 xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-mariadb/src/deb/control/postinst delete mode 100644 xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-mysql/src/deb/control/control delete mode 100644 xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-mysql/src/deb/control/postinst delete mode 100644 xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-pgsql/src/deb/control/control delete mode 100644 xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-pgsql/src/deb/control/postinst delete mode 100644 xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-common/src/deb/control/control delete mode 100644 xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-common/src/deb/resources/etc/systemd/system/tomcat9.service.d/xwiki-tomcat9-systemd.conf delete mode 100644 xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-mariadb/pom.xml delete mode 100644 xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-mariadb/src/deb/control/postinst delete mode 100644 xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-mariadb/src/deb/control/postrm delete mode 100644 xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-mysql/pom.xml delete mode 100644 xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-mysql/src/deb/control/postinst delete mode 100644 xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-mysql/src/deb/control/postrm delete mode 100644 xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-pgsql/src/deb/control/postinst delete mode 100644 xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-pgsql/src/deb/control/postrm delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-bytebufferpool.xml delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-deploy.xml delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-ee-webapp.xml delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-ee8-deploy.xml delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-ee8-webapp.xml delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-http-forwarded.xml delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-http.xml delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-https.xml delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-jmx.xml delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-requestlog.xml delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-ssl-context.xml delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-ssl.xml delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-threadpool.xml delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty.xml delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/sessions/id-manager.xml delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/webdefault-ee8.xml rename xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/{jetty-xwiki.xml => xwiki.xml} (100%) delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/bytebufferpool.mod delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/client.mod delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/console-capture.mod delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/deploy.mod delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee-webapp.mod delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee8-annotations.mod delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee8-apache-jsp.mod delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee8-deploy.mod delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee8-jndi.mod delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee8-plus.mod delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee8-security.mod delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee8-servlet.mod delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee8-webapp.mod delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee8-websocket-javax.mod delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee8-websocket-jetty.mod delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ext.mod delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/http-forwarded.mod delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/http.mod delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/https.mod delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/jmx.mod delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/jndi.mod delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/jvm.mod delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/logging/jetty/resources/jetty-logging.properties delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/logging/slf4j.mod delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/plus.mod delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/requestlog.mod delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/resources.mod delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/security.mod delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/server.mod delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/sessions.mod delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ssl.mod delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/threadpool.mod delete mode 100644 xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/xwiki-logging.mod diff --git a/pom.xml b/pom.xml index 1490a2b906d5..9e324d191d16 100644 --- a/pom.xml +++ b/pom.xml @@ -58,14 +58,6 @@ 12.0.15 10.0.24 ${jetty.client.version} - - 2.0.16 - - 9.0.96 4.1.116.Final 5.6.15.Final 3.4.1 @@ -1052,6 +1044,10 @@ org.glassfish.hk2.external jakarta.inject + + jakarta.validation + jakarta.validation-api + diff --git a/xwiki-platform-core/pom.xml b/xwiki-platform-core/pom.xml index f9729b5dad4f..59dc6b417219 100644 --- a/xwiki-platform-core/pom.xml +++ b/xwiki-platform-core/pom.xml @@ -137,6 +137,17 @@ Single justification example: + + + + + java.method.removed + method void org.xwiki.diff.xml.XMLDiff::xxx() + Unstable API added by mistake. + highlight + + + --> @@ -497,6 +508,125 @@ + + + + revapi false positives + allowed + + + true + true + java.method.addedToInterface + .*@ com.xpn.xwiki.web.XWikiResponse + + + true + true + java.method.addedToInterface + .*@ com.xpn.xwiki.web.XWikiRequest + + + true + java.class.nonFinalClassInheritsFromNewClass + class com.xpn.xwiki.render.ScriptXWikiServletRequest + class com.xpn.xwiki.render.ScriptXWikiServletRequest + javax.servlet.ServletRequestWrapper + + + true + java.class.nonFinalClassInheritsFromNewClass + class com.xpn.xwiki.web.WrappingXWikiRequest + class com.xpn.xwiki.web.WrappingXWikiRequest + javax.servlet.ServletRequestWrapper + + + true + java.class.nonFinalClassInheritsFromNewClass + class com.xpn.xwiki.web.XWikiServletRequestStub + class com.xpn.xwiki.web.XWikiServletRequestStub + javax.servlet.ServletRequestWrapper + + + true + java.class.nonFinalClassInheritsFromNewClass + class com.xpn.xwiki.web.XWikiServletResponseStub + class com.xpn.xwiki.web.XWikiServletResponseStub + javax.servlet.ServletResponseWrapper + + + + + Move to Jakarta + highlight + + + true + true + .* + .*org.xwiki.websocket.AbstractXWikiEndpoint.* + + + true + true + .* + .*org.xwiki.container.servlet.SetThreadNameServletRequestListener.* + + + true + true + .* + .*org.xwiki.resource.servlet.ResourceReferenceHandlerServlet.* + + + true + true + .* + .*org.xwiki.resource.servlet.RoutingFilter.* + + + true + true + .* + .*org.xwiki.wysiwyg.filter.ConversionFilter.* + + + true + true + .* + .*com.xpn.xwiki.web.ActionFilter.* + + + true + true + .* + .*com.xpn.xwiki.web.HomePageRedirectServlet.* + + + true + true + .* + .*com.xpn.xwiki.web.LegacyActionServlet.* + + + true + true + .* + .*org.xwiki.container.servlet.XWikiServletContextListener.* + + + true + true + .* + .*com.xpn.xwiki.web.XWikiContextInitializationFilter.* + + + true + java.class.removed + class org.xwiki.wysiwyg.filter.XWikiContextInitializationFilter + + + diff --git a/xwiki-platform-core/xwiki-platform-activeinstalls2/xwiki-platform-activeinstalls2-api/pom.xml b/xwiki-platform-core/xwiki-platform-activeinstalls2/xwiki-platform-activeinstalls2-api/pom.xml index 19eae59eb510..f92b137c52a9 100644 --- a/xwiki-platform-core/xwiki-platform-activeinstalls2/xwiki-platform-activeinstalls2-api/pom.xml +++ b/xwiki-platform-core/xwiki-platform-activeinstalls2/xwiki-platform-activeinstalls2-api/pom.xml @@ -74,9 +74,10 @@ - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api + org.testcontainers diff --git a/xwiki-platform-core/xwiki-platform-annotation/xwiki-platform-annotation-core/pom.xml b/xwiki-platform-core/xwiki-platform-annotation/xwiki-platform-annotation-core/pom.xml index 0f31cba6aae4..b234e3266595 100644 --- a/xwiki-platform-core/xwiki-platform-annotation/xwiki-platform-annotation-core/pom.xml +++ b/xwiki-platform-core/xwiki-platform-annotation/xwiki-platform-annotation-core/pom.xml @@ -85,14 +85,13 @@ test - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test - - org.mortbay.jasper - apache-el + org.glassfish.expressly + expressly test diff --git a/xwiki-platform-core/xwiki-platform-annotation/xwiki-platform-annotation-io/pom.xml b/xwiki-platform-core/xwiki-platform-annotation/xwiki-platform-annotation-io/pom.xml index bc0f882d63cb..30bdc3601b3e 100644 --- a/xwiki-platform-core/xwiki-platform-annotation/xwiki-platform-annotation-io/pom.xml +++ b/xwiki-platform-core/xwiki-platform-annotation/xwiki-platform-annotation-io/pom.xml @@ -67,23 +67,12 @@ - - javax.servlet - javax.servlet-api - test - - - org.xwiki.commons - xwiki-commons-tool-test-component - ${commons.version} - test - org.xwiki.platform - xwiki-platform-oldcore + xwiki-platform-test-oldcore ${project.version} + pom test - test-jar diff --git a/xwiki-platform-core/xwiki-platform-annotation/xwiki-platform-annotation-maintainer/pom.xml b/xwiki-platform-core/xwiki-platform-annotation/xwiki-platform-annotation-maintainer/pom.xml index 149d7b809b51..b971999c01ec 100644 --- a/xwiki-platform-core/xwiki-platform-annotation/xwiki-platform-annotation-maintainer/pom.xml +++ b/xwiki-platform-core/xwiki-platform-annotation/xwiki-platform-annotation-maintainer/pom.xml @@ -108,8 +108,8 @@ test - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test diff --git a/xwiki-platform-core/xwiki-platform-annotation/xwiki-platform-annotation-rest/pom.xml b/xwiki-platform-core/xwiki-platform-annotation/xwiki-platform-annotation-rest/pom.xml index 7f675df163ad..bfec39890833 100644 --- a/xwiki-platform-core/xwiki-platform-annotation/xwiki-platform-annotation-rest/pom.xml +++ b/xwiki-platform-core/xwiki-platform-annotation/xwiki-platform-annotation-rest/pom.xml @@ -64,8 +64,8 @@ ${project.version} - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api org.xwiki.platform diff --git a/xwiki-platform-core/xwiki-platform-attachment/xwiki-platform-attachment-api/pom.xml b/xwiki-platform-core/xwiki-platform-attachment/xwiki-platform-attachment-api/pom.xml index 46dfacd389db..821b3fff768f 100644 --- a/xwiki-platform-core/xwiki-platform-attachment/xwiki-platform-attachment-api/pom.xml +++ b/xwiki-platform-core/xwiki-platform-attachment/xwiki-platform-attachment-api/pom.xml @@ -51,8 +51,8 @@ ${project.version} - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api org.xwiki.platform diff --git a/xwiki-platform-core/xwiki-platform-attachment/xwiki-platform-attachment-validation/xwiki-platform-attachment-validation-api/pom.xml b/xwiki-platform-core/xwiki-platform-attachment/xwiki-platform-attachment-validation/xwiki-platform-attachment-validation-api/pom.xml index 6cc71c8730fe..2da6682317ff 100644 --- a/xwiki-platform-core/xwiki-platform-attachment/xwiki-platform-attachment-validation/xwiki-platform-attachment-validation-api/pom.xml +++ b/xwiki-platform-core/xwiki-platform-attachment/xwiki-platform-attachment-validation/xwiki-platform-attachment-validation-api/pom.xml @@ -42,8 +42,8 @@ ${commons.version} - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api org.xwiki.commons diff --git a/xwiki-platform-core/xwiki-platform-attachment/xwiki-platform-attachment-validation/xwiki-platform-attachment-validation-default/pom.xml b/xwiki-platform-core/xwiki-platform-attachment/xwiki-platform-attachment-validation/xwiki-platform-attachment-validation-default/pom.xml index f16ea31d7f48..e5547f26c6a9 100644 --- a/xwiki-platform-core/xwiki-platform-attachment/xwiki-platform-attachment-validation/xwiki-platform-attachment-validation-default/pom.xml +++ b/xwiki-platform-core/xwiki-platform-attachment/xwiki-platform-attachment-validation/xwiki-platform-attachment-validation-default/pom.xml @@ -68,8 +68,8 @@ test - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test diff --git a/xwiki-platform-core/xwiki-platform-captcha/xwiki-platform-captcha-jcaptcha/xwiki-platform-captcha-jcaptcha-api/pom.xml b/xwiki-platform-core/xwiki-platform-captcha/xwiki-platform-captcha-jcaptcha/xwiki-platform-captcha-jcaptcha-api/pom.xml index 2494009d21cf..6e68565f3e6f 100644 --- a/xwiki-platform-core/xwiki-platform-captcha/xwiki-platform-captcha-jcaptcha/xwiki-platform-captcha-jcaptcha-api/pom.xml +++ b/xwiki-platform-core/xwiki-platform-captcha/xwiki-platform-captcha-jcaptcha/xwiki-platform-captcha-jcaptcha-api/pom.xml @@ -94,8 +94,8 @@ - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api org.xwiki.commons diff --git a/xwiki-platform-core/xwiki-platform-component/xwiki-platform-component-wiki/pom.xml b/xwiki-platform-core/xwiki-platform-component/xwiki-platform-component-wiki/pom.xml index 2f00d161f8ed..06973661208d 100644 --- a/xwiki-platform-core/xwiki-platform-component/xwiki-platform-component-wiki/pom.xml +++ b/xwiki-platform-core/xwiki-platform-component/xwiki-platform-component-wiki/pom.xml @@ -81,14 +81,10 @@ - javax.servlet - javax.servlet-api - test - - - org.xwiki.commons - xwiki-commons-tool-test-component - ${commons.version} + org.xwiki.platform + xwiki-platform-test-oldcore + ${project.version} + pom test @@ -97,13 +93,6 @@ ${commons.version} test - - org.xwiki.platform - xwiki-platform-test-oldcore - ${project.version} - pom - test - diff --git a/xwiki-platform-core/xwiki-platform-configuration/xwiki-platform-configuration-default/pom.xml b/xwiki-platform-core/xwiki-platform-configuration/xwiki-platform-configuration-default/pom.xml index bbcbe5da1ed7..926b1ec30258 100644 --- a/xwiki-platform-core/xwiki-platform-configuration/xwiki-platform-configuration-default/pom.xml +++ b/xwiki-platform-core/xwiki-platform-configuration/xwiki-platform-configuration-default/pom.xml @@ -91,10 +91,6 @@ ${commons.version} test - - javax.servlet - javax.servlet-api - diff --git a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/java/org/xwiki/container/RedirectResponse.java b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/java/org/xwiki/container/RedirectResponse.java index 4438d34a36d1..16a0ea6d0836 100644 --- a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/java/org/xwiki/container/RedirectResponse.java +++ b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/java/org/xwiki/container/RedirectResponse.java @@ -27,7 +27,9 @@ * * @version $Id$ * @since 10.0 + * @deprecated merged with {@link Response} */ +@Deprecated(since = "42.0.0") public interface RedirectResponse extends Response { /** diff --git a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/java/org/xwiki/container/Request.java b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/java/org/xwiki/container/Request.java index 6fa349413bd2..f93fe250a46c 100644 --- a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/java/org/xwiki/container/Request.java +++ b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/java/org/xwiki/container/Request.java @@ -19,18 +19,215 @@ */ package org.xwiki.container; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Enumeration; import java.util.List; +import org.xwiki.stability.Unstable; +import org.xwiki.user.UserReference; + +/** + * Represent metadata associated with a request sent to an XWiki container by a client. + *

+ * The difference between properties and attributes is that the properties are expected to be sent by the client while + * attributes are generally set on server side during the request execution by other components. + * + * @version $Id$ + * @since 1.2M1 + */ public interface Request { - void setProperty(String key, Object value); + /** + * The name of the attribute holding the request effective author. + * + * @since 42.0.0 + */ + @Unstable + public static final String ATTRIBUTE_EFFECTIVE_AUTHOR = Request.class.getName() + "#effectiveAuthor"; + + /** + * Returns the value of a request parameter as a String, or null if the parameter does not + * exist. Request parameters are extra information sent with the request. For HTTP servlets, parameters are + * contained in the query string or posted form data. + *

+ * You should only use this method when you are sure the parameter has only one value. If the parameter might have + * more than one value, use {@link #getProperties}. + *

+ * If you use this method with a multivalued parameter, the value returned is equal to the first value in the array + * returned by getParameterValues. + * + * @param key a String specifying the name of the parameter + * @return an Object containing the value of the parameter, or null if the parameter does + * not exist + * @see #getParameterValues + * @since 42.0.0 + */ + @Unstable + default Object getParameter(String key) + { + return null; + } + + /** + * Returns an array of String objects containing all of the values the given request parameter has, or + * null if the parameter does not exist. + *

+ * If the parameter has a single value, the array has a length of 1. + * + * @param name a String containing the name of the parameter whose value is requested + * @return an array of String objects containing the parameter's values + * @see #getParameter + * @since 42.0.0 + */ + @Unstable + default String[] getParameterValues(String name) + { + return null; + } + + /** + * Returns an Enumeration of String objects containing the names of the parameters + * contained in this request. If the request has no parameters, the method returns an empty + * Enumeration. + * + * @return an Enumeration of String objects, each String containing the name + * of a request parameter; or an empty Enumeration if the request has no parameters + * @since 42.0.0 + */ + @Unstable + default Enumeration getParameterNames() + { + return Collections.emptyEnumeration(); + } - Object getProperty(String key); + /** + * Returns the value of the named attribute as an Object, or null if no attribute of the + * given name exists. + * + * @param name a String specifying the name of the attribute + * @return an Object containing the value of the attribute, or null if the attribute does + * not exist + * @since 42.0.0 + */ + @Unstable + default Object getAttribute(String name) + { + return null; + } /** + * Stores an attribute in this request. Attributes are reset between requests. + * + * @param name a String specifying the name of the attribute + * @param o the Object to be stored + * @since 42.0.0 + */ + @Unstable + default void setAttribute(String name, Object o) + { + + } + + /** + * Removes an attribute from this request. This method is not generally needed as attributes only persist as long as + * the request is being handled. + * + * @param name a String specifying the name of the attribute to remove + * @since 42.0.0 + */ + @Unstable + default void removeAttribute(String name) + { + + } + + /** + * Returns an Enumeration containing the names of the attributes available to this request. This method + * returns an empty Enumeration if the request has no attributes available to it. + * + * @return an Enumeration of strings containing the names of the request's attributes + * @since 42.0.0 + */ + @Unstable + default Enumeration getAttributeNames() + { + return Collections.emptyEnumeration(); + } + + // XWiki + + /** + * @return the user that holds the responsibility, in terms of access rights, for the submitted data and the changes + * triggered by this request. If the request doesn't indicate an effective author then the user that gets + * authenticated with the information provided by this request (or the guest user, if authentication + * information is missing) should be considered the effective author. + * @since 42.0.0 + */ + @Unstable + default UserReference getEffectiveAuthor() + { + return (UserReference) getAttribute(ATTRIBUTE_EFFECTIVE_AUTHOR); + } + + // Deprecated + + /** + * @deprecated use {@link #getParameter(String)} or {@link #getAttribute(String)} instead depending on the need + */ + @Deprecated(since = "42.0.0") + default Object getProperty(String key) + { + Object result; + + // Look first in the Query Parameters and then in the Query Attributes + result = getParameter(key); + if (result == null) { + result = getAttribute(key); + } + + return result; + } + + /** + * @deprecated use {@link #getParameterValues(String)} or {@link #getAttribute(String)} instead depending on the + * need * @since 3.2M3 */ - List getProperties(String key); + @Deprecated(since = "42.0.0") + default List getProperties(String key) + { + List result = new ArrayList<>(); + + // Look first in the parameters, and then in the attributes + Object[] requestParameters = getParameterValues(key); + if (requestParameters != null) { + result.addAll(Arrays.asList(requestParameters)); + } + Object attributeValue = getAttribute(key); + if (attributeValue != null) { + result.add(attributeValue); + } + + return result; + } + + /** + * @deprecated use {@link #setAttribute(String, Object)} instead + */ + @Deprecated(since = "42.0.0") + default void setProperty(String key, Object value) + { + setAttribute(key, value); + } - void removeProperty(String key); + /** + * @deprecated use {@link #removeAttribute(String)} instead + */ + @Deprecated(since = "42.0.0") + default void removeProperty(String key) + { + removeAttribute(key); + } } diff --git a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/java/org/xwiki/container/Response.java b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/java/org/xwiki/container/Response.java index 4d1594bc515b..b62c37c4515b 100644 --- a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/java/org/xwiki/container/Response.java +++ b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/java/org/xwiki/container/Response.java @@ -22,10 +22,13 @@ import java.io.IOException; import java.io.OutputStream; +import org.xwiki.stability.Unstable; + /** * Represents a server response. * * @version $Id$ + * @since 1.2M1 */ public interface Response { @@ -52,4 +55,117 @@ public interface Response * @param mimeType the MIME type for this response, according to the RFC 2045. */ void setContentType(String mimeType); + + // HTTP + + /** + * Sends a temporary redirect response to the client using the specified redirect location URL. + * + * @param location the redirect URL + * @throws IOException if an error happens + * @since 42.0.0 + */ + @Unstable + default void sendRedirect(String location) throws IOException + { + + } + + /** + * Sets the status code for this response. + *

+ * Valid status codes are those in the 2XX, 3XX, 4XX, and 5XX ranges. Other status codes are treated as container + * specific. + * + * @param sc the status code + * @see #sendError + * @since 42.0.0 + */ + @Unstable + default void setStatus(int sc) + { + + } + + /** + * Sends an error response to the client using the specified status and clears the buffer. + *

+ * If the response has already been committed, this method throws an IllegalStateException. After using this method, + * the response should be considered to be committed and should not be written to. + * + * @param sc the error status code + * @param msg the descriptive message + * @exception IOException If an input or output exception occurs + * @exception IllegalStateException If the response was committed + * @since 42.0.0 + */ + @Unstable + default void sendError(int sc, String msg) throws IOException + { + + } + + /** + * Sends an error response to the client using the specified status code and clears the buffer. + *

+ * If the response has already been committed, this method throws an IllegalStateException. After using this method, + * the response should be considered to be committed and should not be written to. + * + * @param sc the error status code + * @exception IOException If an input or output exception occurs + * @exception IllegalStateException If the response was committed before this method call + * @since 42.0.0 + */ + @Unstable + default void sendError(int sc) throws IOException + { + + } + + /** + * Returns a boolean indicating whether the named response header has already been set. + * + * @param name the header name + * @return true if the named response header has already been set; false otherwise + * @since 42.0.0 + */ + @Unstable + default boolean containsHeader(String name) + { + return false; + } + + /** + * Sets a response header with the given name and value. If the header had already been set, the new value + * overwrites the previous one. The containsHeader method can be used to test for the presence of a + * header before setting its value. + * + * @param name the name of the header + * @param value the header value If it contains octet string, it should be encoded according to RFC 2047 + * (http://www.ietf.org/rfc/rfc2047.txt) + * @see #containsHeader + * @see #addHeader + * @since 42.0.0 + */ + @Unstable + default void setHeader(String name, String value) + { + + } + + /** + * Adds a response header with the given name and value. This method allows response headers to have multiple + * values. + * + * @param name the name of the header + * @param value the additional header value If it contains octet string, it should be encoded according to RFC 2047 + * (http://www.ietf.org/rfc/rfc2047.txt) + * @see #setHeader + * @since 42.0.0 + */ + @Unstable + default void addHeader(String name, String value) + { + + } } diff --git a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/java/org/xwiki/container/Session.java b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/java/org/xwiki/container/Session.java index 4fd53b69187a..ca8076498667 100644 --- a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/java/org/xwiki/container/Session.java +++ b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/java/org/xwiki/container/Session.java @@ -19,6 +19,11 @@ */ package org.xwiki.container; +import java.util.Collections; +import java.util.Enumeration; + +import org.xwiki.stability.Unstable; + /** * Represents a session. * @@ -26,4 +31,64 @@ */ public interface Session { + /** + * Returns the object bound with the specified name in this session, or null if no object is bound + * under the name. + * + * @param name a string specifying the name of the object + * @return the object with the specified name + * @exception IllegalStateException if this method is called on an invalidated session + * @since 42.0.0 + */ + @Unstable + default Object getAttribute(String name) + { + return null; + } + + /** + * Binds an object to this session, using the name specified. If an object of the same name is already bound to the + * session, the object is replaced. + *

+ * If the value passed in is null, this has the same effect as calling removeAttribute(). + * + * @param name the name to which the object is bound; cannot be null + * @param value the object to be bound + * @exception IllegalStateException if this method is called on an invalidated session + * @since 42.0.0 + */ + @Unstable + default void setAttribute(String name, Object value) + { + + } + + /** + * Removes the object bound with the specified name from this session. If the session does not have an object bound + * with the specified name, this method does nothing. + * + * @param name the name of the object to remove from this session + * @exception IllegalStateException if this method is called on an invalidated session + * @since 42.0.0 + */ + @Unstable + default void removeAttribute(String name) + { + + } + + /** + * Returns an Enumeration of String objects containing the names of all the objects bound + * to this session. + * + * @return an Enumeration of String objects specifying the names of all the objects bound + * to this session + * @exception IllegalStateException if this method is called on an invalidated session + * @since 42.0.0 + */ + @Unstable + default Enumeration getAttributeNames() + { + return Collections.emptyEnumeration(); + } } diff --git a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/java/org/xwiki/container/internal/script/ScriptRequest.java b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/java/org/xwiki/container/internal/script/ScriptRequest.java new file mode 100644 index 000000000000..3e6086de44fa --- /dev/null +++ b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/java/org/xwiki/container/internal/script/ScriptRequest.java @@ -0,0 +1,159 @@ +/* + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.xwiki.container.internal.script; + +import java.util.Collections; +import java.util.Enumeration; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; + +import org.xwiki.container.Request; +import org.xwiki.container.wrap.WrappingRequest; +import org.xwiki.security.authorization.ContextualAuthorizationManager; +import org.xwiki.security.authorization.Right; + +/** + * A wrapper around {@link Request} with security related checks. + * + * @version $Id$ + * @since 42.0.0 + */ +public class ScriptRequest extends WrappingRequest +{ + /** + * Set of request attributes that require programming rights to be modified. + */ + private static final Set READ_ONLY_ATTRIBUTES = Set.of(Request.ATTRIBUTE_EFFECTIVE_AUTHOR); + + private static final String KEY_SAFEATTRIBUTES = ScriptRequest.class.getName() + "#attributes"; + + private final ContextualAuthorizationManager authorization; + + /** + * @param request the wrapped request + * @param authorization used to check rights of the current author + */ + public ScriptRequest(Request request, ContextualAuthorizationManager authorization) + { + super(request); + + this.authorization = authorization; + } + + @Override + public Request getRequest() + { + return this.authorization.hasAccess(Right.PROGRAM) ? super.getRequest() : null; + } + + /** + * Access an attribute that is safe to use for any script author. + * + * @param name the name of the attribute + * @return the value of the attribute + */ + public Object getSafeAttribute(String name) + { + Map safeAttributes = (Map) this.request.getAttribute(KEY_SAFEATTRIBUTES); + + return safeAttributes != null ? safeAttributes.get(name) : null; + } + + /** + * Set an attribute that is safe to use for any script author. + *

+ * It's recommended to not store anything sensitive in there. + * + * @param name the name of the attribute + * @param value the value of the attribute + */ + public void setSafeAttribute(String name, Object value) + { + if (!READ_ONLY_ATTRIBUTES.contains(name) || this.authorization.hasAccess(Right.PROGRAM)) { + Map safeSession = (Map) this.request.getAttribute(KEY_SAFEATTRIBUTES); + + if (safeSession == null) { + safeSession = new ConcurrentHashMap<>(); + this.request.setAttribute(KEY_SAFEATTRIBUTES, safeSession); + } + + safeSession.put(name, value); + } + } + + /** + * Remove an attribute that is safe to use for any script author. + * + * @param name the name of the attribute + */ + public void removeSafeAttribute(String name) + { + if (!READ_ONLY_ATTRIBUTES.contains(name) || this.authorization.hasAccess(Right.PROGRAM)) { + Map safeSession = (Map) this.request.getAttribute(KEY_SAFEATTRIBUTES); + + if (safeSession != null) { + safeSession.remove(name); + } + } + } + + /** + * @return the names of the attributes which are safe to use for any script author. + */ + public Enumeration getSafeAttributeNames() + { + Map safeSession = (Map) this.request.getAttribute(KEY_SAFEATTRIBUTES); + + return safeSession != null ? Collections.enumeration(safeSession.keySet()) : Collections.emptyEnumeration(); + } + + @Override + public Object getAttribute(String name) + { + return this.authorization.hasAccess(Right.PROGRAM) ? this.request.getAttribute(name) : getSafeAttribute(name); + } + + @Override + public Enumeration getAttributeNames() + { + return this.authorization.hasAccess(Right.PROGRAM) ? this.request.getAttributeNames() : getSafeAttributeNames(); + } + + @Override + public void setAttribute(String name, Object value) + { + if (this.authorization.hasAccess(Right.PROGRAM)) { + this.request.setAttribute(name, value); + } else { + setSafeAttribute(name, value); + } + } + + @Override + public void removeAttribute(String name) + { + if (this.authorization.hasAccess(Right.PROGRAM)) { + this.request.removeAttribute(name); + } else { + removeSafeAttribute(name); + } + } +} diff --git a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/java/org/xwiki/container/internal/script/ScriptResponse.java b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/java/org/xwiki/container/internal/script/ScriptResponse.java new file mode 100644 index 000000000000..22de0da8e42f --- /dev/null +++ b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/java/org/xwiki/container/internal/script/ScriptResponse.java @@ -0,0 +1,53 @@ +/* + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.xwiki.container.internal.script; + +import org.xwiki.container.Response; +import org.xwiki.container.wrap.WrappingResponse; +import org.xwiki.security.authorization.ContextualAuthorizationManager; +import org.xwiki.security.authorization.Right; + +/** + * A wrapper around {@link Response} with security related checks. + * + * @version $Id$ + * @since 42.0.0 + */ +public class ScriptResponse extends WrappingResponse +{ + private final ContextualAuthorizationManager authorization; + + /** + * @param response the wrapped response + * @param authorization used to check rights of the current author + */ + public ScriptResponse(Response response, ContextualAuthorizationManager authorization) + { + super(response); + + this.authorization = authorization; + } + + @Override + public Response getResponse() + { + return this.authorization.hasAccess(Right.PROGRAM) ? super.getResponse() : null; + } +} diff --git a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/java/org/xwiki/container/internal/script/ScriptSession.java b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/java/org/xwiki/container/internal/script/ScriptSession.java new file mode 100644 index 000000000000..65a51f168504 --- /dev/null +++ b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/java/org/xwiki/container/internal/script/ScriptSession.java @@ -0,0 +1,167 @@ +/* + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.xwiki.container.internal.script; + +import java.util.Collections; +import java.util.Enumeration; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import org.xwiki.container.Session; +import org.xwiki.security.authorization.ContextualAuthorizationManager; +import org.xwiki.security.authorization.Right; + +/** + * A wrapper around {@link Session} with security related checks. + * + * @version $Id$ + * @since 42.0.0 + */ +public class ScriptSession implements Session +{ + private static final String KEY_SAFEATTRIBUTES = ScriptSession.class.getName(); + + private final Session session; + + private final ContextualAuthorizationManager authorization; + + /** + * @param session the wrapped session + * @param authorization used to check rights of the current author + */ + public ScriptSession(Session session, ContextualAuthorizationManager authorization) + { + this.session = session; + this.authorization = authorization; + } + + /** + * Access an attribute that is safe to use for any script author. + * + * @param name the name of the attribute + * @return the value of the attribute + */ + public Object getSafeAttribute(String name) + { + Map safeAttributes = (Map) this.session.getAttribute(KEY_SAFEATTRIBUTES); + + return safeAttributes != null ? safeAttributes.get(name) : null; + } + + /** + * Set an attribute that is safe to use for any script author. + *

+ * It's recommended to not store anything sensitive in there. + * + * @param name the name of the attribute + * @param value the value of the attribute + */ + public void setSafeAttribute(String name, Object value) + { + Map safeSession = (Map) this.session.getAttribute(KEY_SAFEATTRIBUTES); + + if (safeSession == null) { + safeSession = new ConcurrentHashMap<>(); + this.session.setAttribute(KEY_SAFEATTRIBUTES, safeSession); + } + + safeSession.put(name, value); + } + + /** + * Remove an attribute that is safe to use for any script author. + * + * @param name the name of the attribute + */ + public void removeSafeAttribute(String name) + { + Map safeSession = (Map) this.session.getAttribute(KEY_SAFEATTRIBUTES); + + if (safeSession != null) { + safeSession.remove(name); + } + } + + /** + * @return the names of the attributes which are safe to use for any script author. + */ + public Enumeration getSafeAttributeNames() + { + Map safeSession = (Map) this.session.getAttribute(KEY_SAFEATTRIBUTES); + + return safeSession != null ? Collections.enumeration(safeSession.keySet()) : Collections.emptyEnumeration(); + } + + /** + * {@inheritDoc} + *

+ * Allow to manipulate only a limited set of attributes when not a programming right user since other might be + * sensitive data. + * + * @see Session#getAttribute(java.lang.String) + */ + @Override + public Object getAttribute(String name) + { + return this.authorization.hasAccess(Right.PROGRAM) ? this.session.getAttribute(name) : getSafeAttribute(name); + } + + @Override + public Enumeration getAttributeNames() + { + return this.authorization.hasAccess(Right.PROGRAM) ? this.session.getAttributeNames() : getSafeAttributeNames(); + } + + /** + * {@inheritDoc} + *

+ * Allow to manipulate only a limited set of attributes when not a programming right user since other might be + * sensitive data. + * + * @see Session#setAttribute(java.lang.String, java.lang.Object) + */ + @Override + public void setAttribute(String name, Object value) + { + if (this.authorization.hasAccess(Right.PROGRAM)) { + this.session.setAttribute(name, value); + } else { + setSafeAttribute(name, value); + } + } + + /** + * {@inheritDoc} + *

+ * Allow to manipulate only a limited set of attributes when not a programming right user since other might be + * sensitive data. + * + * @see Session#removeAttribute(java.lang.String) + */ + @Override + public void removeAttribute(String name) + { + if (this.authorization.hasAccess(Right.PROGRAM)) { + this.session.removeAttribute(name); + } else { + removeSafeAttribute(name); + } + } +} diff --git a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/java/org/xwiki/container/script/ContainerScriptService.java b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/java/org/xwiki/container/script/ContainerScriptService.java new file mode 100644 index 000000000000..9b0dd4dd97ec --- /dev/null +++ b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/java/org/xwiki/container/script/ContainerScriptService.java @@ -0,0 +1,77 @@ +/* + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.xwiki.container.script; + +import javax.inject.Singleton; + +import jakarta.inject.Inject; + +import org.xwiki.component.annotation.Component; +import org.xwiki.container.Container; +import org.xwiki.container.Request; +import org.xwiki.container.Response; +import org.xwiki.container.Session; +import org.xwiki.container.internal.script.ScriptRequest; +import org.xwiki.container.internal.script.ScriptResponse; +import org.xwiki.container.internal.script.ScriptSession; +import org.xwiki.security.authorization.ContextualAuthorizationManager; +import org.xwiki.stability.Unstable; + +/** + * The main entry point for a script to manipulate {@link Container} related APIs. + * + * @version $Id$ + * @since 42.0.0 + */ +@Unstable +@Component +@Singleton +public class ContainerScriptService +{ + @Inject + private Container container; + + @Inject + private ContextualAuthorizationManager authorization; + + /** + * @return the current request + */ + public Request getRequest() + { + return new ScriptRequest(this.container.getRequest(), this.authorization); + } + + /** + * @return the current response + */ + public Response getResponse() + { + return new ScriptResponse(this.container.getResponse(), this.authorization); + } + + /** + * @return the current session + */ + public Session getSession() + { + return new ScriptSession(this.container.getSession(), this.authorization); + } +} diff --git a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/java/org/xwiki/container/wrap/WrappingRequest.java b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/java/org/xwiki/container/wrap/WrappingRequest.java new file mode 100644 index 000000000000..9ed4aacfa3f5 --- /dev/null +++ b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/java/org/xwiki/container/wrap/WrappingRequest.java @@ -0,0 +1,100 @@ +/* + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.xwiki.container.wrap; + +import java.util.Enumeration; + +import org.xwiki.container.Request; +import org.xwiki.user.UserReference; + +/** + * A wrapper around {@link Request}. + * + * @version $Id$ + * @since 42.0.0 + */ +public class WrappingRequest implements Request +{ + protected final Request request; + + /** + * @param request the wrapped request + */ + public WrappingRequest(Request request) + { + this.request = request; + } + + /** + * @return the wrapped request + */ + public Request getRequest() + { + return this.request; + } + + @Override + public Object getParameter(String key) + { + return this.request.getParameter(key); + } + + @Override + public Enumeration getParameterNames() + { + return this.request.getParameterNames(); + } + + @Override + public String[] getParameterValues(String name) + { + return this.request.getParameterValues(name); + } + + @Override + public Object getAttribute(String name) + { + return this.request.getAttribute(name); + } + + @Override + public Enumeration getAttributeNames() + { + return this.request.getAttributeNames(); + } + + @Override + public void setAttribute(String name, Object value) + { + this.request.setAttribute(name, value); + } + + @Override + public void removeAttribute(String name) + { + this.request.removeAttribute(name); + } + + @Override + public UserReference getEffectiveAuthor() + { + return this.request.getEffectiveAuthor(); + } +} diff --git a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/java/org/xwiki/container/wrap/WrappingResponse.java b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/java/org/xwiki/container/wrap/WrappingResponse.java new file mode 100644 index 000000000000..1fd2f0ece265 --- /dev/null +++ b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/java/org/xwiki/container/wrap/WrappingResponse.java @@ -0,0 +1,112 @@ +/* + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.xwiki.container.wrap; + +import java.io.IOException; +import java.io.OutputStream; + +import org.xwiki.container.Response; + +/** + * A wrapper around {@link Response}. + * + * @version $Id$ + * @since 42.0.0 + */ +public class WrappingResponse implements Response +{ + protected final Response response; + + /** + * @param response the wrapped response + */ + public WrappingResponse(Response response) + { + this.response = response; + } + + /** + * @return the wrapped response + */ + public Response getResponse() + { + return this.response; + } + + @Override + public OutputStream getOutputStream() throws IOException + { + return this.response.getOutputStream(); + } + + @Override + public void setContentLength(int length) + { + this.response.setContentLength(length); + } + + @Override + public void setContentType(String mimeType) + { + this.response.setContentType(mimeType); + } + + @Override + public void sendRedirect(String location) throws IOException + { + this.response.sendRedirect(location); + } + + @Override + public void setStatus(int sc) + { + this.response.setStatus(sc); + } + + @Override + public void sendError(int sc, String msg) throws IOException + { + this.response.sendError(sc, msg); + } + + @Override + public void sendError(int sc) throws IOException + { + this.response.sendError(sc); + } + + @Override + public boolean containsHeader(String name) + { + return this.response.containsHeader(name); + } + + @Override + public void setHeader(String name, String value) + { + this.response.setHeader(name, value); + } + + @Override + public void addHeader(String name, String value) + { + this.response.addHeader(name, value); + } +} diff --git a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/resources/META-INF/components.txt b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/resources/META-INF/components.txt index 0fd04e8b028f..ff8cb4567549 100644 --- a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/resources/META-INF/components.txt +++ b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-api/src/main/resources/META-INF/components.txt @@ -1,3 +1,4 @@ org.xwiki.container.internal.DefaultContainer org.xwiki.container.internal.DefaultRequestInitializerManager org.xwiki.container.internal.DefaultApplicationContextListenerManager +org.xwiki.container.script.ContainerScriptService diff --git a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/pom.xml b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/pom.xml index f6fd31cb8eb5..5fa473592366 100644 --- a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/pom.xml +++ b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/pom.xml @@ -35,6 +35,10 @@ 0.15 + + jakarta.servlet + jakarta.servlet-api + org.xwiki.commons xwiki-commons-component-default @@ -71,8 +75,9 @@ ${project.version} - javax.servlet - javax.servlet-api + org.xwiki.commons + xwiki-commons-jakartabridge-servlet + ${commons.version} @@ -100,12 +105,11 @@ default + **/servlet/HttpServletRequestStub.java, + **/servlet/HttpServletResponseStub.java, **/servlet/ServletApplicationContext.java, **/servlet/ServletContainerException.java, **/servlet/ServletContainerInitializer.java, - **/servlet/ServletRequest.java, - **/servlet/ServletResponse.java, - **/servlet/ServletSession.java, **/servlet/filters/internal/SetCharacterEncodingFilter.java, **/servlet/internal/DefaultServletContainerInitializer.java diff --git a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/HttpServletRequestStub.java b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/HttpServletRequestStub.java new file mode 100644 index 000000000000..750e9b617d16 --- /dev/null +++ b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/HttpServletRequestStub.java @@ -0,0 +1,851 @@ +/* + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.xwiki.container.servlet; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URL; +import java.security.Principal; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Enumeration; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Objects; +import java.util.TreeMap; +import java.util.Vector; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import jakarta.servlet.AsyncContext; +import jakarta.servlet.DispatcherType; +import jakarta.servlet.RequestDispatcher; +import jakarta.servlet.ServletContext; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletInputStream; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; +import jakarta.servlet.http.Cookie; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpSession; +import jakarta.servlet.http.HttpUpgradeHandler; +import jakarta.servlet.http.Part; + +import org.apache.commons.lang3.ArrayUtils; + +/** + * This stub is intended to simulate a servlet request in a daemon context, in order to be able to create a custom XWiki + * context. This trick is used in to give a daemon thread access to the XWiki api. + * + * @version $Id$ + * @since 42.0.0 + */ +public class HttpServletRequestStub implements HttpServletRequest +{ + /** + * Builder for {@link HttpServletRequestStub}. + * + * @version $Id$ + */ + public static class Builder + { + private URL requestURL; + + private String contextPath; + + private Map requestParameters; + + private Map> headers; + + private Cookie[] cookies; + + private String remoteAddr; + + private HttpSession httpSession; + + /** + * Default constructor. + */ + public Builder() + { + } + + /** + * @param requestURL the request URL + * @return this builder + */ + public Builder setRequestURL(URL requestURL) + { + this.requestURL = requestURL; + return this; + } + + /** + * @param contextPath the context path + * @return this builder + */ + public Builder setContextPath(String contextPath) + { + this.contextPath = contextPath; + return this; + } + + /** + * @param requestParameters the request parameters + * @return this builder + */ + public Builder setRequestParameters(Map requestParameters) + { + this.requestParameters = requestParameters; + return this; + } + + /** + * @param headers the request headers + * @return this builder + */ + public Builder setHeaders(Map> headers) + { + this.headers = headers; + return this; + } + + /** + * @param cookies the request cookies + * @return this builder + */ + public Builder setCookies(Cookie[] cookies) + { + this.cookies = cookies; + return this; + } + + /** + * @param remoteAddr the remote address + * @return this builder + */ + public Builder setRemoteAddr(String remoteAddr) + { + this.remoteAddr = remoteAddr; + return this; + } + + /** + * @param httpSession the http session to initialize the {@link HttpServletRequestStub} instance with + * @return the current builder + */ + public Builder setHttpSession(HttpSession httpSession) + { + this.httpSession = httpSession; + return this; + } + + /** + * @return the built {@link HttpServletRequestStub} instance + */ + public HttpServletRequestStub build() + { + return new HttpServletRequestStub(this); + } + } + + private boolean secure; + + private String scheme; + + private String protocol; + + private String queryString; + + private String contextPath; + + private String servletPath; + + private String serverName; + + private int serverPort; + + private Map> headers; + + private Map parameters; + + private Cookie[] cookies; + + private List parts = new ArrayList<>(); + + private String requestURI; + + private StringBuffer requestURL; + + private String remoteAddr; + + private boolean daemon = true; + + private HttpSession httpSession; + + public HttpServletRequestStub() + { + } + + protected HttpServletRequestStub(Builder builder) + { + if (builder.requestURL != null) { + this.protocol = builder.requestURL.getProtocol(); + this.scheme = builder.requestURL.getProtocol(); + + this.serverName = builder.requestURL.getHost(); + this.serverPort = builder.requestURL.getPort(); + + this.secure = this.protocol.equalsIgnoreCase("https"); + + this.requestURI = builder.requestURL.getPath(); + this.requestURL = new StringBuffer(builder.requestURL.toString()); + + setHost(builder.requestURL.getHost()); + } + + this.contextPath = builder.contextPath; + this.parameters = clone(builder.requestParameters); + this.headers = cloneHeaders(builder.headers); + this.cookies = clone(builder.cookies); + this.remoteAddr = builder.remoteAddr; + this.httpSession = builder.httpSession; + } + + /** + * @param request the request to copy + */ + public HttpServletRequestStub(HttpServletRequest request) + { + this.secure = request.isSecure(); + this.protocol = request.getProtocol(); + this.scheme = request.getScheme(); + this.serverName = request.getServerName(); + this.serverPort = request.getServerPort(); + + this.contextPath = request.getContextPath(); + this.servletPath = request.getServletPath(); + + this.queryString = request.getQueryString(); + + this.requestURI = request.getRequestURI(); + this.requestURL = new StringBuffer(request.getRequestURL()); + + if (request.getHeaderNames() != null) { + this.headers = Collections.list(request.getHeaderNames()).stream() + .map(headerName -> Map.entry(headerName, Collections.list(request.getHeaders(headerName)))) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (left, right) -> right, + () -> new TreeMap<>(String.CASE_INSENSITIVE_ORDER))); + } + + this.parameters = clone(request.getParameterMap()); + this.cookies = clone(request.getCookies()); + this.remoteAddr = request.getRemoteAddr(); + try { + setParts(request.getParts()); + } catch (Exception e) { + // Failed to get the parts, ignore them + } + + if (request instanceof HttpServletRequestStub requestStub) { + setDaemon(requestStub.isDaemon()); + } + } + + private Map clone(Map map) + { + Map clone; + if (map != null) { + clone = new LinkedHashMap<>(map.size()); + for (Map.Entry entry : map.entrySet()) { + clone.put(entry.getKey(), entry.getValue().clone()); + } + } else { + clone = null; + } + + return clone; + } + + private Map> cloneHeaders(Map> headers) + { + if (headers == null) { + return null; + } + + return headers.entrySet().stream().filter(entry -> entry.getValue() != null && !entry.getValue().isEmpty()) + .map(entry -> Map.entry(entry.getKey(), entry.getValue().stream().collect(Collectors.toList()))) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (left, right) -> right, + () -> new TreeMap<>(String.CASE_INSENSITIVE_ORDER))); + } + + private Cookie[] clone(Cookie[] cookies) + { + if (cookies != null) { + return Stream.of(cookies).map(Cookie::clone).toArray(Cookie[]::new); + } else { + return null; + } + } + + public void setContextPath(String contextPath) + { + this.contextPath = contextPath; + } + + public void setHost(String host) + { + if (this.headers == null) { + this.headers = new LinkedHashMap<>(); + } + + this.headers.put("x-forwarded-host", new Vector(Arrays.asList(host))); + } + + public void setScheme(String scheme) + { + this.scheme = scheme; + } + + public void setrequestURL(StringBuffer requestURL) + { + this.requestURL = requestURL; + } + + public void setRequestURI(String requestURI) + { + this.requestURI = requestURI; + } + + public void setServerName(String serverName) + { + this.serverName = serverName; + } + + @Override + public String getHeader(String headerName) + { + if (this.headers != null) { + List values = this.headers.get(headerName); + + if (values != null && !values.isEmpty()) { + return values.get(0); + } + } + + return null; + } + + public void put(String key, String value) + { + if (this.parameters == null) { + this.parameters = new LinkedHashMap<>(); + } + + String[] values = this.parameters.get(key); + if (values == null) { + values = new String[] {value}; + } else { + values = ArrayUtils.add(values, value); + } + this.parameters.put(key, values); + } + + @Override + public String getAuthType() + { + return null; + } + + @Override + public Cookie[] getCookies() + { + return clone(this.cookies); + } + + @Override + public long getDateHeader(String s) + { + return 0; + } + + @Override + public Enumeration getHeaders(String headerName) + { + if (this.headers != null) { + List values = this.headers.get(headerName); + + if (values != null) { + return Collections.enumeration(values); + } + } + + return Collections.emptyEnumeration(); + } + + @Override + public Enumeration getHeaderNames() + { + return this.headers != null ? Collections.enumeration(this.headers.keySet()) : Collections.emptyEnumeration(); + } + + @Override + public int getIntHeader(String s) + { + String header = getHeader(s); + + return header != null ? Integer.parseInt(header) : -1; + } + + @Override + public String getMethod() + { + return null; + } + + @Override + public String getPathInfo() + { + return null; + } + + @Override + public String getPathTranslated() + { + return null; + } + + @Override + public String getContextPath() + { + return this.contextPath; + } + + @Override + public String getQueryString() + { + return this.queryString; + } + + @Override + public String getRemoteUser() + { + return null; + } + + @Override + public boolean isUserInRole(String s) + { + return false; + } + + @Override + public Principal getUserPrincipal() + { + return null; + } + + @Override + public String getRequestedSessionId() + { + return null; + } + + @Override + public String getRequestURI() + { + return this.requestURI; + } + + @Override + public StringBuffer getRequestURL() + { + return this.requestURL == null ? new StringBuffer() : this.requestURL; + } + + @Override + public String getServletPath() + { + return this.servletPath; + } + + @Override + public HttpSession getSession(boolean b) + { + return this.httpSession; + } + + @Override + public String changeSessionId() + { + return null; + } + + @Override + public HttpSession getSession() + { + return this.httpSession; + } + + /** + * Sets the HttpSession object for the current user session. + * + * @param httpSession the {@link HttpSession} object to be set + */ + public void setSession(HttpSession httpSession) + { + this.httpSession = httpSession; + } + + @Override + public boolean isRequestedSessionIdValid() + { + return false; + } + + @Override + public boolean isRequestedSessionIdFromCookie() + { + return false; + } + + @Override + public boolean isRequestedSessionIdFromURL() + { + return false; + } + + /** + * @deprecated + */ + @Override + @Deprecated + public boolean isRequestedSessionIdFromUrl() + { + return false; + } + + @Override + public Object getAttribute(String s) + { + return null; + } + + @Override + public Enumeration getAttributeNames() + { + return Collections.emptyEnumeration(); + } + + @Override + public String getCharacterEncoding() + { + return null; + } + + @Override + public void setCharacterEncoding(String s) throws UnsupportedEncodingException + { + + } + + @Override + public int getContentLength() + { + return 0; + } + + @Override + public long getContentLengthLong() + { + return 0; + } + + @Override + public String getContentType() + { + return null; + } + + @Override + public ServletInputStream getInputStream() throws IOException + { + return null; + } + + @Override + public String getParameter(String s) + { + if (this.parameters != null) { + String[] values = this.parameters.get(s); + + if (ArrayUtils.isNotEmpty(values)) { + return values[0]; + } + } + + return null; + } + + @Override + public Enumeration getParameterNames() + { + return this.parameters != null ? Collections.enumeration(this.parameters.keySet()) : null; + } + + @Override + public String[] getParameterValues(String s) + { + if (this.parameters != null) { + String[] values = this.parameters.get(s); + + return values != null ? values.clone() : null; + } + + return ArrayUtils.EMPTY_STRING_ARRAY; + } + + @Override + public Map getParameterMap() + { + return clone(this.parameters); + } + + @Override + public String getProtocol() + { + return this.protocol; + } + + @Override + public String getScheme() + { + return this.scheme; + } + + @Override + public String getServerName() + { + return this.serverName; + } + + @Override + public int getServerPort() + { + return this.serverPort; + } + + @Override + public BufferedReader getReader() throws IOException + { + return null; + } + + @Override + public String getRemoteAddr() + { + return this.remoteAddr; + } + + @Override + public String getRemoteHost() + { + return null; + } + + @Override + public void setAttribute(String s, Object o) + { + + } + + @Override + public void removeAttribute(String s) + { + + } + + @Override + public Locale getLocale() + { + return null; + } + + @Override + public Enumeration getLocales() + { + return null; + } + + @Override + public boolean isSecure() + { + return this.secure; + } + + @Override + public RequestDispatcher getRequestDispatcher(String s) + { + return null; + } + + /** + * @deprecated + */ + @Override + @Deprecated + public String getRealPath(String s) + { + return null; + } + + @Override + public int getRemotePort() + { + return 0; + } + + @Override + public String getLocalName() + { + return null; + } + + @Override + public String getLocalAddr() + { + return null; + } + + @Override + public int getLocalPort() + { + return 0; + } + + @Override + public boolean authenticate(HttpServletResponse httpServletResponse) throws IOException, ServletException + { + return false; + } + + @Override + public void login(String s, String s1) throws ServletException + { + } + + @Override + public void logout() throws ServletException + { + + } + + @Override + public Collection getParts() throws IOException, ServletException + { + return this.parts; + } + + @Override + public Part getPart(String s) throws IOException, ServletException + { + return this.parts.stream().filter(part -> Objects.equals(part.getName(), s)).findFirst().orElse(null); + } + + /** + * @param parts the parts + */ + public void setParts(Collection parts) + { + this.parts = new ArrayList<>(parts); + } + + @Override + public ServletContext getServletContext() + { + return null; + } + + @Override + public AsyncContext startAsync() throws IllegalStateException + { + return null; + } + + @Override + public AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse) + throws IllegalStateException + { + return null; + } + + @Override + public boolean isAsyncStarted() + { + return false; + } + + @Override + public boolean isAsyncSupported() + { + return false; + } + + @Override + public AsyncContext getAsyncContext() + { + return null; + } + + @Override + public DispatcherType getDispatcherType() + { + return null; + } + + @Override + public T upgrade(Class handlerClass) throws IOException, ServletException + { + return null; + } + + /** + * @return true if the request is intended to be used in a long standing daemon thread (mails, etc.) and should not + * be taken into account when generating a URL + */ + public boolean isDaemon() + { + return this.daemon; + } + + /** + * @param daemon the daemon to set + */ + public void setDaemon(boolean daemon) + { + this.daemon = daemon; + } +} diff --git a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/HttpServletResponseStub.java b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/HttpServletResponseStub.java new file mode 100644 index 000000000000..6e85a4390f3b --- /dev/null +++ b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/HttpServletResponseStub.java @@ -0,0 +1,275 @@ +/* + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.xwiki.container.servlet; + +import java.io.IOException; +import java.io.OutputStream; +import java.io.PrintWriter; +import java.util.Collection; +import java.util.Locale; + +import jakarta.servlet.ServletOutputStream; +import jakarta.servlet.WriteListener; +import jakarta.servlet.http.Cookie; +import jakarta.servlet.http.HttpServletResponse; + +/** + * This stub is intended to simulate a servlet request in a daemon context, in order to be able to create a custom XWiki + * context. This trick is used in to give a daemon thread access to the XWiki api. + * + * @version $Id$ + * @since 42.0.0 + */ +public class HttpServletResponseStub implements HttpServletResponse +{ + private OutputStream outputStream; + + private ServletOutputStream servletOutputStream = new ServletOutputStream() + { + @Override + public void write(int b) throws IOException + { + if (HttpServletResponseStub.this.outputStream != null) { + HttpServletResponseStub.this.outputStream.write(b); + } + } + + @Override + public boolean isReady() + { + return true; + } + + @Override + public void setWriteListener(WriteListener writeListener) + { + // Not needed + } + }; + + /** + * @param outputStream the stream where to write the response entity + */ + public void setOutpuStream(OutputStream outputStream) + { + this.outputStream = outputStream; + } + + @Override + public void setCharacterEncoding(String s) + { + } + + @Override + public void addCookie(Cookie cookie) + { + } + + @Override + public boolean containsHeader(String name) + { + return false; + } + + @Override + public String encodeURL(String url) + { + return url; + } + + @Override + public String encodeRedirectURL(String url) + { + return url; + } + + @Override + public String encodeUrl(String url) + { + return url; + } + + @Override + public String encodeRedirectUrl(String url) + { + return url; + } + + @Override + public void sendError(int sc, String msg) throws IOException + { + } + + @Override + public void sendError(int sc) throws IOException + { + } + + @Override + public void sendRedirect(String location) throws IOException + { + } + + @Override + public void setDateHeader(String name, long date) + { + } + + @Override + public void addDateHeader(String name, long date) + { + } + + @Override + public void setHeader(String name, String value) + { + } + + @Override + public void addHeader(String name, String value) + { + } + + @Override + public void setIntHeader(String name, int value) + { + } + + @Override + public void addIntHeader(String name, int value) + { + } + + @Override + public void setStatus(int sc) + { + } + + @Override + public void setStatus(int sc, String sm) + { + } + + @Override + public String getCharacterEncoding() + { + return null; + } + + @Override + public String getContentType() + { + return null; + } + + @Override + public ServletOutputStream getOutputStream() throws IOException + { + return this.servletOutputStream; + } + + @Override + public PrintWriter getWriter() throws IOException + { + return null; + } + + @Override + public void setContentLength(int len) + { + } + + @Override + public void setContentLengthLong(long len) + { + } + + @Override + public void setContentType(String type) + { + } + + @Override + public void setBufferSize(int size) + { + } + + @Override + public int getBufferSize() + { + return 0; + } + + @Override + public void flushBuffer() throws IOException + { + } + + @Override + public void resetBuffer() + { + } + + @Override + public boolean isCommitted() + { + return false; + } + + @Override + public void reset() + { + } + + @Override + public void setLocale(Locale loc) + { + } + + @Override + public Locale getLocale() + { + return null; + } + + @Override + public int getStatus() + { + return 0; + } + + @Override + public String getHeader(String s) + { + return null; + } + + @Override + public Collection getHeaders(String s) + { + return null; + } + + @Override + public Collection getHeaderNames() + { + return null; + } +} diff --git a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/HttpServletUtils.java b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/HttpServletUtils.java index e80ce49627a6..9c28951d2e86 100644 --- a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/HttpServletUtils.java +++ b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/HttpServletUtils.java @@ -21,9 +21,14 @@ import java.net.MalformedURLException; import java.net.URL; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.List; +import java.util.Map; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import org.apache.commons.lang3.StringUtils; import org.apache.http.HeaderElement; @@ -31,6 +36,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.xwiki.container.servlet.internal.ForwardedHeader; +import org.xwiki.jakartabridge.servlet.JakartaServletBridge; +import org.xwiki.stability.Unstable; /** * Various helpers around the {@link HttpServletRequest} and {@link HttpServletResponse} API. @@ -82,8 +89,11 @@ private HttpServletUtils() * * @param servletRequest the servlet request input * @return the URL as close as possible from what the client used + * @throws MalformedURLException when an invalid URL was received + * @since 42.0.0 */ - public static URL getSourceURL(HttpServletRequest servletRequest) + @Unstable + public static URL getSourceURL(HttpServletRequest servletRequest) throws MalformedURLException { URL baseURL = getSourceBaseURL(servletRequest); @@ -96,12 +106,7 @@ public static URL getSourceURL(HttpServletRequest servletRequest) path.append(servletRequest.getQueryString()); } - try { - return new URL(baseURL, path.toString()); - } catch (MalformedURLException e) { - // Not really supposed to happen - throw new RuntimeException("XWiki received an invalid URL path or query string", e); - } + return new URL(baseURL, path.toString()); } /** @@ -113,8 +118,11 @@ public static URL getSourceURL(HttpServletRequest servletRequest) * * @param servletRequest the servlet request input * @return the URL as close as possible from what the client used + * @throws MalformedURLException when an invalid URL was received + * @since 42.0.0 */ - public static URL getSourceBaseURL(HttpServletRequest servletRequest) + @Unstable + public static URL getSourceBaseURL(HttpServletRequest servletRequest) throws MalformedURLException { StringBuilder builder = new StringBuilder(); @@ -132,14 +140,9 @@ public static URL getSourceBaseURL(HttpServletRequest servletRequest) } } - private static URL getFinalBaseURL(HttpServletRequest servletRequest) + private static URL getFinalBaseURL(HttpServletRequest servletRequest) throws MalformedURLException { - try { - return new URL(servletRequest.getScheme(), servletRequest.getRemoteHost(), servletRequest.getRemotePort(), - ""); - } catch (MalformedURLException e) { - throw new RuntimeException("XWiki received an invalid URL", e); - } + return new URL(servletRequest.getScheme(), servletRequest.getRemoteHost(), servletRequest.getRemotePort(), ""); } private static void appendScheme(HttpServletRequest request, StringBuilder builder) @@ -241,8 +244,9 @@ private static String getFirstHeaderValue(HttpServletRequest request, String key /** * @param request the servlet request input * @return true if the request explicitly disable getting resources from the cache - * @since 11.8RC1 + * @since 42.0.0 */ + @Unstable public static boolean isCacheReadAllowed(HttpServletRequest request) { String headerValue = request.getHeader(HEADER_CACHE_CONTROL); @@ -258,4 +262,79 @@ public static boolean isCacheReadAllowed(HttpServletRequest request) return true; } + + /** + * @param request the request from which to extract the headers + * @return the headers of the request + * @since 42.0.0 + */ + @Unstable + public static Map> getHeaders(HttpServletRequest request) + { + Map> map = new HashMap<>(); + for (Enumeration eName = request.getHeaderNames(); eName.hasMoreElements();) { + String headerName = eName.nextElement(); + + List headerValues = map.computeIfAbsent(headerName, k -> new ArrayList<>()); + for (Enumeration eValue = request.getHeaders(headerName); eValue.hasMoreElements();) { + headerValues.add(eValue.nextElement()); + } + } + + return map; + } + + // Deprecated + + /** + * Try to extract from various http headers the URL ({@code ://[:]/[?]}) as + * close as possible to the one used by the client. + *

+ * In theory HttpServletRequest#getRequestURL() is supposed to take care of all that but depending on the + * application server and its configuration it's not always reliable. One less thing to configure. + * + * @param servletRequest the servlet request input + * @return the URL as close as possible from what the client used + */ + @Deprecated(since = "42.0.0") + public static URL getSourceURL(javax.servlet.http.HttpServletRequest servletRequest) + { + try { + return getSourceURL(JakartaServletBridge.toJakarta(servletRequest)); + } catch (MalformedURLException e) { + // Not really supposed to happen + throw new RuntimeException("XWiki received an invalid URL path or query string", e); + } + } + + /** + * Try to extract from various http headers the base URL ({@code ://[:]}) as close as possible + * to the one used by the client. + *

+ * In theory HttpServletRequest#getRequestURL() is supposed to take care of all that but depending on the + * application server and its configuration it's not always reliable. One less thing to configure. + * + * @param servletRequest the servlet request input + * @return the URL as close as possible from what the client used + */ + @Deprecated(since = "42.0.0") + public static URL getSourceBaseURL(javax.servlet.http.HttpServletRequest servletRequest) + { + try { + return getSourceBaseURL(JakartaServletBridge.toJakarta(servletRequest)); + } catch (MalformedURLException e) { + throw new RuntimeException("XWiki received an invalid URL", e); + } + } + + /** + * @param request the servlet request input + * @return true if the request explicitly disable getting resources from the cache + * @since 11.8RC1 + */ + @Deprecated(since = "42.0.0") + public static boolean isCacheReadAllowed(javax.servlet.http.HttpServletRequest request) + { + return isCacheReadAllowed(JakartaServletBridge.toJakarta(request)); + } } diff --git a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/ServletContainerInitializer.java b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/ServletContainerInitializer.java index f65ffb16cdd5..d0f5e6af39be 100644 --- a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/ServletContainerInitializer.java +++ b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/ServletContainerInitializer.java @@ -19,28 +19,44 @@ */ package org.xwiki.container.servlet; -import javax.servlet.ServletContext; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import org.xwiki.component.annotation.Role; +import org.xwiki.jakartabridge.servlet.JakartaServletBridge; +import org.xwiki.stability.Unstable; @Role public interface ServletContainerInitializer { - void initializeRequest(HttpServletRequest request, Object xwikiContext) - throws ServletContainerException; - - void initializeRequest(HttpServletRequest request) + @Deprecated(since = "42.0.0") + void initializeRequest(javax.servlet.http.HttpServletRequest request, Object xwikiContext) throws ServletContainerException; - void initializeResponse(HttpServletResponse response); - - void initializeSession(HttpServletRequest request); + @Deprecated(since = "42.0.0") + void initializeRequest(javax.servlet.http.HttpServletRequest request) throws ServletContainerException; + + @Deprecated(since = "42.0.0") + void initializeResponse(javax.servlet.http.HttpServletResponse response); + + @Deprecated(since = "42.0.0") + void initializeSession(javax.servlet.http.HttpServletRequest request); /** * @deprecated use the notion of Environment instead */ @Deprecated(since = "3.5M1") - void initializeApplicationContext(ServletContext servletContext); + void initializeApplicationContext(javax.servlet.ServletContext servletContext); + + /** + * @param request the current request + * @param response the current response + * @since 42.0.0 + */ + @Unstable + default void initializeRequest(HttpServletRequest request, HttpServletResponse response) + throws ServletContainerException + { + initializeRequest(JakartaServletBridge.toJavax(request), JakartaServletBridge.toJavax(response)); + } } diff --git a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/ServletRequest.java b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/ServletRequest.java index 9a6cfc9616c4..6f56edfc2dbd 100644 --- a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/ServletRequest.java +++ b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/ServletRequest.java @@ -19,69 +19,99 @@ */ package org.xwiki.container.servlet; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; +import java.util.Enumeration; -import org.xwiki.container.Request; +import jakarta.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletRequest; +import org.xwiki.container.Request; +import org.xwiki.jakartabridge.servlet.JakartaServletBridge; +/** + * This is the implementation of {@link Request} for {@link HttpServletRequest}. + * + * @version $Id$ + */ public class ServletRequest implements Request { - private HttpServletRequest httpServletRequest; + private final HttpServletRequest jakartaHttpServletRequest; - public ServletRequest(HttpServletRequest httpServletRequest) + /** + * @param jakartaHttpServletRequest the standard Jakarta {@link HttpServletRequest} instance + * @since 42.0.0 + */ + public ServletRequest(HttpServletRequest jakartaHttpServletRequest) { - this.httpServletRequest = httpServletRequest; + this.jakartaHttpServletRequest = jakartaHttpServletRequest; } - public HttpServletRequest getHttpServletRequest() + /** + * @param javaxHttpServletRequest the legacy Javax {@link javax.servlet.http.HttpServletRequest} instance + * @deprecated use {@link #ServletRequest(HttpServletRequest)} instead + */ + @Deprecated(since = "42.0.0") + public ServletRequest(javax.servlet.http.HttpServletRequest javaxHttpServletRequest) { - return this.httpServletRequest; + this.jakartaHttpServletRequest = JakartaServletBridge.toJakarta(javaxHttpServletRequest); } - @Override - public Object getProperty(String key) + /** + * @return the standard Jakarta {@link HttpServletRequest} instance + * @since 42.0.0 + */ + public HttpServletRequest getRequest() { - Object result; + return this.jakartaHttpServletRequest; + } - // Look first in the Query Parameters and then in the Query Attributes - result = this.httpServletRequest.getParameter(key); - if (result == null) { - result = this.httpServletRequest.getAttribute(key); - } + /** + * @return the legacy Javax {@link javax.servlet.http.HttpServletRequest} instance + * @deprecated use {@link #getRequest()} instead + */ + @Deprecated(since = "42.0.0") + public javax.servlet.http.HttpServletRequest getHttpServletRequest() + { + return JakartaServletBridge.toJavax(this.jakartaHttpServletRequest); + } + + @Override + public Object getParameter(String key) + { + return this.jakartaHttpServletRequest.getParameter(key); + } - return result; + @Override + public String[] getParameterValues(String name) + { + return this.jakartaHttpServletRequest.getParameterValues(name); } @Override - public List getProperties(String key) + public Enumeration getParameterNames() { - List result = new ArrayList(); + return this.jakartaHttpServletRequest.getParameterNames(); + } - // Look first in the Query Parameters and then in the Query Attributes - Object[] requestParameters = this.httpServletRequest.getParameterValues(key); - if (requestParameters != null) { - result.addAll(Arrays.asList(requestParameters)); - } - Object attributeValue = this.httpServletRequest.getAttribute(key); - if (attributeValue != null) { - result.add(attributeValue); - } + @Override + public Object getAttribute(String name) + { + return this.jakartaHttpServletRequest.getAttribute(name); + } - return result; + @Override + public Enumeration getAttributeNames() + { + return this.jakartaHttpServletRequest.getAttributeNames(); } @Override - public void setProperty(String key, Object value) + public void setAttribute(String name, Object o) { - this.httpServletRequest.setAttribute(key, value); + this.jakartaHttpServletRequest.setAttribute(name, o); } @Override - public void removeProperty(String key) + public void removeAttribute(String name) { - this.httpServletRequest.removeAttribute(key); + this.jakartaHttpServletRequest.removeAttribute(name); } } diff --git a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/ServletResponse.java b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/ServletResponse.java index d23d98b58b4b..13ce1f38fd15 100644 --- a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/ServletResponse.java +++ b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/ServletResponse.java @@ -22,35 +22,64 @@ import java.io.IOException; import java.io.OutputStream; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServletResponse; import org.xwiki.container.RedirectResponse; import org.xwiki.container.Response; +import org.xwiki.jakartabridge.servlet.JakartaServletBridge; /** * This is the implementation of {@link Response} for {@link HttpServletResponse}. * * @version $Id$ */ -public class ServletResponse implements Response, RedirectResponse +public class ServletResponse implements RedirectResponse { - private HttpServletResponse httpServletResponse; + private final HttpServletResponse jakartaHttpServletResponse; - public ServletResponse(HttpServletResponse httpServletResponse) + /** + * @param jakartaHttpServletResponse the standard Jakarta {@link HttpServletResponse} instance + * @since 42.0.0 + */ + public ServletResponse(HttpServletResponse jakartaHttpServletResponse) { - this.httpServletResponse = httpServletResponse; + this.jakartaHttpServletResponse = jakartaHttpServletResponse; } - public HttpServletResponse getHttpServletResponse() + /** + * @param javaxHttpServletResponse the legacy Javax {@link javax.servlet.http.HttpServletResponse} instance + * @deprecated use {@link #ServletResponse(HttpServletResponse)} instead + */ + @Deprecated(since = "42.0.0") + public ServletResponse(javax.servlet.http.HttpServletResponse javaxHttpServletResponse) { - return this.httpServletResponse; + this.jakartaHttpServletResponse = JakartaServletBridge.toJakarta(javaxHttpServletResponse); + } + + /** + * @return the standard Jakarta {@link HttpServletResponse} instance + * @since 42.0.0 + */ + public HttpServletResponse getResponse() + { + return this.jakartaHttpServletResponse; + } + + /** + * @return the legacy Javax {@link javax.servlet.http.HttpServletResponse} instance + * @deprecated use {@link #getResponse()} instead + */ + @Deprecated(since = "42.0.0") + public javax.servlet.http.HttpServletResponse getHttpServletResponse() + { + return JakartaServletBridge.toJavax(this.jakartaHttpServletResponse); } @Override public OutputStream getOutputStream() throws IOException { try { - return this.httpServletResponse.getOutputStream(); + return this.jakartaHttpServletResponse.getOutputStream(); } catch (IllegalStateException ex) { return null; } @@ -59,18 +88,54 @@ public OutputStream getOutputStream() throws IOException @Override public void setContentLength(int length) { - this.httpServletResponse.setContentLength(length); + this.jakartaHttpServletResponse.setContentLength(length); } @Override public void setContentType(String mimeType) { - this.httpServletResponse.setContentType(mimeType); + this.jakartaHttpServletResponse.setContentType(mimeType); } @Override public void sendRedirect(String location) throws IOException { - this.httpServletResponse.sendRedirect(location); + this.jakartaHttpServletResponse.sendRedirect(location); + } + + @Override + public void setStatus(int sc) + { + this.jakartaHttpServletResponse.setStatus(sc); + } + + @Override + public void sendError(int sc, String msg) throws IOException + { + this.jakartaHttpServletResponse.sendError(sc, msg); + } + + @Override + public void sendError(int sc) throws IOException + { + this.jakartaHttpServletResponse.sendRedirect(null); + } + + @Override + public boolean containsHeader(String name) + { + return this.jakartaHttpServletResponse.containsHeader(name); + } + + @Override + public void setHeader(String name, String value) + { + this.jakartaHttpServletResponse.setHeader(name, value); + } + + @Override + public void addHeader(String name, String value) + { + this.jakartaHttpServletResponse.addHeader(name, value); } } diff --git a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/ServletSession.java b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/ServletSession.java index a7e17b370af6..11b529540d70 100644 --- a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/ServletSession.java +++ b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/ServletSession.java @@ -19,22 +19,85 @@ */ package org.xwiki.container.servlet; -import org.xwiki.container.Session; +import java.util.Enumeration; + +import jakarta.servlet.http.HttpSession; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; +import org.xwiki.container.Request; +import org.xwiki.container.Session; +import org.xwiki.jakartabridge.servlet.JakartaServletBridge; +import org.xwiki.stability.Unstable; +/** + * This is the implementation of {@link Request} for {@link HttpSession}. + * + * @version $Id$ + */ public class ServletSession implements Session { - private HttpSession httpSession; + private final HttpSession httpSession; - public ServletSession(HttpServletRequest request) + /** + * @param request the servlet request + * @deprecated use {@link #ServletSession(HttpSession)} instead + */ + @Deprecated(since = "42.0.0") + public ServletSession(javax.servlet.http.HttpServletRequest request) { - this.httpSession = request.getSession(true); + this(JakartaServletBridge.toJakarta(request.getSession(true))); } - public HttpSession getHttpSession() + /** + * @param session the Servlet session + * @since 42.0.0 + */ + @Unstable + public ServletSession(HttpSession session) + { + this.httpSession = session; + } + + /** + * @return the current Servlet session + * @deprecated use {@link #getSession()} instead + */ + @Deprecated(since = "42.0.0") + public javax.servlet.http.HttpSession getHttpSession() + { + return JakartaServletBridge.toJavax(this.httpSession); + } + + /** + * @return the current Servlet session + * @since 42.0.0 + */ + @Unstable + public HttpSession getSession() { return this.httpSession; } + + @Override + public Object getAttribute(String name) + { + return this.httpSession.getAttribute(name); + } + + @Override + public Enumeration getAttributeNames() + { + return this.httpSession.getAttributeNames(); + } + + @Override + public void removeAttribute(String name) + { + this.httpSession.removeAttribute(name); + } + + @Override + public void setAttribute(String name, Object value) + { + this.httpSession.setAttribute(name, value); + } } diff --git a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/SetThreadNameServletRequestListener.java b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/SetThreadNameServletRequestListener.java index d4d53998a749..2f2670d1f319 100644 --- a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/SetThreadNameServletRequestListener.java +++ b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/SetThreadNameServletRequestListener.java @@ -19,22 +19,27 @@ */ package org.xwiki.container.servlet; -import javax.servlet.ServletRequest; -import javax.servlet.ServletRequestEvent; -import javax.servlet.ServletRequestListener; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletRequestEvent; +import jakarta.servlet.ServletRequestListener; +import jakarta.servlet.http.HttpServletRequest; /** - * Make threads names created by the application server more meaningful. + * Make threads names created by the application server more meaningful. TODO When it will be possible it would be + * better to do this a component like a RequestInitializer component to work for any kind of container. Right now + * component can't really access the initial URL. + *

+ * While the class is much older, the since annotation was moved to 42.0.0 because it implement a completely different + * API from Java point of view. * - * TODO When it will be possible it would be better to do this a component like a RequestInitializer component to work - * for any kind of container. Right now component can't really access the initial URL. * @version $Id$ - * @since 2.0M3 + * @since 42.0.0 */ public class SetThreadNameServletRequestListener implements ServletRequestListener { - /** The name of the servlet request attribute holding the original name of the processing thread. */ + /** + * The name of the servlet request attribute holding the original name of the processing thread. + */ private static final String ORIGINAL_THREAD_NAME_ATTRIBUTE = "xwiki.thread.originalName"; @Override @@ -42,9 +47,7 @@ public void requestInitialized(ServletRequestEvent sre) { ServletRequest servletRequest = sre.getServletRequest(); - if (servletRequest instanceof HttpServletRequest) { - HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest; - + if (servletRequest instanceof HttpServletRequest httpServletRequest) { String threadName = httpServletRequest.getRequestURL().toString(); if (httpServletRequest.getQueryString() != null) { @@ -65,8 +68,7 @@ public void requestInitialized(ServletRequestEvent sre) public void requestDestroyed(ServletRequestEvent sre) { ServletRequest servletRequest = sre.getServletRequest(); - if (servletRequest instanceof HttpServletRequest) { - HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest; + if (servletRequest instanceof HttpServletRequest httpServletRequest) { Thread.currentThread().setName("" + httpServletRequest.getAttribute(ORIGINAL_THREAD_NAME_ATTRIBUTE)); } } diff --git a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/XWikiServletContextListener.java b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/XWikiServletContextListener.java index 7054d0fa2af8..6a7ec8ecfff8 100644 --- a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/XWikiServletContextListener.java +++ b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/XWikiServletContextListener.java @@ -19,31 +19,54 @@ */ package org.xwiki.container.servlet; -import javax.servlet.ServletContextEvent; -import javax.servlet.ServletContextListener; +import java.lang.reflect.Array; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Set; +import javax.management.MBeanServer; +import javax.management.MBeanServerFactory; +import javax.management.ObjectName; + +import jakarta.servlet.ServletContext; +import jakarta.servlet.ServletContextEvent; +import jakarta.servlet.ServletContextListener; + +import org.apache.commons.lang3.reflect.ConstructorUtils; +import org.apache.commons.lang3.reflect.MethodUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.xwiki.component.embed.EmbeddableComponentManager; import org.xwiki.component.internal.StackingComponentEventManager; import org.xwiki.component.manager.ComponentLookupException; +import org.xwiki.configuration.ConfigurationSource; import org.xwiki.container.ApplicationContextListenerManager; import org.xwiki.container.Container; import org.xwiki.container.servlet.internal.HttpSessionManager; import org.xwiki.environment.Environment; import org.xwiki.environment.internal.ServletEnvironment; import org.xwiki.extension.handler.ExtensionInitializer; +import org.xwiki.jakartabridge.servlet.JakartaServletBridge; import org.xwiki.observation.ObservationManager; import org.xwiki.observation.event.ApplicationStartedEvent; import org.xwiki.observation.event.ApplicationStoppedEvent; /** * Implementation of the {@link ServletContextListener}. Initializes component manager and application context. + *

+ * While the class is much older, the since annotation was moved to 42.0.0 because it implement a completely different + * API from Java point of view. * * @version $Id$ + * @since 42.0.0 */ public class XWikiServletContextListener implements ServletContextListener { + private static final Logger LOGGER = LoggerFactory.getLogger(XWikiServletContextListener.class); + + private static final String TOMCAT_CATALINA = "Catalina"; + /** * Logger to use to log shutdown information (opposite of initialization). */ @@ -63,14 +86,8 @@ public void contextInitialized(ServletContextEvent servletContextEvent) ecm.initialize(this.getClass().getClassLoader()); this.componentManager = ecm; - // This is a temporary bridge to allow non XWiki components to lookup XWiki components. // We're putting the XWiki Component Manager instance in the Servlet Context so that it's - // available in the XWikiAction class which in turn puts it into the XWikiContext instance. - // Class that need to lookup then just need to get it from the XWikiContext instance. - // This is of course not necessary for XWiki components since they just need to implement - // the Composable interface to get access to the Component Manager or better they simply - // need to declare their components requirements using the @Inject annotation of the xwiki - // component manager together with a private class member, for automatic injection by the CM on init. + // available in Servlets and Filters. servletContextEvent.getServletContext() .setAttribute(org.xwiki.component.manager.ComponentManager.class.getName(), this.componentManager); @@ -97,7 +114,8 @@ public void contextInitialized(ServletContextEvent servletContextEvent) try { ServletContainerInitializer containerInitializer = this.componentManager.getInstance(ServletContainerInitializer.class); - containerInitializer.initializeApplicationContext(servletContextEvent.getServletContext()); + containerInitializer + .initializeApplicationContext(JakartaServletBridge.toJavax(servletContextEvent.getServletContext())); } catch (ComponentLookupException e) { throw new RuntimeException("Failed to initialize the Application Context", e); } @@ -118,7 +136,7 @@ public void contextInitialized(ServletContextEvent servletContextEvent) throw new RuntimeException("Failed to initialize installed extensions", e); } - // Register the HttpSessionManager as a listener. + // Register the HttpSessionManager as a listener. try { HttpSessionManager httpSessionManager = this.componentManager.getInstance(HttpSessionManager.class); servletContextEvent.getServletContext().addListener(httpSessionManager); @@ -132,10 +150,153 @@ public void contextInitialized(ServletContextEvent servletContextEvent) eventManager.shouldStack(false); eventManager.flushEvents(); + // Force allowing any character in the input URLs, contrary to what Servlet 6 specifications indicate + // FIXME: Remove when https://jira.xwiki.org/browse/XWIKI-19167 is fully fixed + allowAllURLCharacters(servletContextEvent.getServletContext()); + // Indicate to the various components that XWiki is ready observationManager.notify(new ApplicationStartedEvent(), this); } + private void allowAllURLCharacters(ServletContext servletContext) + { + if (isForceAllowAnyCharacter()) { + // Tomcat + allowAllURLCharactersTomcat(); + + // Jetty + allowAllURLCharactersJetty(servletContext); + } + } + + private boolean isForceAllowAnyCharacter() + { + ConfigurationSource configuration; + try { + configuration = this.componentManager.getInstance(ConfigurationSource.class, "xwikiproperties"); + + return configuration.getProperty("url.forceAllowAnyCharacter", true); + } catch (ComponentLookupException e) { + throw new RuntimeException("Failed to access the configuration", e); + } + } + + private void allowAllURLCharactersTomcat() + { + try { + ArrayList mbeanServers = MBeanServerFactory.findMBeanServer(null); + if (!mbeanServers.isEmpty()) { + MBeanServer mBeanServer = mbeanServers.get(0); + ObjectName name = new ObjectName(TOMCAT_CATALINA, "type", "Server"); + Object server = mBeanServer.getAttribute(name, "managedResource"); + Object service = MethodUtils.invokeMethod(server, "findService", TOMCAT_CATALINA); + Object connectors = MethodUtils.invokeMethod(service, "findConnectors"); + for (int i = 0; i < Array.getLength(connectors); ++i) { + Object connector = Array.get(connectors, i); + + // Allow backslash (\) + MethodUtils.invokeMethod(connector, "setAllowBackslash", true); + // Allow slash/solidus (/) + MethodUtils.invokeMethod(connector, "setEncodedSolidusHandling", "passthrough"); + // Try as much as possible to have XWiki being called directly for any URI + MethodUtils.invokeMethod(connector, "setRejectSuspiciousURIs", false); + } + } + } catch (Exception e) { + LOGGER.debug("Failed to configure Tomcat URL constraints", e); + } + } + + private void allowAllURLCharactersJetty(ServletContext servletContext) + { + try { + Object contextHandler = MethodUtils.invokeMethod(servletContext, "getContextHandler"); + + // setDecodeAmbiguousURIs + Object servletHandler = MethodUtils.invokeMethod(contextHandler, "getServletHandler"); + MethodUtils.invokeMethod(servletHandler, "setDecodeAmbiguousURIs", true); + + // URI compliance + Object server = MethodUtils.invokeMethod(contextHandler, "getServer"); + Object connectors = MethodUtils.invokeMethod(server, "getConnectors"); + Object uriCompliance = null; + for (int i = 0; i < Array.getLength(connectors); ++i) { + uriCompliance = configureConnectorJetty(Array.get(connectors, i), uriCompliance); + } + } catch (Exception e) { + LOGGER.debug("Failed to configure Jetty URL constraints", e); + } + } + + private Object configureConnectorJetty(Object connector, Object inputUriCompliance) + { + Object uriCompliance = inputUriCompliance; + + Object factories; + try { + factories = MethodUtils.invokeMethod(connector, "getConnectionFactories"); + if (factories instanceof Collection factoriesCollection) { + for (Object factory : factoriesCollection) { + uriCompliance = configureFactoryJetty(factory, uriCompliance); + } + } + } catch (Exception e) { + LOGGER.debug("Failed to get factories", e); + } + + return uriCompliance; + } + + private Object configureFactoryJetty(Object factory, Object inputUriCompliance) + { + Object uriCompliance = inputUriCompliance; + + try { + Object httpConfiguration = MethodUtils.invokeMethod(factory, "getHttpConfiguration"); + + if (uriCompliance == null) { + uriCompliance = getUriCompliance(httpConfiguration); + } + + MethodUtils.invokeMethod(httpConfiguration, "setUriCompliance", uriCompliance); + } catch (Exception e) { + LOGGER.debug("Failed to set the URI compliance", e); + } + + return uriCompliance; + } + + private Object getUriCompliance(Object httpConfiguration) + throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException + { + // Create a UriCompliance with the right class (we cannot use the one in the current classloader since it's + // coming from XWiki WAR) + + Class uriComplianceClass = MethodUtils.invokeMethod(httpConfiguration, "getUriCompliance").getClass(); + Class violationsClass = getViolationClass(uriComplianceClass); + Set violations = Set.of(Enum.valueOf(violationsClass, "AMBIGUOUS_PATH_SEGMENT"), + Enum.valueOf(violationsClass, "AMBIGUOUS_EMPTY_SEGMENT"), + Enum.valueOf(violationsClass, "AMBIGUOUS_PATH_SEPARATOR"), + Enum.valueOf(violationsClass, "AMBIGUOUS_PATH_PARAMETER"), + Enum.valueOf(violationsClass, "AMBIGUOUS_PATH_ENCODING")); + + return ConstructorUtils.invokeConstructor(uriComplianceClass, "XWiki", violations); + } + + private Class getViolationClass(Class uriComplianceClass) + { + for (Class innerClass : uriComplianceClass.getDeclaredClasses()) { + // We cannot manipulate the class directly because it would probably be the wrong one, so we use reflection + @SuppressWarnings("java:S1872") + boolean isViolationClass = innerClass.getName().equals("org.eclipse.jetty.http.UriCompliance$Violation"); + if (isViolationClass) { + return innerClass; + } + } + + return null; + } + @Override public void contextDestroyed(ServletContextEvent sce) { diff --git a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/filters/SavedRequestManager.java b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/filters/SavedRequestManager.java index 9c62160c4367..47fa5839c4dd 100644 --- a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/filters/SavedRequestManager.java +++ b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/filters/SavedRequestManager.java @@ -23,11 +23,13 @@ import java.util.HashMap; import java.util.Map; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpSession; import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.StringUtils; +import org.xwiki.jakartabridge.servlet.JakartaServletBridge; +import org.xwiki.stability.Unstable; /** * Allows to save a request and restore it later from the stored request identifier (SRID). @@ -64,8 +66,21 @@ public static class SavedRequest implements Serializable * Constructor that copies the needed information from a request. * * @param request the request that needs to be saved + * @deprecated use {@link #SavedRequest(HttpServletRequest)}) instead */ - @SuppressWarnings("unchecked") + @Deprecated(since = "42.0.0") + public SavedRequest(javax.servlet.http.HttpServletRequest request) + { + this(JakartaServletBridge.toJakarta(request)); + } + + /** + * Constructor that copies the needed information from a request. + * + * @param request the request that needs to be saved + * @since 42.0.0 + */ + @Unstable public SavedRequest(HttpServletRequest request) { this.parameters = new HashMap<>(request.getParameterMap()); @@ -73,11 +88,11 @@ public SavedRequest(HttpServletRequest request) } /** - * Gets the value for a parameter, just like {@link javax.servlet.ServletRequest#getParameter(String)}. + * Gets the value for a parameter, just like {@link jakarta.servlet.ServletRequest#getParameter(String)}. * * @param name the name of the parameter * @return The first value for this parameter, or null if no value was sent for this parameter. - * @see javax.servlet.ServletRequest#getParameter(String) + * @see jakarta.servlet.ServletRequest#getParameter(String) * @see #getParameterValues(String) */ public String getParameter(String name) @@ -91,11 +106,11 @@ public String getParameter(String name) /** * Gets all the values stored for a parameter, just like - * {@link javax.servlet.ServletRequest#getParameterValues(String)}. + * {@link jakarta.servlet.ServletRequest#getParameterValues(String)}. * * @param name the name of the parameter * @return All the values for this parameter, or null if no value was sent for this parameter. - * @see javax.servlet.ServletRequest#getParameterValues(String) + * @see jakarta.servlet.ServletRequest#getParameterValues(String) * @see #getParameter(String) */ public String[] getParameterValues(String name) @@ -104,10 +119,10 @@ public String[] getParameterValues(String name) } /** - * Gets all the stored parameters, just like {@link javax.servlet.ServletRequest#getParameterMap()}. + * Gets all the stored parameters, just like {@link jakarta.servlet.ServletRequest#getParameterMap()}. * * @return A map with all the stored parameters. - * @see javax.servlet.ServletRequest#getParameterMap() + * @see jakarta.servlet.ServletRequest#getParameterMap() */ public Map getParameterMap() { @@ -156,7 +171,24 @@ public static String getSavedRequestKey() * * @param request the request to save * @return the identifier of the saved request + * @deprecated use {@link #saveRequest(HttpServletRequest)} instead */ + @Deprecated(since = "42.0.0") + public static String saveRequest(javax.servlet.http.HttpServletRequest request) + { + return saveRequest(JakartaServletBridge.toJakarta(request)); + } + + /** + * Saves the data from a request and stores it in the current session. This method is not thread safe, and does not + * guarantee that saved requests are not overwritten, but given that this should only happen sparingly, and that + * each client uses his own session to save this kind of information, this is not a real issue. + * + * @param request the request to save + * @return the identifier of the saved request + * @since 42.0.0 + */ + @Unstable @SuppressWarnings("unchecked") public static String saveRequest(HttpServletRequest request) { @@ -190,7 +222,25 @@ public static String saveRequest(HttpServletRequest request) * @param request the current request * @return the original requested URL that triggered a detour, or null if there isn't any original * request information + * @deprecated use {@link #getOriginalUrl(HttpServletRequest)} instead + */ + @Deprecated(since = "42.0.0") + public static String getOriginalUrl(javax.servlet.http.HttpServletRequest request) + { + return getOriginalUrl(JakartaServletBridge.toJakarta(request)); + } + + /** + * Retrieves the original URL requested before a detour. This method returns something different from + * null only when there's a srid parameter in the current request, indicating that there was + * another request which data was saved, related to the current request. + * + * @param request the current request + * @return the original requested URL that triggered a detour, or null if there isn't any original + * request information + * @since 42.0.0 */ + @Unstable @SuppressWarnings("unchecked") public static String getOriginalUrl(HttpServletRequest request) { diff --git a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/filters/internal/ResolveRelativeRedirectFilter.java b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/filters/internal/ResolveRelativeRedirectFilter.java new file mode 100644 index 000000000000..ef215ab7ef85 --- /dev/null +++ b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/filters/internal/ResolveRelativeRedirectFilter.java @@ -0,0 +1,149 @@ +/* + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.xwiki.container.servlet.filters.internal; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; + +import jakarta.servlet.Filter; +import jakarta.servlet.FilterChain; +import jakarta.servlet.FilterConfig; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServletResponseWrapper; + +import org.apache.commons.lang3.StringUtils; +import org.xwiki.component.manager.ComponentLookupException; +import org.xwiki.component.manager.ComponentManager; +import org.xwiki.configuration.ConfigurationSource; +import org.xwiki.container.servlet.HttpServletUtils; + +/** + * Filter which inject a response wrapper in charge of resolving the relative URLs on XWiki side instead of application + * server side, to reduce setup requirements. + * + * @version $Id$ + * @since 42.0.0 + */ +public class ResolveRelativeRedirectFilter implements Filter +{ + /** + * Response wrapper in charge of resolving relative references to absolute ones. + * + * @version $Id$ + */ + public class ResolveRelativeRedirectResponse extends HttpServletResponseWrapper + { + private final HttpServletRequest request; + + private URI sourceURI; + + /** + * @param request the request + * @param response the wrapped response + * @throws MalformedURLException when failing to get the current URL + */ + public ResolveRelativeRedirectResponse(HttpServletRequest request, HttpServletResponse response) + throws MalformedURLException + { + super(response); + + this.request = request; + } + + /** + * @return the sourceURL + */ + public URI getSourceURI() + { + if (this.sourceURI == null) { + try { + this.sourceURI = HttpServletUtils.getSourceURL(this.request).toURI(); + } catch (URISyntaxException | MalformedURLException e) { + // It's very unlikely that the source URL would be invalid, but just ignore it in this case + } + } + + return this.sourceURI; + } + + @Override + public void sendRedirect(String location) throws IOException + { + String url = location; + + // Resolve relative URLs + if (StringUtils.isNotBlank(location)) { + try { + URI locationURI = new URI(location); + if (!locationURI.isAbsolute()) { + URI referenceURI = getSourceURI(); + if (referenceURI != null) { + url = referenceURI.resolve(location).toString(); + } + } + } catch (URISyntaxException e) { + // Let invalid URIs go through + } + } + + // Redirect + super.sendRedirect(url); + } + } + + private boolean resolveRedirect = true; + + @Override + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException + { + ServletResponse filteredResponse = response; + + if (this.resolveRedirect && filteredResponse instanceof HttpServletResponse httpResponse) { + filteredResponse = new ResolveRelativeRedirectResponse((HttpServletRequest) request, httpResponse); + } + + chain.doFilter(request, filteredResponse); + } + + @Override + public void init(FilterConfig filterConfig) throws ServletException + { + // Get the Component Manager which has been initialized first in a Servlet Context Listener. + ComponentManager rootComponentManager = + (ComponentManager) filterConfig.getServletContext().getAttribute(ComponentManager.class.getName()); + + // Get the configuration + try { + ConfigurationSource properties = + rootComponentManager.getInstance(ConfigurationSource.class, "xwikiproperties"); + + this.resolveRedirect = properties.getProperty("container.request.resolveRelativeRedirect", true); + } catch (ComponentLookupException e) { + throw new ServletException("Failed to access configuration", e); + } + } +} diff --git a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/filters/internal/SafeRedirectFilter.java b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/filters/internal/SafeRedirectFilter.java new file mode 100644 index 000000000000..46f5e5c4aeee --- /dev/null +++ b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/filters/internal/SafeRedirectFilter.java @@ -0,0 +1,123 @@ +/* + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.xwiki.container.servlet.filters.internal; + +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; + +import jakarta.servlet.Filter; +import jakarta.servlet.FilterChain; +import jakarta.servlet.FilterConfig; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServletResponseWrapper; + +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.xwiki.component.manager.ComponentLookupException; +import org.xwiki.component.manager.ComponentManager; +import org.xwiki.url.URLSecurityManager; + +/** + * Filter which inject a response wrapper in charge of converting the redirect location into a safe URL. + * + * @version $Id$ + * @since 42.0.0 + */ +public class SafeRedirectFilter implements Filter +{ + /** + * Response wrapper in charge of checking the references. + * + * @version $Id$ + */ + public class SafeRedirectResponse extends HttpServletResponseWrapper + { + private static final Logger LOGGER = LoggerFactory.getLogger(SafeRedirectResponse.class); + + private final URLSecurityManager urlSecurityManager; + + /** + * @param urlSecurityManager the tool in charge of validating the URL + * @param response the wrapped response + */ + public SafeRedirectResponse(URLSecurityManager urlSecurityManager, HttpServletResponse response) + { + super(response); + + this.urlSecurityManager = urlSecurityManager; + } + + @Override + public void sendRedirect(String location) throws IOException + { + if (StringUtils.isNotBlank(location)) { + URI uri; + try { + uri = this.urlSecurityManager.parseToSafeURI(location); + + super.sendRedirect(uri.toString()); + } catch (URISyntaxException | SecurityException e) { + LOGGER.warn( + "Possible phishing attack, attempting to redirect to [{}], this request has been blocked. " + + "If the request was legitimate, please check the URL security configuration. You " + + "might need to add the domain related to this request in the list of trusted domains in " + + "the configuration: it can be configured in xwiki.properties in url.trustedDomains.", + location); + LOGGER.debug("Original error preventing the redirect: ", e); + } + } + } + } + + private URLSecurityManager urlSecurityManager; + + @Override + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException + { + ServletResponse filteredResponse = response; + + if (filteredResponse instanceof HttpServletResponse httpResponse) { + filteredResponse = new SafeRedirectResponse(this.urlSecurityManager, httpResponse); + } + + chain.doFilter(request, filteredResponse); + } + + @Override + public void init(FilterConfig filterConfig) throws ServletException + { + // Get the Component Manager which has been initialized first in a Servlet Context Listener. + ComponentManager rootComponentManager = + (ComponentManager) filterConfig.getServletContext().getAttribute(ComponentManager.class.getName()); + + // Get the configuration + try { + this.urlSecurityManager = rootComponentManager.getInstance(URLSecurityManager.class); + } catch (ComponentLookupException e) { + throw new ServletException("Failed to access configuration", e); + } + } +} diff --git a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/filters/internal/SavedRequestRestorerFilter.java b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/filters/internal/SavedRequestRestorerFilter.java index 497f09f8e284..291d70f34314 100644 --- a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/filters/internal/SavedRequestRestorerFilter.java +++ b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/filters/internal/SavedRequestRestorerFilter.java @@ -27,15 +27,15 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletRequestWrapper; -import javax.servlet.http.HttpSession; +import jakarta.servlet.Filter; +import jakarta.servlet.FilterChain; +import jakarta.servlet.FilterConfig; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequestWrapper; +import jakarta.servlet.http.HttpSession; import org.apache.commons.lang3.StringUtils; import org.xwiki.container.servlet.filters.SavedRequestManager; @@ -61,8 +61,12 @@ * safe as a session is, and it will not be available after the session is invalidated. Another consequence is that only * HTTP requests are saved. *

+ *

+ * While the class is much older, the since annotation was moved to 42.0.0 because it implement a completely + * different API from Java point of view. * * @version $Id$ + * @since 42.0.0 */ public class SavedRequestRestorerFilter implements Filter { @@ -156,7 +160,6 @@ public String[] getParameterValues(String name) * @return an immutable Map containing parameter names as keys and parameter values as map values * @see javax.servlet.ServletRequest#getParameterMap() */ - @SuppressWarnings("unchecked") @Override public Map getParameterMap() { @@ -191,13 +194,13 @@ public void init(FilterConfig filterConfig) } @Override - public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, - ServletException + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException { ServletRequest filteredRequest = request; // This filter works only for HTTP requests, because they are the only ones with a session. if (request instanceof HttpServletRequest - && !Boolean.valueOf((String) request.getAttribute(ATTRIBUTE_APPLIED))) { + && !Boolean.valueOf((String) request.getAttribute(ATTRIBUTE_APPLIED))) { // Get the saved request, if any (returns null if not applicable) SavedRequest savedRequest = getSavedRequest((HttpServletRequest) request); // Merge the new and the saved request diff --git a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/filters/internal/SetCharacterEncodingFilter.java b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/filters/internal/SetCharacterEncodingFilter.java index 650288c51cc8..346c9dd94d2b 100644 --- a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/filters/internal/SetCharacterEncodingFilter.java +++ b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/filters/internal/SetCharacterEncodingFilter.java @@ -21,12 +21,12 @@ import java.io.IOException; -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; +import jakarta.servlet.Filter; +import jakarta.servlet.FilterChain; +import jakarta.servlet.FilterConfig; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; /** *

@@ -51,9 +51,12 @@ * characteristics of the incoming request (such as the values of the Accept-Language * and User-Agent headers, or a value stashed in the current user's session. *

+ *

+ * While the class is much older, the since annotation was moved to 42.0.0 because it implement a completely different API + * from Java point of view. * - * @author Craig McClanahan * @version $Id$ + * @since 42.0.0 */ public class SetCharacterEncodingFilter implements Filter { diff --git a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/filters/internal/SetHTTPHeaderFilter.java b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/filters/internal/SetHTTPHeaderFilter.java index a306a2b297e1..f7ae02c175a6 100644 --- a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/filters/internal/SetHTTPHeaderFilter.java +++ b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/filters/internal/SetHTTPHeaderFilter.java @@ -21,19 +21,22 @@ import java.io.IOException; -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.Filter; +import jakarta.servlet.FilterChain; +import jakarta.servlet.FilterConfig; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; +import jakarta.servlet.http.HttpServletResponse; /** * Filter that set the desired header of the HTTP response to the desired value. + *

+ * While the class is much older, the since annotation was moved to 42.0.0 because it implement a completely + * different API from Java point of view. * * @version $Id$ - * @since 6.3M2 + * @since 42.0.0 */ public class SetHTTPHeaderFilter implements Filter { diff --git a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/internal/CacheControlRequestInitializer.java b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/internal/CacheControlRequestInitializer.java index 542c7a0429a3..6023ab382f95 100644 --- a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/internal/CacheControlRequestInitializer.java +++ b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/internal/CacheControlRequestInitializer.java @@ -47,8 +47,8 @@ public class CacheControlRequestInitializer implements RequestInitializer public void initialize(Request request) throws RequestInitializerException { // Indicate if the request explicitly disable getting resources from the cache - if (request instanceof ServletRequest - && !HttpServletUtils.isCacheReadAllowed(((ServletRequest) request).getHttpServletRequest())) { + if (request instanceof ServletRequest servletRequest + && !HttpServletUtils.isCacheReadAllowed(servletRequest.getRequest())) { this.cacheControl.setCacheReadAllowed(false); } } diff --git a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/internal/DefaultServletContainerInitializer.java b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/internal/DefaultServletContainerInitializer.java index 6b710c25d00b..ab97aa88ccce 100644 --- a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/internal/DefaultServletContainerInitializer.java +++ b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/internal/DefaultServletContainerInitializer.java @@ -22,8 +22,9 @@ import javax.inject.Inject; import javax.inject.Singleton; import javax.servlet.ServletContext; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import org.xwiki.component.annotation.Component; import org.xwiki.component.manager.ComponentManager; @@ -45,13 +46,6 @@ @Singleton public class DefaultServletContainerInitializer implements ServletContainerInitializer { - // Implementation note: It's important that we don't use @Inject annotations here - // for RequestInitializerManager and ExecutionContextManager since we can have - // RequestInitializer and ExecutionContextInitializer components which try to access - // the Application Context in their initialize() method and we need it to be available - // (i.e. initializeApplicationContext() needs to have been called) before they are - // looked up (and thus initialized). - @Inject private ApplicationContextListenerManager applicationContextListenerManager; @@ -64,6 +58,41 @@ public class DefaultServletContainerInitializer implements ServletContainerIniti @Inject private ComponentManager componentManager; + @Override + public void initializeRequest(HttpServletRequest request, HttpServletResponse response) + throws ServletContainerException + { + // 1) Set the request and the response in the Container. From this point forward request initializers can use + // the Container object to get any data they want from the Request. + this.container.setRequest(new ServletRequest(request)); + if (response != null) { + this.container.setResponse(new ServletResponse(response)); + } + this.container.setSession(new ServletSession(request.getSession(false))); + + // 2) Create an empty Execution context so that the Container initializers can put things in the + // execution context when they execute. + this.execution.setContext(new ExecutionContext()); + + // 3) Call the request initializers to populate the Request further. + try { + RequestInitializerManager manager = this.componentManager.getInstance(RequestInitializerManager.class); + manager.initializeRequest(this.container.getRequest()); + } catch (Exception e) { + throw new ServletContainerException("Failed to initialize request", e); + } + + // 4) Call Execution Context initializers to perform further Execution Context initializations + try { + ExecutionContextManager manager = this.componentManager.getInstance(ExecutionContextManager.class); + manager.initialize(this.execution.getContext()); + } catch (Exception e) { + throw new ServletContainerException("Failed to initialize Execution Context", e); + } + } + + // Deprecated + /** * @deprecated use the notion of Environment instead */ @@ -77,12 +106,14 @@ public void initializeApplicationContext(ServletContext servletContext) } @Override - public void initializeRequest(HttpServletRequest httpServletRequest, Object xwikiContext) + @Deprecated(since = "42.0.0") + public void initializeRequest(javax.servlet.http.HttpServletRequest httpServletRequest, Object xwikiContext) throws ServletContainerException { // 1) Create an empty request. From this point forward request initializers can use the // Container object to get any data they want from the Request. this.container.setRequest(new ServletRequest(httpServletRequest)); + this.container.setSession(new ServletSession(httpServletRequest)); // 2) Create an empty Execution context so that the Container initializers can put things in the // execution context when they execute. @@ -118,19 +149,23 @@ public void initializeRequest(HttpServletRequest httpServletRequest, Object xwik } @Override - public void initializeRequest(HttpServletRequest httpServletRequest) throws ServletContainerException + @Deprecated(since = "42.0.0") + public void initializeRequest(javax.servlet.http.HttpServletRequest httpServletRequest) + throws ServletContainerException { initializeRequest(httpServletRequest, null); } @Override - public void initializeResponse(HttpServletResponse httpServletResponse) + @Deprecated(since = "42.0.0") + public void initializeResponse(javax.servlet.http.HttpServletResponse httpServletResponse) { this.container.setResponse(new ServletResponse(httpServletResponse)); } @Override - public void initializeSession(HttpServletRequest httpServletRequest) + @Deprecated(since = "42.0.0") + public void initializeSession(javax.servlet.http.HttpServletRequest httpServletRequest) { this.container.setSession(new ServletSession(httpServletRequest)); } diff --git a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/internal/HttpSessionManager.java b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/internal/HttpSessionManager.java index c60ed9b24550..0e52f5c4a38e 100644 --- a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/internal/HttpSessionManager.java +++ b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/main/java/org/xwiki/container/servlet/internal/HttpSessionManager.java @@ -23,11 +23,11 @@ import java.util.List; import java.util.concurrent.ConcurrentLinkedQueue; -import javax.inject.Inject; -import javax.inject.Singleton; -import javax.servlet.http.HttpSession; -import javax.servlet.http.HttpSessionEvent; -import javax.servlet.http.HttpSessionListener; +import jakarta.inject.Inject; +import jakarta.inject.Singleton; +import jakarta.servlet.http.HttpSession; +import jakarta.servlet.http.HttpSessionEvent; +import jakarta.servlet.http.HttpSessionListener; import org.xwiki.component.annotation.Component; import org.xwiki.component.manager.ComponentLifecycleException; @@ -39,13 +39,15 @@ import org.xwiki.observation.ObservationManager; /** - * Manager in charge of keeping track of the {@link HttpSession}. - * One of the role of this component is to properly call {@link HttpSession#invalidate()} on all sessions before - * disposal of the component: this ensures that all listeners relying on the session disposal can be executed. + * Manager in charge of keeping track of the {@link HttpSession}. One of the role of this component is to properly call + * {@link HttpSession#invalidate()} on all sessions before disposal of the component: this ensures that all listeners + * relying on the session disposal can be executed. + *

+ * While the class is much older, the since annotation was moved to 42.0.0 because it implements a completely + * different API from Java point of view. * * @version $Id$ - * @since 14.5 - * @since 14.4.1 + * @since 42.0.0 */ @Component(roles = HttpSessionManager.class) @Singleton diff --git a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/test/java/org/xwiki/container/servlet/internal/HttpSessionManagerTest.java b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/test/java/org/xwiki/container/servlet/internal/HttpSessionManagerTest.java index 02ac3b975375..bcbd3e2cc5ff 100644 --- a/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/test/java/org/xwiki/container/servlet/internal/HttpSessionManagerTest.java +++ b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/test/java/org/xwiki/container/servlet/internal/HttpSessionManagerTest.java @@ -21,8 +21,8 @@ import java.util.List; -import javax.servlet.http.HttpSession; -import javax.servlet.http.HttpSessionEvent; +import jakarta.servlet.http.HttpSession; +import jakarta.servlet.http.HttpSessionEvent; import org.junit.jupiter.api.Test; import org.xwiki.component.manager.ComponentLifecycleException; diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/test/java/com/xpn/xwiki/web/XWikiServletResponseTest.java b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/test/java/org/xwiki/container/servlet/internal/SafeRedirectFilterTest.java similarity index 64% rename from xwiki-platform-core/xwiki-platform-oldcore/src/test/java/com/xpn/xwiki/web/XWikiServletResponseTest.java rename to xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/test/java/org/xwiki/container/servlet/internal/SafeRedirectFilterTest.java index 5f434daf53b5..1a4f5feeb52a 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/test/java/com/xpn/xwiki/web/XWikiServletResponseTest.java +++ b/xwiki-platform-core/xwiki-platform-container/xwiki-platform-container-servlet/src/test/java/org/xwiki/container/servlet/internal/SafeRedirectFilterTest.java @@ -17,22 +17,30 @@ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ -package com.xpn.xwiki.web; +package org.xwiki.container.servlet.internal; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.FilterChain; +import jakarta.servlet.FilterConfig; +import jakarta.servlet.ServletContext; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; +import jakarta.servlet.http.HttpServletResponse; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; import org.xwiki.component.manager.ComponentManager; +import org.xwiki.container.servlet.filters.internal.SafeRedirectFilter; import org.xwiki.test.LogLevel; import org.xwiki.test.annotation.BeforeComponent; import org.xwiki.test.junit5.LogCaptureExtension; import org.xwiki.test.junit5.mockito.ComponentTest; +import org.xwiki.test.junit5.mockito.InjectComponentManager; import org.xwiki.test.junit5.mockito.MockComponent; import org.xwiki.test.mockito.MockitoComponentManager; import org.xwiki.url.URLSecurityManager; @@ -45,19 +53,25 @@ import static org.mockito.Mockito.when; /** - * Tests for {@link XWikiServletResponse}. - * + * Validate {@link SafeRedirectFilter}. + * * @version $Id$ */ @ComponentTest -class XWikiServletResponseTest +class SafeRedirectFilterTest { @MockComponent private URLSecurityManager urlSecurityManager; - private XWikiServletResponse servletResponse; + @InjectComponentManager + private ComponentManager componentManager; + + private SafeRedirectFilter filter; + private HttpServletResponse httpServletResponse; + private HttpServletResponse safeServletResponse; + @RegisterExtension private LogCaptureExtension logCapture = new LogCaptureExtension(LogLevel.WARN); @@ -65,32 +79,48 @@ class XWikiServletResponseTest void beforeComponent(MockitoComponentManager mockitoComponentManager) throws Exception { mockitoComponentManager.registerComponent(ComponentManager.class, "context", mockitoComponentManager); - Utils.setComponentManager(mockitoComponentManager); } @BeforeEach - void setup() + void setup() throws IOException, ServletException { - this.httpServletResponse = mock(HttpServletResponse.class); - this.servletResponse = new XWikiServletResponse(this.httpServletResponse); + this.httpServletResponse = mock(); + + this.filter = new SafeRedirectFilter(); + + FilterConfig filterConfig = mock(); + ServletContext servletContext = mock(); + when(filterConfig.getServletContext()).thenReturn(servletContext); + when(servletContext.getAttribute(ComponentManager.class.getName())).thenReturn(this.componentManager); + this.filter.init(filterConfig); + + this.filter.doFilter(null, this.httpServletResponse, new FilterChain() + { + @Override + public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException + { + safeServletResponse = (HttpServletResponse) response; + } + }); } @Test void sendRedirect() throws IOException, URISyntaxException { - this.servletResponse.sendRedirect(""); + this.safeServletResponse.sendRedirect(""); verify(this.httpServletResponse, never()).sendRedirect(any()); String location = "//xwiki.org/xwiki/something/"; URI expectedURI = new URI("//xwiki.org/xwiki/something/"); when(this.urlSecurityManager.parseToSafeURI(location)).thenReturn(expectedURI); - this.servletResponse.sendRedirect(location); + this.safeServletResponse.sendRedirect(location); verify(this.httpServletResponse).sendRedirect(location); when(this.urlSecurityManager.parseToSafeURI(location)).thenThrow(new SecurityException("Unsafe location")); - this.servletResponse.sendRedirect(location); + this.safeServletResponse.sendRedirect(location); assertEquals(1, this.logCapture.size()); - assertEquals("Possible phishing attack, attempting to redirect to [//xwiki.org/xwiki/something/], this request" + assertEquals( + "Possible phishing attack, attempting to redirect to [//xwiki.org/xwiki/something/], this request" + " has been blocked. If the request was legitimate, please check the URL security configuration. " + "You might need to add the domain related to this request in the list of trusted domains in the " + "configuration: it can be configured in xwiki.properties in url.trustedDomains.", diff --git a/xwiki-platform-core/xwiki-platform-crypto/xwiki-platform-crypto-store/xwiki-platform-crypto-store-wiki/pom.xml b/xwiki-platform-core/xwiki-platform-crypto/xwiki-platform-crypto-store/xwiki-platform-crypto-store-wiki/pom.xml index 8b6364b8833d..55c6bad711ca 100644 --- a/xwiki-platform-core/xwiki-platform-crypto/xwiki-platform-crypto-store/xwiki-platform-crypto-store-wiki/pom.xml +++ b/xwiki-platform-core/xwiki-platform-crypto/xwiki-platform-crypto-store/xwiki-platform-crypto-store-wiki/pom.xml @@ -91,8 +91,8 @@ test - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test diff --git a/xwiki-platform-core/xwiki-platform-csrf/pom.xml b/xwiki-platform-core/xwiki-platform-csrf/pom.xml index b76304840401..d92fff2113a6 100644 --- a/xwiki-platform-core/xwiki-platform-csrf/pom.xml +++ b/xwiki-platform-core/xwiki-platform-csrf/pom.xml @@ -66,8 +66,8 @@ ${project.version} - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api commons-codec diff --git a/xwiki-platform-core/xwiki-platform-csrf/src/main/java/org/xwiki/csrf/internal/DefaultCSRFToken.java b/xwiki-platform-core/xwiki-platform-csrf/src/main/java/org/xwiki/csrf/internal/DefaultCSRFToken.java index de4e66e9ac36..c28107525cbb 100644 --- a/xwiki-platform-core/xwiki-platform-csrf/src/main/java/org/xwiki/csrf/internal/DefaultCSRFToken.java +++ b/xwiki-platform-core/xwiki-platform-csrf/src/main/java/org/xwiki/csrf/internal/DefaultCSRFToken.java @@ -28,7 +28,8 @@ import javax.inject.Inject; import javax.inject.Singleton; -import javax.servlet.http.HttpServletRequest; + +import jakarta.servlet.http.HttpServletRequest; import org.apache.commons.codec.binary.Base64; import org.slf4j.Logger; @@ -70,7 +71,7 @@ public class DefaultCSRFToken implements CSRFToken, Initializable private static final String RESUBMIT_TEMPLATE = "resubmit"; /** Token storage (one token per user). */ - private final ConcurrentMap tokens = new ConcurrentHashMap(); + private final ConcurrentMap tokens = new ConcurrentHashMap<>(); /** Token for guest user. */ private String guestToken; @@ -172,6 +173,7 @@ public boolean isTokenValid(String token) if (token == null || token.isEmpty() || !storedToken.equals(token)) { this.logger.warn("Secret CSRF token verification failed (token: [{}], stored token: [{}])", token, storedToken); + return false; } return true; @@ -241,8 +243,9 @@ private HttpServletRequest getRequest() { Request request = this.container.getRequest(); if (request instanceof ServletRequest servletRequest) { - return servletRequest.getHttpServletRequest(); + return servletRequest.getRequest(); } + throw new RuntimeException("Not supported request type"); } diff --git a/xwiki-platform-core/xwiki-platform-dashboard/xwiki-platform-dashboard-macro/pom.xml b/xwiki-platform-core/xwiki-platform-dashboard/xwiki-platform-dashboard-macro/pom.xml index 838ac46bccdd..5ab7a2de4cf5 100644 --- a/xwiki-platform-core/xwiki-platform-dashboard/xwiki-platform-dashboard-macro/pom.xml +++ b/xwiki-platform-core/xwiki-platform-dashboard/xwiki-platform-dashboard-macro/pom.xml @@ -82,13 +82,8 @@ test - javax.servlet - javax.servlet-api - test - - - org.mortbay.jasper - apache-el + org.glassfish.expressly + expressly test diff --git a/xwiki-platform-core/xwiki-platform-diff/xwiki-platform-diff-xml/pom.xml b/xwiki-platform-core/xwiki-platform-diff/xwiki-platform-diff-xml/pom.xml index 3938519f320a..279cd0f43116 100644 --- a/xwiki-platform-core/xwiki-platform-diff/xwiki-platform-diff-xml/pom.xml +++ b/xwiki-platform-core/xwiki-platform-diff/xwiki-platform-diff-xml/pom.xml @@ -53,22 +53,12 @@ xwiki-platform-security-authentication-api ${project.version} - - javax.servlet - javax.servlet-api - - - org.xwiki.commons - xwiki-commons-tool-test-component - ${commons.version} - test - org.xwiki.platform - xwiki-platform-oldcore + xwiki-platform-test-oldcore ${project.version} + pom test - test-jar \ No newline at end of file diff --git a/xwiki-platform-core/xwiki-platform-eventstream/xwiki-platform-eventstream-stores/xwiki-platform-eventstream-store-solr/pom.xml b/xwiki-platform-core/xwiki-platform-eventstream/xwiki-platform-eventstream-stores/xwiki-platform-eventstream-store-solr/pom.xml index b0d3b3822cd9..2f0938dc2cc3 100644 --- a/xwiki-platform-core/xwiki-platform-eventstream/xwiki-platform-eventstream-stores/xwiki-platform-eventstream-store-solr/pom.xml +++ b/xwiki-platform-core/xwiki-platform-eventstream/xwiki-platform-eventstream-stores/xwiki-platform-eventstream-store-solr/pom.xml @@ -98,11 +98,6 @@ ${commons.version} test - - javax.servlet - javax.servlet-api - test - org.xwiki.platform xwiki-platform-search-solr-api diff --git a/xwiki-platform-core/xwiki-platform-export/xwiki-platform-export-pdf/xwiki-platform-export-pdf-api/pom.xml b/xwiki-platform-core/xwiki-platform-export/xwiki-platform-export-pdf/xwiki-platform-export-pdf-api/pom.xml index ad6cecd4a2de..004dc3d844ef 100644 --- a/xwiki-platform-core/xwiki-platform-export/xwiki-platform-export-pdf/xwiki-platform-export-pdf-api/pom.xml +++ b/xwiki-platform-core/xwiki-platform-export/xwiki-platform-export-pdf/xwiki-platform-export-pdf-api/pom.xml @@ -78,8 +78,8 @@ ${project.version} - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api diff --git a/xwiki-platform-core/xwiki-platform-export/xwiki-platform-export-pdf/xwiki-platform-export-pdf-api/src/main/java/org/xwiki/export/pdf/browser/BrowserTab.java b/xwiki-platform-core/xwiki-platform-export/xwiki-platform-export-pdf/xwiki-platform-export-pdf-api/src/main/java/org/xwiki/export/pdf/browser/BrowserTab.java index f482c1ea1949..d9db96694fbe 100644 --- a/xwiki-platform-core/xwiki-platform-export/xwiki-platform-export-pdf/xwiki-platform-export-pdf-api/src/main/java/org/xwiki/export/pdf/browser/BrowserTab.java +++ b/xwiki-platform-core/xwiki-platform-export/xwiki-platform-export-pdf/xwiki-platform-export-pdf-api/src/main/java/org/xwiki/export/pdf/browser/BrowserTab.java @@ -25,7 +25,10 @@ import java.util.List; import java.util.Map; -import javax.servlet.http.Cookie; +import jakarta.servlet.http.Cookie; + +import org.xwiki.jakartabridge.servlet.JakartaServletBridge; +import org.xwiki.stability.Unstable; /** * Represents a web browser tab. @@ -59,8 +62,42 @@ default void setExtraHTTPHeaders(Map> headers) * @return {@code true} if the navigation was successful, {@code false} otherwise * @throws IOException if navigating to the specified web page fails * @since 14.9 + * @deprecated use {@link #navigate(URL, Cookie[], boolean, int)} instead + */ + @Deprecated(since = "42.0.0") + boolean navigate(URL url, javax.servlet.http.Cookie[] cookies, boolean wait, int timeout) throws IOException; + + /** + * Navigates to the specified web page, optionally waiting for it to be ready (fully loaded). + * + * @param url the URL of the web page we are going to navigate to + * @param cookies the cookies to use when loading the specified web page + * @param wait {@code true} to wait for the page to be ready, {@code false} otherwise + * @param timeout the number of seconds to wait for the web page to be ready before timing out + * @return {@code true} if the navigation was successful, {@code false} otherwise + * @throws IOException if navigating to the specified web page fails + * @since 42.0.0 */ - boolean navigate(URL url, Cookie[] cookies, boolean wait, int timeout) throws IOException; + @Unstable + default boolean navigate(URL url, Cookie[] cookies, boolean wait, int timeout) throws IOException + { + return navigate(url, JakartaServletBridge.toJavax(cookies), wait, timeout); + } + + /** + * Navigates to the specified web page, optionally waiting for it to be ready (fully loaded). + * + * @param url the URL of the web page we are going to navigate to + * @param cookies the cookies to use when loading the specified web page + * @param wait {@code true} to wait for the page to be ready, {@code false} otherwise + * @return {@code true} if the navigation was successful, {@code false} otherwise + * @throws IOException if navigating to the specified web page fails + */ + @Deprecated(since = "42.0.0") + default boolean navigate(URL url, javax.servlet.http.Cookie[] cookies, boolean wait) throws IOException + { + return navigate(url, cookies, wait, 60); + } /** * Navigates to the specified web page, optionally waiting for it to be ready (fully loaded). @@ -70,7 +107,9 @@ default void setExtraHTTPHeaders(Map> headers) * @param wait {@code true} to wait for the page to be ready, {@code false} otherwise * @return {@code true} if the navigation was successful, {@code false} otherwise * @throws IOException if navigating to the specified web page fails + * @since 42.0.0 */ + @Unstable default boolean navigate(URL url, Cookie[] cookies, boolean wait) throws IOException { return navigate(url, cookies, wait, 60); @@ -86,7 +125,7 @@ default boolean navigate(URL url, Cookie[] cookies, boolean wait) throws IOExcep */ default boolean navigate(URL url, boolean wait) throws IOException { - return navigate(url, null, wait); + return navigate(url, (Cookie[]) null, wait); } /** diff --git a/xwiki-platform-core/xwiki-platform-export/xwiki-platform-export-pdf/xwiki-platform-export-pdf-api/src/main/java/org/xwiki/export/pdf/macro/PDFTocMacroParameters.java b/xwiki-platform-core/xwiki-platform-export/xwiki-platform-export-pdf/xwiki-platform-export-pdf-api/src/main/java/org/xwiki/export/pdf/macro/PDFTocMacroParameters.java index 574b09d4e120..66d1c94f4e7e 100644 --- a/xwiki-platform-core/xwiki-platform-export/xwiki-platform-export-pdf/xwiki-platform-export-pdf-api/src/main/java/org/xwiki/export/pdf/macro/PDFTocMacroParameters.java +++ b/xwiki-platform-core/xwiki-platform-export/xwiki-platform-export-pdf/xwiki-platform-export-pdf-api/src/main/java/org/xwiki/export/pdf/macro/PDFTocMacroParameters.java @@ -19,7 +19,7 @@ */ package org.xwiki.export.pdf.macro; -import javax.validation.constraints.Min; +import jakarta.validation.constraints.Min; import org.xwiki.export.pdf.internal.macro.PDFTocMacro; import org.xwiki.properties.annotation.PropertyDescription; diff --git a/xwiki-platform-core/xwiki-platform-export/xwiki-platform-export-pdf/xwiki-platform-export-pdf-api/src/test/java/org/xwiki/export/pdf/browser/BrowserPDFPrinterTest.java b/xwiki-platform-core/xwiki-platform-export/xwiki-platform-export-pdf/xwiki-platform-export-pdf-api/src/test/java/org/xwiki/export/pdf/browser/BrowserPDFPrinterTest.java index 9023af677b09..9a74b424598c 100644 --- a/xwiki-platform-core/xwiki-platform-export/xwiki-platform-export-pdf/xwiki-platform-export-pdf-api/src/test/java/org/xwiki/export/pdf/browser/BrowserPDFPrinterTest.java +++ b/xwiki-platform-core/xwiki-platform-export/xwiki-platform-export-pdf/xwiki-platform-export-pdf-api/src/test/java/org/xwiki/export/pdf/browser/BrowserPDFPrinterTest.java @@ -234,7 +234,7 @@ void printWithReverseProxy() throws Exception when(this.request.getHeader("X-Forwarded-Proto")).thenReturn("ftp"); when(this.browserManager.createIncognitoTab()).thenReturn(this.browserTab); - when(this.browserTab.navigate(browserPrintPreviewURL, null, true, 30)).thenReturn(true); + when(this.browserTab.navigate(browserPrintPreviewURL, (Cookie[]) null, true, 30)).thenReturn(true); this.printer.print(printPreviewURL); @@ -261,7 +261,7 @@ void isAvailable() void navigate() throws Exception { URL url = new URL("http://xwiki.org"); - when(this.browserTab.navigate(url, null, false, 60)).thenReturn(true); + when(this.browserTab.navigate(url, (jakarta.servlet.http.Cookie[]) null, false, 60)).thenReturn(true); assertTrue(this.browserTab.navigate(url)); } } diff --git a/xwiki-platform-core/xwiki-platform-export/xwiki-platform-export-pdf/xwiki-platform-export-pdf-default/pom.xml b/xwiki-platform-core/xwiki-platform-export/xwiki-platform-export-pdf/xwiki-platform-export-pdf-default/pom.xml index 8e0f557e7e4f..c1dfe3417cef 100644 --- a/xwiki-platform-core/xwiki-platform-export/xwiki-platform-export-pdf/xwiki-platform-export-pdf-default/pom.xml +++ b/xwiki-platform-core/xwiki-platform-export/xwiki-platform-export-pdf/xwiki-platform-export-pdf-default/pom.xml @@ -71,8 +71,8 @@ ${project.version} - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api diff --git a/xwiki-platform-core/xwiki-platform-export/xwiki-platform-export-pdf/xwiki-platform-export-pdf-default/src/main/java/org/xwiki/export/pdf/internal/chrome/ChromeTab.java b/xwiki-platform-core/xwiki-platform-export/xwiki-platform-export-pdf/xwiki-platform-export-pdf-default/src/main/java/org/xwiki/export/pdf/internal/chrome/ChromeTab.java index 02fe18da12d4..9b8ba24a4ebe 100644 --- a/xwiki-platform-core/xwiki-platform-export/xwiki-platform-export-pdf/xwiki-platform-export-pdf-default/src/main/java/org/xwiki/export/pdf/internal/chrome/ChromeTab.java +++ b/xwiki-platform-core/xwiki-platform-export/xwiki-platform-export-pdf/xwiki-platform-export-pdf-default/src/main/java/org/xwiki/export/pdf/internal/chrome/ChromeTab.java @@ -30,7 +30,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import javax.servlet.http.Cookie; +import jakarta.servlet.http.Cookie; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; @@ -38,6 +38,7 @@ import org.slf4j.LoggerFactory; import org.xwiki.export.pdf.PDFExportConfiguration; import org.xwiki.export.pdf.browser.BrowserTab; +import org.xwiki.jakartabridge.servlet.JakartaServletBridge; import com.github.kklisura.cdt.protocol.commands.Network; import com.github.kklisura.cdt.protocol.commands.Page; @@ -103,6 +104,12 @@ public void close() this.browserDevToolsService.getTarget().disposeBrowserContext(browserContextId); } + @Override + public boolean navigate(URL url, javax.servlet.http.Cookie[] cookies, boolean wait, int timeout) throws IOException + { + return navigate(url, JakartaServletBridge.toJakarta(cookies), wait, timeout); + } + @Override public boolean navigate(URL url, Cookie[] cookies, boolean wait, int timeout) throws IOException { diff --git a/xwiki-platform-core/xwiki-platform-export/xwiki-platform-export-pdf/xwiki-platform-export-pdf-default/src/test/java/org/xwiki/export/pdf/internal/chrome/ChromeTabTest.java b/xwiki-platform-core/xwiki-platform-export/xwiki-platform-export-pdf/xwiki-platform-export-pdf-default/src/test/java/org/xwiki/export/pdf/internal/chrome/ChromeTabTest.java index 17753f049b71..e80e81aeaefd 100644 --- a/xwiki-platform-core/xwiki-platform-export/xwiki-platform-export-pdf/xwiki-platform-export-pdf-default/src/test/java/org/xwiki/export/pdf/internal/chrome/ChromeTabTest.java +++ b/xwiki-platform-core/xwiki-platform-export/xwiki-platform-export-pdf/xwiki-platform-export-pdf-default/src/test/java/org/xwiki/export/pdf/internal/chrome/ChromeTabTest.java @@ -25,7 +25,7 @@ import java.nio.charset.StandardCharsets; import java.util.List; -import javax.servlet.http.Cookie; +import jakarta.servlet.http.Cookie; import org.apache.commons.io.IOUtils; import org.junit.jupiter.api.BeforeEach; @@ -168,7 +168,7 @@ void navigateWithError() throws Exception when(this.page.navigate(url.toString())).thenReturn(navigate); when(navigate.getErrorText()).thenReturn("Failed to navigate!"); - assertFalse(this.chromeTab.navigate(url, null, false)); + assertFalse(this.chromeTab.navigate(url, (Cookie[]) null, false)); } @Test @@ -192,7 +192,7 @@ void navigateWithWait() throws Exception when(evaluate.getResult()).thenReturn(result); when(result.getValue()).thenReturn("Page ready."); - assertTrue(this.chromeTab.navigate(url, null, true, 25)); + assertTrue(this.chromeTab.navigate(url, (Cookie[]) null, true, 25)); verify(this.runtime).enable(); } @@ -222,7 +222,7 @@ void navigateWithWaitAndException() throws Exception when(exception.getValue()).thenReturn("'xwiki-page-ready' module not found"); try { - this.chromeTab.navigate(url, null, true); + this.chromeTab.navigate(url, (Cookie[]) null, true); fail("Navigation should have thrown an exception."); } catch (IOException e) { assertEquals("Failed to wait for page to be ready. Root cause: 'xwiki-page-ready' module not found", diff --git a/xwiki-platform-core/xwiki-platform-extension/xwiki-platform-extension-distribution/pom.xml b/xwiki-platform-core/xwiki-platform-extension/xwiki-platform-extension-distribution/pom.xml index 1cadb2b52861..85ec11a4b32a 100644 --- a/xwiki-platform-core/xwiki-platform-extension/xwiki-platform-extension-distribution/pom.xml +++ b/xwiki-platform-core/xwiki-platform-extension/xwiki-platform-extension-distribution/pom.xml @@ -66,8 +66,8 @@ ${project.version} - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api diff --git a/xwiki-platform-core/xwiki-platform-extension/xwiki-platform-extension-handlers/xwiki-platform-extension-handler-xar/pom.xml b/xwiki-platform-core/xwiki-platform-extension/xwiki-platform-extension-handlers/xwiki-platform-extension-handler-xar/pom.xml index 748686576a06..9bff0a2d8c11 100644 --- a/xwiki-platform-core/xwiki-platform-extension/xwiki-platform-extension-handlers/xwiki-platform-extension-handler-xar/pom.xml +++ b/xwiki-platform-core/xwiki-platform-extension/xwiki-platform-extension-handlers/xwiki-platform-extension-handler-xar/pom.xml @@ -132,11 +132,6 @@ ${commons.version} test - - javax.servlet - javax.servlet-api - test - org.xwiki.platform xwiki-platform-security-authorization-bridge diff --git a/xwiki-platform-core/xwiki-platform-extension/xwiki-platform-extension-index/pom.xml b/xwiki-platform-core/xwiki-platform-extension/xwiki-platform-extension-index/pom.xml index 9709a1e941ba..9736b19c64ce 100644 --- a/xwiki-platform-core/xwiki-platform-extension/xwiki-platform-extension-index/pom.xml +++ b/xwiki-platform-core/xwiki-platform-extension/xwiki-platform-extension-index/pom.xml @@ -65,17 +65,6 @@ - - org.xwiki.commons - xwiki-commons-tool-test-component - ${commons.version} - test - - - javax.servlet - javax.servlet-api - test - org.xwiki.platform xwiki-platform-search-solr-api diff --git a/xwiki-platform-core/xwiki-platform-extension/xwiki-platform-extension-script/pom.xml b/xwiki-platform-core/xwiki-platform-extension/xwiki-platform-extension-script/pom.xml index 4d941f9ee8c7..57f7579fd61d 100644 --- a/xwiki-platform-core/xwiki-platform-extension/xwiki-platform-extension-script/pom.xml +++ b/xwiki-platform-core/xwiki-platform-extension/xwiki-platform-extension-script/pom.xml @@ -78,11 +78,6 @@ pom test - - javax.servlet - javax.servlet-api - test - diff --git a/xwiki-platform-core/xwiki-platform-extension/xwiki-platform-extension-security/xwiki-platform-extension-security-api/pom.xml b/xwiki-platform-core/xwiki-platform-extension/xwiki-platform-extension-security/xwiki-platform-extension-security-api/pom.xml index a6d90af7d3b2..b77fe60164ea 100644 --- a/xwiki-platform-core/xwiki-platform-extension/xwiki-platform-extension-security/xwiki-platform-extension-security-api/pom.xml +++ b/xwiki-platform-core/xwiki-platform-extension/xwiki-platform-extension-security/xwiki-platform-extension-security-api/pom.xml @@ -62,8 +62,8 @@ - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test diff --git a/xwiki-platform-core/xwiki-platform-feed/xwiki-platform-feed-api/pom.xml b/xwiki-platform-core/xwiki-platform-feed/xwiki-platform-feed-api/pom.xml index 5e7813f34808..28609c762f76 100644 --- a/xwiki-platform-core/xwiki-platform-feed/xwiki-platform-feed-api/pom.xml +++ b/xwiki-platform-core/xwiki-platform-feed/xwiki-platform-feed-api/pom.xml @@ -59,6 +59,7 @@ javax.servlet javax.servlet-api + org.xwiki.platform diff --git a/xwiki-platform-core/xwiki-platform-flamingo/xwiki-platform-flamingo-skin/xwiki-platform-flamingo-skin-test/xwiki-platform-flamingo-skin-test-docker/src/main/java/org/xwiki/test/TestMacroParameters.java b/xwiki-platform-core/xwiki-platform-flamingo/xwiki-platform-flamingo-skin/xwiki-platform-flamingo-skin-test/xwiki-platform-flamingo-skin-test-docker/src/main/java/org/xwiki/test/TestMacroParameters.java index 33fdd755f6c7..c20be5a78d81 100644 --- a/xwiki-platform-core/xwiki-platform-flamingo/xwiki-platform-flamingo-skin/xwiki-platform-flamingo-skin-test/xwiki-platform-flamingo-skin-test-docker/src/main/java/org/xwiki/test/TestMacroParameters.java +++ b/xwiki-platform-core/xwiki-platform-flamingo/xwiki-platform-flamingo-skin/xwiki-platform-flamingo-skin-test/xwiki-platform-flamingo-skin-test-docker/src/main/java/org/xwiki/test/TestMacroParameters.java @@ -19,7 +19,7 @@ */ package org.xwiki.test; -import javax.validation.constraints.AssertTrue; +import jakarta.validation.constraints.AssertTrue; /** * Java bean defining the parameters of {@link TestMacro}. diff --git a/xwiki-platform-core/xwiki-platform-icon/xwiki-platform-icon-default/pom.xml b/xwiki-platform-core/xwiki-platform-icon/xwiki-platform-icon-default/pom.xml index a40b8c4be5dc..939db0026e51 100644 --- a/xwiki-platform-core/xwiki-platform-icon/xwiki-platform-icon-default/pom.xml +++ b/xwiki-platform-core/xwiki-platform-icon/xwiki-platform-icon-default/pom.xml @@ -72,8 +72,8 @@ - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test diff --git a/xwiki-platform-core/xwiki-platform-icon/xwiki-platform-icon-macro/pom.xml b/xwiki-platform-core/xwiki-platform-icon/xwiki-platform-icon-macro/pom.xml index 4bd60aa27e99..ed1617cd8a31 100644 --- a/xwiki-platform-core/xwiki-platform-icon/xwiki-platform-icon-macro/pom.xml +++ b/xwiki-platform-core/xwiki-platform-icon/xwiki-platform-icon-macro/pom.xml @@ -62,6 +62,8 @@ xwiki-platform-rendering-async-macro ${project.version} + + org.xwiki.rendering xwiki-rendering-test @@ -87,13 +89,13 @@ test - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test - org.mortbay.jasper - apache-el + org.glassfish.expressly + expressly test @@ -105,10 +107,10 @@ org.xwiki.platform - xwiki-platform-oldcore + xwiki-platform-test-oldcore ${project.version} + pom test - test-jar org.xwiki.rendering diff --git a/xwiki-platform-core/xwiki-platform-image/xwiki-platform-image-processing/xwiki-platform-image-processing-plugin/pom.xml b/xwiki-platform-core/xwiki-platform-image/xwiki-platform-image-processing/xwiki-platform-image-processing-plugin/pom.xml index 10597f86301b..4f00a4438ffe 100644 --- a/xwiki-platform-core/xwiki-platform-image/xwiki-platform-image-processing/xwiki-platform-image-processing-plugin/pom.xml +++ b/xwiki-platform-core/xwiki-platform-image/xwiki-platform-image-processing/xwiki-platform-image-processing-plugin/pom.xml @@ -50,23 +50,13 @@ xwiki-platform-oldcore ${project.version} - - javax.servlet - javax.servlet-api - compile - + org.xwiki.platform - xwiki-platform-oldcore + xwiki-platform-test-oldcore ${project.version} - test-jar - test - - - org.xwiki.commons - xwiki-commons-tool-test-component - ${commons.version} + pom test diff --git a/xwiki-platform-core/xwiki-platform-image/xwiki-platform-image-style/xwiki-platform-image-style-api/pom.xml b/xwiki-platform-core/xwiki-platform-image/xwiki-platform-image-style/xwiki-platform-image-style-api/pom.xml index 1555d0d96c91..aa693c546b8e 100644 --- a/xwiki-platform-core/xwiki-platform-image/xwiki-platform-image-style/xwiki-platform-image-style-api/pom.xml +++ b/xwiki-platform-core/xwiki-platform-image/xwiki-platform-image-style/xwiki-platform-image-style-api/pom.xml @@ -56,8 +56,8 @@ test - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test diff --git a/xwiki-platform-core/xwiki-platform-image/xwiki-platform-image-style/xwiki-platform-image-style-rest/pom.xml b/xwiki-platform-core/xwiki-platform-image/xwiki-platform-image-style/xwiki-platform-image-style-rest/pom.xml index 92fb13e23a0e..4a1f3e785fea 100644 --- a/xwiki-platform-core/xwiki-platform-image/xwiki-platform-image-style/xwiki-platform-image-style-rest/pom.xml +++ b/xwiki-platform-core/xwiki-platform-image/xwiki-platform-image-style/xwiki-platform-image-style-rest/pom.xml @@ -75,8 +75,8 @@ test - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test diff --git a/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-default/pom.xml b/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-default/pom.xml index 9553f50db3e0..aa001335f4d4 100644 --- a/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-default/pom.xml +++ b/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-default/pom.xml @@ -60,8 +60,8 @@ test - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test diff --git a/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-tree/xwiki-platform-index-tree-api/pom.xml b/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-tree/xwiki-platform-index-tree-api/pom.xml index 36718b027250..fb45766c054e 100644 --- a/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-tree/xwiki-platform-index-tree-api/pom.xml +++ b/xwiki-platform-core/xwiki-platform-index/xwiki-platform-index-tree/xwiki-platform-index-tree-api/pom.xml @@ -88,8 +88,8 @@ test - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test diff --git a/xwiki-platform-core/xwiki-platform-job/xwiki-platform-job-handler/pom.xml b/xwiki-platform-core/xwiki-platform-job/xwiki-platform-job-handler/pom.xml index 4b02812b0944..68be0225eee7 100644 --- a/xwiki-platform-core/xwiki-platform-job/xwiki-platform-job-handler/pom.xml +++ b/xwiki-platform-core/xwiki-platform-job/xwiki-platform-job-handler/pom.xml @@ -76,8 +76,8 @@ ${project.version} - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api diff --git a/xwiki-platform-core/xwiki-platform-legacy/xwiki-platform-legacy-events-hibernate/xwiki-platform-legacy-events-hibernate-api/pom.xml b/xwiki-platform-core/xwiki-platform-legacy/xwiki-platform-legacy-events-hibernate/xwiki-platform-legacy-events-hibernate-api/pom.xml index 43253f7cdc53..960062d089b4 100644 --- a/xwiki-platform-core/xwiki-platform-legacy/xwiki-platform-legacy-events-hibernate/xwiki-platform-legacy-events-hibernate-api/pom.xml +++ b/xwiki-platform-core/xwiki-platform-legacy/xwiki-platform-legacy-events-hibernate/xwiki-platform-legacy-events-hibernate-api/pom.xml @@ -68,8 +68,8 @@ test - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test diff --git a/xwiki-platform-core/xwiki-platform-legacy/xwiki-platform-legacy-mail/xwiki-platform-legacy-mail-send/xwiki-platform-legacy-mail-send-storage/pom.xml b/xwiki-platform-core/xwiki-platform-legacy/xwiki-platform-legacy-mail/xwiki-platform-legacy-mail-send/xwiki-platform-legacy-mail-send-storage/pom.xml index 8c4ce3e5101d..85c522681342 100644 --- a/xwiki-platform-core/xwiki-platform-legacy/xwiki-platform-legacy-mail/xwiki-platform-legacy-mail-send/xwiki-platform-legacy-mail-send-storage/pom.xml +++ b/xwiki-platform-core/xwiki-platform-legacy/xwiki-platform-legacy-mail/xwiki-platform-legacy-mail-send/xwiki-platform-legacy-mail-send-storage/pom.xml @@ -62,8 +62,8 @@ test - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test diff --git a/xwiki-platform-core/xwiki-platform-legacy/xwiki-platform-legacy-messagestream/xwiki-platform-legacy-messagestream-api/pom.xml b/xwiki-platform-core/xwiki-platform-legacy/xwiki-platform-legacy-messagestream/xwiki-platform-legacy-messagestream-api/pom.xml index 6d3d9e7e6b89..dafc2db879e0 100644 --- a/xwiki-platform-core/xwiki-platform-legacy/xwiki-platform-legacy-messagestream/xwiki-platform-legacy-messagestream-api/pom.xml +++ b/xwiki-platform-core/xwiki-platform-legacy/xwiki-platform-legacy-messagestream/xwiki-platform-legacy-messagestream-api/pom.xml @@ -84,8 +84,8 @@ test - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test diff --git a/xwiki-platform-core/xwiki-platform-legacy/xwiki-platform-legacy-rendering/xwiki-platform-legacy-rendering-wikimacro/xwiki-platform-legacy-rendering-wikimacro-store/pom.xml b/xwiki-platform-core/xwiki-platform-legacy/xwiki-platform-legacy-rendering/xwiki-platform-legacy-rendering-wikimacro/xwiki-platform-legacy-rendering-wikimacro-store/pom.xml index 908b11ca7da8..b703b95c29bc 100644 --- a/xwiki-platform-core/xwiki-platform-legacy/xwiki-platform-legacy-rendering/xwiki-platform-legacy-rendering-wikimacro/xwiki-platform-legacy-rendering-wikimacro-store/pom.xml +++ b/xwiki-platform-core/xwiki-platform-legacy/xwiki-platform-legacy-rendering/xwiki-platform-legacy-rendering-wikimacro/xwiki-platform-legacy-rendering-wikimacro-store/pom.xml @@ -61,6 +61,7 @@ org.aspectj aspectjrt + org.xwiki.platform diff --git a/xwiki-platform-core/xwiki-platform-legacy/xwiki-platform-legacy-security/xwiki-platform-legacy-security-authentication/xwiki-platform-legacy-security-authentication-api/pom.xml b/xwiki-platform-core/xwiki-platform-legacy/xwiki-platform-legacy-security/xwiki-platform-legacy-security-authentication/xwiki-platform-legacy-security-authentication-api/pom.xml index 3b931a0d05f7..7076bb4ff8d2 100644 --- a/xwiki-platform-core/xwiki-platform-legacy/xwiki-platform-legacy-security/xwiki-platform-legacy-security-authentication/xwiki-platform-legacy-security-authentication-api/pom.xml +++ b/xwiki-platform-core/xwiki-platform-legacy/xwiki-platform-legacy-security/xwiki-platform-legacy-security-authentication/xwiki-platform-legacy-security-authentication-api/pom.xml @@ -60,8 +60,8 @@ aspectjrt - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api diff --git a/xwiki-platform-core/xwiki-platform-legacy/xwiki-platform-legacy-url/pom.xml b/xwiki-platform-core/xwiki-platform-legacy/xwiki-platform-legacy-url/pom.xml index bcc142bb6888..a8bd77a5af8b 100644 --- a/xwiki-platform-core/xwiki-platform-legacy/xwiki-platform-legacy-url/pom.xml +++ b/xwiki-platform-core/xwiki-platform-legacy/xwiki-platform-legacy-url/pom.xml @@ -48,8 +48,8 @@ - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api diff --git a/xwiki-platform-core/xwiki-platform-lesscss/xwiki-platform-lesscss-default/pom.xml b/xwiki-platform-core/xwiki-platform-lesscss/xwiki-platform-lesscss-default/pom.xml index 53d063a08b0f..6d2a478fad4b 100644 --- a/xwiki-platform-core/xwiki-platform-lesscss/xwiki-platform-lesscss-default/pom.xml +++ b/xwiki-platform-core/xwiki-platform-lesscss/xwiki-platform-lesscss-default/pom.xml @@ -63,8 +63,8 @@ ${project.version} - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api com.github.sommeri diff --git a/xwiki-platform-core/xwiki-platform-lesscss/xwiki-platform-lesscss-script/pom.xml b/xwiki-platform-core/xwiki-platform-lesscss/xwiki-platform-lesscss-script/pom.xml index 39ac153f828a..101af878d8c1 100644 --- a/xwiki-platform-core/xwiki-platform-lesscss/xwiki-platform-lesscss-script/pom.xml +++ b/xwiki-platform-core/xwiki-platform-lesscss/xwiki-platform-lesscss-script/pom.xml @@ -68,8 +68,8 @@ - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test diff --git a/xwiki-platform-core/xwiki-platform-like/xwiki-platform-like-api/pom.xml b/xwiki-platform-core/xwiki-platform-like/xwiki-platform-like-api/pom.xml index 19fdf3e55b68..11bc929c0f20 100644 --- a/xwiki-platform-core/xwiki-platform-like/xwiki-platform-like-api/pom.xml +++ b/xwiki-platform-core/xwiki-platform-like/xwiki-platform-like-api/pom.xml @@ -91,8 +91,8 @@ - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test diff --git a/xwiki-platform-core/xwiki-platform-linkchecker/xwiki-platform-linkchecker-api/pom.xml b/xwiki-platform-core/xwiki-platform-linkchecker/xwiki-platform-linkchecker-api/pom.xml index 4821460761ce..ea3e3ed46dca 100644 --- a/xwiki-platform-core/xwiki-platform-linkchecker/xwiki-platform-linkchecker-api/pom.xml +++ b/xwiki-platform-core/xwiki-platform-linkchecker/xwiki-platform-linkchecker-api/pom.xml @@ -61,8 +61,8 @@ - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test diff --git a/xwiki-platform-core/xwiki-platform-livedata/xwiki-platform-livedata-livetable/pom.xml b/xwiki-platform-core/xwiki-platform-livedata/xwiki-platform-livedata-livetable/pom.xml index de4339096a91..44eab8bce19f 100644 --- a/xwiki-platform-core/xwiki-platform-livedata/xwiki-platform-livedata-livetable/pom.xml +++ b/xwiki-platform-core/xwiki-platform-livedata/xwiki-platform-livedata-livetable/pom.xml @@ -53,8 +53,8 @@ ${project.version} - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api diff --git a/xwiki-platform-core/xwiki-platform-livedata/xwiki-platform-livedata-rest/pom.xml b/xwiki-platform-core/xwiki-platform-livedata/xwiki-platform-livedata-rest/pom.xml index 2948700afcef..10273061b2f9 100644 --- a/xwiki-platform-core/xwiki-platform-livedata/xwiki-platform-livedata-rest/pom.xml +++ b/xwiki-platform-core/xwiki-platform-livedata/xwiki-platform-livedata-rest/pom.xml @@ -81,8 +81,8 @@ test - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test diff --git a/xwiki-platform-core/xwiki-platform-livetable/xwiki-platform-livetable-ui/pom.xml b/xwiki-platform-core/xwiki-platform-livetable/xwiki-platform-livetable-ui/pom.xml index 9f96f184b198..273418fcb57e 100644 --- a/xwiki-platform-core/xwiki-platform-livetable/xwiki-platform-livetable-ui/pom.xml +++ b/xwiki-platform-core/xwiki-platform-livetable/xwiki-platform-livetable-ui/pom.xml @@ -75,11 +75,6 @@ runtime - - javax.servlet - javax.servlet-api - test - org.xwiki.platform xwiki-platform-test-page diff --git a/xwiki-platform-core/xwiki-platform-localization/xwiki-platform-localization-sources/xwiki-platform-localization-source-legacy/pom.xml b/xwiki-platform-core/xwiki-platform-localization/xwiki-platform-localization-sources/xwiki-platform-localization-source-legacy/pom.xml index 51e77e1396c1..8802511ae761 100644 --- a/xwiki-platform-core/xwiki-platform-localization/xwiki-platform-localization-sources/xwiki-platform-localization-source-legacy/pom.xml +++ b/xwiki-platform-core/xwiki-platform-localization/xwiki-platform-localization-sources/xwiki-platform-localization-source-legacy/pom.xml @@ -64,7 +64,6 @@ - org.xwiki.platform xwiki-platform-test-oldcore @@ -72,13 +71,6 @@ pom test - - - - org.jmock - jmock-legacy - test - diff --git a/xwiki-platform-core/xwiki-platform-localization/xwiki-platform-localization-sources/xwiki-platform-localization-source-wiki/pom.xml b/xwiki-platform-core/xwiki-platform-localization/xwiki-platform-localization-sources/xwiki-platform-localization-source-wiki/pom.xml index 6d883f2bbc7e..0abe9c50c71f 100644 --- a/xwiki-platform-core/xwiki-platform-localization/xwiki-platform-localization-sources/xwiki-platform-localization-source-wiki/pom.xml +++ b/xwiki-platform-core/xwiki-platform-localization/xwiki-platform-localization-sources/xwiki-platform-localization-source-wiki/pom.xml @@ -68,7 +68,6 @@ - org.xwiki.platform xwiki-platform-test-oldcore @@ -76,13 +75,6 @@ pom test - - - - org.jmock - jmock-legacy - test - diff --git a/xwiki-platform-core/xwiki-platform-mail/xwiki-platform-mail-general/pom.xml b/xwiki-platform-core/xwiki-platform-mail/xwiki-platform-mail-general/pom.xml index 322d56680378..d1ea1ffe056b 100644 --- a/xwiki-platform-core/xwiki-platform-mail/xwiki-platform-mail-general/pom.xml +++ b/xwiki-platform-core/xwiki-platform-mail/xwiki-platform-mail-general/pom.xml @@ -67,13 +67,6 @@ ${commons.version} test - - - javax.servlet - javax.servlet-api - test - - org.xwiki.platform xwiki-platform-oldcore diff --git a/xwiki-platform-core/xwiki-platform-mail/xwiki-platform-mail-send/xwiki-platform-mail-send-default/pom.xml b/xwiki-platform-core/xwiki-platform-mail/xwiki-platform-mail-send/xwiki-platform-mail-send-default/pom.xml index 7ddcd80e66c3..a6999c6bee3c 100644 --- a/xwiki-platform-core/xwiki-platform-mail/xwiki-platform-mail-send/xwiki-platform-mail-send-default/pom.xml +++ b/xwiki-platform-core/xwiki-platform-mail/xwiki-platform-mail-send/xwiki-platform-mail-send-default/pom.xml @@ -73,8 +73,8 @@ - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api org.xwiki.platform @@ -99,9 +99,9 @@ org.xwiki.platform - xwiki-platform-oldcore + xwiki-platform-test-oldcore ${project.version} - test-jar + pom test @@ -109,12 +109,6 @@ greenmail-junit5 test - - org.xwiki.commons - xwiki-commons-tool-test-component - ${commons.version} - test - org.xwiki.platform xwiki-platform-security-authorization-bridge diff --git a/xwiki-platform-core/xwiki-platform-mail/xwiki-platform-mail-send/xwiki-platform-mail-send-storage/pom.xml b/xwiki-platform-core/xwiki-platform-mail/xwiki-platform-mail-send/xwiki-platform-mail-send-storage/pom.xml index 656fe3c4556e..2a4f4bbc788d 100644 --- a/xwiki-platform-core/xwiki-platform-mail/xwiki-platform-mail-send/xwiki-platform-mail-send-storage/pom.xml +++ b/xwiki-platform-core/xwiki-platform-mail/xwiki-platform-mail-send/xwiki-platform-mail-send-storage/pom.xml @@ -70,8 +70,8 @@ test - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test diff --git a/xwiki-platform-core/xwiki-platform-mailsender/pom.xml b/xwiki-platform-core/xwiki-platform-mailsender/pom.xml index 6cb058fcb1d8..e5fc5dd976f1 100644 --- a/xwiki-platform-core/xwiki-platform-mailsender/pom.xml +++ b/xwiki-platform-core/xwiki-platform-mailsender/pom.xml @@ -44,6 +44,8 @@ xwiki-platform-oldcore ${project.version} + + com.icegreen greenmail-junit5 diff --git a/xwiki-platform-core/xwiki-platform-mentions/pom.xml b/xwiki-platform-core/xwiki-platform-mentions/pom.xml index 2d3d7bb1082f..0ec71bdbcd91 100644 --- a/xwiki-platform-core/xwiki-platform-mentions/pom.xml +++ b/xwiki-platform-core/xwiki-platform-mentions/pom.xml @@ -39,8 +39,8 @@ test - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test diff --git a/xwiki-platform-core/xwiki-platform-model/xwiki-platform-model-validation/xwiki-platform-model-validation-default/pom.xml b/xwiki-platform-core/xwiki-platform-model/xwiki-platform-model-validation/xwiki-platform-model-validation-default/pom.xml index e106767fef56..6e21fbb7a7c7 100644 --- a/xwiki-platform-core/xwiki-platform-model/xwiki-platform-model-validation/xwiki-platform-model-validation-default/pom.xml +++ b/xwiki-platform-core/xwiki-platform-model/xwiki-platform-model-validation/xwiki-platform-model-validation-default/pom.xml @@ -48,8 +48,8 @@ ${project.version} - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api diff --git a/xwiki-platform-core/xwiki-platform-netflux/xwiki-platform-netflux-api/pom.xml b/xwiki-platform-core/xwiki-platform-netflux/xwiki-platform-netflux-api/pom.xml index c8f442c430fb..0cc0afa6f14a 100644 --- a/xwiki-platform-core/xwiki-platform-netflux/xwiki-platform-netflux-api/pom.xml +++ b/xwiki-platform-core/xwiki-platform-netflux/xwiki-platform-netflux-api/pom.xml @@ -68,9 +68,10 @@ ${project.version} - javax.websocket - javax.websocket-api + jakarta.websocket + jakarta.websocket-client-api + org.xwiki.commons @@ -78,5 +79,15 @@ ${commons.version} test + + jakarta.servlet + jakarta.servlet-api + test + + + jakarta.websocket + jakarta.websocket-api + test + diff --git a/xwiki-platform-core/xwiki-platform-netflux/xwiki-platform-netflux-api/src/test/java/org/xwiki/netflux/internal/DefaultEntityChannelStoreTest.java b/xwiki-platform-core/xwiki-platform-netflux/xwiki-platform-netflux-api/src/test/java/org/xwiki/netflux/internal/DefaultEntityChannelStoreTest.java index 35dce1a5d652..9665e4218844 100644 --- a/xwiki-platform-core/xwiki-platform-netflux/xwiki-platform-netflux-api/src/test/java/org/xwiki/netflux/internal/DefaultEntityChannelStoreTest.java +++ b/xwiki-platform-core/xwiki-platform-netflux/xwiki-platform-netflux-api/src/test/java/org/xwiki/netflux/internal/DefaultEntityChannelStoreTest.java @@ -19,14 +19,9 @@ */ package org.xwiki.netflux.internal; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertSame; -import static org.mockito.Mockito.when; - import java.util.List; -import javax.websocket.Session; +import jakarta.websocket.Session; import org.junit.jupiter.api.Test; import org.mockito.Mock; @@ -36,6 +31,11 @@ import org.xwiki.test.junit5.mockito.InjectMockComponents; import org.xwiki.test.junit5.mockito.MockComponent; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.mockito.Mockito.when; + /** * Unit tests for {@link DefaultEntityChannelStore}. * diff --git a/xwiki-platform-core/xwiki-platform-netflux/xwiki-platform-netflux-api/src/test/java/org/xwiki/netflux/internal/EntityChannelScriptAuthorBotTest.java b/xwiki-platform-core/xwiki-platform-netflux/xwiki-platform-netflux-api/src/test/java/org/xwiki/netflux/internal/EntityChannelScriptAuthorBotTest.java index 0a27fdb81c8a..3ee57ae55f84 100644 --- a/xwiki-platform-core/xwiki-platform-netflux/xwiki-platform-netflux-api/src/test/java/org/xwiki/netflux/internal/EntityChannelScriptAuthorBotTest.java +++ b/xwiki-platform-core/xwiki-platform-netflux/xwiki-platform-netflux-api/src/test/java/org/xwiki/netflux/internal/EntityChannelScriptAuthorBotTest.java @@ -19,19 +19,10 @@ */ package org.xwiki.netflux.internal; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - import java.util.List; import java.util.Optional; -import javax.websocket.Session; +import jakarta.websocket.Session; import org.junit.jupiter.api.Test; import org.xwiki.model.reference.DocumentReference; @@ -45,6 +36,15 @@ import org.xwiki.user.UserReferenceResolver; import org.xwiki.websocket.WebSocketContext; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + /** * Unit tests for {@link EntityChannelScriptAuthorBot}. * diff --git a/xwiki-platform-core/xwiki-platform-netflux/xwiki-platform-netflux-rest/pom.xml b/xwiki-platform-core/xwiki-platform-netflux/xwiki-platform-netflux-rest/pom.xml index b6c41eedbf86..fdea2a976743 100644 --- a/xwiki-platform-core/xwiki-platform-netflux/xwiki-platform-netflux-rest/pom.xml +++ b/xwiki-platform-core/xwiki-platform-netflux/xwiki-platform-netflux-rest/pom.xml @@ -59,6 +59,7 @@ jakarta.ws.rs jakarta.ws.rs-api + org.xwiki.commons @@ -72,8 +73,8 @@ test - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test diff --git a/xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-filters/xwiki-platform-notifications-filters-api/pom.xml b/xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-filters/xwiki-platform-notifications-filters-api/pom.xml index 68431f72b14c..82e135325813 100644 --- a/xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-filters/xwiki-platform-notifications-filters-api/pom.xml +++ b/xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-filters/xwiki-platform-notifications-filters-api/pom.xml @@ -72,8 +72,8 @@ test - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test diff --git a/xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-filters/xwiki-platform-notifications-filters-default/pom.xml b/xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-filters/xwiki-platform-notifications-filters-default/pom.xml index ad122dcc05e8..2aaacde4b90d 100644 --- a/xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-filters/xwiki-platform-notifications-filters-default/pom.xml +++ b/xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-filters/xwiki-platform-notifications-filters-default/pom.xml @@ -57,23 +57,12 @@ - - org.xwiki.commons - xwiki-commons-tool-test-component - ${commons.version} - test - - - javax.servlet - javax.servlet-api - test - org.xwiki.platform - xwiki-platform-oldcore + xwiki-platform-test-oldcore ${project.version} + pom test - test-jar \ No newline at end of file diff --git a/xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-filters/xwiki-platform-notifications-filters-watch/pom.xml b/xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-filters/xwiki-platform-notifications-filters-watch/pom.xml index 892f62f44908..c6ec8a8805ef 100644 --- a/xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-filters/xwiki-platform-notifications-filters-watch/pom.xml +++ b/xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-filters/xwiki-platform-notifications-filters-watch/pom.xml @@ -52,8 +52,8 @@ test - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test diff --git a/xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-notifiers/xwiki-platform-notifications-notifiers-api/pom.xml b/xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-notifiers/xwiki-platform-notifications-notifiers-api/pom.xml index b72f75f69edf..ab44a7983a39 100644 --- a/xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-notifiers/xwiki-platform-notifications-notifiers-api/pom.xml +++ b/xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-notifiers/xwiki-platform-notifications-notifiers-api/pom.xml @@ -81,11 +81,6 @@ ${rendering.version} test - - javax.servlet - javax.servlet-api - test - org.xwiki.platform xwiki-platform-test-oldcore diff --git a/xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-notifiers/xwiki-platform-notifications-notifiers-default/pom.xml b/xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-notifiers/xwiki-platform-notifications-notifiers-default/pom.xml index c3d4f6168753..841cd15ba270 100644 --- a/xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-notifiers/xwiki-platform-notifications-notifiers-default/pom.xml +++ b/xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-notifiers/xwiki-platform-notifications-notifiers-default/pom.xml @@ -75,8 +75,8 @@ test - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test diff --git a/xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-notifiers/xwiki-platform-notifications-notifiers-default/src/test/java/org/xwiki/notifications/notifiers/internal/email/DefaultNotificationEmailRendererTest.java b/xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-notifiers/xwiki-platform-notifications-notifiers-default/src/test/java/org/xwiki/notifications/notifiers/internal/email/DefaultNotificationEmailRendererTest.java index 39d23ffa19e3..a540ec7eb1db 100644 --- a/xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-notifiers/xwiki-platform-notifications-notifiers-default/src/test/java/org/xwiki/notifications/notifiers/internal/email/DefaultNotificationEmailRendererTest.java +++ b/xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-notifiers/xwiki-platform-notifications-notifiers-default/src/test/java/org/xwiki/notifications/notifiers/internal/email/DefaultNotificationEmailRendererTest.java @@ -159,7 +159,7 @@ void executeTemplate() throws Exception XWiki wiki = mock(XWiki.class); when(context.getWiki()).thenReturn(wiki); - XWikiServletRequestStub xWikiServletRequestStub = mock(XWikiServletRequestStub.class); + XWikiServletRequestStub xWikiServletRequestStub = new XWikiServletRequestStub(); when(context.getRequest()).thenReturn(xWikiServletRequestStub); ScriptContext scriptContext = mock(ScriptContext.class); diff --git a/xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-preferences/xwiki-platform-notifications-preferences-api/pom.xml b/xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-preferences/xwiki-platform-notifications-preferences-api/pom.xml index a314015face7..95fa7b222d7a 100644 --- a/xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-preferences/xwiki-platform-notifications-preferences-api/pom.xml +++ b/xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-preferences/xwiki-platform-notifications-preferences-api/pom.xml @@ -60,8 +60,8 @@ test - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test diff --git a/xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-preferences/xwiki-platform-notifications-preferences-default/pom.xml b/xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-preferences/xwiki-platform-notifications-preferences-default/pom.xml index 0eee7f93b569..c75fd91a708d 100644 --- a/xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-preferences/xwiki-platform-notifications-preferences-default/pom.xml +++ b/xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-preferences/xwiki-platform-notifications-preferences-default/pom.xml @@ -57,8 +57,8 @@ test - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test diff --git a/xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-rest/pom.xml b/xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-rest/pom.xml index beb7d661a211..ca5fac9fba13 100644 --- a/xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-rest/pom.xml +++ b/xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-rest/pom.xml @@ -76,9 +76,8 @@ rome - javax.servlet - javax.servlet-api - compile + jakarta.servlet + jakarta.servlet-api org.xwiki.commons diff --git a/xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-sources/pom.xml b/xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-sources/pom.xml index 4b1a0ef90558..c79d1e2c5053 100644 --- a/xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-sources/pom.xml +++ b/xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-sources/pom.xml @@ -75,8 +75,8 @@ test - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test diff --git a/xwiki-platform-core/xwiki-platform-observation/xwiki-platform-observation-test/xwiki-platform-observation-test-tests/pom.xml b/xwiki-platform-core/xwiki-platform-observation/xwiki-platform-observation-test/xwiki-platform-observation-test-tests/pom.xml index c47daa39f14a..97f22fcb5339 100644 --- a/xwiki-platform-core/xwiki-platform-observation/xwiki-platform-observation-test/xwiki-platform-observation-test-tests/pom.xml +++ b/xwiki-platform-core/xwiki-platform-observation/xwiki-platform-observation-test/xwiki-platform-observation-test-tests/pom.xml @@ -105,8 +105,8 @@ test - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test diff --git a/xwiki-platform-core/xwiki-platform-oldcore/pom.xml b/xwiki-platform-core/xwiki-platform-oldcore/pom.xml index 95213cec9ed6..b91d48c76fa2 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/pom.xml +++ b/xwiki-platform-core/xwiki-platform-oldcore/pom.xml @@ -130,6 +130,10 @@ javax.servlet javax.servlet-api + + jakarta.servlet + jakarta.servlet-api + + + javax.validation + validation-api + jakarta.xml.bind @@ -165,6 +174,10 @@ hibernate-validator runtime + + org.glassfish.expressly + expressly + org.liquibase liquibase-core @@ -646,12 +659,6 @@ test - - - org.mortbay.jasper - apache-el - test - org.xwiki.platform xwiki-platform-index-api diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/XWiki.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/XWiki.java index c286a59f07b4..728c845f3912 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/XWiki.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/XWiki.java @@ -1131,6 +1131,7 @@ private static EntityResourceReference initializeResourceFromURL(XWikiContext co return entityResourceReference; } + @Deprecated(since = "42.0.0") public static URL getRequestURL(XWikiRequest request) throws XWikiException { return HttpServletUtils.getSourceURL(request); @@ -3229,6 +3230,7 @@ public String getLanguagePreference(XWikiContext context) * @return A list of language codes, in the client preference order; might be empty if the header is not well * formed. */ + @Deprecated(since = "42.0.0") private List getAcceptedLanguages(XWikiRequest request) { List result = new ArrayList(); @@ -5727,6 +5729,7 @@ public int checkActive(String user, XWikiContext context) throws XWikiException /** * @since 2.3M1 */ + @Deprecated(since = "42.0.0") public DocumentReference getDocumentReference(XWikiRequest request, XWikiContext context) { DocumentReference reference; @@ -5793,6 +5796,7 @@ public static String stripSegmentFromPath(String path, String segment) return path.substring(segment.length()); } + @Deprecated(since = "42.0.0") public boolean prepareDocuments(XWikiRequest request, XWikiContext context, VelocityContext vcontext) throws XWikiException { diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/XWikiContext.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/XWikiContext.java index 16c9f3f97bf5..d971cae5289a 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/XWikiContext.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/XWikiContext.java @@ -35,6 +35,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.xwiki.component.util.DefaultParameterizedType; +import org.xwiki.container.Container; import org.xwiki.context.Execution; import org.xwiki.context.ExecutionContext; import org.xwiki.localization.LocaleUtils; @@ -270,11 +271,21 @@ public void setEngineContext(XWikiEngineContext engine_context) this.engine_context = engine_context; } + /** + * @return the request in the context + * @deprecated use the {@link Container} API instead + */ + @Deprecated(since = "42.0.0") public XWikiRequest getRequest() { return this.request; } + /** + * @param request the request to put in the context + * @deprecated use the {@link Container} API instead + */ + @Deprecated(since = "42.0.0") public void setRequest(XWikiRequest request) { this.request = request; @@ -290,11 +301,21 @@ public void setAction(String action) this.action = action; } + /** + * @return the response in the context + * @deprecated use the {@link Container} API instead + */ + @Deprecated(since = "42.0.0") public XWikiResponse getResponse() { return this.response; } + /** + * @param response the response to put in the context + * @deprecated use the {@link Container} API instead + */ + @Deprecated(since = "42.0.0") public void setResponse(XWikiResponse response) { this.response = response; diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/api/Context.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/api/Context.java index 674723936f93..fafbae89f2e4 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/api/Context.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/api/Context.java @@ -27,6 +27,7 @@ import com.xpn.xwiki.XWikiContext; import com.xpn.xwiki.doc.XWikiDocument; import com.xpn.xwiki.render.ScriptXWikiServletRequest; +import com.xpn.xwiki.render.ScriptXWikiServletResponse; import com.xpn.xwiki.util.Programming; import com.xpn.xwiki.validation.XWikiValidationStatus; import com.xpn.xwiki.web.XWikiRequest; @@ -64,7 +65,8 @@ public Context(XWikiContext context) */ public XWikiRequest getRequest() { - return new ScriptXWikiServletRequest(getXWikiContext().getRequest(), getContextualAuthorizationManager()); + XWikiRequest request = getXWikiContext().getRequest(); + return request != null ? new ScriptXWikiServletRequest(request, getContextualAuthorizationManager()) : request; } /** @@ -75,7 +77,8 @@ public XWikiRequest getRequest() */ public XWikiResponse getResponse() { - return getXWikiContext().getResponse(); + XWikiResponse response = getXWikiContext().getResponse(); + return response != null ? new ScriptXWikiServletResponse(response) : response; } /** diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/internal/DefaultXWikiContextInitializer.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/internal/DefaultXWikiContextInitializer.java index db9b82b11646..8bc856bfe79d 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/internal/DefaultXWikiContextInitializer.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/internal/DefaultXWikiContextInitializer.java @@ -19,10 +19,10 @@ */ package com.xpn.xwiki.internal; -import javax.inject.Inject; -import javax.inject.Named; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.inject.Inject; +import jakarta.inject.Named; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import org.slf4j.Logger; import org.xwiki.component.annotation.Component; @@ -33,6 +33,7 @@ import org.xwiki.container.servlet.ServletRequest; import org.xwiki.container.servlet.ServletResponse; import org.xwiki.context.ExecutionContext; +import org.xwiki.jakartabridge.servlet.JakartaServletBridge; import org.xwiki.model.reference.DocumentReference; import org.xwiki.model.reference.DocumentReferenceResolver; import org.xwiki.model.reference.SpaceReference; @@ -103,18 +104,11 @@ public XWikiContext initialize(ExecutionContext econtext) throws XWikiException XWikiContext xcontext; - if (!(request instanceof ServletRequest)) { - if (this.fallbackOnStub) { - xcontext = this.contextProvider.createStubContext(); - } else { - throw new XWikiException(XWikiException.MODULE_XWIKI_USER, XWikiException.ERROR_XWIKI_USER_INIT, - "Unsupported request type [" + request.getClass() + "]"); - } - } else { + if (request instanceof ServletRequest servletRequest) { try { - HttpServletRequest httpServletRequest = ((ServletRequest) request).getHttpServletRequest(); + HttpServletRequest httpServletRequest = servletRequest.getRequest(); HttpServletResponse httpServletReponse = - ((ServletResponse) this.container.getResponse()).getHttpServletResponse(); + ((ServletResponse) this.container.getResponse()).getResponse(); xcontext = initializeXWikiContext(httpServletRequest, httpServletReponse); @@ -134,6 +128,13 @@ public XWikiContext initialize(ExecutionContext econtext) throws XWikiException "Failed to initialize XWikiContext", e); } } + } else { + if (this.fallbackOnStub) { + xcontext = this.contextProvider.createStubContext(); + } else { + throw new XWikiException(XWikiException.MODULE_XWIKI_USER, XWikiException.ERROR_XWIKI_USER_INIT, + "Unsupported request type [" + request.getClass() + "]"); + } } // Put the XWikiContext in the ExecutionContext @@ -147,9 +148,10 @@ public XWikiContext initialize(ExecutionContext econtext) throws XWikiException private static XWikiContext initializeXWikiContext(HttpServletRequest request, HttpServletResponse response) throws XWikiException { - XWikiServletContext xwikiEngine = new XWikiServletContext(request.getServletContext()); - XWikiServletRequest xwikiRequest = new XWikiServletRequest(request); - XWikiServletResponse xwikiResponse = new XWikiServletResponse(response); + XWikiServletContext xwikiEngine = + new XWikiServletContext(JakartaServletBridge.toJavax(request.getServletContext())); + XWikiServletRequest xwikiRequest = new XWikiServletRequest(JakartaServletBridge.toJavax(request)); + XWikiServletResponse xwikiResponse = new XWikiServletResponse(JakartaServletBridge.toJavax(response)); // Create the XWiki context. XWikiContext context = Utils.prepareContext("", xwikiRequest, xwikiResponse, xwikiEngine); diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/internal/XWikiContextProvider.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/internal/XWikiContextProvider.java index ab490f5c17ac..5c472d3f305b 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/internal/XWikiContextProvider.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/internal/XWikiContextProvider.java @@ -27,6 +27,7 @@ import org.xwiki.container.Container; import org.xwiki.container.servlet.ServletRequest; import org.xwiki.container.servlet.ServletResponse; +import org.xwiki.container.servlet.ServletSession; import org.xwiki.context.Execution; import org.xwiki.context.ExecutionContext; @@ -96,10 +97,11 @@ private XWikiContext createStubContext(ExecutionContext econtext) xcontext.declareInExecutionContext(econtext); // Set the stub request and the response - if (this.container.getRequest() == null) { + if (this.container.getRequest() == null && xcontext.getRequest() != null) { this.container.setRequest(new ServletRequest(xcontext.getRequest())); + this.container.setSession(new ServletSession(xcontext.getRequest())); } - if (this.container.getResponse() == null) { + if (this.container.getResponse() == null && xcontext.getResponse() != null) { this.container.setResponse(new ServletResponse(xcontext.getResponse())); } } diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/internal/XWikiStubContextInitializer.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/internal/XWikiStubContextInitializer.java index bfaf303731d8..2111f94f0dab 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/internal/XWikiStubContextInitializer.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/internal/XWikiStubContextInitializer.java @@ -27,6 +27,7 @@ import org.xwiki.container.Container; import org.xwiki.container.servlet.ServletRequest; import org.xwiki.container.servlet.ServletResponse; +import org.xwiki.container.servlet.ServletSession; import org.xwiki.context.ExecutionContext; import org.xwiki.context.ExecutionContextException; import org.xwiki.context.ExecutionContextInitializer; @@ -69,10 +70,11 @@ public void initialize(ExecutionContext context) throws ExecutionContextExceptio stubContext.declareInExecutionContext(context); // Set the stub request and the response - if (this.container.getRequest() == null) { + if (this.container.getRequest() == null && stubContext.getRequest() != null) { this.container.setRequest(new ServletRequest(stubContext.getRequest())); + this.container.setSession(new ServletSession(stubContext.getRequest())); } - if (this.container.getResponse() == null) { + if (this.container.getResponse() == null && stubContext.getResponse() != null) { this.container.setResponse(new ServletResponse(stubContext.getResponse())); } } diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/internal/context/RequestInitializer.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/internal/context/RequestInitializer.java index 768f3c3f2ff9..b8a41a84907d 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/internal/context/RequestInitializer.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/internal/context/RequestInitializer.java @@ -36,6 +36,7 @@ import org.xwiki.container.Container; import org.xwiki.container.servlet.HttpServletUtils; import org.xwiki.container.servlet.ServletRequest; +import org.xwiki.container.servlet.ServletSession; import com.xpn.xwiki.XWikiContext; import com.xpn.xwiki.web.XWikiRequest; @@ -181,6 +182,7 @@ private void restoreRequest(URL url, XWikiServletRequestStub stubRequest, XWikiC { xcontext.setRequest(stubRequest); this.container.setRequest(new ServletRequest(stubRequest)); + this.container.setSession(new ServletSession(stubRequest)); // Update to create the URL factory XWikiURLFactory urlFactory = xcontext.getURLFactory(); diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/internal/web/LegacyAction.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/internal/web/LegacyAction.java index 15a09520e8f1..fd880c256c22 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/internal/web/LegacyAction.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/internal/web/LegacyAction.java @@ -19,10 +19,11 @@ */ package com.xpn.xwiki.internal.web; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import org.xwiki.component.annotation.Role; +import org.xwiki.jakartabridge.servlet.JakartaServletBridge; import com.xpn.xwiki.web.XWikiAction; @@ -41,6 +42,23 @@ public interface LegacyAction * @param servletRequest the request passed to the servlet * @param servletResponse the response passed to the servlet * @throws Exception when the action produces an unexptected error + * @deprecated use {@link #execute(HttpServletRequest, HttpServletResponse)} instead */ - void execute(HttpServletRequest servletRequest, HttpServletResponse servletResponse) throws Exception; + @Deprecated(since = "42.0.0") + default void execute(javax.servlet.http.HttpServletRequest servletRequest, + javax.servlet.http.HttpServletResponse servletResponse) throws Exception + { + execute(JakartaServletBridge.toJakarta(servletRequest), JakartaServletBridge.toJakarta(servletResponse)); + } + + /** + * @param servletRequest the request passed to the servlet + * @param servletResponse the response passed to the servlet + * @throws Exception when the action produces an unexptected error + * @since 42.0.0 + */ + default void execute(HttpServletRequest servletRequest, HttpServletResponse servletResponse) throws Exception + { + execute(JakartaServletBridge.toJavax(servletRequest), JakartaServletBridge.toJavax(servletResponse)); + } } diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/render/ScriptHttpSession.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/render/ScriptHttpSession.java index 06547a79c272..d2ec8ad914a4 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/render/ScriptHttpSession.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/render/ScriptHttpSession.java @@ -37,7 +37,10 @@ * @version $Id$ * @since 12.4RC1 * @since 11.10.5 + * @deprecated use the container script service instead */ +// TODO: uncomment the annotation when XWiki Standard scripts are fully migrated to the new API +// @Deprecated(since = "42.0.0") public class ScriptHttpSession implements HttpSession, HttpSessionContext { private static final String KEY_SAFESESSION = ScriptHttpSession.class.getName(); diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/render/ScriptXWikiServletRequest.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/render/ScriptXWikiServletRequest.java index 81e486d2330a..3355ea84e87f 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/render/ScriptXWikiServletRequest.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/render/ScriptXWikiServletRequest.java @@ -39,7 +39,10 @@ * @since 12.3RC1 * @since 12.2.1 * @since 11.10.5 + * @deprecated use the {@link org.xwiki.container.script.ContainerScriptService} instead */ +// TODO: uncomment the annotation when XWiki Standard scripts are fully migrated to the new API +// @Deprecated(since = "42.0.0") public class ScriptXWikiServletRequest extends WrappingXWikiRequest { /** diff --git a/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/filter/XWikiContextInitializationFilter.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/render/ScriptXWikiServletResponse.java similarity index 59% rename from xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/filter/XWikiContextInitializationFilter.java rename to xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/render/ScriptXWikiServletResponse.java index d2f4e50aa5c4..062e80edb914 100644 --- a/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/filter/XWikiContextInitializationFilter.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/render/ScriptXWikiServletResponse.java @@ -17,16 +17,27 @@ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ -package org.xwiki.wysiwyg.filter; +package com.xpn.xwiki.render; + +import com.xpn.xwiki.web.WrappingXWikiResponse; +import com.xpn.xwiki.web.XWikiResponse; /** - * This filter can be used to initialize the XWiki context before processing a request. + * A wrapper around {@link XWikiResponse} for scripts. * * @version $Id$ - * @deprecated since 13.4RC1, use {@link com.xpn.xwiki.web.XWikiContextInitializationFilter} instead + * @since 42.0.0 + * @deprecated use the {@link org.xwiki.container.script.ContainerScriptService} instead */ -@Deprecated -public class XWikiContextInitializationFilter extends com.xpn.xwiki.web.XWikiContextInitializationFilter +// TODO: uncomment the annotation when XWiki Standard scripts are fully migrated to the new API +// @Deprecated(since = "42.0.0") +public class ScriptXWikiServletResponse extends WrappingXWikiResponse { - + /** + * @param response the wrapped response + */ + public ScriptXWikiServletResponse(XWikiResponse response) + { + super(response); + } } diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/util/Util.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/util/Util.java index 66163c1b3774..ee0c4839b465 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/util/Util.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/util/Util.java @@ -193,6 +193,7 @@ public static PatternCache getPatterns() return patterns; } + @Deprecated(since = "42.0.0") public static Map getObject(XWikiRequest request, String prefix) { @SuppressWarnings("unchecked") diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/ActionFilter.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/ActionFilter.java index 38b0fe51d9a8..3d5afcc9cc69 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/ActionFilter.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/ActionFilter.java @@ -24,14 +24,14 @@ import java.util.Objects; import java.util.stream.Stream; -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.Filter; +import jakarta.servlet.FilterChain; +import jakarta.servlet.FilterConfig; +import jakarta.servlet.RequestDispatcher; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; +import jakarta.servlet.http.HttpServletRequest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -46,8 +46,8 @@ * XHTML form has only one target URL. In previous versions of XWiki this was accomplished using javascript code, with a * fall-back on a pseudo-dispatcher inside the {@link PreviewAction}, which was on obvious case of bad code design. *

- * The filter dispatches requests based on the presence of a request parameter starting with {@code action_} followed - * by the name of the action that should actually process the request. For example, the button that does + * The filter dispatches requests based on the presence of a request parameter starting with {@code action_} followed by + * the name of the action that should actually process the request. For example, the button that does * {@code Save and Continue} looks like: * *

@@ -56,9 +56,13 @@
  *
  * As a result, when clicking the button, the request is not sent to the form's target ({@code preview}), but is
  * actually forwarded internally to {@code /bin/saveandcontinue/The/Document}.
+ * 

+ * While the class is much older, the since annotation was moved to 42.0.0 because it implement a completely + * different API from Java point of view. * * @version $Id$ * @since 1.8M1 + * @since 42.0.0 */ public class ActionFilter implements Filter { @@ -83,31 +87,28 @@ public void init(FilterConfig filterConfig) throws ServletException { } - @SuppressWarnings("unchecked") @Override - public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, - ServletException + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException { // Only HTTP requests can be dispatched. - if (request instanceof HttpServletRequest - && !Boolean.parseBoolean((String) request.getAttribute(ATTRIBUTE_ACTION_DISPATCHED))) - { - HttpServletRequest hrequest = (HttpServletRequest) request; + if (request instanceof HttpServletRequest hrequest + && !Boolean.parseBoolean((String) request.getAttribute(ATTRIBUTE_ACTION_DISPATCHED))) { Enumeration parameterNames = hrequest.getParameterNames(); while (parameterNames.hasMoreElements()) { String parameter = parameterNames.nextElement(); - + // If some xactions are passed as parameter, the parameters prefixed with 'action_' are only taken into // account if they are part of the xaction list. Otherwise, all the parameters prefixed with 'action_' // are accepted. String[] xactions = request.getParameterValues("xaction"); - if (parameter.startsWith(ACTION_PREFIX) && (xactions == null || Stream.of(xactions) - .anyMatch(it -> Objects.equals(parameter, String.format("action_%s", it))))) - { + if (parameter.startsWith(ACTION_PREFIX) && (xactions == null + || Stream.of(xactions).anyMatch(it -> Objects.equals(parameter, String.format("action_%s", it))))) { String targetURL = getTargetURL(hrequest, parameter); RequestDispatcher dispatcher = hrequest.getRequestDispatcher(targetURL); if (dispatcher != null) { - LOGGER.debug("Forwarding request to " + targetURL); + LOGGER.debug("Forwarding request to [{}]", targetURL); + request.setAttribute(ATTRIBUTE_ACTION_DISPATCHED, "true"); dispatcher.forward(hrequest, response); // Allow multiple calls to this filter as long as they are not nested. @@ -136,8 +137,8 @@ public void destroy() * * @param request the original request * @param action the action parameter, starting with {@code action_} - * @return The rebuilt URL path, with the specified action in place of the original action. Note that unlike - * the HTTP path, this does not contain the application context part. + * @return The rebuilt URL path, with the specified action in place of the original action. Note that unlike the + * HTTP path, this does not contain the application context part. */ private String getTargetURL(HttpServletRequest request, String action) { @@ -163,9 +164,8 @@ private String getTargetURL(HttpServletRequest request, String action) ConfigurationSource configuration = Utils.getComponent(ConfigurationSource.class, XWikiCfgConfigurationSource.ROLEHINT); if ("1".equals(configuration.getProperty("xwiki.virtual.usepath", "1"))) { - if (servletPath.equals(PATH_SEPARATOR - + configuration.getProperty("xwiki.virtual.usepath.servletpath", "wiki"))) - { + if (servletPath + .equals(PATH_SEPARATOR + configuration.getProperty("xwiki.virtual.usepath.servletpath", "wiki"))) { // Move the wiki name together with the servlet path servletPath += path.substring(0, index); index = path.indexOf(PATH_SEPARATOR, index + 1); diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/CommentAddAction.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/CommentAddAction.java index 8484241350f6..7b568c19ac37 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/CommentAddAction.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/CommentAddAction.java @@ -190,6 +190,7 @@ private boolean checkCaptcha(XWikiContext context) throws XWikiException } } + @Deprecated(since = "42.0.0") protected void handleTemporaryUploadedFiles(XWikiDocument document, XWikiRequest request) throws XWikiException { String[] uploadedFiles = request.getParameterValues("uploadedFiles"); diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/DownloadAction.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/DownloadAction.java index 7e3a0fd33b07..c668086b9628 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/DownloadAction.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/DownloadAction.java @@ -296,6 +296,7 @@ private void writeByteRange(final XWikiAttachment attachment, Long start, Long e * @param context the XWikiContext just in case it is needed to load the attachment content * @throws XWikiException if something goes wrong */ + @Deprecated(since = "42.0.0") protected void sendContent(final XWikiAttachment attachment, final XWikiRequest request, final XWikiResponse response, final XWikiContext context) throws XWikiException { diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/HomePageRedirectServlet.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/HomePageRedirectServlet.java index 624e22640048..2827958ebfb3 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/HomePageRedirectServlet.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/HomePageRedirectServlet.java @@ -21,15 +21,20 @@ import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; /** * A simple action that redirects to the main page of the wiki. This is to allow users to enter a URL like * http://localhost:8080/xwiki and be redirected automatically to * http://localhost:8080/xwiki/bin/view/Main/. + *

+ * While the class is much older, the since annotation was moved to 42.0.0 because it implement a completely different API + * from Java point of view. + * + * @since 42.0.0 */ public class HomePageRedirectServlet extends HttpServlet { @@ -39,7 +44,6 @@ public class HomePageRedirectServlet extends HttpServlet @Override public void init() throws ServletException { - super.init(); // TODO: we cannot use the XWiki API to determine the right URL, because this is a servlet and the core // is reachable mainly from Struts. Getting access to the core requires too much duplication, so for the // moment we're going the easy way: hardcoded values. diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/LegacyActionServlet.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/LegacyActionServlet.java index e876b1fd02d3..12a1bbc89a42 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/LegacyActionServlet.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/LegacyActionServlet.java @@ -23,10 +23,10 @@ import java.net.URL; import java.util.Collections; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import org.xwiki.component.manager.ComponentLookupException; import org.xwiki.component.manager.ComponentManager; @@ -42,9 +42,12 @@ /** * Executed the right right action depending on the XWiki configuration (for example leading to view action by default * if enabled, etc.). + *

+ * While the class is much older, the since annotation was moved to 42.0.0 because it implement a completely different + * API from Java point of view. * * @version $Id$ - * @since 13.0 + * @since 42.0.0 */ public class LegacyActionServlet extends HttpServlet { diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/SkinAction.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/SkinAction.java index dd694284bd29..d1f8381eb52c 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/SkinAction.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/SkinAction.java @@ -530,6 +530,7 @@ protected void setupHeaders(XWikiResponse response, String mimetype, Date lastCh * @since 11.3.6 * @since 10.11.10 */ + @Deprecated(since = "42.0.0") protected void setupHeaders(XWikiResponse response, String mimetype, Date lastChanged, long length) { if (!StringUtils.isBlank(mimetype)) { diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/Utils.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/Utils.java index 88a4f843d766..d44c369a6de9 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/Utils.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/Utils.java @@ -242,6 +242,7 @@ public static void parseTemplate(String template, boolean write, XWikiContext co * @param defaultRedirect the default value to use if no {@code xredirect} parameter is present * @return the destination URL, as specified in the {@code xredirect} parameter, or the specified default URL */ + @Deprecated(since = "42.0.0") public static String getRedirect(XWikiRequest request, String defaultRedirect) { String redirect = request.getParameter("xredirect"); @@ -327,6 +328,7 @@ public static String getRedirect(String action, XWikiContext context) * @return the name of the requested template, as specified in the {@code xpage} parameter, or the specified default * template */ + @Deprecated(since = "42.0.0") public static String getPage(XWikiRequest request, String defaultpage) { String page = request.getParameter("xpage"); @@ -389,6 +391,7 @@ public static byte[] getContent(List filelist, String name) throws XWi return null; } + @Deprecated(since = "42.0.0") public static XWikiContext prepareContext(String action, XWikiRequest request, XWikiResponse response, XWikiEngineContext engine_context) throws XWikiException { diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/WrappingXWikiRequest.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/WrappingXWikiRequest.java index 1a50d89ff66c..998dccc5f01c 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/WrappingXWikiRequest.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/WrappingXWikiRequest.java @@ -19,32 +19,11 @@ */ package com.xpn.xwiki.web; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.security.Principal; -import java.util.Collection; -import java.util.Enumeration; -import java.util.Locale; -import java.util.Map; -import java.util.Optional; - -import javax.servlet.AsyncContext; -import javax.servlet.DispatcherType; -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletContext; -import javax.servlet.ServletException; -import javax.servlet.ServletInputStream; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; -import javax.servlet.http.HttpUpgradeHandler; -import javax.servlet.http.Part; +import javax.servlet.http.HttpServletRequestWrapper; -import org.xwiki.user.UserReference; +import org.xwiki.container.Container; /** * A wrapper around {@link XWikiRequest}. @@ -52,8 +31,11 @@ * @version $Id$ * @since 12.4RC1 * @since 11.10.5 + * @deprecated use the {@link Container} API instead */ -public class WrappingXWikiRequest implements XWikiRequest +// TODO: uncomment the annotation when XWiki Standard scripts are fully migrated to the new API +// @Deprecated(since = "42.0.0") +public class WrappingXWikiRequest extends HttpServletRequestWrapper implements XWikiRequest { protected final XWikiRequest request; @@ -62,13 +44,9 @@ public class WrappingXWikiRequest implements XWikiRequest */ public WrappingXWikiRequest(XWikiRequest request) { - this.request = request; - } + super(request); - @Override - public ServletContext getServletContext() - { - return this.request.getServletContext(); + this.request = request; } @Override @@ -77,415 +55,6 @@ public HttpServletRequest getHttpServletRequest() return this.request.getHttpServletRequest(); } - @Override - public HttpSession getSession() - { - return this.request.getSession(); - } - - @Override - public HttpSession getSession(boolean create) - { - return this.request.getSession(create); - } - - @Override - public String getAuthType() - { - return this.request.getAuthType(); - } - - @Override - public Cookie[] getCookies() - { - return this.request.getCookies(); - } - - @Override - public long getDateHeader(String name) - { - return this.request.getDateHeader(name); - } - - @Override - public String getHeader(String name) - { - return this.request.getHeader(name); - } - - @Override - public Enumeration getHeaders(String name) - { - return this.request.getHeaders(name); - } - - @Override - public Enumeration getHeaderNames() - { - return this.request.getHeaderNames(); - } - - @Override - public int getIntHeader(String name) - { - return this.request.getIntHeader(name); - } - - @Override - public String getMethod() - { - return this.request.getMethod(); - } - - @Override - public String getPathInfo() - { - return this.request.getPathInfo(); - } - - @Override - public String getPathTranslated() - { - return this.request.getPathTranslated(); - } - - @Override - public String getContextPath() - { - return this.request.getContextPath(); - } - - @Override - public String getQueryString() - { - return this.request.getQueryString(); - } - - @Override - public String getRemoteUser() - { - return this.request.getRemoteUser(); - } - - @Override - public boolean isUserInRole(String role) - { - return this.request.isUserInRole(role); - } - - @Override - public Principal getUserPrincipal() - { - return this.request.getUserPrincipal(); - } - - @Override - public String getRequestedSessionId() - { - return this.request.getRequestedSessionId(); - } - - @Override - public String getRequestURI() - { - return this.request.getRequestURI(); - } - - @Override - public StringBuffer getRequestURL() - { - return this.request.getRequestURL(); - } - - @Override - public String getServletPath() - { - return this.request.getServletPath(); - } - - @Override - public String changeSessionId() - { - return this.request.changeSessionId(); - } - - @Override - public boolean isRequestedSessionIdValid() - { - return this.request.isRequestedSessionIdValid(); - } - - @Override - public boolean isRequestedSessionIdFromCookie() - { - return this.request.isRequestedSessionIdFromCookie(); - } - - @Override - public boolean isRequestedSessionIdFromURL() - { - return this.request.isRequestedSessionIdFromURL(); - } - - @Override - public boolean isRequestedSessionIdFromUrl() - { - return this.request.isRequestedSessionIdFromUrl(); - } - - @Override - public boolean authenticate(HttpServletResponse response) throws IOException, ServletException - { - return this.request.authenticate(response); - } - - @Override - public void login(String username, String password) throws ServletException - { - this.request.login(username, password); - } - - @Override - public void logout() throws ServletException - { - this.request.logout(); - } - - @Override - public Collection getParts() throws IOException, ServletException - { - return this.request.getParts(); - } - - @Override - public Part getPart(String name) throws IOException, ServletException - { - return this.request.getPart(name); - } - - @Override - public T upgrade(Class handlerClass) throws IOException, ServletException - { - return this.request.upgrade(handlerClass); - } - - @Override - public Object getAttribute(String name) - { - return this.request.getAttribute(name); - } - - @Override - public Enumeration getAttributeNames() - { - return this.request.getAttributeNames(); - } - - @Override - public String getCharacterEncoding() - { - return this.request.getCharacterEncoding(); - } - - @Override - public void setCharacterEncoding(String env) throws UnsupportedEncodingException - { - this.request.setCharacterEncoding(env); - } - - @Override - public int getContentLength() - { - return this.request.getContentLength(); - } - - @Override - public long getContentLengthLong() - { - return this.request.getContentLengthLong(); - } - - @Override - public String getContentType() - { - return this.request.getContentType(); - } - - @Override - public ServletInputStream getInputStream() throws IOException - { - return this.request.getInputStream(); - } - - @Override - public String getParameter(String name) - { - return this.request.getParameter(name); - } - - @Override - public Enumeration getParameterNames() - { - return this.request.getParameterNames(); - } - - @Override - public String[] getParameterValues(String name) - { - return this.request.getParameterValues(name); - } - - @Override - public Map getParameterMap() - { - return this.request.getParameterMap(); - } - - @Override - public String getProtocol() - { - return this.request.getProtocol(); - } - - @Override - public String getScheme() - { - return this.request.getScheme(); - } - - @Override - public String getServerName() - { - return this.request.getServerName(); - } - - @Override - public int getServerPort() - { - return this.request.getServerPort(); - } - - @Override - public BufferedReader getReader() throws IOException - { - return this.request.getReader(); - } - - @Override - public String getRemoteAddr() - { - return this.request.getRemoteAddr(); - } - - @Override - public String getRemoteHost() - { - return this.request.getRemoteHost(); - } - - @Override - public void setAttribute(String name, Object o) - { - this.request.setAttribute(name, o); - } - - @Override - public void removeAttribute(String name) - { - this.request.removeAttribute(name); - } - - @Override - public Locale getLocale() - { - return this.request.getLocale(); - } - - @Override - public Enumeration getLocales() - { - return this.request.getLocales(); - } - - @Override - public boolean isSecure() - { - return this.request.isSecure(); - } - - @Override - public RequestDispatcher getRequestDispatcher(String path) - { - return this.request.getRequestDispatcher(path); - } - - @Override - public String getRealPath(String path) - { - return this.request.getRealPath(path); - } - - @Override - public int getRemotePort() - { - return this.request.getRemotePort(); - } - - @Override - public String getLocalName() - { - return this.request.getLocalName(); - } - - @Override - public String getLocalAddr() - { - return this.request.getLocalAddr(); - } - - @Override - public int getLocalPort() - { - return this.request.getLocalPort(); - } - - @Override - public AsyncContext startAsync() throws IllegalStateException - { - return this.request.startAsync(); - } - - @Override - public AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse) - throws IllegalStateException - { - return this.request.startAsync(servletRequest, servletResponse); - } - - @Override - public boolean isAsyncStarted() - { - return this.request.isAsyncStarted(); - } - - @Override - public boolean isAsyncSupported() - { - return this.request.isAsyncSupported(); - } - - @Override - public AsyncContext getAsyncContext() - { - return this.request.getAsyncContext(); - } - - @Override - public DispatcherType getDispatcherType() - { - return this.request.getDispatcherType(); - } - @Override public String get(String name) { @@ -497,10 +66,4 @@ public Cookie getCookie(String cookieName) { return this.request.getCookie(cookieName); } - - @Override - public Optional getEffectiveAuthor() - { - return this.request.getEffectiveAuthor(); - } } diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/WrappingXWikiResponse.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/WrappingXWikiResponse.java new file mode 100644 index 000000000000..2d7f6db215ff --- /dev/null +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/WrappingXWikiResponse.java @@ -0,0 +1,61 @@ +/* + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package com.xpn.xwiki.web; + +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpServletResponseWrapper; + +import org.xwiki.container.Container; + +/** + * A wrapper around {@link XWikiResponse}. + * + * @version $Id$ + * @since 42.0.0 + * @deprecated use the {@link Container} API instead + */ +// TODO: uncomment the annotation when XWiki Standard scripts are fully migrated to the new API +// @Deprecated(since = "42.0.0") +public class WrappingXWikiResponse extends HttpServletResponseWrapper implements XWikiResponse +{ + protected final XWikiResponse response; + + /** + * @param response the wrapped response + */ + public WrappingXWikiResponse(XWikiResponse response) + { + super(response); + + this.response = response; + } + + @Override + public HttpServletResponse getHttpServletResponse() + { + return this.response.getHttpServletResponse(); + } + + @Override + public void removeCookie(String cookieName, XWikiRequest request) + { + this.response.removeCookie(cookieName, request); + } +} diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiAction.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiAction.java index 6e12fd6e05bd..532ec9a04ca5 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiAction.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiAction.java @@ -33,8 +33,9 @@ import javax.inject.Named; import javax.script.ScriptContext; import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.exception.ExceptionUtils; @@ -56,6 +57,7 @@ import org.xwiki.context.ExecutionContext; import org.xwiki.csrf.CSRFToken; import org.xwiki.internal.web.DocExistValidator; +import org.xwiki.jakartabridge.servlet.JakartaServletBridge; import org.xwiki.job.event.status.JobProgressManager; import org.xwiki.job.internal.DefaultJobProgress; import org.xwiki.localization.ContextualLocalizationManager; @@ -329,7 +331,8 @@ public void execute(HttpServletRequest servletRequest, HttpServletResponse servl // Initialize the XWiki Context which is the main object used to pass information across // classes/methods. It's also wrapping the request, response, and all container objects // in general. - context = initializeXWikiContext(servletRequest, servletResponse); + context = + initializeXWikiContext(JakartaServletBridge.toJavax(servletRequest), JakartaServletBridge.toJavax(servletResponse)); // From this line forward all information can be found in the XWiki Context. execute(context); @@ -827,8 +830,9 @@ private void renderInit(XWikiContext xcontext) throws Exception xcontext.setFinished(true); } - protected XWikiContext initializeXWikiContext(HttpServletRequest servletRequest, - HttpServletResponse servletResponse) + @Deprecated(since = "42.0.0") + protected XWikiContext initializeXWikiContext(javax.servlet.http.HttpServletRequest servletRequest, + javax.servlet.http.HttpServletResponse servletResponse) throws XWikiException, ServletException, InstantiationException, IllegalAccessException { XWikiForm form; @@ -850,8 +854,9 @@ protected String getName() return this.componentDescriptor.getRoleHint(); } - protected XWikiContext initializeXWikiContext(HttpServletRequest servletRequest, - HttpServletResponse servletResponse, XWikiForm form) throws XWikiException, ServletException + @Deprecated(since = "42.0.0") + protected XWikiContext initializeXWikiContext(javax.servlet.http.HttpServletRequest servletRequest, + javax.servlet.http.HttpServletResponse servletResponse, XWikiForm form) throws XWikiException, ServletException { String action = getName(); @@ -906,8 +911,8 @@ public String getRealPath(String path) { Request request = this.container.getRequest(); - if (request instanceof ServletRequest) { - return ((ServletRequest) request).getHttpServletRequest().getServletContext().getRealPath(path); + if (request instanceof ServletRequest servletRequest) { + return servletRequest.getRequest().getServletContext().getRealPath(path); } return null; diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiContextInitializationFilter.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiContextInitializationFilter.java index 374ce5c727d8..6a8c71a3e857 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiContextInitializationFilter.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiContextInitializationFilter.java @@ -22,19 +22,20 @@ import java.io.IOException; import java.lang.reflect.Type; -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.Filter; +import jakarta.servlet.FilterChain; +import jakarta.servlet.FilterConfig; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import org.xwiki.container.Container; import org.xwiki.container.servlet.ServletContainerException; import org.xwiki.container.servlet.ServletContainerInitializer; import org.xwiki.context.Execution; +import org.xwiki.jakartabridge.servlet.JakartaServletBridge; import org.xwiki.model.reference.DocumentReference; import com.xpn.xwiki.XWiki; @@ -45,28 +46,20 @@ /** * This filter can be used to initialize the XWiki context before processing a request. + *

+ * While the class is much older, the since annotation was moved to 42.0.0 because it implement a completely different + * API from Java point of view. * * @version $Id$ - * @since 13.4RC1 + * @since 42.0.0 */ public class XWikiContextInitializationFilter implements Filter { - /** - * The filter configuration object. - */ - private FilterConfig filterConfig; - /** * XWiki context mode. */ private int mode; - @Override - public void destroy() - { - this.filterConfig = null; - } - @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException @@ -87,8 +80,6 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha @Override public void init(FilterConfig filterConfig) throws ServletException { - this.filterConfig = filterConfig; - try { this.mode = Integer.parseInt(filterConfig.getInitParameter("mode")); } catch (Exception e) { @@ -102,15 +93,34 @@ public void init(FilterConfig filterConfig) throws ServletException * @param request the request being processed * @param response the response * @throws ServletException if the initialization fails + * @deprecated use {@link #initializeXWikiContext(ServletRequest, ServletResponse)} instead + */ + @Deprecated(since = "42.0.0") + protected void initializeXWikiContext(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response) + throws ServletException + { + initializeXWikiContext(JakartaServletBridge.toJakarta(request), JakartaServletBridge.toJakarta(response)); + } + + /** + * Initializes the XWiki context. + * + * @param request the request being processed + * @param response the response + * @throws ServletException if the initialization fails + * @since 42.0.0 */ protected void initializeXWikiContext(ServletRequest request, ServletResponse response) throws ServletException { try { // Not all request types specify an action (e.g. GWT-RPC) so we default to the empty string. String action = ""; - XWikiServletContext xwikiEngine = new XWikiServletContext(this.filterConfig.getServletContext()); - XWikiServletRequest xwikiRequest = new XWikiServletRequest((HttpServletRequest) request); - XWikiServletResponse xwikiResponse = new XWikiServletResponse((HttpServletResponse) response); + XWikiServletContext xwikiEngine = + new XWikiServletContext(JakartaServletBridge.toJavax(request.getServletContext())); + XWikiServletRequest xwikiRequest = + new XWikiServletRequest(JakartaServletBridge.toJavax((HttpServletRequest) request)); + XWikiServletResponse xwikiResponse = + new XWikiServletResponse(JakartaServletBridge.toJavax((HttpServletResponse) response)); // Create the XWiki context. XWikiContext context = Utils.prepareContext(action, xwikiRequest, xwikiResponse, xwikiEngine); diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiForm.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiForm.java index d141b0518276..5bd97cdf2f83 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiForm.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiForm.java @@ -56,12 +56,14 @@ public void reset(HttpServletRequest request) * @param request The servlet request we are processing * @since 13.0 */ + @Deprecated(since = "42.0.0") public void reset(XWikiRequest request) { this.request = request; readRequest(); } + @Deprecated(since = "42.0.0") public XWikiRequest getRequest() { return this.request; diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiRequest.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiRequest.java index a39e3612217f..5a9adad8dd1b 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiRequest.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiRequest.java @@ -24,9 +24,15 @@ import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; +import org.xwiki.container.Request; import org.xwiki.stability.Unstable; import org.xwiki.user.UserReference; +/** + * @version $Id$ + * @deprecated use the {@link org.xwiki.container.Container} API instead + */ +@Deprecated(since = "42.0.0") public interface XWikiRequest extends HttpServletRequest { String get(String name); @@ -47,6 +53,6 @@ public interface XWikiRequest extends HttpServletRequest @Unstable default Optional getEffectiveAuthor() { - return Optional.empty(); + return Optional.ofNullable((UserReference) getAttribute(Request.ATTRIBUTE_EFFECTIVE_AUTHOR)); } } diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiResponse.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiResponse.java index b3de82729421..55f314b054da 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiResponse.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiResponse.java @@ -21,6 +21,11 @@ import javax.servlet.http.HttpServletResponse; +/** + * @version $Id$ + * @deprecated use {@link org.xwiki.container.Container} API instead + */ +@Deprecated(since = "42.0.0") public interface XWikiResponse extends HttpServletResponse { /** diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiServletContext.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiServletContext.java index 98ecd06b161a..f738f6d8252a 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiServletContext.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiServletContext.java @@ -25,6 +25,13 @@ import javax.servlet.ServletContext; +/** + * Servlet based implementation of {@link XWikiEngineContext}. + * + * @version $Id$ + * @deprecated use the {@link org.xwiki.container.Container} API instead + */ +@Deprecated(since = "42.0.0") public class XWikiServletContext implements XWikiEngineContext { private ServletContext scontext; diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiServletRequest.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiServletRequest.java index f77e5ec2c7c2..163888d6f45b 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiServletRequest.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiServletRequest.java @@ -19,13 +19,12 @@ */ package com.xpn.xwiki.web; -import java.util.Optional; - import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequestWrapper; -import org.xwiki.user.UserReference; +import org.xwiki.container.Request; +import org.xwiki.jakartabridge.JavaxToJakartaWrapper; import com.xpn.xwiki.util.Util; @@ -34,9 +33,11 @@ * * @version $Id$ */ -public class XWikiServletRequest extends HttpServletRequestWrapper implements XWikiRequest +@Deprecated(since = "42.0.0") +public class XWikiServletRequest extends HttpServletRequestWrapper + implements XWikiRequest, JavaxToJakartaWrapper { - public static final String ATTRIBUTE_EFFECTIVE_AUTHOR = XWikiRequest.class.getName() + "#effectiveAuthor"; + public static final String ATTRIBUTE_EFFECTIVE_AUTHOR = Request.ATTRIBUTE_EFFECTIVE_AUTHOR; public XWikiServletRequest(HttpServletRequest request) { @@ -44,6 +45,18 @@ public XWikiServletRequest(HttpServletRequest request) super(request != null ? request : new XWikiServletRequestStub()); } + // JavaxToJakartaWrapper + + @Override + public jakarta.servlet.http.HttpServletRequest getJakarta() + { + if (getRequest() instanceof JavaxToJakartaWrapper wrapper) { + return (jakarta.servlet.http.HttpServletRequest) wrapper.getJakarta(); + } + + return null; + } + // XWikiRequest @Override @@ -66,12 +79,6 @@ public Cookie getCookie(String cookieName) // HttpServletRequest - @Override - public StringBuffer getRequestURL() - { - return getHttpServletRequest().getRequestURL(); - } - @Override public String getParameter(String s) { @@ -107,10 +114,4 @@ public String getRemoteHost() return request.getRemoteHost(); } - - @Override - public Optional getEffectiveAuthor() - { - return Optional.ofNullable((UserReference) getAttribute(ATTRIBUTE_EFFECTIVE_AUTHOR)); - } } diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiServletRequestStub.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiServletRequestStub.java index a1efa9b0d9cf..d947af828959 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiServletRequestStub.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiServletRequestStub.java @@ -19,52 +19,33 @@ */ package com.xpn.xwiki.web; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.UnsupportedEncodingException; import java.net.URL; -import java.security.Principal; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Enumeration; -import java.util.LinkedHashMap; import java.util.List; -import java.util.Locale; import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.TreeMap; -import java.util.Vector; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import javax.servlet.AsyncContext; -import javax.servlet.DispatcherType; -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletContext; -import javax.servlet.ServletException; -import javax.servlet.ServletInputStream; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; + import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpServletRequestWrapper; import javax.servlet.http.HttpSession; -import javax.servlet.http.HttpUpgradeHandler; -import javax.servlet.http.Part; -import org.apache.commons.lang3.ArrayUtils; -import org.xwiki.user.UserReference; +import org.xwiki.container.servlet.HttpServletRequestStub; +import org.xwiki.jakartabridge.JavaxToJakartaWrapper; +import org.xwiki.jakartabridge.servlet.JakartaServletBridge; +import org.xwiki.stability.Unstable; + +import com.xpn.xwiki.util.Util; /** * This stub is intended to simulate a servlet request in a daemon context, in order to be able to create a custom XWiki * context. This trick is used in to give a daemon thread access to the XWiki api. * * @version $Id$ + * @deprecated use {@link HttpServletRequestStub} instead */ -public class XWikiServletRequestStub implements XWikiRequest +// TODO: uncomment the annotation when XWiki Standard scripts are fully migrated to the new API +// @Deprecated(since = "42.0.0") +public class XWikiServletRequestStub extends HttpServletRequestWrapper + implements XWikiRequest, JavaxToJakartaWrapper { /** * Builder for {@link XWikiServletRequestStub}. @@ -175,67 +156,40 @@ public XWikiServletRequestStub build() } } - private boolean secure; - - private String scheme; - - private String protocol; - - private String queryString; - - private String contextPath; - - private String servletPath; - - private String serverName; - - private int serverPort; - - private Map> headers; - - private Map parameters; - - private Cookie[] cookies; - - private List parts = new ArrayList<>(); - - private String requestURI; - - private StringBuffer requestURL; - - private String remoteAddr; - - private boolean daemon = true; - - private HttpSession httpSession; - public XWikiServletRequestStub() { + this(new HttpServletRequestStub()); } - protected XWikiServletRequestStub(Builder builder) + /** + * @param request the request to copy + * @since 10.7RC1 + */ + public XWikiServletRequestStub(XWikiRequest request) { - if (builder.requestURL != null) { - this.protocol = builder.requestURL.getProtocol(); - this.scheme = builder.requestURL.getProtocol(); - - this.serverName = builder.requestURL.getHost(); - this.serverPort = builder.requestURL.getPort(); - - this.secure = this.protocol.equalsIgnoreCase("https"); + this(new HttpServletRequestStub(JakartaServletBridge.toJakarta(request))); - this.requestURI = builder.requestURL.getPath(); - this.requestURL = new StringBuffer(builder.requestURL.toString()); - - setHost(builder.requestURL.getHost()); + if (request instanceof XWikiServletRequestStub requestStub) { + setDaemon(requestStub.isDaemon()); } + } - this.contextPath = builder.contextPath; - this.parameters = clone(builder.requestParameters); - this.headers = cloneHeaders(builder.headers); - this.cookies = clone(builder.cookies); - this.remoteAddr = builder.remoteAddr; - this.httpSession = builder.httpSession; + /** + * @param jakarta the request wrap + * @since 42.0.0 + */ + @Unstable + public XWikiServletRequestStub(HttpServletRequestStub jakarta) + { + super(JakartaServletBridge.toJavax(jakarta)); + } + + protected XWikiServletRequestStub(Builder builder) + { + this(new HttpServletRequestStub.Builder().setRequestURL(builder.requestURL).setContextPath(builder.contextPath) + .setRequestParameters(builder.requestParameters).setHeaders(builder.headers) + .setRemoteAddr(builder.remoteAddr).setCookies(JakartaServletBridge.toJakarta(builder.cookies)) + .setHttpSession(JakartaServletBridge.toJakarta(builder.httpSession)).build()); } /** @@ -272,96 +226,19 @@ public XWikiServletRequestStub(URL requestURL, String contextPath, Map Map.entry(headerName, Collections.list(request.getHeaders(headerName)))) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (left, right) -> right, - () -> new TreeMap<>(String.CASE_INSENSITIVE_ORDER))); - } - - this.parameters = clone(request.getParameterMap()); - this.cookies = clone(request.getCookies()); - this.remoteAddr = request.getRemoteAddr(); - - if (request instanceof XWikiServletRequestStub) { - this.daemon = ((XWikiServletRequestStub) request).daemon; - this.parts = new ArrayList<>(((XWikiServletRequestStub) request).parts); - } - } - - private Map clone(Map map) - { - Map clone; - if (map != null) { - clone = new LinkedHashMap<>(map.size()); - for (Map.Entry entry : map.entrySet()) { - clone.put(entry.getKey(), entry.getValue().clone()); - } - } else { - clone = null; - } - - return clone; - } - - private Map> cloneHeaders(Map> headers) - { - if (headers == null) { - return null; - } - - return headers.entrySet().stream().filter(entry -> entry.getValue() != null && !entry.getValue().isEmpty()) - .map(entry -> Map.entry(entry.getKey(), entry.getValue().stream().collect(Collectors.toList()))) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (left, right) -> right, - () -> new TreeMap<>(String.CASE_INSENSITIVE_ORDER))); - } - - private Cookie[] clone(Cookie[] cookies) - { - if (cookies != null) { - return Stream.of(cookies).map(Cookie::clone).toArray(Cookie[]::new); - } else { - return null; - } - } - public void setContextPath(String contextPath) { - this.contextPath = contextPath; + getJakarta().setContextPath(contextPath); } public void setHost(String host) { - if (this.headers == null) { - this.headers = new LinkedHashMap<>(); - } - - this.headers.put("x-forwarded-host", new Vector(Arrays.asList(host))); + getJakarta().setHost(host); } public void setScheme(String scheme) { - this.scheme = scheme; + getJakarta().setScheme(scheme); } /** @@ -370,7 +247,7 @@ public void setScheme(String scheme) */ public void setrequestURL(StringBuffer requestURL) { - this.requestURL = requestURL; + getJakarta().setrequestURL(requestURL); } /** @@ -378,7 +255,7 @@ public void setrequestURL(StringBuffer requestURL) */ public void setRequestURI(String requestURI) { - this.requestURI = requestURI; + getJakarta().setRequestURI(requestURI); } /** @@ -387,21 +264,7 @@ public void setRequestURI(String requestURI) */ public void setServerName(String serverName) { - this.serverName = serverName; - } - - @Override - public String getHeader(String headerName) - { - if (this.headers != null) { - List values = this.headers.get(headerName); - - if (values != null && !values.isEmpty()) { - return values.get(0); - } - } - - return null; + getJakarta().setServerName(serverName); } /** @@ -409,176 +272,7 @@ public String getHeader(String headerName) */ public void put(String key, String value) { - if (this.parameters == null) { - this.parameters = new LinkedHashMap<>(); - } - - String[] values = this.parameters.get(key); - if (values == null) { - values = new String[] {value}; - } else { - values = ArrayUtils.add(values, value); - } - this.parameters.put(key, values); - } - - @Override - public String get(String name) - { - return getParameter(name); - } - - @Override - public HttpServletRequest getHttpServletRequest() - { - return this; - } - - @Override - public Cookie getCookie(String cookieName) - { - if (this.cookies != null) { - return Stream.of(this.cookies).filter(cookie -> Objects.equals(cookieName, cookie.getName())).findFirst() - .orElse(null); - } else { - return null; - } - } - - @Override - public String getAuthType() - { - return null; - } - - @Override - public Cookie[] getCookies() - { - return clone(this.cookies); - } - - @Override - public long getDateHeader(String s) - { - return 0; - } - - @Override - public Enumeration getHeaders(String headerName) - { - if (this.headers != null) { - List values = this.headers.get(headerName); - - if (values != null) { - return Collections.enumeration(values); - } - } - - return Collections.emptyEnumeration(); - } - - @Override - public Enumeration getHeaderNames() - { - return this.headers != null ? Collections.enumeration(this.headers.keySet()) : Collections.emptyEnumeration(); - } - - @Override - public int getIntHeader(String s) - { - String header = getHeader(s); - - return header != null ? Integer.parseInt(header) : -1; - } - - @Override - public String getMethod() - { - return null; - } - - @Override - public String getPathInfo() - { - return null; - } - - @Override - public String getPathTranslated() - { - return null; - } - - @Override - public String getContextPath() - { - return this.contextPath; - } - - @Override - public String getQueryString() - { - return this.queryString; - } - - @Override - public String getRemoteUser() - { - return null; - } - - @Override - public boolean isUserInRole(String s) - { - return false; - } - - @Override - public Principal getUserPrincipal() - { - return null; - } - - @Override - public String getRequestedSessionId() - { - return null; - } - - @Override - public String getRequestURI() - { - return this.requestURI; - } - - @Override - public StringBuffer getRequestURL() - { - return this.requestURL == null ? new StringBuffer() : this.requestURL; - } - - @Override - public String getServletPath() - { - return this.servletPath; - } - - @Override - public HttpSession getSession(boolean b) - { - return this.httpSession; - } - - @Override - public String changeSessionId() - { - return null; - } - - @Override - public HttpSession getSession() - { - return this.httpSession; + getJakarta().put(key, value); } /** @@ -589,338 +283,59 @@ public HttpSession getSession() */ public void setSession(HttpSession httpSession) { - this.httpSession = httpSession; - } - - @Override - public boolean isRequestedSessionIdValid() - { - return false; - } - - @Override - public boolean isRequestedSessionIdFromCookie() - { - return false; - } - - @Override - public boolean isRequestedSessionIdFromURL() - { - return false; + getJakarta().setSession(JakartaServletBridge.toJakarta(httpSession)); } /** - * @deprecated + * @return true if the request is intended to be used in a long standing daemon thread (mails, etc.) and should not + * be taken into account when generating a URL + * @since 10.11RC1 */ - @Override - @Deprecated - public boolean isRequestedSessionIdFromUrl() - { - return false; - } - - @Override - public Object getAttribute(String s) - { - return null; - } - - @Override - public Enumeration getAttributeNames() - { - return Collections.emptyEnumeration(); - } - - @Override - public String getCharacterEncoding() - { - return null; - } - - @Override - public void setCharacterEncoding(String s) throws UnsupportedEncodingException - { - - } - - @Override - public int getContentLength() - { - return 0; - } - - @Override - public long getContentLengthLong() - { - return 0; - } - - @Override - public String getContentType() - { - return null; - } - - @Override - public ServletInputStream getInputStream() throws IOException - { - return null; - } - - @Override - public String getParameter(String s) - { - if (this.parameters != null) { - String[] values = this.parameters.get(s); - - if (ArrayUtils.isNotEmpty(values)) { - return values[0]; - } - } - - return null; - } - - @Override - public Enumeration getParameterNames() - { - return this.parameters != null ? Collections.enumeration(this.parameters.keySet()) : null; - } - - @Override - public String[] getParameterValues(String s) - { - if (this.parameters != null) { - String[] values = this.parameters.get(s); - - return values != null ? values.clone() : null; - } - - return ArrayUtils.EMPTY_STRING_ARRAY; - } - - @Override - public Map getParameterMap() - { - return clone(this.parameters); - } - - @Override - public String getProtocol() - { - return this.protocol; - } - - @Override - public String getScheme() - { - return this.scheme; - } - - @Override - public String getServerName() - { - return this.serverName; - } - - @Override - public int getServerPort() - { - return this.serverPort; - } - - @Override - public BufferedReader getReader() throws IOException - { - return null; - } - - @Override - public String getRemoteAddr() - { - return this.remoteAddr; - } - - @Override - public String getRemoteHost() - { - return null; - } - - @Override - public void setAttribute(String s, Object o) - { - - } - - @Override - public void removeAttribute(String s) - { - - } - - @Override - public Locale getLocale() - { - return null; - } - - @Override - public Enumeration getLocales() - { - return null; - } - - @Override - public boolean isSecure() - { - return this.secure; - } - - @Override - public RequestDispatcher getRequestDispatcher(String s) + public boolean isDaemon() { - return null; + return getJakarta().isDaemon(); } /** - * @deprecated + * @param daemon the daemon to set + * @since 10.11RC1 */ - @Override - @Deprecated - public String getRealPath(String s) - { - return null; - } - - @Override - public int getRemotePort() - { - return 0; - } - - @Override - public String getLocalName() - { - return null; - } - - @Override - public String getLocalAddr() - { - return null; - } - - @Override - public int getLocalPort() - { - return 0; - } - - @Override - public boolean authenticate(HttpServletResponse httpServletResponse) throws IOException, ServletException - { - return false; - } - - @Override - public void login(String s, String s1) throws ServletException - { - } - - @Override - public void logout() throws ServletException - { - - } - - @Override - public Collection getParts() throws IOException, ServletException - { - return this.parts; - } - - @Override - public Part getPart(String s) throws IOException, ServletException + public void setDaemon(boolean daemon) { - return this.parts.stream() - .filter(part -> Objects.equals(part.getName(), s)) - .findFirst() - .orElse(null); + getJakarta().setDaemon(daemon); } - @Override - public ServletContext getServletContext() - { - return null; - } + // JavaxToJakartaWrapper @Override - public AsyncContext startAsync() throws IllegalStateException + public HttpServletRequestStub getJakarta() { - return null; - } + if (getRequest() instanceof JavaxToJakartaWrapper wrapper) { + return (HttpServletRequestStub) wrapper.getJakarta(); + } - @Override - public AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse) - throws IllegalStateException - { return null; } - @Override - public boolean isAsyncStarted() - { - return false; - } - - @Override - public boolean isAsyncSupported() - { - return false; - } - - @Override - public AsyncContext getAsyncContext() - { - return null; - } + // XWikiRequest @Override - public DispatcherType getDispatcherType() + public HttpServletRequest getHttpServletRequest() { - return null; + // For retro compatibility reason it's expected that #getHttpServletRequest() return this in the case of a + // XWikiServletRequestStub + return this; } @Override - public T upgrade(Class handlerClass) throws IOException, ServletException - { - return null; - } - - /** - * @return true if the request is intended to be used in a long standing daemon thread (mails, etc.) and should not - * be taken into account when generating a URL - * @since 10.11RC1 - */ - public boolean isDaemon() - { - return this.daemon; - } - - /** - * @param daemon the daemon to set - * @since 10.11RC1 - */ - public void setDaemon(boolean daemon) + public String get(String name) { - this.daemon = daemon; + return getRequest().getParameter(name); } @Override - public Optional getEffectiveAuthor() + public Cookie getCookie(String cookieName) { - return Optional.ofNullable((UserReference) getAttribute(XWikiServletRequest.ATTRIBUTE_EFFECTIVE_AUTHOR)); + return Util.getCookie(cookieName, this); } } diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiServletResponse.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiServletResponse.java index 1974c4eeb355..617327e62828 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiServletResponse.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiServletResponse.java @@ -19,57 +19,39 @@ */ package com.xpn.xwiki.web; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; - import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponseWrapper; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.xwiki.url.URLSecurityManager; +import org.xwiki.jakartabridge.JavaxToJakartaWrapper; -public class XWikiServletResponse extends HttpServletResponseWrapper implements XWikiResponse +@Deprecated(since = "42.0.0") +public class XWikiServletResponse extends HttpServletResponseWrapper + implements XWikiResponse, JavaxToJakartaWrapper { - private static final Logger LOGGER = LoggerFactory.getLogger(XWikiServletResponse.class); - public XWikiServletResponse(HttpServletResponse response) { super(response); } - @Override - public HttpServletResponse getHttpServletResponse() - { - return (HttpServletResponse) getResponse(); - } + // JavaxToJakartaWrapper @Override - public void sendRedirect(String redirect) throws IOException + public jakarta.servlet.http.HttpServletResponse getJakarta() { - if (!StringUtils.isBlank(redirect)) { - URI uri; - try { - uri = getURLSecurityManager().parseToSafeURI(redirect); - getHttpServletResponse().sendRedirect(uri.toString()); - } catch (URISyntaxException | SecurityException e) { - LOGGER.warn( - "Possible phishing attack, attempting to redirect to [{}], this request has been blocked. " - + "If the request was legitimate, please check the URL security configuration. You " - + "might need to add the domain related to this request in the list of trusted domains in " - + "the configuration: it can be configured in xwiki.properties in url.trustedDomains.", - redirect); - LOGGER.debug("Original error preventing the redirect: ", e); - } + if (getResponse() instanceof JavaxToJakartaWrapper wrapper) { + return (jakarta.servlet.http.HttpServletResponse) wrapper.getJakarta(); } + + return null; } - private URLSecurityManager getURLSecurityManager() + // XWikiResponse + + @Override + public HttpServletResponse getHttpServletResponse() { - return Utils.getComponent(URLSecurityManager.class); + return (HttpServletResponse) getResponse(); } public void addCookie(String cookieName, String cookieValue, int age) diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiServletResponseStub.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiServletResponseStub.java index 5aa18a4c4b24..54e9cda868d7 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiServletResponseStub.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiServletResponseStub.java @@ -19,264 +19,72 @@ */ package com.xpn.xwiki.web; -import java.io.IOException; import java.io.OutputStream; -import java.io.PrintWriter; -import java.util.Collection; -import java.util.Locale; -import javax.servlet.ServletOutputStream; -import javax.servlet.WriteListener; -import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpServletResponseWrapper; + +import org.xwiki.container.Container; +import org.xwiki.container.servlet.HttpServletResponseStub; +import org.xwiki.jakartabridge.JavaxToJakartaWrapper; +import org.xwiki.jakartabridge.servlet.JakartaServletBridge; +import org.xwiki.stability.Unstable; /** * This stub is intended to simulate a servlet request in a daemon context, in order to be able to create a custom XWiki * context. This trick is used in to give a daemon thread access to the XWiki api. * * @version $Id$ + * @deprecated use the {@link Container} API instead */ -public class XWikiServletResponseStub implements XWikiResponse +// TODO: uncomment the annotation when XWiki Standard scripts are fully migrated to the new API +// @Deprecated(since = "42.0.0") +public class XWikiServletResponseStub extends HttpServletResponseWrapper + implements XWikiResponse, JavaxToJakartaWrapper { - private OutputStream outputStream; - - private ServletOutputStream servletOutputStream = new ServletOutputStream() - { - @Override - public void write(int b) throws IOException - { - if (XWikiServletResponseStub.this.outputStream != null) { - XWikiServletResponseStub.this.outputStream.write(b); - } - } - - @Override - public boolean isReady() - { - return true; - } - - @Override - public void setWriteListener(WriteListener writeListener) - { - // Not needed - } - }; - - public void setOutpuStream(OutputStream outputStream) - { - this.outputStream = outputStream; - } - - @Override - public HttpServletResponse getHttpServletResponse() - { - return null; - } - - @Override - public void setCharacterEncoding(String s) + public XWikiServletResponseStub() { + this(new HttpServletResponseStub()); } - @Override - public void removeCookie(String cookieName, XWikiRequest request) - { - } - - @Override - public void addCookie(Cookie cookie) - { - } - - @Override - public boolean containsHeader(String name) + /** + * @param jakarta the request wrap + * @since 42.0.0 + */ + @Unstable + public XWikiServletResponseStub(HttpServletResponseStub jakarta) { - return false; + super(JakartaServletBridge.toJavax(jakarta)); } - @Override - public String encodeURL(String url) - { - return url; - } - - @Override - public String encodeRedirectURL(String url) - { - return url; - } - - @Override - public String encodeUrl(String url) - { - return url; - } - - @Override - public String encodeRedirectUrl(String url) - { - return url; - } - - @Override - public void sendError(int sc, String msg) throws IOException - { - } - - @Override - public void sendError(int sc) throws IOException - { - } - - @Override - public void sendRedirect(String location) throws IOException - { - } - - @Override - public void setDateHeader(String name, long date) - { - } - - @Override - public void addDateHeader(String name, long date) - { - } - - @Override - public void setHeader(String name, String value) - { - } - - @Override - public void addHeader(String name, String value) - { - } - - @Override - public void setIntHeader(String name, int value) - { - } - - @Override - public void addIntHeader(String name, int value) - { - } - - @Override - public void setStatus(int sc) - { - } - - @Override - public void setStatus(int sc, String sm) - { - } - - @Override - public String getCharacterEncoding() - { - return null; - } - - @Override - public String getContentType() - { - return null; - } - - @Override - public ServletOutputStream getOutputStream() throws IOException - { - return this.servletOutputStream; - } - - @Override - public PrintWriter getWriter() throws IOException - { - return null; - } - - @Override - public void setContentLength(int len) - { - } - - @Override - public void setContentLengthLong(long len) - { - } - - @Override - public void setContentType(String type) - { - } - - @Override - public void setBufferSize(int size) - { - } - - @Override - public int getBufferSize() - { - return 0; - } - - @Override - public void flushBuffer() throws IOException - { - } - - @Override - public void resetBuffer() - { - } - - @Override - public boolean isCommitted() + public void setOutpuStream(OutputStream outputStream) { - return false; + getJakarta().setOutpuStream(outputStream); } - @Override - public void reset() - { - } + // JavaxToJakartaWrapper @Override - public void setLocale(Locale loc) + public HttpServletResponseStub getJakarta() { - } + if (getResponse() instanceof JavaxToJakartaWrapper wrapper) { + return (HttpServletResponseStub) wrapper.getJakarta(); + } - @Override - public Locale getLocale() - { return null; } - @Override - public int getStatus() - { - return 0; - } + // XWikiResponse @Override - public String getHeader(String s) + public HttpServletResponse getHttpServletResponse() { - return null; + return this; } @Override - public Collection getHeaders(String s) + public void removeCookie(String cookieName, XWikiRequest request) { - return null; - } - @Override - public Collection getHeaderNames() - { - return null; } } diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiServletURLFactory.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiServletURLFactory.java index d2c852bce1d0..223acb09ba24 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiServletURLFactory.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/web/XWikiServletURLFactory.java @@ -54,6 +54,7 @@ import com.xpn.xwiki.doc.XWikiAttachment; import com.xpn.xwiki.doc.XWikiDocument; +@Deprecated(since = "42.0.0") public class XWikiServletURLFactory extends XWikiDefaultURLFactory { private static final Logger LOGGER = LoggerFactory.getLogger(XWikiServletURLFactory.class); diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/org/xwiki/internal/script/XWikiScriptContextInitializer.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/org/xwiki/internal/script/XWikiScriptContextInitializer.java index f1f0353f45c4..8940096f91ca 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/org/xwiki/internal/script/XWikiScriptContextInitializer.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/org/xwiki/internal/script/XWikiScriptContextInitializer.java @@ -37,6 +37,7 @@ import com.xpn.xwiki.api.XWiki; import com.xpn.xwiki.doc.XWikiDocument; import com.xpn.xwiki.render.ScriptXWikiServletRequest; +import com.xpn.xwiki.render.ScriptXWikiServletResponse; /** * Inject in the {@link ScriptContext} the XWiki context and the {@link XWiki} instance for backward compatibility. @@ -83,9 +84,14 @@ public void initialize(ScriptContext scriptContext) // It's safe to overwrite the following bindings because they don't have a real state. Moreover the request and // the response objects from the XWiki context can be replaced so the script bindings have to be synchronized. - scriptContext.setAttribute("request", new ScriptXWikiServletRequest(xcontext.getRequest(), this.authorization), - ScriptContext.ENGINE_SCOPE); - scriptContext.setAttribute("response", xcontext.getResponse(), ScriptContext.ENGINE_SCOPE); + if (xcontext.getRequest() != null) { + scriptContext.setAttribute("request", + new ScriptXWikiServletRequest(xcontext.getRequest(), this.authorization), ScriptContext.ENGINE_SCOPE); + } + if (xcontext.getResponse() != null) { + scriptContext.setAttribute("response", new ScriptXWikiServletResponse(xcontext.getResponse()), + ScriptContext.ENGINE_SCOPE); + } // Current document Document docAPI = null; diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/org/xwiki/store/TemporaryAttachmentSessionsManager.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/org/xwiki/store/TemporaryAttachmentSessionsManager.java index 8c6796540721..ddc73cdb50b0 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/org/xwiki/store/TemporaryAttachmentSessionsManager.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/org/xwiki/store/TemporaryAttachmentSessionsManager.java @@ -23,12 +23,14 @@ import java.util.List; import java.util.Optional; -import javax.servlet.http.Part; +import jakarta.servlet.http.Part; import org.xwiki.attachment.validation.AttachmentValidationException; import org.xwiki.component.annotation.Role; +import org.xwiki.jakartabridge.servlet.JakartaServletBridge; import org.xwiki.model.reference.AttachmentReference; import org.xwiki.model.reference.DocumentReference; +import org.xwiki.stability.Unstable; import com.xpn.xwiki.doc.XWikiAttachment; import com.xpn.xwiki.doc.XWikiDocument; @@ -39,7 +41,7 @@ * The idea of this API is to allow obtaining directly a temporary {@link XWikiAttachment} from a {@link Part} and to * keep it in cache until it's saved. *

- * The manager is handling a separated map of attachments for each {@link javax.servlet.http.HttpSession}. + * The manager is handling a separated map of attachments for each {@link jakarta.servlet.http.HttpSession}. * * @version $Id$ * @since 14.3RC1 @@ -57,9 +59,33 @@ public interface TemporaryAttachmentSessionsManager * @throws TemporaryAttachmentException in case of problem when reading the part * @throws AttachmentValidationException in case of error when validating the attachment (e.g., the maximum filesize * is reached) + * @deprecated use {@link #uploadAttachment(DocumentReference, Part)} instead */ - XWikiAttachment uploadAttachment(DocumentReference documentReference, Part part) - throws TemporaryAttachmentException, AttachmentValidationException; + @Deprecated(since = "42.0.0") + default XWikiAttachment uploadAttachment(DocumentReference documentReference, javax.servlet.http.Part part) + throws TemporaryAttachmentException, AttachmentValidationException + { + return uploadAttachment(documentReference, part, null); + } + + /** + * Temporary store the given {@link Part} to a cached {@link XWikiAttachment} attached to the given + * {@link DocumentReference}. + * + * @param documentReference the reference of the document that the attachment should be attached to. + * @param part the actual data that is uploaded. + * @return an attachment that is not saved yet but cached and contains the data of the given part. + * @throws TemporaryAttachmentException in case of problem when reading the part + * @throws AttachmentValidationException in case of error when validating the attachment (e.g., the maximum filesize + * is reached) + * @since 42.0.0 + */ + @Unstable + default XWikiAttachment uploadAttachment(DocumentReference documentReference, Part part) + throws TemporaryAttachmentException, AttachmentValidationException + { + return uploadAttachment(documentReference, part, null); + } /** * Temporary store the given {@link Part} to a cached {@link XWikiAttachment} attached to the given @@ -74,10 +100,33 @@ XWikiAttachment uploadAttachment(DocumentReference documentReference, Part part) * @throws AttachmentValidationException in case of error when validating the attachment (e.g., the maximum filesize * is reached) * @since 14.9RC1 + * @deprecated use {@link #uploadAttachment(DocumentReference, Part, String)} instead */ - XWikiAttachment uploadAttachment(DocumentReference documentReference, Part part, String filename) + @Deprecated(since = "42.0.0") + XWikiAttachment uploadAttachment(DocumentReference documentReference, javax.servlet.http.Part part, String filename) throws TemporaryAttachmentException, AttachmentValidationException; + /** + * Temporary store the given {@link Part} to a cached {@link XWikiAttachment} attached to the given + * {@link DocumentReference}. + * + * @param documentReference the reference of the document that the attachment should be attached to + * @param part the actual data that is uploaded + * @param filename an optional filename used instead of using {@link Part#getSubmittedFileName()}, ignored when + * {@code null} or blank + * @return an attachment that is not saved yet but cached and contains the data of the given part + * @throws TemporaryAttachmentException in case of problem when reading the part + * @throws AttachmentValidationException in case of error when validating the attachment (e.g., the maximum filesize + * is reached) + * @since 42.0.0 + */ + @Unstable + default XWikiAttachment uploadAttachment(DocumentReference documentReference, Part part, String filename) + throws TemporaryAttachmentException, AttachmentValidationException + { + return uploadAttachment(documentReference, JakartaServletBridge.toJavax(part), filename); + } + /** * Allow to temporarily attach the given instance of {@link XWikiAttachment} to the given document reference. *

diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/test/java/com/xpn/xwiki/internal/context/XWikiContextContextStoreTest.java b/xwiki-platform-core/xwiki-platform-oldcore/src/test/java/com/xpn/xwiki/internal/context/XWikiContextContextStoreTest.java index 3cf45f15ba4d..af3345082597 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/test/java/com/xpn/xwiki/internal/context/XWikiContextContextStoreTest.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/test/java/com/xpn/xwiki/internal/context/XWikiContextContextStoreTest.java @@ -63,6 +63,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotSame; import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; @@ -182,7 +183,7 @@ void saveAndRestoreRequest() throws Exception assertEquals(headers, contextStore.get(XWikiContextContextStore.PROP_REQUEST_HEADERS)); assertEquals("172.12.0.2", contextStore.get(XWikiContextContextStore.PROP_REQUEST_REMOTE_ADDR)); - assertEquals(session, + assertSame(session, ((SerializableHttpSessionWrapper) contextStore.get(XWikiContextContextStore.PROP_REQUEST_SESSION)) .getSession()); diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/test/java/com/xpn/xwiki/test/AbstractBridgedComponentTestCase.java b/xwiki-platform-core/xwiki-platform-oldcore/src/test/java/com/xpn/xwiki/test/AbstractBridgedComponentTestCase.java index df69c6bd7b38..194c2e7d3484 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/test/java/com/xpn/xwiki/test/AbstractBridgedComponentTestCase.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/test/java/com/xpn/xwiki/test/AbstractBridgedComponentTestCase.java @@ -103,7 +103,7 @@ public void setUp() throws Exception will(returnValue(null)); allowing(mockServletContext).getResourceAsStream("/WEB-INF/xwiki.cfg"); will(returnValue(null)); - allowing(mockServletContext).getAttribute("javax.servlet.context.tempdir"); + allowing(mockServletContext).getAttribute("jakarta.servlet.context.tempdir"); will(returnValue(new File(System.getProperty("java.io.tmpdir")))); }}); diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/test/java/com/xpn/xwiki/test/MockitoOldcore.java b/xwiki-platform-core/xwiki-platform-oldcore/src/test/java/com/xpn/xwiki/test/MockitoOldcore.java index 903f5cfcfae5..ddcaf7fef44b 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/test/java/com/xpn/xwiki/test/MockitoOldcore.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/test/java/com/xpn/xwiki/test/MockitoOldcore.java @@ -528,11 +528,11 @@ public InputStream answer(InvocationOnMock invocation) throws Throwable // Also note that setting a non null request forces us to set a non null URL as otherwise it would lead // to another NPE... XWikiRequest originalRequest = getXWikiContext().getRequest(); - if (getXWikiContext().getRequest() == null) { + if (originalRequest == null) { getXWikiContext().setRequest(new XWikiServletRequestStub()); } URL originalURL = getXWikiContext().getURL(); - if (getXWikiContext().getURL() == null) { + if (originalURL == null) { getXWikiContext().setURL(new URL("http://localhost:8080")); } stubContextProvider.initialize(getXWikiContext()); diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/test/java/com/xpn/xwiki/web/ActionFilterTest.java b/xwiki-platform-core/xwiki-platform-oldcore/src/test/java/com/xpn/xwiki/web/ActionFilterTest.java index f5911a91b607..ec4f07d3049f 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/test/java/com/xpn/xwiki/web/ActionFilterTest.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/test/java/com/xpn/xwiki/web/ActionFilterTest.java @@ -19,10 +19,10 @@ */ package com.xpn.xwiki.web; -import javax.servlet.FilterChain; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.FilterChain; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; +import jakarta.servlet.http.HttpServletRequest; import org.junit.jupiter.api.Test; import org.xwiki.component.manager.ComponentManager; diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/test/java/com/xpn/xwiki/web/XWikiServletURLFactoryTest.java b/xwiki-platform-core/xwiki-platform-oldcore/src/test/java/com/xpn/xwiki/web/XWikiServletURLFactoryTest.java index d6b23470b3ae..ce48004ec3a0 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/test/java/com/xpn/xwiki/web/XWikiServletURLFactoryTest.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/test/java/com/xpn/xwiki/web/XWikiServletURLFactoryTest.java @@ -27,10 +27,15 @@ import java.util.Locale; import java.util.Map; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; +import org.xwiki.container.servlet.HttpServletRequestStub; +import org.xwiki.jakartabridge.servlet.JakartaServletBridge; import org.xwiki.model.reference.DocumentReference; import org.xwiki.model.reference.WikiReference; import org.xwiki.resource.internal.entity.EntityResourceActionLister; @@ -63,7 +68,7 @@ */ @OldcoreTest @ReferenceComponentList -public class XWikiServletURLFactoryTest +class XWikiServletURLFactoryTest { @MockComponent private WikiDescriptorManager descriptorManager; @@ -76,7 +81,7 @@ public class XWikiServletURLFactoryTest private XWikiServletURLFactory urlFactory; - private XWikiRequest mockXWikiRequest; + private HttpServletRequest mockHttpRequest; /** * Flag indicating if the request is secure. A request is secure if either its URL uses the HTTPS scheme or the @@ -103,12 +108,12 @@ public void beforeEach() throws Exception doReturn("DefaultSpace").when(this.oldcore.getSpyXWiki()).getDefaultSpace(any(XWikiContext.class)); // Request - this.mockXWikiRequest = mock(XWikiRequest.class); + this.mockHttpRequest = mock(); prepareMockRequest("127.0.0.1", -1); // Response - XWikiResponse xwikiResponse = mock(XWikiResponse.class); - when(xwikiResponse.encodeURL(any())).then(new Answer() + HttpServletResponse httpResponse = mock(); + when(httpResponse.encodeURL(any())).then(new Answer() { @Override public String answer(InvocationOnMock invocation) throws Throwable @@ -116,7 +121,8 @@ public String answer(InvocationOnMock invocation) throws Throwable return invocation.getArgument(0); } }); - this.oldcore.getXWikiContext().setResponse(xwikiResponse); + this.oldcore.getXWikiContext() + .setResponse(new XWikiServletResponse(JakartaServletBridge.toJavax(httpResponse))); // Create sub-wikis. createWiki("wiki1"); @@ -141,10 +147,10 @@ private void createWiki(String wikiName) throws XWikiException, WikiManagerExcep private void prepareMockRequest(String host, int port) { - when(this.mockXWikiRequest.getScheme()).thenReturn("http"); - when(this.mockXWikiRequest.getServerName()).thenReturn(host); - when(this.mockXWikiRequest.getServerPort()).thenReturn(port); - when(this.mockXWikiRequest.isSecure()).then(new Answer() + when(this.mockHttpRequest.getScheme()).thenReturn("http"); + when(this.mockHttpRequest.getServerName()).thenReturn(host); + when(this.mockHttpRequest.getServerPort()).thenReturn(port); + when(this.mockHttpRequest.isSecure()).then(new Answer() { @Override public Boolean answer(InvocationOnMock invocation) throws Throwable @@ -152,9 +158,9 @@ public Boolean answer(InvocationOnMock invocation) throws Throwable return secure; } }); - when(this.mockXWikiRequest.getServletPath()).thenReturn(""); - when(this.mockXWikiRequest.getContextPath()).thenReturn("/xwiki"); - when(this.mockXWikiRequest.getHeader(any())).then(new Answer() + when(this.mockHttpRequest.getServletPath()).thenReturn(""); + when(this.mockHttpRequest.getContextPath()).thenReturn("/xwiki"); + when(this.mockHttpRequest.getHeader(any())).then(new Answer() { @Override public String answer(InvocationOnMock invocation) throws Throwable @@ -162,7 +168,13 @@ public String answer(InvocationOnMock invocation) throws Throwable return httpHeaders.get(invocation.getArgument(0)); } }); - this.oldcore.getXWikiContext().setRequest(mockXWikiRequest); + XWikiRequest request; + if (this.mockHttpRequest instanceof HttpServletRequestStub httpServletStub) { + request = new XWikiServletRequestStub(httpServletStub); + } else { + request = new XWikiServletRequest(JakartaServletBridge.toJavax(this.mockHttpRequest)); + } + this.oldcore.getXWikiContext().setRequest(request); } private void initRequest(String host, int port) @@ -170,15 +182,13 @@ private void initRequest(String host, int port) prepareMockRequest(host, port); // Reinitialize the URL factory to take into account the new request URL. - urlFactory.init(this.oldcore.getXWikiContext()); + this.urlFactory.init(this.oldcore.getXWikiContext()); } private void initDaemonRequest(String host, int port) { - this.mockXWikiRequest = mock(XWikiServletRequestStub.class); - when(((XWikiServletRequestStub) this.mockXWikiRequest).isDaemon()).thenReturn(true); - when(((XWikiServletRequestStub) this.mockXWikiRequest).getHttpServletRequest()) - .thenReturn(this.mockXWikiRequest); + this.mockHttpRequest = mock(HttpServletRequestStub.class); + when(((HttpServletRequestStub) this.mockHttpRequest).isDaemon()).thenReturn(true); initRequest(host, port); } @@ -186,7 +196,7 @@ private void initDaemonRequest(String host, int port) // Tests @Test - public void createURLOnMainWiki() + void createURLOnMainWiki() { URL url = this.urlFactory.createURL("Space", "Page", "view", "param1=1", "anchor", "xwiki", this.oldcore.getXWikiContext()); @@ -194,7 +204,7 @@ public void createURLOnMainWiki() } @Test - public void createURLOnSubWiki() + void createURLOnSubWiki() { URL url = this.urlFactory.createURL("Space", "Page", "view", "param1=1", "anchor", "wiki1", this.oldcore.getXWikiContext()); @@ -202,7 +212,7 @@ public void createURLOnSubWiki() } @Test - public void createURLOnMainWikiInPathMode() + void createURLOnMainWikiInPathMode() { this.oldcore.getMockXWikiCfg().setProperty("xwiki.virtual.usepath", "1"); @@ -212,7 +222,7 @@ public void createURLOnMainWikiInPathMode() } @Test - public void createURLOnSubWikiInPathMode() throws MalformedURLException + void createURLOnSubWikiInPathMode() throws MalformedURLException { this.oldcore.getMockXWikiCfg().setProperty("xwiki.virtual.usepath", "1"); @@ -226,7 +236,7 @@ public void createURLOnSubWikiInPathMode() throws MalformedURLException } @Test - public void createURLOnSubWikiInPathModeDaemonThread() throws WikiManagerException + void createURLOnSubWikiInPathModeDaemonThread() throws WikiManagerException { this.oldcore.getMockXWikiCfg().setProperty("xwiki.virtual.usepath", "1"); initDaemonRequest("request", 8080); @@ -240,7 +250,7 @@ public void createURLOnSubWikiInPathModeDaemonThread() throws WikiManagerExcepti } @Test - public void createURLOnSubWikiFromSubWikiInPathMode() throws MalformedURLException + void createURLOnSubWikiFromSubWikiInPathMode() throws MalformedURLException { this.oldcore.getMockXWikiCfg().setProperty("xwiki.virtual.usepath", "1"); @@ -258,22 +268,22 @@ public void createURLOnSubWikiFromSubWikiInPathMode() throws MalformedURLExcepti } @Test - public void createSecureURLOnSubWikiInPathMode() + void createSecureURLOnSubWikiInPathMode() { this.oldcore.getMockXWikiCfg().setProperty("xwiki.virtual.usepath", "1"); - secure = true; + this.secure = true; initRequest("localhost", 8080); URL url = this.urlFactory.createURL("Space", "Page", "view", "param1=1", "anchor", "wiki1", this.oldcore.getXWikiContext()); assertEquals("https://localhost:8080/xwiki/wiki/wiki1server/view/Space/Page?param1=1#anchor", url.toString()); assertEquals("/xwiki/wiki/wiki1server/view/Space/Page?param1=1#anchor", - urlFactory.getURL(url, this.oldcore.getXWikiContext())); + this.urlFactory.getURL(url, this.oldcore.getXWikiContext())); } @Test - public void createURLOnMainWikiInDomainMode() + void createURLOnMainWikiInDomainMode() { this.oldcore.getMockXWikiCfg().setProperty("xwiki.virtual.usepath", "0"); @@ -283,7 +293,7 @@ public void createURLOnMainWikiInDomainMode() } @Test - public void createURLOnSubWikiInDomainMode() + void createURLOnSubWikiInDomainMode() { this.oldcore.getMockXWikiCfg().setProperty("xwiki.virtual.usepath", "0"); @@ -296,75 +306,75 @@ public void createURLOnSubWikiInDomainMode() * Checks the URLs created on the main wiki when XWiki is behind a reverse proxy. */ @Test - public void createURLOnMainWikiInDomainModeInReverseProxyMode() + void createURLOnMainWikiInDomainModeInReverseProxyMode() { - secure = true; - httpHeaders.put("x-forwarded-host", "www.xwiki.org"); + this.secure = true; + this.httpHeaders.put("x-forwarded-host", "www.xwiki.org"); // Reinitialize the URL factory to take into account the new security level and HTTP headers. - urlFactory.init(this.oldcore.getXWikiContext()); + this.urlFactory.init(this.oldcore.getXWikiContext()); this.oldcore.getMockXWikiCfg().setProperty("xwiki.virtual.usepath", "0"); - URL url = urlFactory.createURL("Space", "Page", "view", "param1=1", "anchor", "xwiki", + URL url = this.urlFactory.createURL("Space", "Page", "view", "param1=1", "anchor", "xwiki", this.oldcore.getXWikiContext()); assertEquals("https://www.xwiki.org/xwiki/bin/view/Space/Page?param1=1#anchor", url.toString()); assertEquals("/xwiki/bin/view/Space/Page?param1=1#anchor", - urlFactory.getURL(url, this.oldcore.getXWikiContext())); + this.urlFactory.getURL(url, this.oldcore.getXWikiContext())); } @Test - public void createURLOnSubWikiInDomainModeInReverseProxyMode() + void createURLOnSubWikiInDomainModeInReverseProxyMode() { - httpHeaders.put("x-forwarded-host", "www.xwiki.org"); + this.httpHeaders.put("x-forwarded-host", "www.xwiki.org"); // Reinitialize the URL factory to take into account the new HTTP headers. - urlFactory.init(this.oldcore.getXWikiContext()); + this.urlFactory.init(this.oldcore.getXWikiContext()); this.oldcore.getMockXWikiCfg().setProperty("xwiki.virtual.usepath", "0"); - URL url = urlFactory.createURL("Space", "Page", "view", "param1=1", "anchor", "wiki1", + URL url = this.urlFactory.createURL("Space", "Page", "view", "param1=1", "anchor", "wiki1", this.oldcore.getXWikiContext()); assertEquals("http://wiki1server/xwiki/bin/view/Space/Page?param1=1#anchor", url.toString()); // The URL remains absolute in this case. assertEquals("http://wiki1server/xwiki/bin/view/Space/Page?param1=1#anchor", - urlFactory.getURL(url, this.oldcore.getXWikiContext())); + this.urlFactory.getURL(url, this.oldcore.getXWikiContext())); } @Test - public void createURLOnSubWikiModeInDomainModeInReverseProxyMode() + void createURLOnSubWikiModeInDomainModeInReverseProxyMode() { - secure = true; - httpHeaders.put("x-forwarded-host", "www.xwiki.org"); + this.secure = true; + this.httpHeaders.put("x-forwarded-host", "www.xwiki.org"); // Reinitialize the URL factory to take into account the new security level and HTTP headers. - urlFactory.init(this.oldcore.getXWikiContext()); + this.urlFactory.init(this.oldcore.getXWikiContext()); this.oldcore.getMockXWikiCfg().setProperty("xwiki.virtual.usepath", "0"); - URL url = urlFactory.createURL("Space", "Page", "view", "param1=1", "anchor", "wiki1", + URL url = this.urlFactory.createURL("Space", "Page", "view", "param1=1", "anchor", "wiki1", this.oldcore.getXWikiContext()); assertEquals("http://wiki1server/xwiki/bin/view/Space/Page?param1=1#anchor", url.toString()); // The URL remains absolute in this case. assertEquals("http://wiki1server/xwiki/bin/view/Space/Page?param1=1#anchor", - urlFactory.getURL(url, this.oldcore.getXWikiContext())); + this.urlFactory.getURL(url, this.oldcore.getXWikiContext())); } @Test - public void createURLOnMainWikiInPathModeInReverseProxyMode() + void createURLOnMainWikiInPathModeInReverseProxyMode() { - httpHeaders.put("x-forwarded-host", "www.xwiki.org"); + this.httpHeaders.put("x-forwarded-host", "www.xwiki.org"); // Reinitialize the URL factory to take into account the new HTTP headers. - urlFactory.init(this.oldcore.getXWikiContext()); + this.urlFactory.init(this.oldcore.getXWikiContext()); this.oldcore.getMockXWikiCfg().setProperty("xwiki.virtual.usepath", "1"); - URL url = urlFactory.createURL("Space", "Page", "view", "param1=1", "anchor", "xwiki", + URL url = this.urlFactory.createURL("Space", "Page", "view", "param1=1", "anchor", "xwiki", this.oldcore.getXWikiContext()); assertEquals("http://www.xwiki.org/xwiki/bin/view/Space/Page?param1=1#anchor", url.toString()); assertEquals("/xwiki/bin/view/Space/Page?param1=1#anchor", - urlFactory.getURL(url, this.oldcore.getXWikiContext())); + this.urlFactory.getURL(url, this.oldcore.getXWikiContext())); } @Test - public void createURLOnSubWikiInPathModeInReverseProxyHost() + void createURLOnSubWikiInPathModeInReverseProxyHost() { secure = true; httpHeaders.put("x-forwarded-host", "www.xwiki.org"); @@ -381,7 +391,7 @@ public void createURLOnSubWikiInPathModeInReverseProxyHost() } @Test - public void createURLOnSubWikiModeInPathModeInReverseProxyHostPort() + void createURLOnSubWikiModeInPathModeInReverseProxyHostPort() { httpHeaders.put("x-forwarded-host", "www.xwiki.org:8080"); // Reinitialize the URL factory to take into account the new HTTP headers. @@ -398,7 +408,7 @@ public void createURLOnSubWikiModeInPathModeInReverseProxyHostPort() } @Test - public void createURLOnMainWikiInPathModeWithForcedProtocol() + void createURLOnMainWikiInPathModeWithForcedProtocol() { this.oldcore.getMockXWikiCfg().setProperty("xwiki.url.protocol", "https"); // Reinitialize the URL factory to take into account the configuration @@ -416,7 +426,7 @@ public void createURLOnMainWikiInPathModeWithForcedProtocol() * set from code on the XWiki context) are different. */ @Test - public void getURLWhenRequestWikiAndContextWikiAreDifferent() throws MalformedURLException + void getURLWhenRequestWikiAndContextWikiAreDifferent() throws MalformedURLException { initRequest("wiki1server", -1); @@ -431,9 +441,11 @@ public void getURLWhenRequestWikiAndContextWikiAreDifferent() throws MalformedUR assertEquals("http://wiki2server/xwiki/bin/view/Space/Page", url); } - /** When the URL contains only the hostname, without a path, / is returned instead of the empty string. */ + /** + * When the URL contains only the hostname, without a path, / is returned instead of the empty string. + */ @Test - public void getURLWithEmptyPathReturnsSlash() throws MalformedURLException + void getURLWithEmptyPathReturnsSlash() throws MalformedURLException { initRequest("wiki1server", -1); @@ -445,7 +457,7 @@ public void getURLWithEmptyPathReturnsSlash() throws MalformedURLException * Make sure the right reference URL used in daemon mode. */ @Test - public void getURLWhenDeamonRequest() throws MalformedURLException + void getURLWhenDeamonRequest() throws MalformedURLException { this.oldcore.getMockXWikiCfg().setProperty("xwiki.virtual.usepath", "0"); @@ -454,19 +466,19 @@ public void getURLWhenDeamonRequest() throws MalformedURLException this.oldcore.getXWikiContext().setWikiId("wiki1"); - assertEquals("/xwiki/bin/view/Space/Page", - urlFactory.getURL(new URL("http://wiki1server/xwiki/bin/view/Space/Page"), this.oldcore.getXWikiContext())); + assertEquals("/xwiki/bin/view/Space/Page", this.urlFactory + .getURL(new URL("http://wiki1server/xwiki/bin/view/Space/Page"), this.oldcore.getXWikiContext())); - assertEquals("http://wiki2server/xwiki/bin/view/Space/Page", - urlFactory.getURL(new URL("http://wiki2server/xwiki/bin/view/Space/Page"), this.oldcore.getXWikiContext())); + assertEquals("http://wiki2server/xwiki/bin/view/Space/Page", this.urlFactory + .getURL(new URL("http://wiki2server/xwiki/bin/view/Space/Page"), this.oldcore.getXWikiContext())); this.oldcore.getXWikiContext().setWikiId("wiki2"); - assertEquals("http://wiki1server/xwiki/bin/view/Space/Page", - urlFactory.getURL(new URL("http://wiki1server/xwiki/bin/view/Space/Page"), this.oldcore.getXWikiContext())); + assertEquals("http://wiki1server/xwiki/bin/view/Space/Page", this.urlFactory + .getURL(new URL("http://wiki1server/xwiki/bin/view/Space/Page"), this.oldcore.getXWikiContext())); - assertEquals("/xwiki/bin/view/Space/Page", - urlFactory.getURL(new URL("http://wiki2server/xwiki/bin/view/Space/Page"), this.oldcore.getXWikiContext())); + assertEquals("/xwiki/bin/view/Space/Page", this.urlFactory + .getURL(new URL("http://wiki2server/xwiki/bin/view/Space/Page"), this.oldcore.getXWikiContext())); } /** @@ -474,7 +486,7 @@ public void getURLWhenDeamonRequest() throws MalformedURLException * xwiki.home should be returned. see: XWIKI-5981 */ @Test - public void getServerURLFromSubWikiWithXWikiDotHomeEnabled() throws MalformedURLException + void getServerURLFromSubWikiWithXWikiDotHomeEnabled() throws MalformedURLException { // This is called by XWiki#getXWiki() and is set to whatever the user asks for. // The test sets it to "xwiki" which is wrong for this test. @@ -486,14 +498,14 @@ public void getServerURLFromSubWikiWithXWikiDotHomeEnabled() throws MalformedURL initRequest("virtual1.mywiki.tld", -1); assertEquals("http://mainwiki.mywiki.tld/", - urlFactory.getServerURL("xwiki", this.oldcore.getXWikiContext()).toString()); + this.urlFactory.getServerURL("xwiki", this.oldcore.getXWikiContext()).toString()); } /** * Proves that from a virtual wiki, URLs generated to point to the main wiki will use xwiki.home. see: XWIKI-5981 */ @Test - public void createURLWhenWikiDotHomeParameterFromSubWiki() + void createURLWhenWikiDotHomeParameterFromSubWiki() { this.oldcore.getXWikiContext().setWikiId("subwiki"); @@ -506,19 +518,19 @@ public void createURLWhenWikiDotHomeParameterFromSubWiki() initRequest("virtual1.mywiki.tld", -1); // No wiki passed, assume same wiki. we should expect it to return http://virtual1.mywiki.tld/ - URL url = - urlFactory.createURL("Space", "Page", "view", "param1=1", "anchor", null, this.oldcore.getXWikiContext()); + URL url = this.urlFactory.createURL("Space", "Page", "view", "param1=1", "anchor", null, + this.oldcore.getXWikiContext()); assertEquals("http://virtual1.mywiki.tld/xwiki/bin/view/Space/Page?param1=1#anchor", url.toString()); // We are already in virtual1 so it should be a relative reference. assertEquals("/xwiki/bin/view/Space/Page?param1=1#anchor", - urlFactory.getURL(url, this.oldcore.getXWikiContext())); + this.urlFactory.getURL(url, this.oldcore.getXWikiContext())); // Pass "xwiki" as the wiki, expect it to return the main wiki as set in the xwiki.home parameter. url = urlFactory.createURL("Space", "Page", "view", "param1=1", "anchor", "xwiki", this.oldcore.getXWikiContext()); assertEquals("http://mainwiki.mywiki.tld/xwiki/bin/view/Space/Page?param1=1#anchor", url.toString()); assertEquals("http://mainwiki.mywiki.tld/xwiki/bin/view/Space/Page?param1=1#anchor", - urlFactory.getURL(url, this.oldcore.getXWikiContext())); + this.urlFactory.getURL(url, this.oldcore.getXWikiContext())); } /** @@ -526,23 +538,23 @@ public void createURLWhenWikiDotHomeParameterFromSubWiki() * set, xwiki.home should be returned. see: XWIKI-5981 */ @Test - public void getServerURLWithXWikiDotHomeEnabled() throws MalformedURLException + void getServerURLWithXWikiDotHomeEnabled() throws MalformedURLException { this.oldcore.getMockXWikiCfg().setProperty("xwiki.home", "http://mainwiki.mywiki.tld/"); initRequest("localhost", 8080); // TODO: Fix getServerURL() so that is is consistent about returning a trailing / or not. assertEquals("http://mainwiki.mywiki.tld/", - urlFactory.getServerURL("xwiki", this.oldcore.getXWikiContext()).toString()); + this.urlFactory.getServerURL("xwiki", this.oldcore.getXWikiContext()).toString()); assertEquals("http://mainwiki.mywiki.tld/", - urlFactory.getServerURL(null, this.oldcore.getXWikiContext()).toString()); + this.urlFactory.getServerURL(null, this.oldcore.getXWikiContext()).toString()); } /** * Proves that in a single wiki instance, URLs are always generated using xwiki.home if present. see: XWIKI-5981 */ @Test - public void createURLWhenXWikiDotHomeParameterNonVirtualMode() + void createURLWhenXWikiDotHomeParameterNonVirtualMode() { // Some proxies will modify the host field without adding a x-forwarded-host field, // Using xwiki.home we should be able to make it work anyway. @@ -551,25 +563,25 @@ public void createURLWhenXWikiDotHomeParameterNonVirtualMode() // No wiki passed, assume main wiki. we should expect it to return mainwiki.mywiki.tld and not // xwiki.mywiki.tld. - URL url = - urlFactory.createURL("Space", "Page", "view", "param1=1", "anchor", null, this.oldcore.getXWikiContext()); + URL url = this.urlFactory.createURL("Space", "Page", "view", "param1=1", "anchor", null, + this.oldcore.getXWikiContext()); assertEquals("http://mainwiki.mywiki.tld/xwiki/bin/view/Space/Page?param1=1#anchor", url.toString()); assertEquals("/xwiki/bin/view/Space/Page?param1=1#anchor", - urlFactory.getURL(url, this.oldcore.getXWikiContext())); + this.urlFactory.getURL(url, this.oldcore.getXWikiContext())); // Pass "xwiki" as the wiki, expect same result. - url = urlFactory.createURL("Space", "Page", "view", "param1=1", "anchor", "xwiki", + url = this.urlFactory.createURL("Space", "Page", "view", "param1=1", "anchor", "xwiki", this.oldcore.getXWikiContext()); assertEquals("http://mainwiki.mywiki.tld/xwiki/bin/view/Space/Page?param1=1#anchor", url.toString()); assertEquals("/xwiki/bin/view/Space/Page?param1=1#anchor", - urlFactory.getURL(url, this.oldcore.getXWikiContext())); + this.urlFactory.getURL(url, this.oldcore.getXWikiContext())); } /** * Verify that jsessionid is removed from URL. */ @Test - public void normalizeURL() throws MalformedURLException + void normalizeURL() throws MalformedURLException { assertEquals("http://www.xwiki.org/xwiki/bin/view/Blog/Bug+Fixing+Day+35?language=en", XWikiServletURLFactory @@ -579,7 +591,7 @@ public void normalizeURL() throws MalformedURLException } @Test - public void createURLWithNestedSpaces() + void createURLWithNestedSpaces() { URL url = this.urlFactory.createURL("Space1.Space2", "Page", this.oldcore.getXWikiContext()); assertEquals("http://127.0.0.1/xwiki/bin/view/Space1/Space2/Page", url.toString()); @@ -589,7 +601,7 @@ public void createURLWithNestedSpaces() * Check that if the attachment cannot be found a URL is still created with the right schema. */ @Test - public void createAttachmentURLFileNotAvailable() + void createAttachmentURLFileNotAvailable() { XWikiContext xwikiContext = this.oldcore.getXWikiContext(); xwikiContext.setDoc(new XWikiDocument(new DocumentReference("xwiki", "currentspace", "currentpage"))); @@ -602,7 +614,7 @@ public void createAttachmentURLFileNotAvailable() * Check that the version of the attachment is looked for to create the URL */ @Test - public void createAttachmentURLFindRev() + void createAttachmentURLFindRev() { XWikiContext xwikiContext = this.oldcore.getXWikiContext(); XWikiDocument doc = new XWikiDocument(new DocumentReference("xwiki", "currentspace", "currentpage")); @@ -619,7 +631,7 @@ public void createAttachmentURLFindRev() * Checked that the nested spaces are correctly resolved for creating the URL */ @Test - public void createAttachmentURLFindRevNestedSpace() + void createAttachmentURLFindRevNestedSpace() { XWikiContext xwikiContext = this.oldcore.getXWikiContext(); XWikiDocument doc = new XWikiDocument( @@ -638,7 +650,7 @@ public void createAttachmentURLFindRevNestedSpace() * Checked that the context doc is taken into account for finding the attachment to create the URL */ @Test - public void createAttachmentURLFindRevAnotherContextDoc() throws XWikiException, WikiManagerException + void createAttachmentURLFindRevAnotherContextDoc() throws XWikiException, WikiManagerException { XWikiContext xwikiContext = this.oldcore.getXWikiContext(); XWikiDocument contextDoc = new XWikiDocument(new DocumentReference("xwiki", "currentspace", "currentpage")); @@ -671,7 +683,7 @@ public void createAttachmentURLFindRevAnotherContextDoc() throws XWikiException, * Checked that the translation is not mixed up with the document for getting the URL */ @Test - public void createAttachmentURLFindRevNestedSpaceTranslation() throws XWikiException + void createAttachmentURLFindRevNestedSpaceTranslation() throws XWikiException { XWikiContext xwikiContext = this.oldcore.getXWikiContext(); XWikiDocument contextDoc = new XWikiDocument( @@ -693,7 +705,7 @@ public void createAttachmentURLFindRevNestedSpaceTranslation() throws XWikiExcep } @Test - public void createAttachmentURLWhenViewRevAndRevSpecifiedAndIsNotContextDoc() + void createAttachmentURLWhenViewRevAndRevSpecifiedAndIsNotContextDoc() { XWikiContext xwikiContext = this.oldcore.getXWikiContext(); xwikiContext.put("rev", "1.0"); @@ -703,8 +715,7 @@ public void createAttachmentURLWhenViewRevAndRevSpecifiedAndIsNotContextDoc() } @Test - public void createAttachmentURLWhenViewRevAndRevSpecifiedAndIsContextDocAndAttachmentDoesntExist() - throws XWikiException + void createAttachmentURLWhenViewRevAndRevSpecifiedAndIsContextDocAndAttachmentDoesntExist() throws XWikiException { XWikiContext xwikiContext = this.oldcore.getXWikiContext(); xwikiContext.put("rev", "1.0"); @@ -721,7 +732,7 @@ public void createAttachmentURLWhenViewRevAndRevSpecifiedAndIsContextDocAndAttac } @Test - public void createURLWhenShowViewActionFalse() + void createURLWhenShowViewActionFalse() { doReturn(false).when(this.oldcore.getSpyXWiki()).showViewAction(any(XWikiContext.class)); @@ -730,7 +741,7 @@ public void createURLWhenShowViewActionFalse() } @Test - public void createURLWhenShowViewActionFalseAndSpaceIsNamedAfterAnAction() + void createURLWhenShowViewActionFalseAndSpaceIsNamedAfterAnAction() { doReturn(false).when(this.oldcore.getSpyXWiki()).showViewAction(any(XWikiContext.class)); @@ -739,7 +750,7 @@ public void createURLWhenShowViewActionFalseAndSpaceIsNamedAfterAnAction() } @Test - public void createResourceURL() + void createResourceURL() { // Verify that the URL factory encodes each path segment. URL url = this.urlFactory.createResourceURL("o;ne/t?w&o/t=hr#e e", false, this.oldcore.getXWikiContext()); @@ -768,7 +779,7 @@ public String toString() } @Test - public void createURLWhenCharactersNeedToBeEncoded() throws Exception + void createURLWhenCharactersNeedToBeEncoded() throws Exception { // Note: The query string is not encoded, and used as is. It's the responsibility of the caller to // url-encode it. diff --git a/xwiki-platform-core/xwiki-platform-ratings/xwiki-platform-ratings-api/pom.xml b/xwiki-platform-core/xwiki-platform-ratings/xwiki-platform-ratings-api/pom.xml index 5bc39ad3ddd1..22ea7520b17c 100644 --- a/xwiki-platform-core/xwiki-platform-ratings/xwiki-platform-ratings-api/pom.xml +++ b/xwiki-platform-core/xwiki-platform-ratings/xwiki-platform-ratings-api/pom.xml @@ -68,8 +68,8 @@ - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test diff --git a/xwiki-platform-core/xwiki-platform-realtime/xwiki-platform-realtime-api/pom.xml b/xwiki-platform-core/xwiki-platform-realtime/xwiki-platform-realtime-api/pom.xml index 58dc8f4302ce..bedc6fb965e1 100644 --- a/xwiki-platform-core/xwiki-platform-realtime/xwiki-platform-realtime-api/pom.xml +++ b/xwiki-platform-core/xwiki-platform-realtime/xwiki-platform-realtime-api/pom.xml @@ -67,8 +67,8 @@ test - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test diff --git a/xwiki-platform-core/xwiki-platform-realtime/xwiki-platform-realtime-wiki/xwiki-platform-realtime-wiki-test/xwiki-platform-realtime-wiki-test-docker/pom.xml b/xwiki-platform-core/xwiki-platform-realtime/xwiki-platform-realtime-wiki/xwiki-platform-realtime-wiki-test/xwiki-platform-realtime-wiki-test-docker/pom.xml index 86a06f99a12b..eb15fc16c538 100644 --- a/xwiki-platform-core/xwiki-platform-realtime/xwiki-platform-realtime-wiki/xwiki-platform-realtime-wiki-test/xwiki-platform-realtime-wiki-test-docker/pom.xml +++ b/xwiki-platform-core/xwiki-platform-realtime/xwiki-platform-realtime-wiki/xwiki-platform-realtime-wiki-test/xwiki-platform-realtime-wiki-test-docker/pom.xml @@ -76,8 +76,13 @@ - javax.websocket - javax.websocket-api + jakarta.websocket + jakarta.websocket-api + test + + + jakarta.websocket + jakarta.websocket-client-api test diff --git a/xwiki-platform-core/xwiki-platform-realtime/xwiki-platform-realtime-wysiwyg/xwiki-platform-realtime-wysiwyg-test/xwiki-platform-realtime-wysiwyg-test-docker/pom.xml b/xwiki-platform-core/xwiki-platform-realtime/xwiki-platform-realtime-wysiwyg/xwiki-platform-realtime-wysiwyg-test/xwiki-platform-realtime-wysiwyg-test-docker/pom.xml index 6b5ad23a3de3..4f4feb9ce08a 100644 --- a/xwiki-platform-core/xwiki-platform-realtime/xwiki-platform-realtime-wysiwyg/xwiki-platform-realtime-wysiwyg-test/xwiki-platform-realtime-wysiwyg-test-docker/pom.xml +++ b/xwiki-platform-core/xwiki-platform-realtime/xwiki-platform-realtime-wysiwyg/xwiki-platform-realtime-wysiwyg-test/xwiki-platform-realtime-wysiwyg-test-docker/pom.xml @@ -107,8 +107,13 @@ - javax.websocket - javax.websocket-api + jakarta.websocket + jakarta.websocket-api + test + + + jakarta.websocket + jakarta.websocket-client-api test diff --git a/xwiki-platform-core/xwiki-platform-refactoring/xwiki-platform-refactoring-default/pom.xml b/xwiki-platform-core/xwiki-platform-refactoring/xwiki-platform-refactoring-default/pom.xml index 41eb0796129d..0f554ab797bf 100644 --- a/xwiki-platform-core/xwiki-platform-refactoring/xwiki-platform-refactoring-default/pom.xml +++ b/xwiki-platform-core/xwiki-platform-refactoring/xwiki-platform-refactoring-default/pom.xml @@ -62,11 +62,6 @@ - - javax.servlet - javax.servlet-api - test - org.xwiki.commons xwiki-commons-tool-test-component diff --git a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-async/xwiki-platform-rendering-async-macro/pom.xml b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-async/xwiki-platform-rendering-async-macro/pom.xml index e31dadcfca06..ecc5f6b01afa 100644 --- a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-async/xwiki-platform-rendering-async-macro/pom.xml +++ b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-async/xwiki-platform-rendering-async-macro/pom.xml @@ -83,13 +83,13 @@ test - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test - org.mortbay.jasper - apache-el + org.glassfish.expressly + expressly test diff --git a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-macros/pom.xml b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-macros/pom.xml index db832cbe801c..b366511f7f8b 100644 --- a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-macros/pom.xml +++ b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-macros/pom.xml @@ -64,8 +64,8 @@ test - org.mortbay.jasper - apache-el + org.glassfish.expressly + expressly test diff --git a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-macros/xwiki-platform-rendering-macro-context/pom.xml b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-macros/xwiki-platform-rendering-macro-context/pom.xml index 9be0338eeed4..d8d6d53827e1 100644 --- a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-macros/xwiki-platform-rendering-macro-context/pom.xml +++ b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-macros/xwiki-platform-rendering-macro-context/pom.xml @@ -69,13 +69,13 @@ test - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test - org.mortbay.jasper - apache-el + org.glassfish.expressly + expressly test diff --git a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-wikimacro/xwiki-platform-rendering-wikimacro-store/pom.xml b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-wikimacro/xwiki-platform-rendering-wikimacro-store/pom.xml index 3b8b1e96e568..358f7161d66e 100644 --- a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-wikimacro/xwiki-platform-rendering-wikimacro-store/pom.xml +++ b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-wikimacro/xwiki-platform-rendering-wikimacro-store/pom.xml @@ -162,14 +162,8 @@ test - org.mortbay.jasper - apache-el - test - - - - org.jmock - jmock-legacy + org.glassfish.expressly + expressly test diff --git a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/pom.xml b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/pom.xml index eac7695c6941..a4c616ae0186 100644 --- a/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/pom.xml +++ b/xwiki-platform-core/xwiki-platform-rendering/xwiki-platform-rendering-xwiki/pom.xml @@ -118,6 +118,20 @@ test-jar test + + org.apache.httpcomponents + httpclient + + + org.xwiki.platform + xwiki-platform-icon-api + ${project.version} + + + org.xwiki.platform + xwiki-platform-localization-api + ${project.version} + diff --git a/xwiki-platform-core/xwiki-platform-resource/xwiki-platform-resource-servlet/pom.xml b/xwiki-platform-core/xwiki-platform-resource/xwiki-platform-resource-servlet/pom.xml index 94cfb9a1fd30..b2604563a77a 100644 --- a/xwiki-platform-core/xwiki-platform-resource/xwiki-platform-resource-servlet/pom.xml +++ b/xwiki-platform-core/xwiki-platform-resource/xwiki-platform-resource-servlet/pom.xml @@ -48,10 +48,11 @@ xwiki-platform-tika-detect ${project.version} - - javax.servlet - javax.servlet-api + + jakarta.servlet + jakarta.servlet-api + org.xwiki.commons diff --git a/xwiki-platform-core/xwiki-platform-resource/xwiki-platform-resource-servlet/src/main/java/org/xwiki/resource/servlet/AbstractServletResourceReferenceHandler.java b/xwiki-platform-core/xwiki-platform-resource/xwiki-platform-resource-servlet/src/main/java/org/xwiki/resource/servlet/AbstractServletResourceReferenceHandler.java index 7cdb6d3004be..2ea3d0e7cb2b 100644 --- a/xwiki-platform-core/xwiki-platform-resource/xwiki-platform-resource-servlet/src/main/java/org/xwiki/resource/servlet/AbstractServletResourceReferenceHandler.java +++ b/xwiki-platform-core/xwiki-platform-resource/xwiki-platform-resource-servlet/src/main/java/org/xwiki/resource/servlet/AbstractServletResourceReferenceHandler.java @@ -27,8 +27,8 @@ import java.util.Date; import java.util.Objects; -import javax.inject.Inject; -import javax.servlet.http.HttpServletResponse; +import jakarta.inject.Inject; +import jakarta.servlet.http.HttpServletResponse; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; @@ -122,18 +122,19 @@ private boolean shouldBrowserUseCachedContent(R resourceReference) // If the request contains an "If-Modified-Since" header and the requested resource has not been modified then // return a 304 Not Modified to tell the browser to use its cached version. Request request = this.container.getRequest(); - if (request instanceof ServletRequest - && ((ServletRequest) request).getHttpServletRequest().getHeader("If-Modified-Since") != null - && isResourceCacheable(resourceReference)) - { + if (request instanceof ServletRequest servletRequest + && servletRequest.getRequest().getHeader("If-Modified-Since") != null + && isResourceCacheable(resourceReference)) { // The user probably used F5 to reload the page and the browser checks if there are changes. Response response = this.container.getResponse(); - if (response instanceof ServletResponse) { + if (response instanceof ServletResponse servletResponse) { // Return the 304 Not Modified. - ((ServletResponse) response).getHttpServletResponse().setStatus(HttpServletResponse.SC_NOT_MODIFIED); + servletResponse.getResponse().setStatus(HttpServletResponse.SC_NOT_MODIFIED); + return true; } } + return false; } @@ -169,7 +170,7 @@ private void serveResource(R resourceReference, InputStream rawResourceStream) throws ResourceReferenceHandlerException { InputStream resourceStream = rawResourceStream; - + // Make sure the resource stream supports mark & reset which is needed in order be able to detect the // content type without affecting the stream (Tika may need to read a few bytes from the start of the // stream, in which case it will mark & reset the stream). @@ -189,8 +190,8 @@ private void serveResource(R resourceReference, InputStream rawResourceStream) } /** - * Computes the content type of the resource. By default the content type is inferred by {@link - * TikaUtils#detect(InputStream, String)} based on the resource content and name. + * Computes the content type of the resource. By default the content type is inferred by + * {@link TikaUtils#detect(InputStream, String)} based on the resource content and name. * * @param resourceStream the stream of the requested resource * @param resourceReference the reference of the request resource @@ -198,8 +199,7 @@ private void serveResource(R resourceReference, InputStream rawResourceStream) * @throws IOException in case of error during the content type analysis * @since 13.3RC1 */ - protected String getContentType(InputStream resourceStream, R resourceReference) - throws IOException + protected String getContentType(InputStream resourceStream, R resourceReference) throws IOException { return TikaUtils.detect(resourceStream, getResourceName(resourceReference)); } @@ -228,7 +228,7 @@ private void setResponseHeaders(Response response, R resourceReference) if (!(response instanceof ServletResponse)) { return; } - HttpServletResponse httpResponse = ((ServletResponse) response).getHttpServletResponse(); + HttpServletResponse httpResponse = ((ServletResponse) response).getResponse(); // Cache the resource if possible. if (isResourceCacheable(resourceReference)) { @@ -288,8 +288,9 @@ private void sendError(int statusCode, String message, Object... parameters) throws ResourceReferenceHandlerException { Response response = this.container.getResponse(); - if (response instanceof ServletResponse) { - HttpServletResponse httpResponse = ((ServletResponse) response).getHttpServletResponse(); + if (response instanceof ServletResponse servletResponse) { + HttpServletResponse httpResponse = servletResponse.getResponse(); + try { httpResponse.sendError(statusCode, String.format(message, parameters)); } catch (IOException e) { diff --git a/xwiki-platform-core/xwiki-platform-resource/xwiki-platform-resource-servlet/src/main/java/org/xwiki/resource/servlet/ResourceReferenceHandlerServlet.java b/xwiki-platform-core/xwiki-platform-resource/xwiki-platform-resource-servlet/src/main/java/org/xwiki/resource/servlet/ResourceReferenceHandlerServlet.java index c0b733882a84..1c8bfedca946 100644 --- a/xwiki-platform-core/xwiki-platform-resource/xwiki-platform-resource-servlet/src/main/java/org/xwiki/resource/servlet/ResourceReferenceHandlerServlet.java +++ b/xwiki-platform-core/xwiki-platform-resource/xwiki-platform-resource-servlet/src/main/java/org/xwiki/resource/servlet/ResourceReferenceHandlerServlet.java @@ -23,10 +23,10 @@ import java.lang.reflect.Type; import java.util.Collections; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import org.xwiki.component.manager.ComponentLookupException; import org.xwiki.component.manager.ComponentManager; @@ -47,9 +47,12 @@ * add a new Resource Type in the XWiki URL simply needs to register a Handler component (of role * {@link org.xwiki.resource.ResourceReferenceHandler}) and any URL matching the corresponding {@link ResourceType} will * be handled. + *

+ * While the class is much older, the since annotation was moved to 42.0.0 because it implements a completely + * different API from Java point of view. * * @version $Id$ - * @since 7.1M1 + * @since 42.0.0 */ public class ResourceReferenceHandlerServlet extends HttpServlet { @@ -58,7 +61,7 @@ public class ResourceReferenceHandlerServlet extends HttpServlet */ private static final long serialVersionUID = 1L; - private ComponentManager rootComponentManager; + private transient ComponentManager rootComponentManager; @Override public void init() throws ServletException @@ -136,9 +139,7 @@ private void initializeContainerComponent(HttpServletRequest httpRequest, HttpSe throw new ServletException("Failed to locate a ServletContainerInitializer component", e); } try { - containerInitializer.initializeRequest(httpRequest); - containerInitializer.initializeResponse(httpResponse); - containerInitializer.initializeSession(httpRequest); + containerInitializer.initializeRequest(httpRequest, httpResponse); } catch (ServletContainerException e) { throw new ServletException("Failed to initialize Request/Response or Session", e); } diff --git a/xwiki-platform-core/xwiki-platform-resource/xwiki-platform-resource-servlet/src/main/java/org/xwiki/resource/servlet/RoutingFilter.java b/xwiki-platform-core/xwiki-platform-resource/xwiki-platform-resource-servlet/src/main/java/org/xwiki/resource/servlet/RoutingFilter.java index 96683321275a..b2fa1d1456f2 100644 --- a/xwiki-platform-core/xwiki-platform-resource/xwiki-platform-resource-servlet/src/main/java/org/xwiki/resource/servlet/RoutingFilter.java +++ b/xwiki-platform-core/xwiki-platform-resource/xwiki-platform-resource-servlet/src/main/java/org/xwiki/resource/servlet/RoutingFilter.java @@ -24,14 +24,14 @@ import java.net.URL; import java.util.Collections; -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletContext; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.Filter; +import jakarta.servlet.FilterChain; +import jakarta.servlet.FilterConfig; +import jakarta.servlet.ServletContext; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; +import jakarta.servlet.http.HttpServletRequest; import org.apache.commons.lang3.StringUtils; import org.xwiki.component.manager.ComponentLookupException; @@ -46,23 +46,26 @@ /** * Decides how to route an incoming URL into the XWiki system. There are various possibilities: *

    - *
  • If there's a registered component of type {@link org.xwiki.resource.ResourceReferenceHandler} matching the - * {@link ResourceType} passed in the URL (for example when using the {@code standard} URL scheme, the Resource - * Type is the segment path just after the Context Path, i.e. {@code bin} in - * {@code http:///xwiki/bin/view/Space/Page}), then the {@code resourceReferenceHandler} Servlet is - * called to handle it.
  • - *
  • If not, then continue executing the rest of the {@code web.xml} file, thus bridging to the old system, - * including the existing Struts Action Servlet.
  • + *
  • If there's a registered component of type {@link org.xwiki.resource.ResourceReferenceHandler} matching the + * {@link ResourceType} passed in the URL (for example when using the {@code standard} URL scheme, the Resource Type is + * the segment path just after the Context Path, i.e. {@code bin} in {@code http:///xwiki/bin/view/Space/Page}), + * then the {@code resourceReferenceHandler} Servlet is called to handle it.
  • + *
  • If not, then continue executing the rest of the {@code web.xml} file, thus bridging to the old system, including + * the existing Struts Action Servlet.
  • *
* As time progresses it is expected that more and more Resource Types will have registered * {@link org.xwiki.resource.ResourceReferenceHandler}. + *

+ * While the class is much older, the since annotation was moved to 42.0.0 because it implement a completely different + * API from Java point of view. * * @version $Id$ - * @since 7.1M1 + * @since 42.0.0 */ public class RoutingFilter implements Filter { static final String RESOURCE_TYPE_NAME = "resourceType"; + static final String RESOURCE_EXTENDEDURL = "resourceURL"; private ComponentManager rootComponentManager; @@ -169,8 +172,8 @@ private ResourceTypeResolver getResourceTypeResolver() throws Servl { ResourceTypeResolver urlResourceTypeResolver; try { - urlResourceTypeResolver = this.rootComponentManager.getInstance( - new DefaultParameterizedType(null, ResourceTypeResolver.class, ExtendedURL.class)); + urlResourceTypeResolver = this.rootComponentManager + .getInstance(new DefaultParameterizedType(null, ResourceTypeResolver.class, ExtendedURL.class)); } catch (ComponentLookupException e) { // Should not happen since an ExtendedURL Resource Type Resolver should exist on the system. throw new ServletException("Failed to locate an ExtendedURL Resource Type Resolver component", e); @@ -208,7 +211,8 @@ private URL getRequestURL(HttpServletRequest request) throws ServletException // Shouldn't happen normally! throw new ServletException( String.format("Failed to reconstruct URL from HTTP Servlet Request (URL [%s], Query String [%s])", - request.getRequestURL(), request.getQueryString()), e); + request.getRequestURL(), request.getQueryString()), + e); } return url; } diff --git a/xwiki-platform-core/xwiki-platform-rest/xwiki-platform-rest-jersey/pom.xml b/xwiki-platform-core/xwiki-platform-rest/xwiki-platform-rest-jersey/pom.xml index f1a9988d560b..ef902444587b 100644 --- a/xwiki-platform-core/xwiki-platform-rest/xwiki-platform-rest-jersey/pom.xml +++ b/xwiki-platform-core/xwiki-platform-rest/xwiki-platform-rest-jersey/pom.xml @@ -84,8 +84,17 @@ aopalliance - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api + + + javax.validation + validation-api + + + org.xwiki.commons + xwiki-commons-jakartabridge-servlet + ${commons.version} diff --git a/xwiki-platform-core/xwiki-platform-rest/xwiki-platform-rest-jersey/src/main/java/org/xwiki/rest/jersey/internal/JerseyServletContainer.java b/xwiki-platform-core/xwiki-platform-rest/xwiki-platform-rest-jersey/src/main/java/org/xwiki/rest/jersey/internal/JerseyServletContainer.java index 630611267ede..7794fe664f61 100644 --- a/xwiki-platform-core/xwiki-platform-rest/xwiki-platform-rest-jersey/src/main/java/org/xwiki/rest/jersey/internal/JerseyServletContainer.java +++ b/xwiki-platform-core/xwiki-platform-rest/xwiki-platform-rest-jersey/src/main/java/org/xwiki/rest/jersey/internal/JerseyServletContainer.java @@ -24,28 +24,32 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; -import javax.servlet.ServletContext; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServlet; +import jakarta.inject.Inject; +import jakarta.inject.Named; +import jakarta.inject.Singleton; +import jakarta.servlet.ServletContext; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; +import jakarta.servlet.http.HttpServlet; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.servlet.ServletContainer; import org.xwiki.component.annotation.Component; import org.xwiki.component.descriptor.ComponentDescriptor; import org.xwiki.component.manager.ComponentManager; +import org.xwiki.jakartabridge.servlet.JakartaServletBridge; import org.xwiki.rest.XWikiRestComponent; /** * Encapsulate the Jersey {@link ServletContainer} to control it's initialization and reload (when a REST component is * registered/unregistered). + *

+ * While the class is much older, the since annotation was moved to 42.0.0 because it implement a completely different + * API from Java point of view. * * @version $Id$ - * @since 16.2.0RC1 + * @since 42.0.0 */ @Component(roles = JerseyServletContainer.class) @Singleton @@ -66,7 +70,11 @@ public void init() throws ServletException { // Create and initialize the Jersey servlet ServletContainer newContainer = new ServletContainer(createResourceConfig()); - newContainer.init(getServletConfig()); + try { + newContainer.init(JakartaServletBridge.toJavax(getServletConfig())); + } catch (javax.servlet.ServletException e) { + throw new ServletException(e); + } // Remember the previous container ServletContainer previousContainer = this.container; @@ -128,7 +136,9 @@ public void service(ServletRequest req, ServletResponse res) throws ServletExcep try { // Execute the request - this.container.service(req, res); + this.container.service(JakartaServletBridge.toJavax(req), JakartaServletBridge.toJavax(res)); + } catch (javax.servlet.ServletException e) { + throw new ServletException(e); } finally { // Decrement the counter counter.decrementAndGet(); @@ -159,6 +169,6 @@ public void destroy() @Override public ServletContext getServletContext() { - return this.container.getServletContext(); + return JakartaServletBridge.toJakarta(this.container.getServletContext()); } } diff --git a/xwiki-platform-core/xwiki-platform-rest/xwiki-platform-rest-jersey/src/main/java/org/xwiki/rest/jersey/internal/XWikiRESTServlet.java b/xwiki-platform-core/xwiki-platform-rest/xwiki-platform-rest-jersey/src/main/java/org/xwiki/rest/jersey/internal/XWikiRESTServlet.java index b433c07cbc31..b441b6eb03dc 100644 --- a/xwiki-platform-core/xwiki-platform-rest/xwiki-platform-rest-jersey/src/main/java/org/xwiki/rest/jersey/internal/XWikiRESTServlet.java +++ b/xwiki-platform-core/xwiki-platform-rest/xwiki-platform-rest-jersey/src/main/java/org/xwiki/rest/jersey/internal/XWikiRESTServlet.java @@ -21,11 +21,11 @@ import java.io.IOException; -import javax.servlet.ServletContext; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServlet; +import jakarta.servlet.ServletContext; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; +import jakarta.servlet.http.HttpServlet; import org.glassfish.jersey.servlet.ServletContainer; import org.glassfish.jersey.servlet.ServletProperties; @@ -37,9 +37,12 @@ *

    *
  • Injection of XWikiResource components
  • *
+ *

+ * While the class is much older, the since annotation was moved to 42.0.0 because it implement a completely different + * API from Java point of view. * * @version $Id$ - * @since 16.2.0RC1 + * @since 42.0.0 */ public class XWikiRESTServlet extends HttpServlet { diff --git a/xwiki-platform-core/xwiki-platform-rest/xwiki-platform-rest-server/pom.xml b/xwiki-platform-core/xwiki-platform-rest/xwiki-platform-rest-server/pom.xml index cd3979e689ec..10bce2ca85c6 100644 --- a/xwiki-platform-core/xwiki-platform-rest/xwiki-platform-rest-server/pom.xml +++ b/xwiki-platform-core/xwiki-platform-rest/xwiki-platform-rest-server/pom.xml @@ -129,6 +129,10 @@ javax.servlet javax.servlet-api + + jakarta.servlet + jakarta.servlet-api + org.xwiki.platform diff --git a/xwiki-platform-core/xwiki-platform-scheduler/xwiki-platform-scheduler-api/pom.xml b/xwiki-platform-core/xwiki-platform-scheduler/xwiki-platform-scheduler-api/pom.xml index 941ed472f382..a76a34127aa0 100644 --- a/xwiki-platform-core/xwiki-platform-scheduler/xwiki-platform-scheduler-api/pom.xml +++ b/xwiki-platform-core/xwiki-platform-scheduler/xwiki-platform-scheduler-api/pom.xml @@ -46,21 +46,11 @@ org.quartz-scheduler quartz - - javax.servlet - javax.servlet-api - org.xwiki.platform - xwiki-platform-oldcore + xwiki-platform-test-oldcore ${project.version} - test-jar - test - - - org.xwiki.commons - xwiki-commons-tool-test-component - ${commons.version} + pom test diff --git a/xwiki-platform-core/xwiki-platform-search/xwiki-platform-search-solr/xwiki-platform-search-solr-api/pom.xml b/xwiki-platform-core/xwiki-platform-search/xwiki-platform-search-solr/xwiki-platform-search-solr-api/pom.xml index 337067b4f3c5..dcfb0d3f6d00 100644 --- a/xwiki-platform-core/xwiki-platform-search/xwiki-platform-search-solr/xwiki-platform-search-solr-api/pom.xml +++ b/xwiki-platform-core/xwiki-platform-search/xwiki-platform-search-solr/xwiki-platform-search-solr-api/pom.xml @@ -53,6 +53,11 @@ org.apache.solr solr-core + + + javax.validation + validation-api + org.apache.solr solr-analysis-extras @@ -134,11 +139,6 @@ ${commons.version} test - - javax.servlet - javax.servlet-api - test - org.xwiki.platform xwiki-platform-test-oldcore diff --git a/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-authentication/xwiki-platform-security-authentication-api/pom.xml b/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-authentication/xwiki-platform-security-authentication-api/pom.xml index aaa473590114..5d24fe83af51 100644 --- a/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-authentication/xwiki-platform-security-authentication-api/pom.xml +++ b/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-authentication/xwiki-platform-security-authentication-api/pom.xml @@ -77,8 +77,13 @@ ${project.version} - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api + + + org.xwiki.commons + xwiki-commons-jakartabridge-servlet + ${commons.version} diff --git a/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-authentication/xwiki-platform-security-authentication-api/src/main/java/org/xwiki/security/authentication/AuthenticationFailureManager.java b/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-authentication/xwiki-platform-security-authentication-api/src/main/java/org/xwiki/security/authentication/AuthenticationFailureManager.java index 33318e7dd175..8a3db61c99cd 100644 --- a/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-authentication/xwiki-platform-security-authentication-api/src/main/java/org/xwiki/security/authentication/AuthenticationFailureManager.java +++ b/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-authentication/xwiki-platform-security-authentication-api/src/main/java/org/xwiki/security/authentication/AuthenticationFailureManager.java @@ -19,10 +19,12 @@ */ package org.xwiki.security.authentication; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import org.xwiki.component.annotation.Role; +import org.xwiki.jakartabridge.servlet.JakartaServletBridge; import org.xwiki.model.reference.DocumentReference; +import org.xwiki.stability.Unstable; /** * Manager of the authentication failures strategies. @@ -35,12 +37,33 @@ public interface AuthenticationFailureManager { /** * Record that the given username fails to authenticate. + * * @param username the username that fails the authentication. Should be the username typed by the user and not a - * computed login. + * computed login. * @param request a wrapping of the request used for the authentication. * @return true if the authentication failure limits defined by the configuration has been reached. + * @deprecated use {@link #recordAuthenticationFailure(String, HttpServletRequest)} */ - boolean recordAuthenticationFailure(String username, HttpServletRequest request); + @Deprecated(since = "42.0.0") + default boolean recordAuthenticationFailure(String username, javax.servlet.http.HttpServletRequest request) + { + return recordAuthenticationFailure(username, JakartaServletBridge.toJakarta(request)); + } + + /** + * Record that the given username fails to authenticate. + * + * @param username the username that fails the authentication. Should be the username typed by the user and not a + * computed login. + * @param request a wrapping of the request used for the authentication. + * @return true if the authentication failure limits defined by the configuration has been reached. + * @since 42.0.0 + */ + @Unstable + default boolean recordAuthenticationFailure(String username, HttpServletRequest request) + { + return recordAuthenticationFailure(username, JakartaServletBridge.toJavax(request)); + } /** * Remove all records of authentication failure for the given user. @@ -56,19 +79,62 @@ public interface AuthenticationFailureManager * not a computed login. * @param request a wrapping of the request used for the authentication. * @return the aggregated form information to add to the standard login form, or an empty string. + * @deprecated use {@link #getForm(String, HttpServletRequest)} instead + */ + @Deprecated(since = "42.0.0") + default String getForm(String username, javax.servlet.http.HttpServletRequest request) + { + return getForm(username, JakartaServletBridge.toJakarta(request)); + } + + /** + * If the user reached the authentication failure limit, aggregate form information returned by the different + * strategies (see {@link AuthenticationFailureStrategy#getForm(String)}). Else return an empty string. + * @param username the username that is used for the authentication. Should be the username typed by the user and + * not a computed login. + * @param request a wrapping of the request used for the authentication. + * @return the aggregated form information to add to the standard login form, or an empty string. + * @since 42.0.0 */ - String getForm(String username, HttpServletRequest request); + @Unstable + default String getForm(String username, HttpServletRequest request) + { + return getForm(username, JakartaServletBridge.toJavax(request)); + } /** * If the user reached the authentication failure limit, validate the form information against the different - * strategies used and return the result - * (see {@link AuthenticationFailureStrategy#validateForm(String, HttpServletRequest)}). Else returns true. + * strategies used and return the result (see + * {@link AuthenticationFailureStrategy#validateForm(String, HttpServletRequest)}). Else returns true. + * * @param username the username that is used for the authentication. Should be the username typed by the user and - * not a computed login. + * not a computed login. + * @param request a wrapping of the request used for the authentication. + * @return true if all strategies validate the request or if the user didn't reach the limit. + * @deprecated use {@link #validateForm(String, HttpServletRequest)} instead + */ + @Deprecated(since = "42.0.0") + default boolean validateForm(String username, javax.servlet.http.HttpServletRequest request) + { + return validateForm(username, JakartaServletBridge.toJakarta(request)); + } + + /** + * If the user reached the authentication failure limit, validate the form information against the different + * strategies used and return the result (see + * {@link AuthenticationFailureStrategy#validateForm(String, HttpServletRequest)}). Else returns true. + * + * @param username the username that is used for the authentication. Should be the username typed by the user and + * not a computed login. * @param request a wrapping of the request used for the authentication. * @return true if all strategies validate the request or if the user didn't reach the limit. + * @since 42.0.0 */ - boolean validateForm(String username, HttpServletRequest request); + @Unstable + default boolean validateForm(String username, HttpServletRequest request) + { + return validateForm(username, JakartaServletBridge.toJavax(request)); + } /** * If the user reached the authentication failure limit, aggregate the error message of the different strategies diff --git a/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-authentication/xwiki-platform-security-authentication-api/src/main/java/org/xwiki/security/authentication/AuthenticationFailureStrategy.java b/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-authentication/xwiki-platform-security-authentication-api/src/main/java/org/xwiki/security/authentication/AuthenticationFailureStrategy.java index a57f5b319fba..1abca3995d49 100644 --- a/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-authentication/xwiki-platform-security-authentication-api/src/main/java/org/xwiki/security/authentication/AuthenticationFailureStrategy.java +++ b/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-authentication/xwiki-platform-security-authentication-api/src/main/java/org/xwiki/security/authentication/AuthenticationFailureStrategy.java @@ -19,9 +19,11 @@ */ package org.xwiki.security.authentication; -import javax.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequest; import org.xwiki.component.annotation.Role; +import org.xwiki.jakartabridge.servlet.JakartaServletBridge; +import org.xwiki.stability.Unstable; /** * Describes a strategy to perform in case the limit of authentication failures is reached. @@ -57,8 +59,25 @@ public interface AuthenticationFailureStrategy * @param username the username used for the authentication failure. * @param request the authentication request. * @return true if the authentication request can be validated, i.e. if the user should be authorized to login. + * @deprecated use {@link #validateForm(String, HttpServletRequest)} instead */ - boolean validateForm(String username, HttpServletRequest request); + @Deprecated(since = "42.0.0") + default boolean validateForm(String username, javax.servlet.http.HttpServletRequest request) + { + return validateForm(username, JakartaServletBridge.toJakarta(request)); + } + + /** + * @param username the username used for the authentication failure. + * @param request the authentication request. + * @return true if the authentication request can be validated, i.e. if the user should be authorized to login. + * @since 42.0.0 + */ + @Unstable + default boolean validateForm(String username, HttpServletRequest request) + { + return validateForm(username, JakartaServletBridge.toJavax(request)); + } /** * Notify the strategy about an authentication failure limit reached. diff --git a/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-authentication/xwiki-platform-security-authentication-default/pom.xml b/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-authentication/xwiki-platform-security-authentication-default/pom.xml index d5b71c790b85..7b2138b13dcb 100644 --- a/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-authentication/xwiki-platform-security-authentication-default/pom.xml +++ b/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-authentication/xwiki-platform-security-authentication-default/pom.xml @@ -31,7 +31,7 @@ Default implementation of the Authentication API ${basedir}/src/checkstyle/checkstyle-suppressions.xml - 0.80 + 0.79 Authentication API Implementation @@ -78,8 +78,8 @@ ${project.version} - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api diff --git a/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-authentication/xwiki-platform-security-authentication-default/src/main/java/org/xwiki/security/authentication/internal/CaptchaAuthenticationFailureStrategy.java b/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-authentication/xwiki-platform-security-authentication-default/src/main/java/org/xwiki/security/authentication/internal/CaptchaAuthenticationFailureStrategy.java index 965a00579ce7..46ae26badd28 100644 --- a/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-authentication/xwiki-platform-security-authentication-default/src/main/java/org/xwiki/security/authentication/internal/CaptchaAuthenticationFailureStrategy.java +++ b/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-authentication/xwiki-platform-security-authentication-default/src/main/java/org/xwiki/security/authentication/internal/CaptchaAuthenticationFailureStrategy.java @@ -25,7 +25,8 @@ import javax.inject.Inject; import javax.inject.Named; import javax.inject.Singleton; -import javax.servlet.http.HttpServletRequest; + +import jakarta.servlet.http.HttpServletRequest; import org.apache.commons.lang3.exception.ExceptionUtils; import org.slf4j.Logger; @@ -39,9 +40,8 @@ import org.xwiki.security.authentication.AuthenticationFailureStrategy; /** - * Captcha Strategy for repeated authentication failures. - * The main idea of this strategy is to add a captcha form field in the login form and to ask user to fill it for - * validating their authentication. + * Captcha Strategy for repeated authentication failures. The main idea of this strategy is to add a captcha form field + * in the login form and to ask user to fill it for validating their authentication. * * @version $Id$ * @since 11.6RC1 @@ -54,8 +54,8 @@ public class CaptchaAuthenticationFailureStrategy implements AuthenticationFailu /** * Exception message thrown by jCaptcha library when no captcha is registered for the session id. */ - private static final String UNEXISTING_CAPTCHA_EXCEPTION = "Invalid ID, could not validate unexisting or already " - + "validated captcha"; + private static final String UNEXISTING_CAPTCHA_EXCEPTION = + "Invalid ID, could not validate unexisting or already " + "validated captcha"; @Inject private CaptchaConfiguration captchaConfiguration; diff --git a/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-authentication/xwiki-platform-security-authentication-default/src/main/java/org/xwiki/security/authentication/internal/DefaultAuthenticationFailureManager.java b/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-authentication/xwiki-platform-security-authentication-default/src/main/java/org/xwiki/security/authentication/internal/DefaultAuthenticationFailureManager.java index 2a8359b30f68..cbb3f4d1ea9d 100644 --- a/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-authentication/xwiki-platform-security-authentication-default/src/main/java/org/xwiki/security/authentication/internal/DefaultAuthenticationFailureManager.java +++ b/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-authentication/xwiki-platform-security-authentication-default/src/main/java/org/xwiki/security/authentication/internal/DefaultAuthenticationFailureManager.java @@ -32,7 +32,8 @@ import javax.inject.Named; import javax.inject.Provider; import javax.inject.Singleton; -import javax.servlet.http.HttpServletRequest; + +import jakarta.servlet.http.HttpServletRequest; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; @@ -134,8 +135,8 @@ private void buildStrategyList() this.failureStrategyList = new LinkedList<>(); for (String failureStrategyName : this.failureStrategyNames) { try { - this.failureStrategyList.add(this.componentManager.getInstance(AuthenticationFailureStrategy.class, - failureStrategyName)); + this.failureStrategyList + .add(this.componentManager.getInstance(AuthenticationFailureStrategy.class, failureStrategyName)); } catch (ComponentLookupException e) { logger.error("Error while getting authentication failure strategy [{}]. ", failureStrategyName, e); } @@ -156,9 +157,7 @@ private boolean isAuthenticationSecurityEnabled() { // historically the feature was considered as disabled if max attempts = 0, max time = 0 or the strategy list // was empty. We keep that as possible way to say it's disabled. - return configuration.isAuthenticationSecurityEnabled() - && getMaxNbAttempts() != 0 - && getMaxTime() != 0 + return configuration.isAuthenticationSecurityEnabled() && getMaxNbAttempts() != 0 && getMaxTime() != 0 && !getFailureStrategyList().isEmpty(); } @@ -169,9 +168,9 @@ private void clearRecords() } /** - * Determine which username we should skip. - * We don't handle empty usernames to avoid triggering the security mechanism for nothing and having unexpected - * behaviours. + * Determine which username we should skip. We don't handle empty usernames to avoid triggering the security + * mechanism for nothing and having unexpected behaviours. + * * @param username the username to check. * @return {@code true} if the username is empty. */ @@ -350,14 +349,14 @@ private int getMaxNbAttempts() } /** - * This class aims at storing the authentication failure record information about a login. - * It only stores the first failing date and the number of failing attempts since then. - * Those two are resetted if another failure happens outside of the given time window. - * (See {@link AuthenticationConfiguration#getTimeWindow()}) + * This class aims at storing the authentication failure record information about a login. It only stores the first + * failing date and the number of failing attempts since then. Those two are resetted if another failure happens + * outside of the given time window. (See {@link AuthenticationConfiguration#getTimeWindow()}) */ class AuthFailureRecord { private long firstFailingDate; + private int nbAttempts; AuthFailureRecord() @@ -374,12 +373,12 @@ void incrementAttemptOrReset() this.firstFailingDate = new Date().getTime(); this.nbAttempts++; - // If the threshold not reached yet and we're out of the time window, we can reset the data. + // If the threshold not reached yet and we're out of the time window, we can reset the data. } else if (firstFailingDate + getMaxTime() < new Date().getTime()) { this.firstFailingDate = new Date().getTime(); this.nbAttempts = 1; - // Else the threshold not reached but we are in the time window: we increment the number of attempts. + // Else the threshold not reached but we are in the time window: we increment the number of attempts. } else { this.nbAttempts++; } diff --git a/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-authentication/xwiki-platform-security-authentication-default/src/main/java/org/xwiki/security/authentication/internal/DisableAccountFailureStrategy.java b/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-authentication/xwiki-platform-security-authentication-default/src/main/java/org/xwiki/security/authentication/internal/DisableAccountFailureStrategy.java index 38cff2df7285..a300ec638ee1 100644 --- a/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-authentication/xwiki-platform-security-authentication-default/src/main/java/org/xwiki/security/authentication/internal/DisableAccountFailureStrategy.java +++ b/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-authentication/xwiki-platform-security-authentication-default/src/main/java/org/xwiki/security/authentication/internal/DisableAccountFailureStrategy.java @@ -26,7 +26,8 @@ import javax.inject.Named; import javax.inject.Provider; import javax.inject.Singleton; -import javax.servlet.http.HttpServletRequest; + +import jakarta.servlet.http.HttpServletRequest; import org.xwiki.bridge.event.DocumentUpdatedEvent; import org.xwiki.component.annotation.Component; @@ -109,6 +110,7 @@ public boolean validateForm(String username, HttpServletRequest request) if (userDocumentReference != null) { return !new XWikiUser(userDocumentReference).isDisabled(this.contextProvider.get()); } + return false; } diff --git a/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-authentication/xwiki-platform-security-authentication-default/src/test/java/org/xwiki/security/authentication/internal/DefaultAuthenticationFailureManagerTest.java b/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-authentication/xwiki-platform-security-authentication-default/src/test/java/org/xwiki/security/authentication/internal/DefaultAuthenticationFailureManagerTest.java index c37fed206dd5..2d6c86de6681 100644 --- a/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-authentication/xwiki-platform-security-authentication-default/src/test/java/org/xwiki/security/authentication/internal/DefaultAuthenticationFailureManagerTest.java +++ b/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-authentication/xwiki-platform-security-authentication-default/src/test/java/org/xwiki/security/authentication/internal/DefaultAuthenticationFailureManagerTest.java @@ -25,8 +25,9 @@ import javax.inject.Named; import javax.inject.Provider; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpSession; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -59,8 +60,8 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.times; @@ -74,7 +75,7 @@ * @since 11.6RC1 */ @ComponentTest -public class DefaultAuthenticationFailureManagerTest +class DefaultAuthenticationFailureManagerTest { @InjectMockComponents private DefaultAuthenticationFailureManager defaultAuthenticationFailureManager; @@ -163,7 +164,7 @@ private HttpServletRequest getRequest(String sessionId) * Ensure that a AuthenticationFailureEvent is triggered. */ @Test - public void authenticationFailureIsTriggered() + void authenticationFailureIsTriggered() { assertFalse(this.defaultAuthenticationFailureManager.recordAuthenticationFailure(this.failingLogin, getRequest("something"))); @@ -234,7 +235,7 @@ void authenticationFailureEmptyLogin() * Ensure that the time window configuration is taken into account properly. */ @Test - public void repeatedAuthenticationFailureOutOfTimeWindow() throws InterruptedException + void repeatedAuthenticationFailureOutOfTimeWindow() throws InterruptedException { HttpServletRequest request = getRequest("anotherId"); when(configuration.getTimeWindow()).thenReturn(1); @@ -258,7 +259,7 @@ public void repeatedAuthenticationFailureOutOfTimeWindow() throws InterruptedExc * Ensure that the max attempt configuration is taken into account properly. */ @Test - public void repeatedAuthenticationFailureDifferentThreshold() + void repeatedAuthenticationFailureDifferentThreshold() { HttpServletRequest request = getRequest("foobar"); when(configuration.getMaxAuthorizedAttempts()).thenReturn(5); @@ -281,7 +282,7 @@ public void repeatedAuthenticationFailureDifferentThreshold() * Ensure that the failure record reset is working properly. */ @Test - public void resetAuthFailureRecord() + void resetAuthFailureRecord() { HttpServletRequest request = getRequest("reset"); assertFalse(this.defaultAuthenticationFailureManager.recordAuthenticationFailure(this.failingLogin, request)); @@ -304,7 +305,7 @@ public void resetAuthFailureRecord() * Ensure that the failure record reset is working properly. */ @Test - public void resetAuthFailureRecordWithDocumentReference() + void resetAuthFailureRecordWithDocumentReference() { HttpServletRequest request = getRequest("reset2"); assertFalse(this.defaultAuthenticationFailureManager.recordAuthenticationFailure(this.failingLogin, request)); @@ -327,7 +328,7 @@ public void resetAuthFailureRecordWithDocumentReference() * Ensure that the threshold mechanism works properly with different login. */ @Test - public void recordAuthFailureDifferentLogin() + void recordAuthFailureDifferentLogin() { HttpServletRequest request = getRequest("multilogin"); String login1 = this.failingLogin.toLowerCase(); @@ -390,7 +391,7 @@ void recordAuthenticationFailureWithFailingSession() * Ensure that the authentication threshold auth is deactivated if max attempt is set to 0 */ @Test - public void deactivateThresholdAuthWithMaxAttempt() + void deactivateThresholdAuthWithMaxAttempt() { HttpServletRequest request = getRequest("manyattempt"); when(this.configuration.getMaxAuthorizedAttempts()).thenReturn(0); @@ -410,7 +411,7 @@ public void deactivateThresholdAuthWithMaxAttempt() * Ensure that the authentication threshold auth is deactivated if time window is set to 0 */ @Test - public void deactivateThresholdAuthWithTimeWindow() + void deactivateThresholdAuthWithTimeWindow() { HttpServletRequest request = getRequest("manyattempt2"); when(this.configuration.getTimeWindow()).thenReturn(0); @@ -430,7 +431,7 @@ public void deactivateThresholdAuthWithTimeWindow() * Validate that getForm is working properly. */ @Test - public void getForm() + void getForm() { HttpServletRequest request = getRequest("getForm"); String formStrategy1 = "formStrategy1"; @@ -468,7 +469,7 @@ void getFormFailingSession() * Validate that getErrorMessages is working properly. */ @Test - public void getErrorMessages() + void getErrorMessages() { HttpServletRequest request = getRequest("errorMsg"); String errorMessage1 = "errorMessage1"; @@ -489,7 +490,7 @@ public void getErrorMessages() * Validate that getForm is working properly. */ @Test - public void validateForm() + void validateForm() { HttpServletRequest request = getRequest("validate"); String login1 = this.failingLogin; @@ -506,13 +507,13 @@ public void validateForm() this.defaultAuthenticationFailureManager.recordAuthenticationFailure(login2, request); this.defaultAuthenticationFailureManager.recordAuthenticationFailure(login2, request); - when(this.strategy1.validateForm(login1, null)).thenReturn(true); - when(this.strategy2.validateForm(login1, null)).thenReturn(true); - assertTrue(this.defaultAuthenticationFailureManager.validateForm(login1, null)); + when(this.strategy1.validateForm(login1, (HttpServletRequest) null)).thenReturn(true); + when(this.strategy2.validateForm(login1, (HttpServletRequest) null)).thenReturn(true); + assertTrue(this.defaultAuthenticationFailureManager.validateForm(login1, (HttpServletRequest) null)); - when(this.strategy1.validateForm(login2, null)).thenReturn(true); - when(this.strategy2.validateForm(login2, null)).thenReturn(false); - assertFalse(this.defaultAuthenticationFailureManager.validateForm(login2, null)); + when(this.strategy1.validateForm(login2, (HttpServletRequest) null)).thenReturn(true); + when(this.strategy2.validateForm(login2, (HttpServletRequest) null)).thenReturn(false); + assertFalse(this.defaultAuthenticationFailureManager.validateForm(login2, (HttpServletRequest) null)); } @Test @@ -531,7 +532,7 @@ void validateFormFailingSession() * Validate that getUser is working properly. */ @Test - public void getUserNotFound() throws XWikiException + void getUserNotFound() throws XWikiException { when(context.getMainXWiki()).thenReturn("mainwiki"); when(context.getWikiId()).thenReturn("currentwiki"); @@ -553,7 +554,7 @@ public void getUserNotFound() throws XWikiException * Validate that getUser is working properly. */ @Test - public void getUserGlobalFound() throws XWikiException + void getUserGlobalFound() throws XWikiException { when(context.getMainXWiki()).thenReturn("mainwiki"); DocumentReference globalReference = new DocumentReference("mainwiki", "XWiki", "foo"); @@ -575,7 +576,7 @@ public void getUserGlobalFound() throws XWikiException * Validate that getUser is working properly. */ @Test - public void getUserLocalFound() throws XWikiException + void getUserLocalFound() throws XWikiException { when(context.getMainXWiki()).thenReturn("mainwiki"); when(context.getWikiId()).thenReturn("currentwiki"); @@ -597,7 +598,7 @@ public void getUserLocalFound() throws XWikiException } @Test - public void strategiesAreRebuildInCaseOfReset() + void strategiesAreRebuildInCaseOfReset() { HttpServletRequest request = getRequest("reset"); when(configuration.getFailureStrategies()).thenReturn(new String[] { "strategy1" }); diff --git a/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-authentication/xwiki-platform-security-authentication-default/src/test/java/org/xwiki/security/authentication/internal/DisableAccountFailureStrategyTest.java b/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-authentication/xwiki-platform-security-authentication-default/src/test/java/org/xwiki/security/authentication/internal/DisableAccountFailureStrategyTest.java index f5cabc1afc92..d033d8b7638f 100644 --- a/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-authentication/xwiki-platform-security-authentication-default/src/test/java/org/xwiki/security/authentication/internal/DisableAccountFailureStrategyTest.java +++ b/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-authentication/xwiki-platform-security-authentication-default/src/test/java/org/xwiki/security/authentication/internal/DisableAccountFailureStrategyTest.java @@ -19,6 +19,12 @@ */ package org.xwiki.security.authentication.internal; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + import javax.inject.Provider; import org.junit.jupiter.api.BeforeEach; @@ -32,16 +38,9 @@ import org.xwiki.test.junit5.mockito.InjectMockComponents; import org.xwiki.test.junit5.mockito.MockComponent; -import com.xpn.xwiki.XWikiException; import com.xpn.xwiki.doc.XWikiDocument; import com.xpn.xwiki.objects.BaseObject; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - /** * Unit tests for {@link DisableAccountFailureStrategy}. * @@ -49,7 +48,7 @@ * @since 11.8RC1 */ @ComponentTest -public class DisableAccountFailureStrategyTest +class DisableAccountFailureStrategyTest { @InjectMockComponents(role = AuthenticationFailureStrategy.class) private DisableAccountFailureStrategy disableStrategy; @@ -61,7 +60,7 @@ public class DisableAccountFailureStrategyTest private XWikiDocument updatedDocument; @BeforeEach - public void configure() throws XWikiException + public void configure() { DocumentReference documentReference = new DocumentReference("test", "Some", "Page"); @@ -81,7 +80,7 @@ public void configure() throws XWikiException } @Test - public void resetAuthenticationFailureCounterWhenAccountIsActivated() + void resetAuthenticationFailureCounterWhenAccountIsActivated() { when(this.updatedDocument.getOriginalDocument().getXObject(DisableAccountFailureStrategy.USER_CLASS_REFERENCE) .getIntValue("active")).thenReturn(0); @@ -95,7 +94,7 @@ public void resetAuthenticationFailureCounterWhenAccountIsActivated() } @Test - public void dontResetAuthenticationFailureCounterWhenAccountRemainsInactive() + void dontResetAuthenticationFailureCounterWhenAccountRemainsInactive() { when(this.updatedDocument.getOriginalDocument().getXObject(DisableAccountFailureStrategy.USER_CLASS_REFERENCE) .getIntValue("active")).thenReturn(0); @@ -109,7 +108,7 @@ public void dontResetAuthenticationFailureCounterWhenAccountRemainsInactive() } @Test - public void dontResetAuthenticationFailureCounterWhenAccountRemainsActive() + void dontResetAuthenticationFailureCounterWhenAccountRemainsActive() { when(this.updatedDocument.getOriginalDocument().getXObject(DisableAccountFailureStrategy.USER_CLASS_REFERENCE) .getIntValue("active")).thenReturn(1); @@ -123,7 +122,7 @@ public void dontResetAuthenticationFailureCounterWhenAccountRemainsActive() } @Test - public void dontResetAuthenticationFailureCounterWhenAccountIsDeactivated() + void dontResetAuthenticationFailureCounterWhenAccountIsDeactivated() { when(this.updatedDocument.getOriginalDocument().getXObject(DisableAccountFailureStrategy.USER_CLASS_REFERENCE) .getIntValue("active")).thenReturn(1); @@ -137,7 +136,7 @@ public void dontResetAuthenticationFailureCounterWhenAccountIsDeactivated() } @Test - public void onDocumentUpdatedNoUserAccount() + void onDocumentUpdatedNoUserAccount() { when(this.updatedDocument.getXObject(DisableAccountFailureStrategy.USER_CLASS_REFERENCE)).thenReturn(null); @@ -147,7 +146,7 @@ public void onDocumentUpdatedNoUserAccount() } @Test - public void onDocumentUpdatedNoUserAccountStateChange() + void onDocumentUpdatedNoUserAccountStateChange() { disableStrategy.onEvent(new DocumentUpdatedEvent(), updatedDocument, null); @@ -155,8 +154,8 @@ public void onDocumentUpdatedNoUserAccountStateChange() } @Test - public void validateFormReturnsFalseWhenUserNotFound() + void validateFormReturnsFalseWhenUserNotFound() { - assertFalse(this.disableStrategy.validateForm("Foo", null)); + assertFalse(this.disableStrategy.validateForm("Foo", (javax.servlet.http.HttpServletRequest) null)); } } diff --git a/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-authentication/xwiki-platform-security-authentication-script/pom.xml b/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-authentication/xwiki-platform-security-authentication-script/pom.xml index 28c6c74aebd3..76bb079e383c 100644 --- a/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-authentication/xwiki-platform-security-authentication-script/pom.xml +++ b/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-authentication/xwiki-platform-security-authentication-script/pom.xml @@ -62,8 +62,8 @@ test - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api diff --git a/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-requiredrights/xwiki-platform-security-requiredrights-default/pom.xml b/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-requiredrights/xwiki-platform-security-requiredrights-default/pom.xml index 7e72cfe54642..b32be0c191c8 100644 --- a/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-requiredrights/xwiki-platform-security-requiredrights-default/pom.xml +++ b/xwiki-platform-core/xwiki-platform-security/xwiki-platform-security-requiredrights/xwiki-platform-security-requiredrights-default/pom.xml @@ -57,6 +57,8 @@ xwiki-platform-rendering-macro-script ${project.version} + + org.xwiki.platform xwiki-platform-test-oldcore diff --git a/xwiki-platform-core/xwiki-platform-skin/xwiki-platform-skin-skinx/pom.xml b/xwiki-platform-core/xwiki-platform-skin/xwiki-platform-skin-skinx/pom.xml index 3ed593d13497..53ea33820252 100644 --- a/xwiki-platform-core/xwiki-platform-skin/xwiki-platform-skin-skinx/pom.xml +++ b/xwiki-platform-core/xwiki-platform-skin/xwiki-platform-skin-skinx/pom.xml @@ -41,8 +41,8 @@ aspectjrt - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api org.xwiki.platform diff --git a/xwiki-platform-core/xwiki-platform-store/xwiki-platform-store-filesystem-oldcore/pom.xml b/xwiki-platform-core/xwiki-platform-store/xwiki-platform-store-filesystem-oldcore/pom.xml index bad84dc59742..3776abb356f8 100644 --- a/xwiki-platform-core/xwiki-platform-store/xwiki-platform-store-filesystem-oldcore/pom.xml +++ b/xwiki-platform-core/xwiki-platform-store/xwiki-platform-store-filesystem-oldcore/pom.xml @@ -99,8 +99,8 @@ ${commons.version} - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api org.xwiki.platform diff --git a/xwiki-platform-core/xwiki-platform-store/xwiki-platform-store-filesystem-oldcore/src/main/java/org/xwiki/store/filesystem/internal/DefaultTemporaryAttachmentSessionsManager.java b/xwiki-platform-core/xwiki-platform-store/xwiki-platform-store-filesystem-oldcore/src/main/java/org/xwiki/store/filesystem/internal/DefaultTemporaryAttachmentSessionsManager.java index 2279a858b089..242d289f00f3 100644 --- a/xwiki-platform-core/xwiki-platform-store/xwiki-platform-store-filesystem-oldcore/src/main/java/org/xwiki/store/filesystem/internal/DefaultTemporaryAttachmentSessionsManager.java +++ b/xwiki-platform-core/xwiki-platform-store/xwiki-platform-store-filesystem-oldcore/src/main/java/org/xwiki/store/filesystem/internal/DefaultTemporaryAttachmentSessionsManager.java @@ -27,15 +27,18 @@ import javax.inject.Inject; import javax.inject.Provider; import javax.inject.Singleton; -import javax.servlet.http.HttpSession; -import javax.servlet.http.Part; + +import jakarta.servlet.http.HttpSession; +import jakarta.servlet.http.Part; import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; import org.xwiki.attachment.validation.AttachmentValidationException; import org.xwiki.attachment.validation.AttachmentValidator; import org.xwiki.component.annotation.Component; +import org.xwiki.container.Container; +import org.xwiki.container.servlet.ServletSession; import org.xwiki.internal.attachment.XWikiAttachmentAccessWrapper; +import org.xwiki.jakartabridge.servlet.JakartaServletBridge; import org.xwiki.model.reference.DocumentReference; import org.xwiki.store.TemporaryAttachmentException; import org.xwiki.store.TemporaryAttachmentSessionsManager; @@ -63,12 +66,11 @@ public class DefaultTemporaryAttachmentSessionsManager implements TemporaryAttac private Provider attachmentValidator; @Inject - private Logger logger; + private Provider container; private HttpSession getSession() { - XWikiContext context = this.contextProvider.get(); - return context.getRequest().getSession(); + return ((ServletSession) this.container.get().getSession()).getSession(); } private TemporaryAttachmentSession getOrCreateSession() @@ -90,6 +92,14 @@ public XWikiAttachment uploadAttachment(DocumentReference documentReference, Par return uploadAttachment(documentReference, part, null); } + @Override + @Deprecated + public XWikiAttachment uploadAttachment(DocumentReference documentReference, javax.servlet.http.Part part, + String filename) throws TemporaryAttachmentException, AttachmentValidationException + { + return uploadAttachment(documentReference, JakartaServletBridge.toJakarta(part), filename); + } + @Override public XWikiAttachment uploadAttachment(DocumentReference documentReference, Part part, String filename) throws TemporaryAttachmentException, AttachmentValidationException @@ -107,7 +117,7 @@ public XWikiAttachment uploadAttachment(DocumentReference documentReference, Par xWikiAttachment.setFilename(actualFilename); xWikiAttachment.setContent(part.getInputStream()); xWikiAttachment.setAuthorReference(context.getUserReference()); - // Initialize an empty document with the right document reference and locale. We don't set the actual + // Initialize an empty document with the right document reference and locale. We don't set the actual // document since it's a temporary attachment, but it is still useful to have a minimal knowledge of the // document it is stored for. xWikiAttachment.setDoc(new XWikiDocument(documentReference, documentReference.getLocale()), false); diff --git a/xwiki-platform-core/xwiki-platform-store/xwiki-platform-store-filesystem-oldcore/src/test/java/org/xwiki/store/filesystem/internal/DefaultTemporaryAttachmentSessionsManagerTest.java b/xwiki-platform-core/xwiki-platform-store/xwiki-platform-store-filesystem-oldcore/src/test/java/org/xwiki/store/filesystem/internal/DefaultTemporaryAttachmentSessionsManagerTest.java index dbc7d1d46da8..fc437f72a387 100644 --- a/xwiki-platform-core/xwiki-platform-store/xwiki-platform-store-filesystem-oldcore/src/test/java/org/xwiki/store/filesystem/internal/DefaultTemporaryAttachmentSessionsManagerTest.java +++ b/xwiki-platform-core/xwiki-platform-store/xwiki-platform-store-filesystem-oldcore/src/test/java/org/xwiki/store/filesystem/internal/DefaultTemporaryAttachmentSessionsManagerTest.java @@ -20,7 +20,6 @@ package org.xwiki.store.filesystem.internal; import java.io.ByteArrayInputStream; -import java.io.File; import java.io.InputStream; import java.util.Arrays; import java.util.Collections; @@ -28,9 +27,10 @@ import java.util.Optional; import javax.inject.Provider; -import javax.servlet.http.HttpSession; import javax.servlet.http.Part; +import jakarta.servlet.http.HttpSession; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; @@ -39,11 +39,13 @@ import org.mockito.Mock; import org.xwiki.attachment.validation.AttachmentValidationException; import org.xwiki.attachment.validation.AttachmentValidator; -import org.xwiki.environment.Environment; +import org.xwiki.container.Container; +import org.xwiki.container.servlet.ServletSession; import org.xwiki.model.reference.DocumentReference; import org.xwiki.model.reference.SpaceReference; import org.xwiki.store.TemporaryAttachmentException; -import org.xwiki.test.junit5.XWikiTempDir; +import org.xwiki.test.TestEnvironment; +import org.xwiki.test.annotation.ComponentList; import org.xwiki.test.junit5.mockito.ComponentTest; import org.xwiki.test.junit5.mockito.InjectMockComponents; import org.xwiki.test.junit5.mockito.MockComponent; @@ -54,7 +56,6 @@ import com.xpn.xwiki.doc.XWikiAttachment; import com.xpn.xwiki.doc.XWikiDocument; import com.xpn.xwiki.web.Utils; -import com.xpn.xwiki.web.XWikiRequest; import static com.xpn.xwiki.plugin.fileupload.FileUploadPlugin.UPLOAD_MAXSIZE_PARAMETER; import static java.nio.charset.StandardCharsets.UTF_8; @@ -79,6 +80,7 @@ * @since 14.3RC1 */ @ComponentTest +@ComponentList(TestEnvironment.class) class DefaultTemporaryAttachmentSessionsManagerTest { private static final String ATTRIBUTE_KEY = "xwikiTemporaryAttachments"; @@ -92,12 +94,12 @@ class DefaultTemporaryAttachmentSessionsManagerTest @MockComponent private Provider attachmentValidatorProvider; + @MockComponent + private Container container; + @Mock private AttachmentValidator attachmentValidator; - @XWikiTempDir - private File tmpDir; - @Mock private XWikiContext context; @@ -109,14 +111,11 @@ void setup(MockitoComponentManager mockitoComponentManager) throws Exception { when(this.contextProvider.get()).thenReturn(this.context); - XWikiRequest xWikiRequest = mock(XWikiRequest.class); - when(xWikiRequest.getSession()).thenReturn(this.httpSession); - when(this.context.getRequest()).thenReturn(xWikiRequest); + ServletSession session = mock(ServletSession.class); + when(session.getSession()).thenReturn(this.httpSession); + when(this.container.getSession()).thenReturn(session); Utils.setComponentManager(mockitoComponentManager); - Environment environment = mockitoComponentManager.registerMockComponent(Environment.class); - when(environment.getTemporaryDirectory()).thenReturn(this.tmpDir); - when(this.attachmentValidatorProvider.get()).thenReturn(this.attachmentValidator); } diff --git a/xwiki-platform-core/xwiki-platform-tag/xwiki-platform-tag-api/pom.xml b/xwiki-platform-core/xwiki-platform-tag/xwiki-platform-tag-api/pom.xml index cb777d0cb43c..a9d9adcf62b7 100644 --- a/xwiki-platform-core/xwiki-platform-tag/xwiki-platform-tag-api/pom.xml +++ b/xwiki-platform-core/xwiki-platform-tag/xwiki-platform-tag-api/pom.xml @@ -65,10 +65,5 @@ ${commons.version} test - - javax.servlet - javax.servlet-api - test - diff --git a/xwiki-platform-core/xwiki-platform-test/xwiki-platform-test-docker/pom.xml b/xwiki-platform-core/xwiki-platform-test/xwiki-platform-test-docker/pom.xml index 363a57f73067..4d0edf435eb7 100644 --- a/xwiki-platform-core/xwiki-platform-test/xwiki-platform-test-docker/pom.xml +++ b/xwiki-platform-core/xwiki-platform-test/xwiki-platform-test-docker/pom.xml @@ -165,8 +165,8 @@ commons-httpclient - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api compile diff --git a/xwiki-platform-core/xwiki-platform-test/xwiki-platform-test-docker/src/main/java/org/xwiki/test/docker/internal/junit5/servletengine/ServletContainerExecutor.java b/xwiki-platform-core/xwiki-platform-test/xwiki-platform-test-docker/src/main/java/org/xwiki/test/docker/internal/junit5/servletengine/ServletContainerExecutor.java index 0748284935eb..b9d3b94cc587 100644 --- a/xwiki-platform-core/xwiki-platform-test/xwiki-platform-test-docker/src/main/java/org/xwiki/test/docker/internal/junit5/servletengine/ServletContainerExecutor.java +++ b/xwiki-platform-core/xwiki-platform-test/xwiki-platform-test-docker/src/main/java/org/xwiki/test/docker/internal/junit5/servletengine/ServletContainerExecutor.java @@ -269,9 +269,8 @@ private void configureTomcat(File sourceWARDirectory) throws Exception catalinaOpts.add("-Xmx1024m"); catalinaOpts.add("-Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true"); catalinaOpts.add("-Dorg.apache.catalina.connector.CoyoteAdapter.ALLOW_BACKSLASH=true"); - catalinaOpts.add("-Dsecurerandom.source=file:/dev/urandom"); - // Note: Tomcat 9.x automatically add the various "--add-opens" to make XWiki work on Java 17, so we don't + // Note: Tomcat automatically add the various "--add-opens" to make XWiki work on Java 17, so we don't // need to add them as we do for Jetty. // see https://jira.xwiki.org/browse/XWIKI-19034 and https://jira.xwiki.org/browse/XRENDERING-616 @@ -372,7 +371,7 @@ private String getDockerImageTag(TestConfiguration testConfiguration) // TODO: We currently cannot use Tomcat 10.x as it corresponds to a package change for JakartaEE and we'll need // XWiki to move to the new packages first. This is why we force an older version for Tomcat. return testConfiguration.getServletEngineTag() != null ? testConfiguration.getServletEngineTag() - : (testConfiguration.getServletEngine().equals(ServletEngine.TOMCAT) ? "9-jdk17" : LATEST); + : (testConfiguration.getServletEngine().equals(ServletEngine.TOMCAT) ? "10-jdk17" : LATEST); } private GenericContainer createServletContainer() throws Exception diff --git a/xwiki-platform-core/xwiki-platform-test/xwiki-platform-test-integration/pom.xml b/xwiki-platform-core/xwiki-platform-test/xwiki-platform-test-integration/pom.xml index 8f0c445647d4..479fce830ea9 100644 --- a/xwiki-platform-core/xwiki-platform-test/xwiki-platform-test-integration/pom.xml +++ b/xwiki-platform-core/xwiki-platform-test/xwiki-platform-test-integration/pom.xml @@ -79,8 +79,8 @@ - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api org.xwiki.platform diff --git a/xwiki-platform-core/xwiki-platform-test/xwiki-platform-test-oldcore/pom.xml b/xwiki-platform-core/xwiki-platform-test/xwiki-platform-test-oldcore/pom.xml index 6dea8930bb74..f7bb86f0b66c 100644 --- a/xwiki-platform-core/xwiki-platform-test/xwiki-platform-test-oldcore/pom.xml +++ b/xwiki-platform-core/xwiki-platform-test/xwiki-platform-test-oldcore/pom.xml @@ -49,15 +49,15 @@ test-jar - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api compile - + - org.mortbay.jasper - apache-el + org.glassfish.expressly + expressly runtime diff --git a/xwiki-platform-core/xwiki-platform-test/xwiki-platform-test-page/pom.xml b/xwiki-platform-core/xwiki-platform-test/xwiki-platform-test-page/pom.xml index 6d8ee94132db..0a4a388c30fa 100644 --- a/xwiki-platform-core/xwiki-platform-test/xwiki-platform-test-page/pom.xml +++ b/xwiki-platform-core/xwiki-platform-test/xwiki-platform-test-page/pom.xml @@ -108,6 +108,10 @@ xwiki-platform-rendering-transformation-macro ${project.version} + + jakarta.servlet + jakarta.servlet-api + org.jsoup jsoup diff --git a/xwiki-platform-core/xwiki-platform-test/xwiki-platform-test-page/src/main/java/org/xwiki/test/page/PageTest.java b/xwiki-platform-core/xwiki-platform-test/xwiki-platform-test-page/src/main/java/org/xwiki/test/page/PageTest.java index d1312510a15d..273af0be6348 100644 --- a/xwiki-platform-core/xwiki-platform-test/xwiki-platform-test-page/src/main/java/org/xwiki/test/page/PageTest.java +++ b/xwiki-platform-core/xwiki-platform-test/xwiki-platform-test-page/src/main/java/org/xwiki/test/page/PageTest.java @@ -31,6 +31,8 @@ import org.xwiki.cache.CacheFactory; import org.xwiki.cache.CacheManager; import org.xwiki.cache.config.CacheConfiguration; +import org.xwiki.container.servlet.HttpServletRequestStub; +import org.xwiki.container.servlet.HttpServletResponseStub; import org.xwiki.context.Execution; import org.xwiki.context.ExecutionContext; import org.xwiki.context.ExecutionContextManager; @@ -89,12 +91,32 @@ public class PageTest /** * The stubbed request used to simulate a real Servlet Request. + * + * @since 42.0.0 */ + protected HttpServletRequestStub stubRequest; + + /** + * The javax version of the stubbed request used to simulate a real Servlet Request. + * + * @deprecated use {@link #stubRequest} instead + */ + @Deprecated(since = "42.0.0") protected XWikiServletRequestStub request; /** * The stubbed response used to simulate a real Servlet Response. + * + * @since 42.0.0 + */ + protected HttpServletResponseStub stubResponse; + + /** + * The javax version of the stubbed response used to simulate a real Servlet Response. + * + * @deprecated use {@link #stubResponse} instead */ + @Deprecated(since = "42.0.0") protected XWikiServletResponseStub response; /** @@ -261,39 +283,42 @@ protected void setOutputSyntax(Syntax syntax) throws Exception void setUpForPageTest() throws Exception { // Configure mocks from OldcoreRule - context = oldcore.getXWikiContext(); - xwiki = oldcore.getSpyXWiki(); + this.context = this.oldcore.getXWikiContext(); + this.xwiki = this.oldcore.getSpyXWiki(); // We need this one because some component in its init creates a query... - when(oldcore.getQueryManager().createQuery(any(String.class), any(String.class))).thenReturn(mock(Query.class)); + when(this.oldcore.getQueryManager().createQuery(any(String.class), any(String.class))) + .thenReturn(mock(Query.class)); // Set up a fake Request // Configure request so that $!request.outputSyntax" == 'plain // Need to be executed before ecm.initialize() so that XWikiScriptContextInitializer will initialize the // script context properly - request = new XWikiServletRequestStub(); - request.setScheme("http"); - context.setRequest(request); + this.stubRequest = new HttpServletRequestStub(); + this.request = new XWikiServletRequestStub(this.stubRequest); + this.request.setScheme("http"); + this.context.setRequest(this.request); - response = new XWikiServletResponseStub(); - context.setResponse(response); + this.stubResponse = new HttpServletResponseStub(); + this.response = new XWikiServletResponseStub(this.stubResponse); + this.context.setResponse(this.response); - ExecutionContextManager ecm = componentManager.getInstance(ExecutionContextManager.class); - ecm.initialize(oldcore.getExecutionContext()); + ExecutionContextManager ecm = this.componentManager.getInstance(ExecutionContextManager.class); + ecm.initialize(this.oldcore.getExecutionContext()); - // Let the user have view access to all pages - when(oldcore.getMockRightService().hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), any(), - eq(context))).thenReturn(true); - when(oldcore.getMockContextualAuthorizationManager().hasAccess(same(Right.VIEW), any())).thenReturn(true); + // Let the user have view access on all pages + when(this.oldcore.getMockRightService().hasAccessLevel(eq("view"), eq("XWiki.XWikiGuest"), any(), eq(context))) + .thenReturn(true); + when(this.oldcore.getMockContextualAuthorizationManager().hasAccess(same(Right.VIEW), any())).thenReturn(true); // Set up URL Factory - URLFactorySetup.setUp(context); + URLFactorySetup.setUp(this.context); // Set up Localization - LocalizationSetup.setUp(componentManager); + LocalizationSetup.setUp(this.componentManager); // Set up Skin Extensions - SkinExtensionSetup.setUp(xwiki, context); + SkinExtensionSetup.setUp(this.xwiki, this.context); } /** diff --git a/xwiki-platform-core/xwiki-platform-url/xwiki-platform-url-container/pom.xml b/xwiki-platform-core/xwiki-platform-url/xwiki-platform-url-container/pom.xml index 78903c7b4dcb..02de139de801 100644 --- a/xwiki-platform-core/xwiki-platform-url/xwiki-platform-url-container/pom.xml +++ b/xwiki-platform-core/xwiki-platform-url/xwiki-platform-url-container/pom.xml @@ -75,8 +75,8 @@ commons-lang3 - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api diff --git a/xwiki-platform-core/xwiki-platform-url/xwiki-platform-url-default/pom.xml b/xwiki-platform-core/xwiki-platform-url/xwiki-platform-url-default/pom.xml index 86db382e6034..c08d3c873361 100644 --- a/xwiki-platform-core/xwiki-platform-url/xwiki-platform-url-default/pom.xml +++ b/xwiki-platform-core/xwiki-platform-url/xwiki-platform-url-default/pom.xml @@ -44,7 +44,7 @@ org.xwiki.platform - xwiki-platform-oldcore + xwiki-platform-container-servlet ${project.version} @@ -52,10 +52,15 @@ xwiki-platform-wiki-api ${project.version} + + org.xwiki.platform + xwiki-platform-oldcore + ${project.version} + - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api diff --git a/xwiki-platform-core/xwiki-platform-url/xwiki-platform-url-default/src/main/java/org/xwiki/url/internal/DefaultURLSecurityManager.java b/xwiki-platform-core/xwiki-platform-url/xwiki-platform-url-default/src/main/java/org/xwiki/url/internal/DefaultURLSecurityManager.java index 3972efde45e0..b7a4fdf840e8 100644 --- a/xwiki-platform-core/xwiki-platform-url/xwiki-platform-url-default/src/main/java/org/xwiki/url/internal/DefaultURLSecurityManager.java +++ b/xwiki-platform-core/xwiki-platform-url/xwiki-platform-url-default/src/main/java/org/xwiki/url/internal/DefaultURLSecurityManager.java @@ -29,13 +29,16 @@ import java.util.regex.Pattern; import javax.inject.Inject; -import javax.inject.Provider; import javax.inject.Singleton; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.exception.ExceptionUtils; import org.slf4j.Logger; import org.xwiki.component.annotation.Component; +import org.xwiki.container.Container; +import org.xwiki.container.Request; +import org.xwiki.container.servlet.HttpServletUtils; +import org.xwiki.container.servlet.ServletRequest; import org.xwiki.context.Execution; import org.xwiki.url.URLConfiguration; import org.xwiki.url.URLSecurityManager; @@ -43,12 +46,10 @@ import org.xwiki.wiki.descriptor.WikiDescriptorManager; import org.xwiki.wiki.manager.WikiManagerException; -import com.xpn.xwiki.XWikiContext; - /** - * Default implementation of {@link URLSecurityManager}. - * This implementation keeps a HashSet in memory containing the trusted domains defined in the configuration and - * for all subwikis. Use {@link #invalidateCache()} to compute back this hashset. + * Default implementation of {@link URLSecurityManager}. This implementation keeps a HashSet in memory containing the + * trusted domains defined in the configuration and for all subwikis. Use {@link #invalidateCache()} to compute back + * this hashset. * * @version $Id$ * @since 13.3RC1 @@ -59,10 +60,12 @@ public class DefaultURLSecurityManager implements URLSecurityManager { private static final char DOT = '.'; + private static final char PERCENT = '%'; /** * Dedicated string used to escape {@code %} character. + * * @see #parseToSafeURI(String) */ private static final String PERCENT_ESCAPE = "__XWIKI_URL_SECURITY_PERCENT__"; @@ -83,13 +86,13 @@ public class DefaultURLSecurityManager implements URLSecurityManager private WikiDescriptorManager wikiDescriptorManager; @Inject - private Execution execution; + private Container container; @Inject - private Logger logger; + private Execution execution; @Inject - private Provider contextProvider; + private Logger logger; private Set trustedDomains; @@ -108,8 +111,9 @@ private synchronized void computeTrustedDomains() result.addAll(wikiDescriptor.getAliases()); } } catch (WikiManagerException e) { - logger.warn("Error while getting wiki descriptor to fill list of trusted domains: [{}]. " - + "The subwikis won't be taken into account for the list of trusted domains.", + logger.warn( + "Error while getting wiki descriptor to fill list of trusted domains: [{}]. " + + "The subwikis won't be taken into account for the list of trusted domains.", ExceptionUtils.getRootCauseMessage(e)); } @@ -120,18 +124,19 @@ private synchronized void computeTrustedDomains() private String getCurrentDomain() { - XWikiContext context = this.contextProvider.get(); - if (context.getRequest() != null && context.getRequest().getHttpServletRequest() != null) { - String request = context.getRequest().getHttpServletRequest().getRequestURL().toString(); + Request request = this.container.getRequest(); + if (request instanceof ServletRequest servletRequest) { try { - URL requestURL = new URL(request); - return requestURL.getHost(); + URL sourceBaseURL = HttpServletUtils.getSourceBaseURL(servletRequest.getRequest()); + + return sourceBaseURL.getHost(); } catch (MalformedURLException e) { // this should never happen throw new RuntimeException( - String.format("URL used to access the server is not a proper URL: [%s]", request)); + String.format("Failed to resolve the source URL: [%s]", servletRequest.getRequest().toString()), e); } } + return ""; } @@ -152,8 +157,8 @@ public boolean isDomainTrusted(URL urlToCheck) } } while (!"".equals(host)); - Object bypassCheckProperty = execution.getContext() - .getProperty(URLSecurityManager.BYPASS_DOMAIN_SECURITY_CHECK_CONTEXT_PROPERTY); + Object bypassCheckProperty = + execution.getContext().getProperty(URLSecurityManager.BYPASS_DOMAIN_SECURITY_CHECK_CONTEXT_PROPERTY); boolean bypassCheck = bypassCheckProperty != null && Boolean.parseBoolean(bypassCheckProperty.toString()); if (bypassCheck) { @@ -214,10 +219,7 @@ public boolean isURITrusted(URI uri) // it. Note that the scheme used here is only for building a proper URL for then checking domain: // it's never actually used to perform any request. if (!uri.isAbsolute()) { - URI uriWithScheme = new URI("https", - uri.getRawAuthority(), - uri.getRawPath(), - uri.getRawQuery(), + URI uriWithScheme = new URI("https", uri.getRawAuthority(), uri.getRawPath(), uri.getRawQuery(), uri.getRawFragment()); result = this.isDomainTrusted(uriWithScheme.toURL()); } else if (this.urlConfiguration.getTrustedSchemes().contains(uri.getScheme().toLowerCase())) { @@ -248,12 +250,11 @@ public URI parseToSafeURI(String serializedURI) throws URISyntaxException, Secur } catch (URISyntaxException e) { // We don't try to repair URI if they use our internal marker to avoid mistakes. if (serializedURI.contains(PERCENT_ESCAPE)) { - throw new IllegalArgumentException( - String.format("The given uri [%s] contains the string [%s] which is used internally " + throw new IllegalArgumentException(String.format( + "The given uri [%s] contains the string [%s] which is used internally " + "for performing escaping operations when trying to 'repair' a URI which cannot be parsed. " + "Check the original error for repairing the URI or try to use a different marker.", - serializedURI, - PERCENT_ESCAPE), e); + serializedURI, PERCENT_ESCAPE), e); } // Attempt repairing the invalid URI similar to org.eclipse.jetty.client.HttpRedirector#sanitize by // extracting the different parts and then passing them to the multi-argument constructor that quotes @@ -279,8 +280,7 @@ public URI parseToSafeURI(String serializedURI) throws URISyntaxException, Secur if (this.isURITrusted(uri)) { return uri; } else { - throw new SecurityException(String.format("The given URI [%s] is not safe on this server.", - uri)); + throw new SecurityException(String.format("The given URI [%s] is not safe on this server.", uri)); } } @@ -297,8 +297,8 @@ public URI parseToSafeURI(String serializedURI, String requestHost) throws URISy * replacement chain if and only if this {@code %} character belongs to a percent encoded byte. * * @param originalString the string to parse - * @return a string containing a replacement chain for all {@code %} characters not belonging to a percent - * encoded byte + * @return a string containing a replacement chain for all {@code %} characters not belonging to a percent encoded + * byte */ private String replaceUnquotedPercent(String originalString) { @@ -307,8 +307,8 @@ private String replaceUnquotedPercent(String originalString) char[] charArray = originalString.toCharArray(); for (int i = 0; i < charArray.length; i++) { char currentChar = charArray[i]; - if ((currentChar == PERCENT) && (i < (charArray.length - 2)) - && isQuotedChar(charArray[i + 1]) && isQuotedChar(charArray[i + 2])) { + if ((currentChar == PERCENT) && (i < (charArray.length - 2)) && isQuotedChar(charArray[i + 1]) + && isQuotedChar(charArray[i + 2])) { result.append(PERCENT_ESCAPE); } else { result.append(currentChar); @@ -322,6 +322,7 @@ && isQuotedChar(charArray[i + 1]) && isQuotedChar(charArray[i + 2])) { /** * Check if the given char belongs to the range of character that forms a percent encoded byte. + * * @param nextChar the char to check if it belongs to the range * @return {@code true} if it belongs to the range */ diff --git a/xwiki-platform-core/xwiki-platform-url/xwiki-platform-url-default/src/test/java/org/xwiki/url/internal/DefaultURLSecurityManagerTest.java b/xwiki-platform-core/xwiki-platform-url/xwiki-platform-url-default/src/test/java/org/xwiki/url/internal/DefaultURLSecurityManagerTest.java index 0e1e304271a4..81a5ed87d9a7 100644 --- a/xwiki-platform-core/xwiki-platform-url/xwiki-platform-url-default/src/test/java/org/xwiki/url/internal/DefaultURLSecurityManagerTest.java +++ b/xwiki-platform-core/xwiki-platform-url/xwiki-platform-url-default/src/test/java/org/xwiki/url/internal/DefaultURLSecurityManagerTest.java @@ -28,11 +28,14 @@ import java.util.List; import javax.inject.Provider; -import javax.servlet.http.HttpServletRequest; + +import jakarta.servlet.http.HttpServletRequest; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; +import org.xwiki.container.Container; +import org.xwiki.container.servlet.ServletRequest; import org.xwiki.context.Execution; import org.xwiki.context.ExecutionContext; import org.xwiki.test.LogLevel; @@ -46,7 +49,6 @@ import org.xwiki.wiki.descriptor.WikiDescriptorManager; import com.xpn.xwiki.XWikiContext; -import com.xpn.xwiki.web.XWikiRequest; import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -80,6 +82,9 @@ class DefaultURLSecurityManagerTest @MockComponent private Execution execution; + @MockComponent + private Container container; + @MockComponent private Provider contextProvider; @@ -119,10 +124,11 @@ void isDomainTrusted() throws Exception "enterprise.eu" )); - XWikiRequest request = mock(XWikiRequest.class); - when(this.xWikiContext.getRequest()).thenReturn(request); - HttpServletRequest servletRequest = mock(HttpServletRequest.class); - when(request.getHttpServletRequest()).thenReturn(servletRequest); + ServletRequest request = mock(); + when(this.container.getRequest()).thenReturn(request); + HttpServletRequest servletRequest = mock(); + when(request.getRequest()).thenReturn(servletRequest); + when(servletRequest.getScheme()).thenReturn("http"); when(servletRequest.getRequestURL()).thenReturn(new StringBuffer("http://localhost:8080/xwiki/bin/register/")); when(this.wikiDescriptorManager.getAll()).thenReturn(Arrays.asList(wikiDescriptor1, wikiDescriptor2)); diff --git a/xwiki-platform-core/xwiki-platform-url/xwiki-platform-url-schemes/xwiki-platform-url-scheme-standard/pom.xml b/xwiki-platform-core/xwiki-platform-url/xwiki-platform-url-schemes/xwiki-platform-url-scheme-standard/pom.xml index 1b764488d246..a34edf8d10bc 100644 --- a/xwiki-platform-core/xwiki-platform-url/xwiki-platform-url-schemes/xwiki-platform-url-scheme-standard/pom.xml +++ b/xwiki-platform-core/xwiki-platform-url/xwiki-platform-url-schemes/xwiki-platform-url-scheme-standard/pom.xml @@ -65,8 +65,8 @@ ${project.version} - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api diff --git a/xwiki-platform-core/xwiki-platform-user/xwiki-platform-user-default/pom.xml b/xwiki-platform-core/xwiki-platform-user/xwiki-platform-user-default/pom.xml index 5928dd693bb9..224eb12e500a 100644 --- a/xwiki-platform-core/xwiki-platform-user/xwiki-platform-user-default/pom.xml +++ b/xwiki-platform-core/xwiki-platform-user/xwiki-platform-user-default/pom.xml @@ -64,6 +64,7 @@ xwiki-platform-configuration-default ${project.version} + org.xwiki.platform diff --git a/xwiki-platform-core/xwiki-platform-user/xwiki-platform-user-resource/pom.xml b/xwiki-platform-core/xwiki-platform-user/xwiki-platform-user-resource/pom.xml index 2f4fb03127da..19b55c15769d 100644 --- a/xwiki-platform-core/xwiki-platform-user/xwiki-platform-user-resource/pom.xml +++ b/xwiki-platform-core/xwiki-platform-user/xwiki-platform-user-resource/pom.xml @@ -59,8 +59,8 @@ test - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test diff --git a/xwiki-platform-core/xwiki-platform-velocity/xwiki-platform-velocity-webapp/pom.xml b/xwiki-platform-core/xwiki-platform-velocity/xwiki-platform-velocity-webapp/pom.xml index aa08f1c775b1..57db5200183e 100644 --- a/xwiki-platform-core/xwiki-platform-velocity/xwiki-platform-velocity-webapp/pom.xml +++ b/xwiki-platform-core/xwiki-platform-velocity/xwiki-platform-velocity-webapp/pom.xml @@ -46,8 +46,8 @@ ${project.version} - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api diff --git a/xwiki-platform-core/xwiki-platform-vfs/xwiki-platform-vfs-api/pom.xml b/xwiki-platform-core/xwiki-platform-vfs/xwiki-platform-vfs-api/pom.xml index fd485b831e75..35f473df0d49 100644 --- a/xwiki-platform-core/xwiki-platform-vfs/xwiki-platform-vfs-api/pom.xml +++ b/xwiki-platform-core/xwiki-platform-vfs/xwiki-platform-vfs-api/pom.xml @@ -223,8 +223,8 @@ - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test diff --git a/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-war/src/main/webapp/WEB-INF/jetty-web.xml b/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-war/src/main/webapp/WEB-INF/jetty-web.xml index 489e4a8e6d2d..474918d675ad 100644 --- a/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-war/src/main/webapp/WEB-INF/jetty-web.xml +++ b/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-war/src/main/webapp/WEB-INF/jetty-web.xml @@ -1,5 +1,5 @@ - + - + + + ResolveRelativeRedirectFilter + org.xwiki.container.servlet.filters.internal.ResolveRelativeRedirectFilter + + + + + SafeRedirectFilter + org.xwiki.container.servlet.filters.internal.SafeRedirectFilter + + diff --git a/xwiki-platform-core/xwiki-platform-webjars/xwiki-platform-webjars-api/src/test/java/org/xwiki/webjars/internal/WebJarsResourceReferenceHandlerTest.java b/xwiki-platform-core/xwiki-platform-webjars/xwiki-platform-webjars-api/src/test/java/org/xwiki/webjars/internal/WebJarsResourceReferenceHandlerTest.java index 33ccf91b7342..e62411a09a89 100644 --- a/xwiki-platform-core/xwiki-platform-webjars/xwiki-platform-webjars-api/src/test/java/org/xwiki/webjars/internal/WebJarsResourceReferenceHandlerTest.java +++ b/xwiki-platform-core/xwiki-platform-webjars/xwiki-platform-webjars-api/src/test/java/org/xwiki/webjars/internal/WebJarsResourceReferenceHandlerTest.java @@ -26,8 +26,9 @@ import java.util.Date; import javax.inject.Named; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import org.apache.commons.io.input.CharSequenceInputStream; import org.apache.velocity.exception.VelocityException; @@ -114,11 +115,11 @@ void setUp() throws Exception when(this.response.getOutputStream()).thenReturn(responseOutputStream); HttpServletResponse httpResponse = mock(HttpServletResponse.class); - when(this.response.getHttpServletResponse()).thenReturn(httpResponse); + when(this.response.getResponse()).thenReturn(httpResponse); when(this.container.getResponse()).thenReturn(this.response); HttpServletRequest httpRequest = mock(HttpServletRequest.class); - when(this.request.getHttpServletRequest()).thenReturn(httpRequest); + when(this.request.getRequest()).thenReturn(httpRequest); when(this.container.getRequest()).thenReturn(this.request); when(this.classLoaderManager.getURLClassLoader("wiki:wiki", true)).thenReturn(this.classLoader); @@ -133,8 +134,8 @@ void executeWhenResourceDoesntExist() throws Exception this.handler.handle(reference, this.chain); verify(this.classLoader).getResourceAsStream("META-INF/resources/webjars/angular/2.1.11/angular.js"); - verify(this.response.getHttpServletResponse()) - .sendError(404, "Resource not found [angular/2.1.11/angular.js]."); + verify(this.response.getResponse()).sendError(404, + "Resource not found [angular/2.1.11/angular.js]."); verify(this.chain).handleNext(reference); } @@ -145,8 +146,8 @@ void executeWhenResourceExists() throws Exception new WebJarsResourceReference("wiki:wiki", asList("angular", "2.1.11", "angular.js")); ByteArrayInputStream resourceStream = new ByteArrayInputStream("content".getBytes()); - when(this.classLoader.getResourceAsStream("META-INF/resources/webjars/angular/2.1.11/angular.js")).thenReturn( - resourceStream); + when(this.classLoader.getResourceAsStream("META-INF/resources/webjars/angular/2.1.11/angular.js")) + .thenReturn(resourceStream); long now = new Date().getTime(); this.handler.handle(reference, this.chain); @@ -160,15 +161,15 @@ void executeWhenResourceExists() throws Exception verify(this.response).setContentType("application/javascript"); // Verify that the static resource is cached permanently. - verify(this.response.getHttpServletResponse()).setHeader("Cache-Control", "public"); + verify(this.response.getResponse()).setHeader("Cache-Control", "public"); ArgumentCaptor expireDate = ArgumentCaptor.forClass(Long.class); - verify(this.response.getHttpServletResponse()).setDateHeader(eq("Expires"), expireDate.capture()); + verify(this.response.getResponse()).setDateHeader(eq("Expires"), expireDate.capture()); // The expiration date should be in one year from now. assertTrue(expireDate.getValue() >= (now + 365 * 24 * 3600 * 1000L)); // Also verify that the "Last-Modified" header has been set in the response so that the browser will send // an If-Modified-Since header for the next request and we can tell it to use its cache. - verify(this.response.getHttpServletResponse()).setDateHeader(eq("Last-Modified"), anyLong()); + verify(this.response.getResponse()).setDateHeader(eq("Last-Modified"), anyLong()); verify(this.chain).handleNext(reference); } @@ -179,12 +180,12 @@ void return304WhenIfModifiedSinceHeader() throws Exception WebJarsResourceReference reference = new WebJarsResourceReference("wiki:wiki", asList("angular", "2.1.11", "angular.js")); - when(this.request.getHttpServletRequest().getHeader("If-Modified-Since")).thenReturn("some value"); + when(this.request.getRequest().getHeader("If-Modified-Since")).thenReturn("some value"); this.handler.handle(reference, this.chain); // This the test: we verify that 304 is returned when the "If-Modified-Since" header is found in the request - verify(this.response.getHttpServletResponse()).setStatus(304); + verify(this.response.getResponse()).setStatus(304); verify(this.chain).handleNext(reference); } @@ -198,8 +199,7 @@ void evaluateResource() throws Exception try (ByteArrayInputStream resourceStream = new ByteArrayInputStream("content".getBytes())) { when(this.classLoader.getResourceAsStream("META-INF/resources/webjars/angular/2.1.11/angular.js")) - .thenReturn( - resourceStream); + .thenReturn(resourceStream); } when(this.velocityFilter.filter(any(), any())) @@ -214,8 +214,8 @@ void evaluateResource() throws Exception verify(this.response).setContentType("application/javascript"); // Verify that the dynamic resource is not cached. - verify(this.response.getHttpServletResponse(), never()).setHeader(any(), any()); - verify(this.response.getHttpServletResponse(), never()).setDateHeader(any(), anyLong()); + verify(this.response.getResponse(), never()).setHeader(any(), any()); + verify(this.response.getResponse(), never()).setDateHeader(any(), anyLong()); } @Test @@ -243,7 +243,7 @@ void failingResourceEvaluation() throws Exception this.logCapture.getMessage(0)); // Verify that the client is properly notified about the failure. - verify(this.response.getHttpServletResponse()).sendError(500, + verify(this.response.getResponse()).sendError(500, "Failed to evaluate the Velocity code from WebJar resource [angular/2.1.11/angular.js]"); // The next handlers are still called. @@ -284,9 +284,8 @@ void getContentType() throws Exception WebJarsResourceReference resourceReference = new WebJarsResourceReference("testNamespace", asList("testdirectory", "testfile.less")); - String mimeType = - this.handler.getContentType(new CharSequenceInputStream("a:\n color: #f00;", StandardCharsets.UTF_8), - resourceReference); + String mimeType = this.handler.getContentType( + new CharSequenceInputStream("a:\n color: #f00;", StandardCharsets.UTF_8), resourceReference); assertEquals("text/x-less", mimeType); } @@ -297,9 +296,8 @@ void getContentTypeLessAndEvaluate() throws Exception new WebJarsResourceReference("testNamespace", asList("testdirectory", "testfile.less")); resourceReference.addParameter("evaluate", "true"); - String mimeType = - this.handler.getContentType(new CharSequenceInputStream("a:\n color: #f00;", StandardCharsets.UTF_8), - resourceReference); + String mimeType = this.handler.getContentType( + new CharSequenceInputStream("a:\n color: #f00;", StandardCharsets.UTF_8), resourceReference); assertEquals("text/css", mimeType); } diff --git a/xwiki-platform-core/xwiki-platform-websocket/pom.xml b/xwiki-platform-core/xwiki-platform-websocket/pom.xml index c9da5daa6868..d8bd69838cee 100644 --- a/xwiki-platform-core/xwiki-platform-websocket/pom.xml +++ b/xwiki-platform-core/xwiki-platform-websocket/pom.xml @@ -52,12 +52,16 @@ ${project.version} - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api - javax.websocket - javax.websocket-api + jakarta.websocket + jakarta.websocket-api + + + jakarta.websocket + jakarta.websocket-client-api diff --git a/xwiki-platform-core/xwiki-platform-websocket/src/main/java/org/xwiki/websocket/AbstractXWikiEndpoint.java b/xwiki-platform-core/xwiki-platform-websocket/src/main/java/org/xwiki/websocket/AbstractXWikiEndpoint.java index af8cee9fc621..8fcbd6dd1881 100644 --- a/xwiki-platform-core/xwiki-platform-websocket/src/main/java/org/xwiki/websocket/AbstractXWikiEndpoint.java +++ b/xwiki-platform-core/xwiki-platform-websocket/src/main/java/org/xwiki/websocket/AbstractXWikiEndpoint.java @@ -26,10 +26,11 @@ import java.util.List; import javax.inject.Inject; -import javax.websocket.CloseReason; -import javax.websocket.EncodeException; -import javax.websocket.Endpoint; -import javax.websocket.Session; + +import jakarta.websocket.CloseReason; +import jakarta.websocket.EncodeException; +import jakarta.websocket.Endpoint; +import jakarta.websocket.Session; import org.apache.commons.lang3.exception.ExceptionUtils; import org.slf4j.Logger; diff --git a/xwiki-platform-core/xwiki-platform-websocket/src/main/java/org/xwiki/websocket/internal/DefaultWebSocketContext.java b/xwiki-platform-core/xwiki-platform-websocket/src/main/java/org/xwiki/websocket/internal/DefaultWebSocketContext.java index 767e51efea53..17630e188d19 100644 --- a/xwiki-platform-core/xwiki-platform-websocket/src/main/java/org/xwiki/websocket/internal/DefaultWebSocketContext.java +++ b/xwiki-platform-core/xwiki-platform-websocket/src/main/java/org/xwiki/websocket/internal/DefaultWebSocketContext.java @@ -25,10 +25,6 @@ import javax.inject.Inject; import javax.inject.Singleton; -import javax.websocket.HandshakeResponse; -import javax.websocket.Session; -import javax.websocket.server.HandshakeRequest; -import javax.websocket.server.ServerEndpointConfig; import org.slf4j.Logger; import org.xwiki.component.annotation.Component; @@ -38,11 +34,19 @@ import org.xwiki.container.servlet.ServletSession; import org.xwiki.context.Execution; import org.xwiki.context.ExecutionContext; +import org.xwiki.jakartabridge.servlet.JakartaServletBridge; import org.xwiki.websocket.WebSocketContext; import com.xpn.xwiki.XWikiContext; import com.xpn.xwiki.user.api.XWikiUser; import com.xpn.xwiki.util.XWikiStubContextProvider; +import com.xpn.xwiki.web.XWikiServletRequest; +import com.xpn.xwiki.web.XWikiServletResponse; + +import jakarta.websocket.HandshakeResponse; +import jakarta.websocket.Session; +import jakarta.websocket.server.HandshakeRequest; +import jakarta.websocket.server.ServerEndpointConfig; /** * Default {@link WebSocketContext} implementation. Initializes the XWiki execution context and binds it to the @@ -52,6 +56,7 @@ * @version $Id$ * @since 13.7RC1 */ +@SuppressWarnings("checkstyle:ClassFanOutComplexity") @Component @Singleton public class DefaultWebSocketContext implements WebSocketContext @@ -116,9 +121,13 @@ private void initialize(ExecutionContext context) XWikiContext xcontext = getXWikiContext(); if (xcontext != null) { - this.container.setRequest(new ServletRequest(xcontext.getRequest())); - this.container.setResponse(new ServletResponse(xcontext.getResponse())); - this.container.setSession(new ServletSession(xcontext.getRequest())); + if (xcontext.getRequest() != null) { + this.container.setRequest(new ServletRequest(xcontext.getRequest())); + this.container.setSession(new ServletSession(xcontext.getRequest())); + } + if (xcontext.getResponse() != null) { + this.container.setResponse(new ServletResponse(xcontext.getResponse())); + } } } @@ -159,8 +168,10 @@ private ExecutionContext createExecutionContext(ServerEndpointConfig config, Han xcontext.setWikiId(wiki); } - xcontext.setRequest(new XWikiWebSocketRequestStub(request)); - xcontext.setResponse(new XWikiWebSocketResponseStub(response)); + xcontext.setRequest( + new XWikiServletRequest(JakartaServletBridge.toJavax(new XWikiWebSocketRequestStub(request)))); + xcontext.setResponse( + new XWikiServletResponse(JakartaServletBridge.toJavax(new XWikiWebSocketResponseStub(response)))); xcontext.declareInExecutionContext(context); } diff --git a/xwiki-platform-core/xwiki-platform-websocket/src/main/java/org/xwiki/websocket/internal/DynamicEchoEndpoint.java b/xwiki-platform-core/xwiki-platform-websocket/src/main/java/org/xwiki/websocket/internal/DynamicEchoEndpoint.java index 9db5a523f5a8..532d2c7cedc8 100644 --- a/xwiki-platform-core/xwiki-platform-websocket/src/main/java/org/xwiki/websocket/internal/DynamicEchoEndpoint.java +++ b/xwiki-platform-core/xwiki-platform-websocket/src/main/java/org/xwiki/websocket/internal/DynamicEchoEndpoint.java @@ -22,10 +22,11 @@ import javax.inject.Inject; import javax.inject.Named; import javax.inject.Singleton; -import javax.websocket.CloseReason; -import javax.websocket.EndpointConfig; -import javax.websocket.MessageHandler; -import javax.websocket.Session; + +import jakarta.websocket.CloseReason; +import jakarta.websocket.EndpointConfig; +import jakarta.websocket.MessageHandler; +import jakarta.websocket.Session; import org.xwiki.bridge.DocumentAccessBridge; import org.xwiki.component.annotation.Component; diff --git a/xwiki-platform-core/xwiki-platform-websocket/src/main/java/org/xwiki/websocket/internal/StaticEchoEndpoint.java b/xwiki-platform-core/xwiki-platform-websocket/src/main/java/org/xwiki/websocket/internal/StaticEchoEndpoint.java index d25f5e935a3e..8dd5f9b4b305 100644 --- a/xwiki-platform-core/xwiki-platform-websocket/src/main/java/org/xwiki/websocket/internal/StaticEchoEndpoint.java +++ b/xwiki-platform-core/xwiki-platform-websocket/src/main/java/org/xwiki/websocket/internal/StaticEchoEndpoint.java @@ -24,11 +24,12 @@ import javax.inject.Inject; import javax.inject.Named; import javax.inject.Singleton; -import javax.websocket.CloseReason; -import javax.websocket.OnMessage; -import javax.websocket.OnOpen; -import javax.websocket.Session; -import javax.websocket.server.ServerEndpoint; + +import jakarta.websocket.CloseReason; +import jakarta.websocket.OnMessage; +import jakarta.websocket.OnOpen; +import jakarta.websocket.Session; +import jakarta.websocket.server.ServerEndpoint; import org.slf4j.Logger; import org.xwiki.bridge.DocumentAccessBridge; diff --git a/xwiki-platform-core/xwiki-platform-websocket/src/main/java/org/xwiki/websocket/internal/XWikiWebSocketRequestStub.java b/xwiki-platform-core/xwiki-platform-websocket/src/main/java/org/xwiki/websocket/internal/XWikiWebSocketRequestStub.java index 9f01f14c134d..1965cc841d34 100644 --- a/xwiki-platform-core/xwiki-platform-websocket/src/main/java/org/xwiki/websocket/internal/XWikiWebSocketRequestStub.java +++ b/xwiki-platform-core/xwiki-platform-websocket/src/main/java/org/xwiki/websocket/internal/XWikiWebSocketRequestStub.java @@ -33,23 +33,21 @@ import java.util.Optional; import java.util.TreeMap; -import javax.servlet.http.Cookie; -import javax.servlet.http.HttpSession; -import javax.websocket.server.HandshakeRequest; +import jakarta.servlet.http.Cookie; +import jakarta.servlet.http.HttpSession; +import jakarta.websocket.server.HandshakeRequest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - -import com.xpn.xwiki.web.XWikiRequest; -import com.xpn.xwiki.web.XWikiServletRequestStub; +import org.xwiki.container.servlet.HttpServletRequestStub; /** - * Adapts a {@link HandshakeRequest} to {@link XWikiRequest}. + * Adapts a {@link HandshakeRequest} to {@link jakarta.servlet.http.HttpServletRequest}. * * @version $Id$ * @since 13.7RC1 */ -public class XWikiWebSocketRequestStub extends XWikiServletRequestStub +public class XWikiWebSocketRequestStub extends HttpServletRequestStub { private static final Logger LOGGER = LoggerFactory.getLogger(XWikiWebSocketRequestStub.class); diff --git a/xwiki-platform-core/xwiki-platform-websocket/src/main/java/org/xwiki/websocket/internal/XWikiWebSocketResponseStub.java b/xwiki-platform-core/xwiki-platform-websocket/src/main/java/org/xwiki/websocket/internal/XWikiWebSocketResponseStub.java index 807e94650a48..ad8e6c290282 100644 --- a/xwiki-platform-core/xwiki-platform-websocket/src/main/java/org/xwiki/websocket/internal/XWikiWebSocketResponseStub.java +++ b/xwiki-platform-core/xwiki-platform-websocket/src/main/java/org/xwiki/websocket/internal/XWikiWebSocketResponseStub.java @@ -33,24 +33,21 @@ import java.util.Set; import java.util.stream.Collectors; -import javax.servlet.http.Cookie; -import javax.websocket.HandshakeResponse; +import jakarta.servlet.http.Cookie; +import jakarta.websocket.HandshakeResponse; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - -import com.xpn.xwiki.web.XWikiRequest; -import com.xpn.xwiki.web.XWikiResponse; -import com.xpn.xwiki.web.XWikiServletResponseStub; +import org.xwiki.container.servlet.HttpServletResponseStub; /** - * Adapts a {@link HandshakeResponse} to {@link XWikiResponse}. + * Adapts a {@link HandshakeResponse} to {@link jakarta.servlet.http.HttpServletResponse}. * * @version $Id$ * @since 13.7RC1 */ -public class XWikiWebSocketResponseStub extends XWikiServletResponseStub +public class XWikiWebSocketResponseStub extends HttpServletResponseStub { private static final Logger LOGGER = LoggerFactory.getLogger(XWikiWebSocketResponseStub.class); @@ -185,15 +182,4 @@ public void addCookie(Cookie cookie) addHeader("Set-Cookie", header.toString()); } - - @Override - public void removeCookie(String cookieName, XWikiRequest request) - { - Cookie cookie = request.getCookie(cookieName); - if (cookie != null) { - cookie.setMaxAge(0); - cookie.setPath(cookie.getPath()); - addCookie(cookie); - } - } } diff --git a/xwiki-platform-core/xwiki-platform-websocket/src/test/java/org/xwiki/websocket/internal/DefaultWebSocketContextTest.java b/xwiki-platform-core/xwiki-platform-websocket/src/test/java/org/xwiki/websocket/internal/DefaultWebSocketContextTest.java index ecb65ddffa8f..22677bccfd74 100644 --- a/xwiki-platform-core/xwiki-platform-websocket/src/test/java/org/xwiki/websocket/internal/DefaultWebSocketContextTest.java +++ b/xwiki-platform-core/xwiki-platform-websocket/src/test/java/org/xwiki/websocket/internal/DefaultWebSocketContextTest.java @@ -24,11 +24,11 @@ import java.util.HashMap; import java.util.Map; -import javax.servlet.http.HttpSession; -import javax.websocket.HandshakeResponse; -import javax.websocket.Session; -import javax.websocket.server.HandshakeRequest; -import javax.websocket.server.ServerEndpointConfig; +import jakarta.servlet.http.HttpSession; +import jakarta.websocket.HandshakeResponse; +import jakarta.websocket.Session; +import jakarta.websocket.server.HandshakeRequest; +import jakarta.websocket.server.ServerEndpointConfig; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/xwiki-platform-core/xwiki-platform-websocket/src/test/java/org/xwiki/websocket/internal/DynamicEchoEndpointTest.java b/xwiki-platform-core/xwiki-platform-websocket/src/test/java/org/xwiki/websocket/internal/DynamicEchoEndpointTest.java index e3b6a08bde71..df9831a14d3d 100644 --- a/xwiki-platform-core/xwiki-platform-websocket/src/test/java/org/xwiki/websocket/internal/DynamicEchoEndpointTest.java +++ b/xwiki-platform-core/xwiki-platform-websocket/src/test/java/org/xwiki/websocket/internal/DynamicEchoEndpointTest.java @@ -19,10 +19,10 @@ */ package org.xwiki.websocket.internal; -import javax.websocket.CloseReason; -import javax.websocket.MessageHandler; -import javax.websocket.RemoteEndpoint.Basic; -import javax.websocket.Session; +import jakarta.websocket.CloseReason; +import jakarta.websocket.MessageHandler; +import jakarta.websocket.RemoteEndpoint.Basic; +import jakarta.websocket.Session; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/xwiki-platform-core/xwiki-platform-websocket/src/test/java/org/xwiki/websocket/internal/XWikiWebSocketRequestStubTest.java b/xwiki-platform-core/xwiki-platform-websocket/src/test/java/org/xwiki/websocket/internal/XWikiWebSocketRequestStubTest.java index 9b17de29365f..93db0fb0ddf6 100644 --- a/xwiki-platform-core/xwiki-platform-websocket/src/test/java/org/xwiki/websocket/internal/XWikiWebSocketRequestStubTest.java +++ b/xwiki-platform-core/xwiki-platform-websocket/src/test/java/org/xwiki/websocket/internal/XWikiWebSocketRequestStubTest.java @@ -26,9 +26,10 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.stream.Stream; -import javax.servlet.http.HttpSession; -import javax.websocket.server.HandshakeRequest; +import jakarta.servlet.http.HttpSession; +import jakarta.websocket.server.HandshakeRequest; import org.junit.jupiter.api.Test; @@ -80,7 +81,9 @@ void verifyStub() throws Exception assertEquals("red", stub.getParameter("color")); assertArrayEquals(new String[] {"red", "blue"}, stub.getParameterValues("color")); - assertEquals("xyz", stub.getCookie("validation").getValue()); + String validationCookie = Stream.of(stub.getCookies()).filter(c -> c.getName().equals("validation")) + .map(c -> c.getValue()).findFirst().get(); + assertEquals("xyz", validationCookie); assertEquals(6, stub.getCookies().length); assertEquals(1212491130000L, stub.getDateHeader("daTe")); diff --git a/xwiki-platform-core/xwiki-platform-websocket/src/test/java/org/xwiki/websocket/internal/XWikiWebSocketResponseStubTest.java b/xwiki-platform-core/xwiki-platform-websocket/src/test/java/org/xwiki/websocket/internal/XWikiWebSocketResponseStubTest.java index ec88e98c5ed5..13e5e67c78e2 100644 --- a/xwiki-platform-core/xwiki-platform-websocket/src/test/java/org/xwiki/websocket/internal/XWikiWebSocketResponseStubTest.java +++ b/xwiki-platform-core/xwiki-platform-websocket/src/test/java/org/xwiki/websocket/internal/XWikiWebSocketResponseStubTest.java @@ -26,13 +26,11 @@ import java.util.List; import java.util.Map; -import javax.servlet.http.Cookie; -import javax.websocket.HandshakeResponse; +import jakarta.servlet.http.Cookie; +import jakarta.websocket.HandshakeResponse; import org.junit.jupiter.api.Test; -import com.xpn.xwiki.web.XWikiRequest; - import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNull; @@ -59,15 +57,13 @@ void verifyStub() stub.addCookie(new Cookie("foo", "bar")); - XWikiRequest request = mock(XWikiRequest.class); Cookie cookie = new Cookie("bar", "abc"); cookie.setDomain("xwiki.org"); cookie.setPath("/xwiki/websocket"); - cookie.setMaxAge(3600); cookie.setHttpOnly(true); cookie.setSecure(true); - when(request.getCookie("bar")).thenReturn(cookie); - stub.removeCookie("bar", request); + cookie.setMaxAge(0); + stub.addCookie(cookie); stub.setDateHeader("datE", 1626247690000L); stub.addDateHeader("Date", 1212491130000L); diff --git a/xwiki-platform-core/xwiki-platform-wiki/xwiki-platform-wiki-creationjob/pom.xml b/xwiki-platform-core/xwiki-platform-wiki/xwiki-platform-wiki-creationjob/pom.xml index 333613ea5dfc..5eb64dd588b2 100644 --- a/xwiki-platform-core/xwiki-platform-wiki/xwiki-platform-wiki-creationjob/pom.xml +++ b/xwiki-platform-core/xwiki-platform-wiki/xwiki-platform-wiki-creationjob/pom.xml @@ -92,8 +92,8 @@ - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test diff --git a/xwiki-platform-core/xwiki-platform-wiki/xwiki-platform-wiki-default/pom.xml b/xwiki-platform-core/xwiki-platform-wiki/xwiki-platform-wiki-default/pom.xml index e501f0a4a55c..1d14ca5e78f0 100644 --- a/xwiki-platform-core/xwiki-platform-wiki/xwiki-platform-wiki-default/pom.xml +++ b/xwiki-platform-core/xwiki-platform-wiki/xwiki-platform-wiki-default/pom.xml @@ -76,8 +76,8 @@ ${project.version} - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api diff --git a/xwiki-platform-core/xwiki-platform-wiki/xwiki-platform-wiki-script/pom.xml b/xwiki-platform-core/xwiki-platform-wiki/xwiki-platform-wiki-script/pom.xml index 4df29dd5b387..37e52e6053e6 100644 --- a/xwiki-platform-core/xwiki-platform-wiki/xwiki-platform-wiki-script/pom.xml +++ b/xwiki-platform-core/xwiki-platform-wiki/xwiki-platform-wiki-script/pom.xml @@ -65,8 +65,8 @@ - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test diff --git a/xwiki-platform-core/xwiki-platform-wiki/xwiki-platform-wiki-template/xwiki-platform-wiki-template-default/pom.xml b/xwiki-platform-core/xwiki-platform-wiki/xwiki-platform-wiki-template/xwiki-platform-wiki-template-default/pom.xml index 2553a028b0cf..6ee09508a017 100644 --- a/xwiki-platform-core/xwiki-platform-wiki/xwiki-platform-wiki-template/xwiki-platform-wiki-template-default/pom.xml +++ b/xwiki-platform-core/xwiki-platform-wiki/xwiki-platform-wiki-template/xwiki-platform-wiki-template-default/pom.xml @@ -53,8 +53,8 @@ - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test diff --git a/xwiki-platform-core/xwiki-platform-wiki/xwiki-platform-wiki-template/xwiki-platform-wiki-template-script/pom.xml b/xwiki-platform-core/xwiki-platform-wiki/xwiki-platform-wiki-template/xwiki-platform-wiki-template-script/pom.xml index 6c55c4c3053f..5bbe8bfbe8a3 100644 --- a/xwiki-platform-core/xwiki-platform-wiki/xwiki-platform-wiki-template/xwiki-platform-wiki-template-script/pom.xml +++ b/xwiki-platform-core/xwiki-platform-wiki/xwiki-platform-wiki-template/xwiki-platform-wiki-template-script/pom.xml @@ -50,8 +50,8 @@ - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test diff --git a/xwiki-platform-core/xwiki-platform-wiki/xwiki-platform-wiki-user/xwiki-platform-wiki-user-script/pom.xml b/xwiki-platform-core/xwiki-platform-wiki/xwiki-platform-wiki-user/xwiki-platform-wiki-user-script/pom.xml index d5904cf95980..7482ccd75ae6 100644 --- a/xwiki-platform-core/xwiki-platform-wiki/xwiki-platform-wiki-user/xwiki-platform-wiki-user-script/pom.xml +++ b/xwiki-platform-core/xwiki-platform-wiki/xwiki-platform-wiki-user/xwiki-platform-wiki-user-script/pom.xml @@ -53,8 +53,8 @@ - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test diff --git a/xwiki-platform-core/xwiki-platform-wiki/xwiki-platform-wiki-workspaces-migrator/pom.xml b/xwiki-platform-core/xwiki-platform-wiki/xwiki-platform-wiki-workspaces-migrator/pom.xml index 88e3040b4b95..e07c4108d599 100644 --- a/xwiki-platform-core/xwiki-platform-wiki/xwiki-platform-wiki-workspaces-migrator/pom.xml +++ b/xwiki-platform-core/xwiki-platform-wiki/xwiki-platform-wiki-workspaces-migrator/pom.xml @@ -53,8 +53,8 @@ - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test diff --git a/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/pom.xml b/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/pom.xml index faefa8aeb398..504dbf667b21 100644 --- a/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/pom.xml +++ b/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/pom.xml @@ -37,9 +37,9 @@ WYSIWYG Editor Module - - javax.servlet - javax.servlet-api + + jakarta.servlet + jakarta.servlet-api diff --git a/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/converter/JakartaRequestParameterConversionResult.java b/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/converter/JakartaRequestParameterConversionResult.java new file mode 100644 index 000000000000..319e8b02806c --- /dev/null +++ b/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/converter/JakartaRequestParameterConversionResult.java @@ -0,0 +1,78 @@ +/* + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.xwiki.wysiwyg.converter; + +import java.util.LinkedHashMap; +import java.util.Map; + +import org.xwiki.wysiwyg.filter.MutableJakartaServletRequest; + +/** + * Simple POJO holding the result of a conversion performed with {@link RequestParameterConverter}. More specifically + * this class contains a mutable request, resulting of the conversion, a map of errors that might have occurred during + * the conversion for each parameter, and a map of the output of the conversion for each parameter. + * + * @version $Id$ + * @since 42.0.0 + */ +public class JakartaRequestParameterConversionResult +{ + private MutableJakartaServletRequest request; + + private Map errors; + + private Map output; + + /** + * Default constructor. + * + * @param request a mutable copy of the original request used for the conversion + */ + public JakartaRequestParameterConversionResult(MutableJakartaServletRequest request) + { + this.request = request; + this.errors = new LinkedHashMap<>(); + this.output = new LinkedHashMap<>(); + } + + /** + * @return the mutable request + */ + public MutableJakartaServletRequest getRequest() + { + return request; + } + + /** + * @return the map of errors indexed by parameters + */ + public Map getErrors() + { + return errors; + } + + /** + * @return the map of conversion output indexed by parameters + */ + public Map getOutput() + { + return output; + } +} diff --git a/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/converter/RequestParameterConversionResult.java b/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/converter/RequestParameterConversionResult.java index f81bb6c53ebd..8672b6a31659 100644 --- a/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/converter/RequestParameterConversionResult.java +++ b/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/converter/RequestParameterConversionResult.java @@ -23,19 +23,24 @@ import java.util.Map; import org.xwiki.wysiwyg.filter.MutableServletRequest; +import org.xwiki.wysiwyg.internal.filter.http.JavaxToJakartaMutableHttpServletRequest; /** - * Simple POJO holding the result of a conversion performed with {@link RequestParameterConverter}. - * More specifically this class contains a mutable request, resulting of the conversion, a map of errors that might have - * occurred during the conversion for each parameter, and a map of the output of the conversion for each parameter. + * Simple POJO holding the result of a conversion performed with {@link RequestParameterConverter}. More specifically + * this class contains a mutable request, resulting of the conversion, a map of errors that might have occurred during + * the conversion for each parameter, and a map of the output of the conversion for each parameter. * * @version $Id$ * @since 14.10 + * @deprecated use {@link JakartaRequestParameterConversionResult} instead */ +@Deprecated(since = "42.0.0") public class RequestParameterConversionResult { private MutableServletRequest request; + private Map errors; + private Map output; /** @@ -50,6 +55,19 @@ public RequestParameterConversionResult(MutableServletRequest request) this.output = new LinkedHashMap<>(); } + /** + * Default constructor. + * + * @param result the jakarta result to copy + * @since 42.0.0 + */ + public RequestParameterConversionResult(JakartaRequestParameterConversionResult result) + { + this.request = new JavaxToJakartaMutableHttpServletRequest(result.getRequest()); + this.errors = result.getErrors(); + this.output = result.getOutput(); + } + /** * @return the mutable request */ diff --git a/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/converter/RequestParameterConverter.java b/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/converter/RequestParameterConverter.java index a7e9910a1ceb..d6fa26f93ef7 100644 --- a/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/converter/RequestParameterConverter.java +++ b/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/converter/RequestParameterConverter.java @@ -22,10 +22,13 @@ import java.io.IOException; import java.util.Optional; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; import org.xwiki.component.annotation.Role; +import org.xwiki.jakartabridge.servlet.JakartaServletBridge; +import org.xwiki.stability.Unstable; +import org.xwiki.wysiwyg.internal.filter.http.JakartaToJavaxMutableHttpServletRequest; /** * Check if the given request contains parameters that needs conversion and perform the needing conversion. @@ -37,30 +40,83 @@ public interface RequestParameterConverter { /** - * Check if the given request needs conversion and perform those conversions. - * This method creates a mutable request, modifies and returns it. However in case of - * error it will return an empty optional, and it will handle directly the errors in the response. - * See {@link #convert(ServletRequest)} for using an exception for handling the errors. + * Check if the given request needs conversion and perform those conversions. This method creates a mutable request, + * modifies and returns it. However in case of error it will return an empty optional, and it will handle directly + * the errors in the response. See {@link #convert(javax.servlet.ServletRequest)} for using an exception for + * handling the errors. * * @param request the request that might contain parameter needing conversion or an {@link Optional#empty()} in case - * of error + * of error * @param response the response used to redirect or do changes in case of conversion error * @return a mutable request with the converted parameters, or an empty optional in case of error * @throws IOException in case of problem to write an answer in the response + * @deprecated use {@link #convert(ServletRequest, ServletResponse)} instead */ - Optional convert(ServletRequest request, ServletResponse response) throws IOException; + @Deprecated(since = "42.0.0") + default Optional convert(javax.servlet.ServletRequest request, + javax.servlet.ServletResponse response) throws IOException + { + Optional result = + convert(JakartaServletBridge.toJakarta(request), JakartaServletBridge.toJakarta(response)); + + return result.isEmpty() ? Optional.empty() : Optional.of(JakartaServletBridge.toJavax(result.get())); + } /** - * Check if the given request needs conversion and perform those conversions. - * This method creates a mutable request, modifies it and returns it along with the errors and output that have - * occurred as part of the conversion, all that holds in the returned {@link RequestParameterConversionResult}. - * Consumer of this API should always check if the obtained result contains errors or not to know if the conversion - * properly succeeded. + * Check if the given request needs conversion and perform those conversions. This method creates a mutable request, + * modifies and returns it. However in case of error it will return an empty optional, and it will handle directly + * the errors in the response. See {@link #convert(javax.servlet.ServletRequest)} for using an exception for + * handling the errors. + * + * @param request the request that might contain parameter needing conversion or an {@link Optional#empty()} in case + * of error + * @param response the response used to redirect or do changes in case of conversion error + * @return a mutable request with the converted parameters, or an empty optional in case of error + * @throws IOException in case of problem to write an answer in the response + * @since 42.0.0 + */ + @Unstable + default Optional convert(ServletRequest request, ServletResponse response) throws IOException + { + Optional result = + convert(JakartaServletBridge.toJavax(request), JakartaServletBridge.toJavax(response)); + + return result.isEmpty() ? Optional.empty() : Optional.of(JakartaServletBridge.toJakarta(result.get())); + } + + /** + * Check if the given request needs conversion and perform those conversions. This method creates a mutable request, + * modifies it and returns it along with the errors and output that have occurred as part of the conversion, all + * that holds in the returned {@link RequestParameterConversionResult}. Consumer of this API should always check if + * the obtained result contains errors or not to know if the conversion properly succeeded. * * @param request the request that might contain parameter needing conversion * @return an instance of {@link RequestParameterConversionResult} containing the modified request and the output * and errors that might have occurred * @since 14.10 + * @deprecated use {@link #convert(ServletRequest)} instead + */ + @Deprecated(since = "42.0.0") + default RequestParameterConversionResult convert(javax.servlet.ServletRequest request) + { + return new RequestParameterConversionResult(convert(JakartaServletBridge.toJakarta(request))); + } + + /** + * Check if the given request needs conversion and perform those conversions. This method creates a mutable request, + * modifies it and returns it along with the errors and output that have occurred as part of the conversion, all + * that holds in the returned {@link RequestParameterConversionResult}. Consumer of this API should always check if + * the obtained result contains errors or not to know if the conversion properly succeeded. + * + * @param request the request that might contain parameter needing conversion + * @return an instance of {@link RequestParameterConversionResult} containing the modified request and the output + * and errors that might have occurred + * @since 42.0.0 */ - RequestParameterConversionResult convert(ServletRequest request); + @Unstable + default JakartaRequestParameterConversionResult convert(ServletRequest request) + { + return new JakartaRequestParameterConversionResult( + new JakartaToJavaxMutableHttpServletRequest(convert(JakartaServletBridge.toJavax(request)).getRequest())); + } } diff --git a/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/filter/ConversionFilter.java b/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/filter/ConversionFilter.java index 995db15d284b..989fc954ac36 100644 --- a/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/filter/ConversionFilter.java +++ b/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/filter/ConversionFilter.java @@ -22,12 +22,12 @@ import java.io.IOException; import java.util.Optional; -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; +import jakarta.servlet.Filter; +import jakarta.servlet.FilterChain; +import jakarta.servlet.FilterConfig; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; import org.xwiki.context.Execution; import org.xwiki.context.ExecutionContext; @@ -38,8 +38,12 @@ /** * This filter is used to convert the values of request parameters that require HTML conversion before being processed. * A HTML editor can use this filter to convert its output to a specific syntax before it is saved. + *

+ * While the class is much older, the since annotation was moved to 42.0.0 because it implement a completely different + * API from Java point of view. * * @version $Id$ + * @since 42.0.0 */ public class ConversionFilter implements Filter { diff --git a/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/filter/MutableJakartaServletRequest.java b/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/filter/MutableJakartaServletRequest.java new file mode 100644 index 000000000000..8136d84351a0 --- /dev/null +++ b/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/filter/MutableJakartaServletRequest.java @@ -0,0 +1,98 @@ +/* + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.xwiki.wysiwyg.filter; + +import java.io.IOException; + +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; + +/** + * A servlet request that can be modified. It is very useful, for instance, when you need to change the values of some + * request parameters, inside a filter. + * + * @version $Id$ + * @since 42.0.0 + */ +public interface MutableJakartaServletRequest extends ServletRequest +{ + /** + * Sets the value of a request parameter. + * + * @param name the name of the request parameter + * @param value the new value of the request parameter + * @return the old value of the specified request parameter, or {@code null} if this is the first time we set its + * value + */ + String setParameter(String name, String value); + + /** + * Sets the values of a request parameter. + * + * @param name the name of the request parameter + * @param values the new array of values for the specified request parameter + * @return the old values of the specified request parameter, or {@code null} if this is the first time we set its + * values + */ + String[] setParameterValues(String name, String[] values); + + /** + * Removes the request parameter with the specified name. + * + * @param name a string representing the name of the request parameter to be removed + * @return the old value of the specified request parameter, or {@code null} if it wasn't set + */ + String removeParameter(String name); + + /** + * Redirects this request to the specified URL. We had to add this method since there's no generic way to redirect a + * {@link ServletRequest}. + * + * @param response the response object used to redirect + * @param url the location where to redirect + * @throws IOException if the redirect fails + */ + void sendRedirect(ServletResponse response, String url) throws IOException; + + /** + * @return the URL of the requester + */ + String getReferer(); + + /** + * @param attrName the name of the session attribute whose value should be retrieved + * @return the value of the specified session attribute + */ + Object getSessionAttribute(String attrName); + + /** + * Sets the value of a session attribute. + * + * @param attrName the name of the session attribute + * @param attrValue the value to be set + * @return the previous value of the specified session attribute + */ + Object setSessionAttribute(String attrName, Object attrValue); + + /** + * @return the request object wrapped by this object + */ + ServletRequest getRequest(); +} diff --git a/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/filter/MutableServletRequest.java b/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/filter/MutableServletRequest.java index c3efb91d4899..8adb847f2b05 100644 --- a/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/filter/MutableServletRequest.java +++ b/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/filter/MutableServletRequest.java @@ -29,7 +29,9 @@ * request parameters, inside a filter. * * @version $Id$ + * @deprecated use {@link MutableJakartaServletRequest} instead */ +@Deprecated(since = "42.0.0") public interface MutableServletRequest extends ServletRequest { /** diff --git a/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/filter/MutableServletRequestFactory.java b/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/filter/MutableServletRequestFactory.java index e1db8ec5280d..1ce7479aafbb 100644 --- a/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/filter/MutableServletRequestFactory.java +++ b/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/filter/MutableServletRequestFactory.java @@ -19,9 +19,13 @@ */ package org.xwiki.wysiwyg.filter; -import javax.servlet.ServletRequest; +import jakarta.servlet.ServletRequest; import org.xwiki.component.annotation.Role; +import org.xwiki.jakartabridge.servlet.JakartaServletBridge; +import org.xwiki.stability.Unstable; +import org.xwiki.wysiwyg.internal.filter.http.JakartaToJavaxMutableHttpServletRequest; +import org.xwiki.wysiwyg.internal.filter.http.JavaxToJakartaMutableHttpServletRequest; /** * A factory for mutable servlet requests. This factory is needed because concrete mutable servlet requests don't have a @@ -38,6 +42,24 @@ public interface MutableServletRequestFactory * * @param request The original servlet request to wrap. * @return a new mutable servlet request. + * @deprecated use {@link #newInstance(ServletRequest)} instead */ - MutableServletRequest newInstance(ServletRequest request); + @Deprecated(since = "42.0.0") + default MutableServletRequest newInstance(javax.servlet.ServletRequest request) + { + return new JavaxToJakartaMutableHttpServletRequest(newInstance(JakartaServletBridge.toJakarta(request))); + } + + /** + * Creates a new mutable servlet request. + * + * @param request The original servlet request to wrap. + * @return a new mutable servlet request. + * @since 42.0.0 + */ + @Unstable + default MutableJakartaServletRequest newInstance(ServletRequest request) + { + return new JakartaToJavaxMutableHttpServletRequest(newInstance(JakartaServletBridge.toJavax(request))); + } } diff --git a/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/internal/converter/DefaultRequestParameterConverter.java b/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/internal/converter/DefaultRequestParameterConverter.java index 210938131c63..f93c208d0365 100644 --- a/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/internal/converter/DefaultRequestParameterConverter.java +++ b/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/internal/converter/DefaultRequestParameterConverter.java @@ -28,10 +28,11 @@ import javax.inject.Inject; import javax.inject.Singleton; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; + +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.StringUtils; @@ -39,9 +40,9 @@ import org.xwiki.component.annotation.Component; import org.xwiki.url.URLSecurityManager; import org.xwiki.wysiwyg.converter.HTMLConverter; -import org.xwiki.wysiwyg.converter.RequestParameterConversionResult; +import org.xwiki.wysiwyg.converter.JakartaRequestParameterConversionResult; import org.xwiki.wysiwyg.converter.RequestParameterConverter; -import org.xwiki.wysiwyg.filter.MutableServletRequest; +import org.xwiki.wysiwyg.filter.MutableJakartaServletRequest; import org.xwiki.wysiwyg.filter.MutableServletRequestFactory; /** @@ -93,22 +94,25 @@ public class DefaultRequestParameterConverter implements RequestParameterConvert @Override public Optional convert(ServletRequest request, ServletResponse response) throws IOException { - RequestParameterConversionResult conversionResult = this.convert(request); + JakartaRequestParameterConversionResult conversionResult = convert(request); Optional result; if (conversionResult.getErrors().isEmpty()) { result = Optional.of(conversionResult.getRequest()); } else { result = Optional.empty(); - this.handleConversionErrors(conversionResult, response); + handleConversionErrors(conversionResult, response); } + return result; } @Override - public RequestParameterConversionResult convert(ServletRequest request) + public JakartaRequestParameterConversionResult convert(ServletRequest request) { - MutableServletRequest mutableServletRequest = this.mutableServletRequestFactory.newInstance(request); - RequestParameterConversionResult result = new RequestParameterConversionResult(mutableServletRequest); + MutableJakartaServletRequest mutableServletRequest = this.mutableServletRequestFactory.newInstance(request); + JakartaRequestParameterConversionResult result = + new JakartaRequestParameterConversionResult(mutableServletRequest); + // Take the list of request parameters that require HTML conversion. String[] parametersRequiringHTMLConversion = request.getParameterValues(REQUIRES_HTML_CONVERSION); if (parametersRequiringHTMLConversion != null) { @@ -116,13 +120,14 @@ public RequestParameterConversionResult convert(ServletRequest request) result.getRequest().removeParameter(REQUIRES_HTML_CONVERSION); convertHTML(parametersRequiringHTMLConversion, result); } + return result; } private void convertHTML(String[] parametersRequiringHTMLConversion, - RequestParameterConversionResult conversionResult) + JakartaRequestParameterConversionResult conversionResult) { - MutableServletRequest request = conversionResult.getRequest(); + MutableJakartaServletRequest request = conversionResult.getRequest(); for (String parameterName : parametersRequiringHTMLConversion) { String html = request.getParameter(parameterName); // Remove the syntax parameter from the request to avoid interference with further request processing. @@ -141,13 +146,13 @@ private void convertHTML(String[] parametersRequiringHTMLConversion, } } - private void handleConversionErrors(RequestParameterConversionResult conversionResult, ServletResponse res) + private void handleConversionErrors(JakartaRequestParameterConversionResult conversionResult, ServletResponse res) throws IOException { - MutableServletRequest mutableRequest = conversionResult.getRequest(); + MutableJakartaServletRequest mutableRequest = conversionResult.getRequest(); ServletRequest originalRequest = mutableRequest.getRequest(); - if (originalRequest instanceof HttpServletRequest httpServletRequest - && "XMLHttpRequest".equals((httpServletRequest).getHeader("X-Requested-With"))) { + if (originalRequest instanceof HttpServletRequest httpRequest + && "XMLHttpRequest".equals(httpRequest.getHeader("X-Requested-With"))) { // If this is an AJAX request then we should simply send back the error. StringBuilder errorMessage = new StringBuilder(); // Aggregate all error messages (for all fields that have conversion errors). @@ -205,11 +210,11 @@ private void handleConversionErrors(RequestParameterConversionResult conversionR * {@value #CONVERSION_ERRORS} session attributes */ @SuppressWarnings("unchecked") - private String save(RequestParameterConversionResult conversionResult) + private String save(JakartaRequestParameterConversionResult conversionResult) { // Generate a random key to identify the request. String key = RandomStringUtils.secure().nextAlphanumeric(4); - MutableServletRequest request = conversionResult.getRequest(); + MutableJakartaServletRequest request = conversionResult.getRequest(); // Save the output on the session. Map> conversionOutput = diff --git a/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/internal/filter/http/JakartaToJavaxMutableHttpServletRequest.java b/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/internal/filter/http/JakartaToJavaxMutableHttpServletRequest.java new file mode 100644 index 000000000000..119695ee942b --- /dev/null +++ b/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/internal/filter/http/JakartaToJavaxMutableHttpServletRequest.java @@ -0,0 +1,93 @@ +/* + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.xwiki.wysiwyg.internal.filter.http; + +import java.io.IOException; + +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; + +import org.xwiki.jakartabridge.servlet.JakartaServletBridge; +import org.xwiki.jakartabridge.servlet.internal.JakartaToJavaxServletRequest; +import org.xwiki.wysiwyg.filter.MutableJakartaServletRequest; +import org.xwiki.wysiwyg.filter.MutableServletRequest; + +/** + * @version $Id$ + */ +public class JakartaToJavaxMutableHttpServletRequest extends JakartaToJavaxServletRequest + implements MutableJakartaServletRequest +{ + /** + * @param javax + */ + public JakartaToJavaxMutableHttpServletRequest(MutableServletRequest javax) + { + super(javax); + } + + @Override + public String setParameter(String name, String value) + { + return this.javax.setParameter(name, value); + } + + @Override + public String[] setParameterValues(String name, String[] values) + { + return this.javax.setParameterValues(name, values); + } + + @Override + public String removeParameter(String name) + { + return this.javax.removeParameter(name); + } + + @Override + public void sendRedirect(ServletResponse response, String url) throws IOException + { + this.javax.sendRedirect(JakartaServletBridge.toJavax(response), url); + } + + @Override + public String getReferer() + { + return this.javax.getReferer(); + } + + @Override + public Object getSessionAttribute(String attrName) + { + return this.javax.getSessionAttribute(attrName); + } + + @Override + public Object setSessionAttribute(String attrName, Object attrValue) + { + return this.javax.setSessionAttribute(attrName, attrValue); + } + + @Override + public ServletRequest getRequest() + { + return JakartaServletBridge.toJakarta(this.javax.getRequest()); + } +} diff --git a/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/internal/filter/http/JavaxToJakartaMutableHttpServletRequest.java b/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/internal/filter/http/JavaxToJakartaMutableHttpServletRequest.java new file mode 100644 index 000000000000..5039f92048d2 --- /dev/null +++ b/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/internal/filter/http/JavaxToJakartaMutableHttpServletRequest.java @@ -0,0 +1,93 @@ +/* + * See the NOTICE file distributed with this work for additional + * information regarding copyright ownership. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.xwiki.wysiwyg.internal.filter.http; + +import java.io.IOException; + +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; + +import org.xwiki.jakartabridge.servlet.JakartaServletBridge; +import org.xwiki.jakartabridge.servlet.internal.JavaxToJakartaServletRequest; +import org.xwiki.wysiwyg.filter.MutableJakartaServletRequest; +import org.xwiki.wysiwyg.filter.MutableServletRequest; + +/** + * @version $Id$ + */ +public class JavaxToJakartaMutableHttpServletRequest extends JavaxToJakartaServletRequest + implements MutableServletRequest +{ + /** + * @param jakarta + */ + public JavaxToJakartaMutableHttpServletRequest(MutableJakartaServletRequest jakarta) + { + super(jakarta); + } + + @Override + public String setParameter(String name, String value) + { + return this.jakarta.setParameter(name, value); + } + + @Override + public String[] setParameterValues(String name, String[] values) + { + return this.jakarta.setParameterValues(name, values); + } + + @Override + public String removeParameter(String name) + { + return this.jakarta.removeParameter(name); + } + + @Override + public void sendRedirect(ServletResponse response, String url) throws IOException + { + this.jakarta.sendRedirect(JakartaServletBridge.toJakarta(response), url); + } + + @Override + public String getReferer() + { + return this.jakarta.getReferer(); + } + + @Override + public Object getSessionAttribute(String attrName) + { + return this.jakarta.getSessionAttribute(attrName); + } + + @Override + public Object setSessionAttribute(String attrName, Object attrValue) + { + return this.jakarta.setSessionAttribute(attrName, attrValue); + } + + @Override + public ServletRequest getRequest() + { + return JakartaServletBridge.toJavax(this.jakarta.getRequest()); + } +} diff --git a/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/internal/filter/http/MutableHttpServletRequestFactory.java b/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/internal/filter/http/MutableHttpServletRequestFactory.java index 8e5338691ccd..6b0f05736b71 100644 --- a/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/internal/filter/http/MutableHttpServletRequestFactory.java +++ b/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/internal/filter/http/MutableHttpServletRequestFactory.java @@ -19,12 +19,11 @@ */ package org.xwiki.wysiwyg.internal.filter.http; -import javax.inject.Singleton; -import javax.servlet.ServletRequest; -import javax.servlet.http.HttpServletRequest; +import jakarta.inject.Singleton; +import jakarta.servlet.http.HttpServletRequest; import org.xwiki.component.annotation.Component; -import org.xwiki.wysiwyg.filter.MutableServletRequest; +import org.xwiki.wysiwyg.filter.MutableJakartaServletRequest; import org.xwiki.wysiwyg.filter.MutableServletRequestFactory; /** @@ -37,10 +36,10 @@ public class MutableHttpServletRequestFactory implements MutableServletRequestFactory { @Override - public synchronized MutableServletRequest newInstance(ServletRequest request) + public synchronized MutableJakartaServletRequest newInstance(jakarta.servlet.ServletRequest request) { - if (request instanceof HttpServletRequest) { - return new MutableHttpServletRequest((HttpServletRequest) request); + if (request instanceof HttpServletRequest httpRequest) { + return new MutableJakartaHttpServletRequest(httpRequest); } else { throw new IllegalArgumentException(String.format("Expecting HttpServletRequest, got [%s]!", request)); } diff --git a/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/internal/filter/http/MutableHttpServletRequest.java b/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/internal/filter/http/MutableJakartaHttpServletRequest.java similarity index 87% rename from xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/internal/filter/http/MutableHttpServletRequest.java rename to xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/internal/filter/http/MutableJakartaHttpServletRequest.java index a67bea9dae75..337f246b10d0 100644 --- a/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/internal/filter/http/MutableHttpServletRequest.java +++ b/xwiki-platform-core/xwiki-platform-wysiwyg/xwiki-platform-wysiwyg-api/src/main/java/org/xwiki/wysiwyg/internal/filter/http/MutableJakartaHttpServletRequest.java @@ -25,11 +25,12 @@ import java.util.HashMap; import java.util.Map; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletRequestWrapper; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.ServletResponse; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequestWrapper; +import jakarta.servlet.http.HttpServletResponse; +import org.xwiki.wysiwyg.filter.MutableJakartaServletRequest; import org.xwiki.wysiwyg.filter.MutableServletRequest; /** @@ -37,21 +38,20 @@ * * @version $Id$ */ -public class MutableHttpServletRequest extends HttpServletRequestWrapper implements MutableServletRequest +public class MutableJakartaHttpServletRequest extends HttpServletRequestWrapper implements MutableJakartaServletRequest { /** * Parameters used instead of those from the wrapped request. This way exiting request parameters can be overwritten * and also new parameters can be added. */ - private final Map params = new HashMap(); + private final Map params = new HashMap<>(); /** * Wraps the specified request and copies its parameters to {@link #params} where they can be overwritten later. * * @param request The request to be wrapped. */ - @SuppressWarnings("unchecked") - public MutableHttpServletRequest(HttpServletRequest request) + public MutableJakartaHttpServletRequest(HttpServletRequest request) { super(request); diff --git a/xwiki-platform-core/xwiki-platform-zipexplorer/pom.xml b/xwiki-platform-core/xwiki-platform-zipexplorer/pom.xml index eda5c129a32e..e17d7214a7c7 100644 --- a/xwiki-platform-core/xwiki-platform-zipexplorer/pom.xml +++ b/xwiki-platform-core/xwiki-platform-zipexplorer/pom.xml @@ -40,9 +40,10 @@ ${project.version} - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api + org.xwiki.platform diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/pom.xml b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/pom.xml index e67ca224e2d4..5b81ab52fe1c 100644 --- a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/pom.xml +++ b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/pom.xml @@ -32,22 +32,6 @@ pom XWiki Platform - Distribution - Debian - Tomcat - xwiki-platform-distribution-debian-tomcat8-common - xwiki-platform-distribution-debian-tomcat8-mariadb - xwiki-platform-distribution-debian-tomcat8-mysql - xwiki-platform-distribution-debian-tomcat8-pgsql - xwiki-platform-distribution-debian-tomcat9-common - xwiki-platform-distribution-debian-tomcat9-mariadb - xwiki-platform-distribution-debian-tomcat9-mysql - xwiki-platform-distribution-debian-tomcat9-pgsql + xwiki-platform-distribution-debian-tomcat10 - - - ${project.groupId} - xwiki-platform-distribution-debian-common - ${project.version} - runtime - deb - - diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-mariadb/pom.xml b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/pom.xml similarity index 67% rename from xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-mariadb/pom.xml rename to xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/pom.xml index 063a2032bfa4..5ef5a9bc5dd6 100644 --- a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-mariadb/pom.xml +++ b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/pom.xml @@ -27,11 +27,17 @@ xwiki-platform-distribution-debian-tomcat 17.0.0-SNAPSHOT - xwiki-platform-distribution-debian-tomcat8-mariadb - XWiki Platform - Distribution - Debian - Tomcat 8 - MariaDB - deb - XWiki Tomcat8/MariaDB based package + xwiki-platform-distribution-debian-tomcat10 + XWiki Platform - Distribution - Debian - Tomcat ${debian.tomcat.version} + pom + XWiki Platform - Distribution - Debian - Tomcat ${debian.tomcat.version} - xwiki-tomcat8-mariadb + 10 + + xwiki-platform-distribution-debian-tomcat10-common + xwiki-platform-distribution-debian-tomcat10-mariadb + xwiki-platform-distribution-debian-tomcat10-mysql + xwiki-platform-distribution-debian-tomcat10-pgsql + diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-common/pom.xml b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-common/pom.xml similarity index 71% rename from xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-common/pom.xml rename to xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-common/pom.xml index 43d384a4df04..9c7c32174730 100644 --- a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-common/pom.xml +++ b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-common/pom.xml @@ -24,15 +24,15 @@ 4.0.0 org.xwiki.platform - xwiki-platform-distribution-debian-tomcat + xwiki-platform-distribution-debian-tomcat10 17.0.0-SNAPSHOT - xwiki-platform-distribution-debian-tomcat9-common - XWiki Platform - Distribution - Debian - Tomcat 9 - Common + xwiki-platform-distribution-debian-tomcat10-common + XWiki Platform - Distribution - Debian - Tomcat ${debian.tomcat.version} - Common deb - XWiki Tomcat 9 common package + XWiki Tomcat ${debian.tomcat.version} common package - xwiki-tomcat9-common + xwiki-tomcat${debian.tomcat.version}-common @@ -52,16 +52,25 @@ true - + link true /etc/tomcat9/Catalina/localhost/xwiki.xml - /etc/xwiki/xwiki-tomcat9.xml + /etc/xwiki/xwiki-tomcat${debian.tomcat.version}.xml + + + ${project.groupId} + xwiki-platform-distribution-debian-common + ${project.version} + runtime + deb + + diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-common/src/deb/control/control b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-common/src/deb/control/control similarity index 79% rename from xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-common/src/deb/control/control rename to xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-common/src/deb/control/control index e4f1fbd8d9d2..37b78d7f00f8 100644 --- a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-common/src/deb/control/control +++ b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-common/src/deb/control/control @@ -1,9 +1,9 @@ -Package: xwiki-tomcat8-common +Package: [[debian.package]] Version: [[version]] Section: java Priority: optional Architecture: all -Depends: xwiki-common (= [[version]]), tomcat8 +Depends: xwiki-common (= [[version]]), tomcat[[debian.tomcat.version]] Provides: xwiki-tomcat-common Replaces: xwiki-tomcat-common, xwiki-enterprise-tomcat-common Conflicts: xwiki-tomcat-common, xwiki-enterprise-tomcat-common diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-common/src/deb/control/postinst b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-common/src/deb/control/postinst similarity index 78% rename from xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-common/src/deb/control/postinst rename to xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-common/src/deb/control/postinst index 5a2db532abfc..72b39ed0dfad 100644 --- a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-common/src/deb/control/postinst +++ b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-common/src/deb/control/postinst @@ -16,5 +16,5 @@ fi # Restart Tomcat ######################### -# Need to reload systemd for the injected tomcat9 service configuration to be taken into account +# Need to reload systemd for the injected tomcat service configuration to be taken into account systemctl daemon-reload diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-common/src/deb/control/postrm b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-common/src/deb/control/postrm similarity index 66% rename from xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-common/src/deb/control/postrm rename to xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-common/src/deb/control/postrm index 2615af2a35de..3b26ac348d17 100644 --- a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-common/src/deb/control/postrm +++ b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-common/src/deb/control/postrm @@ -12,9 +12,9 @@ fi # Restart Tomcat ######################### -invoke-rc.d --quiet tomcat9 restart || { +invoke-rc.d --quiet tomcat[[debian.tomcat.version]] restart || { RESULT=$? - # Ignore if tomcat9 init script does not exist (yet) + # Ignore if tomcat[[debian.tomcat.version]] init script does not exist (yet) if [ $RESULT != 100 ]; then exit $RESULT fi diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-common/src/deb/resources/etc/systemd/system/tomcat10.service.d/xwiki-tomcat10-systemd.conf b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-common/src/deb/resources/etc/systemd/system/tomcat10.service.d/xwiki-tomcat10-systemd.conf new file mode 100644 index 000000000000..e11a4140d959 --- /dev/null +++ b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-common/src/deb/resources/etc/systemd/system/tomcat10.service.d/xwiki-tomcat10-systemd.conf @@ -0,0 +1,3 @@ +[Service] +# Need to allow Tomcat to read and write in XWiki permanent directory +ReadWritePaths=/var/lib/xwiki/data diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-common/src/deb/resources/etc/xwiki/xwiki-tomcat9.xml b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-common/src/deb/resources/etc/xwiki/xwiki-tomcat10.xml similarity index 100% rename from xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-common/src/deb/resources/etc/xwiki/xwiki-tomcat9.xml rename to xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-common/src/deb/resources/etc/xwiki/xwiki-tomcat10.xml diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-pgsql/pom.xml b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-mariadb/pom.xml similarity index 76% rename from xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-pgsql/pom.xml rename to xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-mariadb/pom.xml index 7c90a0aa7da6..52e573bc9b27 100644 --- a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-pgsql/pom.xml +++ b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-mariadb/pom.xml @@ -24,14 +24,14 @@ 4.0.0 org.xwiki.platform - xwiki-platform-distribution-debian-tomcat + xwiki-platform-distribution-debian-tomcat10 17.0.0-SNAPSHOT - xwiki-platform-distribution-debian-tomcat8-pgsql - XWiki Platform - Distribution - Debian - Tomcat 8 - Postgres SQL + xwiki-platform-distribution-debian-tomcat10-mariadb + XWiki Platform - Distribution - Debian - Tomcat ${debian.tomcat.version} - MariaDB deb - XWiki Tomcat8/PostgreSQL + XWiki Tomcat${debian.tomcat.version}/MariaDB based package - xwiki-tomcat8-pgsql + xwiki-tomcat${debian.tomcat.version}-mariadb diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-mariadb/src/deb/control/control b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-mariadb/src/deb/control/control similarity index 85% rename from xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-mariadb/src/deb/control/control rename to xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-mariadb/src/deb/control/control index 33aa7cf88454..3554bd2b4983 100644 --- a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-mariadb/src/deb/control/control +++ b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-mariadb/src/deb/control/control @@ -1,9 +1,9 @@ -Package: xwiki-tomcat9-mariadb +Package: [[debian.package]] Version: [[version]] Section: java Priority: optional Architecture: all -Depends: xwiki-mariadb-common (= [[version]]), xwiki-tomcat9-common (= [[version]]) +Depends: xwiki-mariadb-common (= [[version]]), xwiki-tomcat[[debian.tomcat.version]]-common (= [[version]]) Provides: xwiki-tomcat-database Replaces: xwiki-tomcat-database, xwiki-enterprise-tomcat7-mysql, xwiki-enterprise-tomcat8-mysql, xwiki-enterprise-tomcat7-pgsql, xwiki-enterprise-tomcat8-pgsql, xwiki-tomcat9-pgsql, xwiki-tomcat8-mysql, xwiki-tomcat8-mariadb, xwiki-tomcat8-pgsql, xwiki-tomcat7-mysql, xwiki-tomcat7-pgsql Conflicts: xwiki-tomcat-database, xwiki-enterprise-tomcat7-mysql, xwiki-enterprise-tomcat8-mysql, xwiki-enterprise-tomcat7-pgsql, xwiki-enterprise-tomcat8-pgsql, xwiki-tomcat9-pgsql, xwiki-tomcat8-mysql, xwiki-tomcat8-mariadb, xwiki-tomcat8-pgsql, xwiki-tomcat7-mysql, xwiki-tomcat7-pgsql diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-mariadb/src/deb/control/postinst b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-mariadb/src/deb/control/postinst new file mode 100644 index 000000000000..43e2a785eef2 --- /dev/null +++ b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-mariadb/src/deb/control/postinst @@ -0,0 +1,14 @@ +#!/bin/sh + +set -e +#set -x + +######################### +# Restart Tomcat +######################### + +# Restart tomcat service (only if it's active) +if ( systemctl -q is-active tomcat[[debian.tomcat.version]].service || systemctl -q is-enabled tomcat[[debian.tomcat.version]].service ) +then + deb-systemd-invoke restart tomcat[[debian.tomcat.version]].service +fi diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-mariadb/src/deb/control/postrm b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-mariadb/src/deb/control/postrm similarity index 100% rename from xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-mariadb/src/deb/control/postrm rename to xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-mariadb/src/deb/control/postrm diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-mysql/pom.xml b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-mysql/pom.xml similarity index 76% rename from xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-mysql/pom.xml rename to xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-mysql/pom.xml index 981a285ca2a6..42d2758e85d9 100644 --- a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-mysql/pom.xml +++ b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-mysql/pom.xml @@ -24,14 +24,14 @@ 4.0.0 org.xwiki.platform - xwiki-platform-distribution-debian-tomcat + xwiki-platform-distribution-debian-tomcat10 17.0.0-SNAPSHOT - xwiki-platform-distribution-debian-tomcat8-mysql - XWiki Platform - Distribution - Debian - Tomcat 8 - MySQL + xwiki-platform-distribution-debian-tomcat10-mysql + XWiki Platform - Distribution - Debian - Tomcat ${debian.tomcat.version} - MySQL deb - XWiki Tomcat8/MySQL based package + XWiki Tomcat${debian.tomcat.version}/MySQL based package - xwiki-tomcat8-mysql + xwiki-tomcat${debian.tomcat.version}-mysql diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-mysql/src/deb/control/control b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-mysql/src/deb/control/control similarity index 85% rename from xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-mysql/src/deb/control/control rename to xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-mysql/src/deb/control/control index 539b01d7ffcf..8acf25821cdc 100644 --- a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-mysql/src/deb/control/control +++ b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-mysql/src/deb/control/control @@ -1,9 +1,9 @@ -Package: xwiki-tomcat9-mysql +Package: [[debian.package]] Version: [[version]] Section: java Priority: optional Architecture: all -Depends: xwiki-mysql-common (= [[version]]), xwiki-tomcat9-common (= [[version]]) +Depends: xwiki-mysql-common (= [[version]]), xwiki-tomcat[[debian.tomcat.version]]-common (= [[version]]) Provides: xwiki-tomcat-database Replaces: xwiki-tomcat-database, xwiki-enterprise-tomcat7-mysql, xwiki-enterprise-tomcat8-mysql, xwiki-enterprise-tomcat7-pgsql, xwiki-enterprise-tomcat8-pgsql, xwiki-tomcat9-pgsql, xwiki-tomcat8-mysql, xwiki-tomcat8-pgsql, xwiki-tomcat7-mysql, xwiki-tomcat7-pgsql Conflicts: xwiki-tomcat-database, xwiki-enterprise-tomcat7-mysql, xwiki-enterprise-tomcat8-mysql, xwiki-enterprise-tomcat7-pgsql, xwiki-enterprise-tomcat8-pgsql, xwiki-tomcat9-pgsql, xwiki-tomcat8-mysql, xwiki-tomcat8-pgsql, xwiki-tomcat7-mysql, xwiki-tomcat7-pgsql diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-mysql/src/deb/control/postinst b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-mysql/src/deb/control/postinst new file mode 100644 index 000000000000..43e2a785eef2 --- /dev/null +++ b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-mysql/src/deb/control/postinst @@ -0,0 +1,14 @@ +#!/bin/sh + +set -e +#set -x + +######################### +# Restart Tomcat +######################### + +# Restart tomcat service (only if it's active) +if ( systemctl -q is-active tomcat[[debian.tomcat.version]].service || systemctl -q is-enabled tomcat[[debian.tomcat.version]].service ) +then + deb-systemd-invoke restart tomcat[[debian.tomcat.version]].service +fi diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-mysql/src/deb/control/postrm b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-mysql/src/deb/control/postrm similarity index 100% rename from xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-mysql/src/deb/control/postrm rename to xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-mysql/src/deb/control/postrm diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-pgsql/pom.xml b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-pgsql/pom.xml similarity index 85% rename from xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-pgsql/pom.xml rename to xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-pgsql/pom.xml index feb67fe0b309..a5558b190569 100644 --- a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-pgsql/pom.xml +++ b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-pgsql/pom.xml @@ -24,11 +24,11 @@ 4.0.0 org.xwiki.platform - xwiki-platform-distribution-debian-tomcat + xwiki-platform-distribution-debian-tomcat10 17.0.0-SNAPSHOT - xwiki-platform-distribution-debian-tomcat9-pgsql - XWiki Platform - Distribution - Debian - Tomcat 9 - Postgres SQL + xwiki-platform-distribution-debian-tomcat10-pgsql + XWiki Platform - Distribution - Debian - Tomcat ${debian.tomcat.version} - Postgres SQL deb XWiki Tomcat9/PostgreSQL diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-pgsql/src/deb/control/control b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-pgsql/src/deb/control/control similarity index 85% rename from xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-pgsql/src/deb/control/control rename to xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-pgsql/src/deb/control/control index 7986fd98bd0f..671908c6087e 100644 --- a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-pgsql/src/deb/control/control +++ b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-pgsql/src/deb/control/control @@ -1,9 +1,9 @@ -Package: xwiki-tomcat9-pgsql +Package: [[debian.package]] Version: [[version]] Section: java Priority: optional Architecture: all -Depends: xwiki-pgsql-common (= [[version]]), xwiki-tomcat9-common (= [[version]]) +Depends: xwiki-pgsql-common (= [[version]]), xwiki-tomcat[[debian.tomcat.version]]-common (= [[version]]) Provides: xwiki-tomcat-database Replaces: xwiki-tomcat-database, xwiki-enterprise-tomcat7-mysql, xwiki-enterprise-tomcat8-mysql, xwiki-enterprise-tomcat7-pgsql, xwiki-enterprise-tomcat8-pgsql, xwiki-tomcat8-mysql, xwiki-tomcat8-mysql, xwiki-tomcat8-pgsql, xwiki-tomcat7-mysql, xwiki-tomcat7-pgsql Conflicts: xwiki-tomcat-database, xwiki-enterprise-tomcat7-mysql, xwiki-enterprise-tomcat8-mysql, xwiki-enterprise-tomcat7-pgsql, xwiki-enterprise-tomcat8-pgsql, xwiki-tomcat8-mysql, xwiki-tomcat8-mysql, xwiki-tomcat8-pgsql, xwiki-tomcat7-mysql, xwiki-tomcat7-pgsql diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-pgsql/src/deb/control/postinst b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-pgsql/src/deb/control/postinst new file mode 100644 index 000000000000..43e2a785eef2 --- /dev/null +++ b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-pgsql/src/deb/control/postinst @@ -0,0 +1,14 @@ +#!/bin/sh + +set -e +#set -x + +######################### +# Restart Tomcat +######################### + +# Restart tomcat service (only if it's active) +if ( systemctl -q is-active tomcat[[debian.tomcat.version]].service || systemctl -q is-enabled tomcat[[debian.tomcat.version]].service ) +then + deb-systemd-invoke restart tomcat[[debian.tomcat.version]].service +fi diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-pgsql/src/deb/control/postrm b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-pgsql/src/deb/control/postrm similarity index 100% rename from xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-pgsql/src/deb/control/postrm rename to xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat10/xwiki-platform-distribution-debian-tomcat10-pgsql/src/deb/control/postrm diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-common/pom.xml b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-common/pom.xml deleted file mode 100644 index 07d9f77c08b3..000000000000 --- a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-common/pom.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - 4.0.0 - - org.xwiki.platform - xwiki-platform-distribution-debian-tomcat - 17.0.0-SNAPSHOT - - xwiki-platform-distribution-debian-tomcat8-common - XWiki Platform - Distribution - Debian - Tomcat 8 - Common - deb - XWiki Tomcat 8 common package - - xwiki-tomcat8-common - - - - - - jdeb - org.vafer - - - - ${project.basedir}/src/deb/resources/ - directory - - perm - - - true - - - - - link - true - /etc/tomcat8/Catalina/localhost/xwiki.xml - /etc/xwiki/xwiki-tomcat8.xml - - - - - - - diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-common/src/deb/control/postinst b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-common/src/deb/control/postinst deleted file mode 100644 index 9f4d77078336..000000000000 --- a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-common/src/deb/control/postinst +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh - -set -e -#set -x - -######################### -# Rights -######################### - -## Make sure Tomcat is able to write in the data folder -if [ ! 'tomcat8' = `stat -c '%U' /var/lib/xwiki/data` ]; then - chown -R tomcat8:tomcat8 /var/lib/xwiki/data -fi diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-common/src/deb/control/postrm b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-common/src/deb/control/postrm deleted file mode 100644 index ce87c981a77a..000000000000 --- a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-common/src/deb/control/postrm +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -set -e -#set -x - -if [ "$1" = "purge" ] && [ -f /usr/share/debconf/confmodule ]; then - . /usr/share/debconf/confmodule - db_purge -fi - -######################### -# Restart Tomcat -######################### - -invoke-rc.d --quiet tomcat8 restart || { - RESULT=$? - # Ignore if tomcat7 init script does not exist (yet) - if [ $RESULT != 100 ]; then - exit $RESULT - fi -} diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-common/src/deb/resources/etc/xwiki/xwiki-tomcat8.xml b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-common/src/deb/resources/etc/xwiki/xwiki-tomcat8.xml deleted file mode 100644 index bab911413e4c..000000000000 --- a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-common/src/deb/resources/etc/xwiki/xwiki-tomcat8.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-mariadb/src/deb/control/control b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-mariadb/src/deb/control/control deleted file mode 100644 index 839de8749b96..000000000000 --- a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-mariadb/src/deb/control/control +++ /dev/null @@ -1,14 +0,0 @@ -Package: xwiki-tomcat8-mariadb -Version: [[version]] -Section: java -Priority: optional -Architecture: all -Depends: xwiki-mariadb-common (= [[version]]), xwiki-tomcat8-common (= [[version]]) -Provides: xwiki-tomcat-database -Replaces: xwiki-tomcat-database, xwiki-enterprise-tomcat7-mysql, xwiki-enterprise-tomcat8-mysql, xwiki-tomcat8-mysql, xwiki-enterprise-tomcat7-pgsql, xwiki-enterprise-tomcat8-pgsql, xwiki-tomcat8-pgsql, xwiki-tomcat7-mysql, xwiki-tomcat7-pgsql -Conflicts: xwiki-tomcat-database, xwiki-enterprise-tomcat7-mysql, xwiki-enterprise-tomcat8-mysql, xwiki-tomcat8-pgsql, xwiki-enterprise-tomcat7-pgsql, xwiki-enterprise-tomcat8-pgsql, xwiki-tomcat8-pgsql, xwiki-tomcat7-mysql, xwiki-tomcat7-pgsql -Maintainer: [[debian.maintainer]] -License: [[debian.license]] -Description: [[debian.description]] -Bugs: [[debian.bugs]] -Homepage: [[debian.homepage]] diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-mariadb/src/deb/control/postinst b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-mariadb/src/deb/control/postinst deleted file mode 100644 index 0c452738112c..000000000000 --- a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-mariadb/src/deb/control/postinst +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -set -e -#set -x - -######################### -# Restart Tomcat -######################### - -invoke-rc.d --quiet tomcat8 restart || { - RESULT=$? - # Ignore if tomcat7 init script does not exist (yet) - if [ $RESULT != 100 ]; then - exit $RESULT - fi -} diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-mysql/src/deb/control/control b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-mysql/src/deb/control/control deleted file mode 100644 index b6e0d28b161a..000000000000 --- a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-mysql/src/deb/control/control +++ /dev/null @@ -1,14 +0,0 @@ -Package: xwiki-tomcat8-mysql -Version: [[version]] -Section: java -Priority: optional -Architecture: all -Depends: xwiki-mysql-common (= [[version]]), xwiki-tomcat8-common (= [[version]]) -Provides: xwiki-tomcat-database -Replaces: xwiki-tomcat-database, xwiki-enterprise-tomcat7-mysql, xwiki-enterprise-tomcat8-mysql, xwiki-enterprise-tomcat7-pgsql, xwiki-enterprise-tomcat8-pgsql, xwiki-tomcat8-pgsql, xwiki-tomcat7-mysql, xwiki-tomcat7-pgsql -Conflicts: xwiki-tomcat-database, xwiki-enterprise-tomcat7-mysql, xwiki-enterprise-tomcat8-mysql, xwiki-enterprise-tomcat7-pgsql, xwiki-enterprise-tomcat8-pgsql, xwiki-tomcat8-pgsql, xwiki-tomcat7-mysql, xwiki-tomcat7-pgsql -Maintainer: [[debian.maintainer]] -License: [[debian.license]] -Description: [[debian.description]] -Bugs: [[debian.bugs]] -Homepage: [[debian.homepage]] diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-mysql/src/deb/control/postinst b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-mysql/src/deb/control/postinst deleted file mode 100644 index 0c452738112c..000000000000 --- a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-mysql/src/deb/control/postinst +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -set -e -#set -x - -######################### -# Restart Tomcat -######################### - -invoke-rc.d --quiet tomcat8 restart || { - RESULT=$? - # Ignore if tomcat7 init script does not exist (yet) - if [ $RESULT != 100 ]; then - exit $RESULT - fi -} diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-pgsql/src/deb/control/control b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-pgsql/src/deb/control/control deleted file mode 100644 index a618005ddba8..000000000000 --- a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-pgsql/src/deb/control/control +++ /dev/null @@ -1,14 +0,0 @@ -Package: xwiki-tomcat8-pgsql -Version: [[version]] -Section: java -Priority: optional -Architecture: all -Depends: xwiki-pgsql-common (= [[version]]), xwiki-tomcat8-common (= [[version]]) -Provides: xwiki-tomcat-database -Replaces: xwiki-tomcat-database, xwiki-enterprise-tomcat7-mysql, xwiki-enterprise-tomcat8-mysql, xwiki-enterprise-tomcat7-pgsql, xwiki-enterprise-tomcat8-pgsql, xwiki-tomcat8-mysql, xwiki-tomcat7-mysql, xwiki-tomcat7-pgsql -Conflicts: xwiki-tomcat-database, xwiki-enterprise-tomcat7-mysql, xwiki-enterprise-tomcat8-mysql, xwiki-enterprise-tomcat7-pgsql, xwiki-enterprise-tomcat8-pgsql, xwiki-tomcat8-mysql, xwiki-tomcat7-mysql, xwiki-tomcat7-pgsql -Maintainer: [[debian.maintainer]] -License: [[debian.license]] -Description: [[debian.description]] -Bugs: [[debian.bugs]] -Homepage: [[debian.homepage]] diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-pgsql/src/deb/control/postinst b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-pgsql/src/deb/control/postinst deleted file mode 100644 index 0c452738112c..000000000000 --- a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat8-pgsql/src/deb/control/postinst +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -set -e -#set -x - -######################### -# Restart Tomcat -######################### - -invoke-rc.d --quiet tomcat8 restart || { - RESULT=$? - # Ignore if tomcat7 init script does not exist (yet) - if [ $RESULT != 100 ]; then - exit $RESULT - fi -} diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-common/src/deb/control/control b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-common/src/deb/control/control deleted file mode 100644 index 7b0fbda8db4d..000000000000 --- a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-common/src/deb/control/control +++ /dev/null @@ -1,14 +0,0 @@ -Package: xwiki-tomcat9-common -Version: [[version]] -Section: java -Priority: optional -Architecture: all -Depends: xwiki-common (= [[version]]), tomcat9 -Provides: xwiki-tomcat-common -Replaces: xwiki-tomcat-common, xwiki-enterprise-tomcat-common -Conflicts: xwiki-tomcat-common, xwiki-enterprise-tomcat-common -Maintainer: [[debian.maintainer]] -License: [[debian.license]] -Description: [[debian.description]] -Bugs: [[debian.bugs]] -Homepage: [[debian.homepage]] diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-common/src/deb/resources/etc/systemd/system/tomcat9.service.d/xwiki-tomcat9-systemd.conf b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-common/src/deb/resources/etc/systemd/system/tomcat9.service.d/xwiki-tomcat9-systemd.conf deleted file mode 100644 index b1471b853434..000000000000 --- a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-common/src/deb/resources/etc/systemd/system/tomcat9.service.d/xwiki-tomcat9-systemd.conf +++ /dev/null @@ -1,3 +0,0 @@ -[Service] -# Need to allow Tomcat9 to read and write in XWiki permanent directory -ReadWritePaths=/var/lib/xwiki/data diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-mariadb/pom.xml b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-mariadb/pom.xml deleted file mode 100644 index 37f6420d6770..000000000000 --- a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-mariadb/pom.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - 4.0.0 - - org.xwiki.platform - xwiki-platform-distribution-debian-tomcat - 17.0.0-SNAPSHOT - - xwiki-platform-distribution-debian-tomcat9-mariadb - XWiki Platform - Distribution - Debian - Tomcat 9 - MariaDB - deb - XWiki Tomcat9/MariaDB based package - - xwiki-tomcat9-mariadb - - diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-mariadb/src/deb/control/postinst b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-mariadb/src/deb/control/postinst deleted file mode 100644 index ae2aa3a9564b..000000000000 --- a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-mariadb/src/deb/control/postinst +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -set -e -#set -x - -######################### -# Restart Tomcat -######################### - -# Restart tomcat9 service (only if it's active) -if ( systemctl -q is-active tomcat9.service || systemctl -q is-enabled tomcat9.service ) -then - deb-systemd-invoke restart tomcat9.service -fi diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-mariadb/src/deb/control/postrm b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-mariadb/src/deb/control/postrm deleted file mode 100644 index 9c9437f85356..000000000000 --- a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-mariadb/src/deb/control/postrm +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -set -e -#set -x - -if [ "$1" = "purge" ] && [ -e /usr/share/debconf/confmodule ]; then - . /usr/share/debconf/confmodule - db_purge -fi diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-mysql/pom.xml b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-mysql/pom.xml deleted file mode 100644 index 09d797e48c44..000000000000 --- a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-mysql/pom.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - 4.0.0 - - org.xwiki.platform - xwiki-platform-distribution-debian-tomcat - 17.0.0-SNAPSHOT - - xwiki-platform-distribution-debian-tomcat9-mysql - XWiki Platform - Distribution - Debian - Tomcat 9 - MySQL - deb - XWiki Tomcat9/MySQL based package - - xwiki-tomcat9-mysql - - diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-mysql/src/deb/control/postinst b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-mysql/src/deb/control/postinst deleted file mode 100644 index ae2aa3a9564b..000000000000 --- a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-mysql/src/deb/control/postinst +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -set -e -#set -x - -######################### -# Restart Tomcat -######################### - -# Restart tomcat9 service (only if it's active) -if ( systemctl -q is-active tomcat9.service || systemctl -q is-enabled tomcat9.service ) -then - deb-systemd-invoke restart tomcat9.service -fi diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-mysql/src/deb/control/postrm b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-mysql/src/deb/control/postrm deleted file mode 100644 index 9c9437f85356..000000000000 --- a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-mysql/src/deb/control/postrm +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -set -e -#set -x - -if [ "$1" = "purge" ] && [ -e /usr/share/debconf/confmodule ]; then - . /usr/share/debconf/confmodule - db_purge -fi diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-pgsql/src/deb/control/postinst b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-pgsql/src/deb/control/postinst deleted file mode 100644 index ae2aa3a9564b..000000000000 --- a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-pgsql/src/deb/control/postinst +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -set -e -#set -x - -######################### -# Restart Tomcat -######################### - -# Restart tomcat9 service (only if it's active) -if ( systemctl -q is-active tomcat9.service || systemctl -q is-enabled tomcat9.service ) -then - deb-systemd-invoke restart tomcat9.service -fi diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-pgsql/src/deb/control/postrm b/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-pgsql/src/deb/control/postrm deleted file mode 100644 index 9c9437f85356..000000000000 --- a/xwiki-platform-distribution/xwiki-platform-distribution-debian/xwiki-platform-distribution-debian-tomcat/xwiki-platform-distribution-debian-tomcat9-pgsql/src/deb/control/postrm +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -set -e -#set -x - -if [ "$1" = "purge" ] && [ -e /usr/share/debconf/confmodule ]; then - . /usr/share/debconf/confmodule - db_purge -fi diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-flavor/xwiki-platform-distribution-flavor-data/pom.xml b/xwiki-platform-distribution/xwiki-platform-distribution-flavor/xwiki-platform-distribution-flavor-data/pom.xml index 0d8831dc6cd5..aad9510fe08a 100644 --- a/xwiki-platform-distribution/xwiki-platform-distribution-flavor/xwiki-platform-distribution-flavor-data/pom.xml +++ b/xwiki-platform-distribution/xwiki-platform-distribution-flavor/xwiki-platform-distribution-flavor-data/pom.xml @@ -209,18 +209,6 @@ xwiki-platform-notifications-preferences-default ${project.version} - - - javax.servlet - javax.servlet-api - ${servlet.version} - - - org.mortbay.jasper - apache-el - ${apache-el.version} - org.xwiki.platform diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-flavor/xwiki-platform-distribution-flavor-test/xwiki-platform-distribution-flavor-test-security/pom.xml b/xwiki-platform-distribution/xwiki-platform-distribution-flavor/xwiki-platform-distribution-flavor-test/xwiki-platform-distribution-flavor-test-security/pom.xml index 93cfe40cb655..b65cb0e05aba 100644 --- a/xwiki-platform-distribution/xwiki-platform-distribution-flavor/xwiki-platform-distribution-flavor-test/xwiki-platform-distribution-flavor-test-security/pom.xml +++ b/xwiki-platform-distribution/xwiki-platform-distribution-flavor/xwiki-platform-distribution-flavor-test/xwiki-platform-distribution-flavor-test-security/pom.xml @@ -62,8 +62,8 @@ test - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api test diff --git a/xwiki-platform-distribution/xwiki-platform-distribution-war/pom.xml b/xwiki-platform-distribution/xwiki-platform-distribution-war/pom.xml index dd6a7847e673..4e3cc356e019 100644 --- a/xwiki-platform-distribution/xwiki-platform-distribution-war/pom.xml +++ b/xwiki-platform-distribution/xwiki-platform-distribution-war/pom.xml @@ -158,7 +158,7 @@ junit:* org.junit.*:* org.mockito:* - javax.servlet:servlet-api:*:*:compile + jakarta.servlet:jakarta.servlet-api:*:*:compile jakarta.mail:jakarta.mail-api diff --git a/xwiki-platform-tools/xwiki-platform-tool-configuration-resources/src/main/resources/xwiki.properties.vm b/xwiki-platform-tools/xwiki-platform-tool-configuration-resources/src/main/resources/xwiki.properties.vm index 7b9fb6ae1f3b..343be6aaa053 100644 --- a/xwiki-platform-tools/xwiki-platform-tool-configuration-resources/src/main/resources/xwiki.properties.vm +++ b/xwiki-platform-tools/xwiki-platform-tool-configuration-resources/src/main/resources/xwiki.properties.vm @@ -1001,6 +1001,15 @@ distribution.automaticStartOnWiki=$xwikiPropertiesAutomaticStartOnWiki #-# The default is: # url.trustedSchemes=http,https,ftp +#-# [Since JAKARTA] +#-# By default, XWiki will try its best to force the application server to let any URL go through despite their default +#-# protections and what Servlet 6.0 recommend. +#-# The point of this option is to allow disabling this bypass of the application server default protections. +#-# For example, if you are using the same application server for something else than XWiki. +#-# +#-# The default is: +# url.forceAllowAnyCharacter=true + #------------------------------------------------------------------------------------- # Attachment #------------------------------------------------------------------------------------- @@ -1622,4 +1631,14 @@ edit.defaultEditor.org.xwiki.rendering.block.XDOM#wysiwyg=$xwikiPropertiesDefaul #-# Default is 10 seconds. # diff.xml.dataURI.httpTimeout = 10 +#------------------------------------------------------------------------------------- +# Container +#------------------------------------------------------------------------------------- + +#-# [Since 42.0.0] +#-# "true" if the relative redirect URLs should be resolved by XWiki instead of the application server. +#-# +#-# Default is "true". +# container.request.resolveRelativeRedirect=true + $!xwikiPropertiesAdditionalProperties diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/README.md b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/README.md index 49c732b8b242..179497b65a8f 100644 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/README.md +++ b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/README.md @@ -3,38 +3,14 @@ XWiki Jetty Configuration These instructions are useful when upgrading the Jetty version used. -We brought the following changes from the default Jetty files obtained from the Jetty zip file (in `jetty-home`): +We brought the following changes from the default Jetty files obtained from the `org.eclipse.jetty:jetty-home` package: -1. Addition of XWiki license headers to all files 1. Addition of `modules/xwiki.mod`, to group all modules we depend on. 1. Addition of `start.d/xwiki.ini` to configure the following properties: - 1. Disable WAR scanning/hot deployment (since we use static deployment, and it speeds up - Jetty) by changing the default values for: - ``` - jetty.deploy.scanInterval=0 - jetty.deploy.extractWars=false - ``` + 1. Disable WAR scanning/hot deployment (since we use static deployment, and it speeds up Jetty). 1. Configure Jetty to use RFC3986 for URLs + allow for ambiguous elements in the URLs as XWiki currently needs them (see the doc in start.d/xwiki.ini). - ``` - jetty.httpConfig.uriCompliance=RFC3986,AMBIGUOUS_PATH_ENCODING,AMBIGUOUS_EMPTY_SEGMENT,AMBIGUOUS_PATH_SEPARATOR - ``` 1. Addition of `etc/jetty-xwiki.xml` to print a message in the console when XWiki is started. -1. Remove support for JSP (since XWiki doesn't use JSPs) by: - 1. Removing the following from `etc/webdefault-ee8.xml`: - ``` - - ... - - ``` - Also remove the `` just below it. - Under `` alors remove the `index.jsp` line. - 1. Keep only the `apache-el-` lib in `modules/ee8-apache-jsp.mod` (i.e. remove the JSP lib references). - We need the EL lib for Hibernate Validator (see XWIKI-19314) -1. Remove alpn (we don't need TLS/SSL for a demo packaging) and http2 support by: - 1. Remove `lib/jetty-alpn-client-${jetty.version}.jar` from `modules/client.mod` - 1. Remove references to the `alpn` and `http2` modules from `modules/https.mod` -1. Addition of `modules/xwiki-logging.mod` to configure logging for XWiki (provides the Jetty `logging` module name) 1. Modification of `etc/console-capture.xml` to send logs to both the console and files. Namely, we wrap: ``` @@ -54,6 +30,6 @@ We brought the following changes from the default Jetty files obtained from the - ``` -1. Note that we don't include all `etc/*.xml` files nor all `modules/*.mod` files since we don't use these extra - features. + ``` + This also means adding commons-io to Jetty. +1. In the pom.xml, we exclude various files we know we don't need in this context, to reduce the size of the resulting zip file \ No newline at end of file diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/pom.xml b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/pom.xml index 8dec94732285..bda17507c8d3 100644 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/pom.xml +++ b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/pom.xml @@ -32,115 +32,92 @@ pom Packages a Jetty installation - - true - ${jetty.server.version} - ${jetty.server.slf4j.version} - ${jetty.server.apache-el.version} + + + org.eclipse.jetty + jetty-home + ${jetty.server.version} + zip + + + + * + * + + + org.xwiki.platform xwiki-platform-tool-jetty-listener ${project.version} true - commons-io commons-io true - - org.eclipse.jetty - jetty-server - ${jetty.version} - true - - - org.eclipse.jetty - jetty-xml - ${jetty.version} - true - - - org.eclipse.jetty - jetty-deploy - ${jetty.version} - true - - - org.eclipse.jetty - jetty-start - ${jetty.version} - shaded - true - - - org.eclipse.jetty - jetty-jmx - ${jetty.version} - true - - - org.eclipse.jetty.ee8 - jetty-ee8-annotations - ${jetty.version} - true - - - org.eclipse.jetty - jetty-plus - ${jetty.version} - true - - - org.eclipse.jetty - jetty-jndi - ${jetty.version} - true - - - org.eclipse.jetty - jetty-slf4j-impl - ${jetty.version} - true - - - org.eclipse.jetty - jetty-client - ${jetty.version} - true - - - - org.eclipse.jetty.ee8.websocket - jetty-ee8-websocket-javax-server - ${jetty.version} - true - - - org.eclipse.jetty.ee8.websocket - jetty-ee8-websocket-javax-client - ${jetty.version} - true - - - - org.mortbay.jasper - apache-el - true - compile - + + + org.apache.maven.plugins + maven-dependency-plugin + + + unpack + prepare-package + + unpack + + + + + org.eclipse.jetty + jetty-home + ${jetty.server.version} + zip + + + **/*demo*, + **/*demo*/, + + **/*ee8*, + **/*ee8*/, + **/*ee9*, + **/*ee9*/, + + **/*http2*, + **/*http2*/, + + **/*http3*, + **/*http3*/, + + **/*cdi*, + **/*cdi*/, + + **/*jstl*, + **/*jstl*/ + + + + ${project.build.directory} + + + + + + org.apache.maven.plugins maven-assembly-plugin @@ -150,7 +127,7 @@ false - ${basedir}/src/main/assembly/distribution.xml + src/main/assembly/distribution.xml diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/assembly/distribution.xml b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/assembly/distribution.xml index c2c32a2b56cc..38e666b775ea 100644 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/assembly/distribution.xml +++ b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/assembly/distribution.xml @@ -26,89 +26,24 @@ zip false - - - - start.jar - /jetty - - org.eclipse.jetty:jetty-start:jar:shaded - - - false - - - /jetty/lib + + + + + ${basedir}/src/main/resources + / - org.eclipse.jetty:jetty-start:jar:shaded - - org.xwiki.platform:xwiki-platform-tool-jetty-listener - commons-io:commons-io - - org.ow2.asm:* - jakarta.annotation:jakarta.annotation-api - - org.slf4j:slf4j-api - org.eclipse.jetty:jetty-slf4j-impl - - org.eclipse.jetty.ee8.websocket:* - *:jetty-javax-websocket-api - - org.mortbay.jasper:apache-el + **/*.sh - - false - - - /jetty/lib/ext - - org.xwiki.platform:xwiki-platform-tool-jetty-listener - commons-io:commons-io - - - false - - - /jetty/lib/ee8-annotations - - org.ow2.asm:* - jakarta.annotation:jakarta.annotation-api - - - false - - - /jetty/lib/ee8-websocket - - org.eclipse.jetty.ee8.websocket:* - *:jetty-javax-websocket-api - - - false - - - - /jetty/lib/logging - - org.slf4j:slf4j-api - org.eclipse.jetty:jetty-slf4j-impl - - - false - - - - - /jetty/lib/ee8-apache-jsp - - org.mortbay.jasper:apache-el - - - false - - - + + + + + ${project.build.directory}/jetty-home-${jetty.server.version} + /jetty/ + 644 + + ${basedir}/src/main/resources @@ -119,18 +54,25 @@ true 755 - - - ${basedir}/src/main/resources - / - - **/*.sh - - + ${basedir}/src/main/resources/logs /logs + + + + /jetty/lib/ext + + + org.xwiki.platform:xwiki-platform-tool-jetty-listener + + commons-io:commons-io + + + false + + diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-bytebufferpool.xml b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-bytebufferpool.xml deleted file mode 100644 index dbde985be754..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-bytebufferpool.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-deploy.xml b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-deploy.xml deleted file mode 100644 index 4a9d32146b28..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-deploy.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-ee-webapp.xml b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-ee-webapp.xml deleted file mode 100644 index 3b94f5cffb91..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-ee-webapp.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-ee8-deploy.xml b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-ee8-deploy.xml deleted file mode 100644 index 1b3f910a1548..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-ee8-deploy.xml +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - - - - - - - org.eclipse.jetty.deploy.DeploymentManager - - - - contextHandlerClass - - - - - - - - ee8 - - - - - - - - - - - - - jetty.deploy.defaultsDescriptorPath - jetty.deploy.defaultsDescriptor - - /etc/webdefault-ee8.xml - - - - - - - - - - - .*/jetty-servlet-api-[^/]*\.jar$|.*jakarta.servlet.jsp.jstl-[^/]*\.jar|.*jsp.jstl-[^/]*\.jar - - - - - - - - - - - - - - - - - diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-ee8-webapp.xml b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-ee8-webapp.xml deleted file mode 100644 index 0bd5e05b400d..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-ee8-webapp.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-http-forwarded.xml b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-http-forwarded.xml deleted file mode 100644 index cbb0632d1294..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-http-forwarded.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-http.xml b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-http.xml deleted file mode 100644 index 1cc65d7ef341..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-http.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-https.xml b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-https.xml deleted file mode 100644 index 13f9cd9698d9..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-https.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - http/1.1 - - - - - - - - - - - - - - diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-jmx.xml b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-jmx.xml deleted file mode 100644 index 290b15494332..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-jmx.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-requestlog.xml b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-requestlog.xml deleted file mode 100644 index d3417016fb34..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-requestlog.xml +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - /yyyy_mm_dd.request.log - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-ssl-context.xml b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-ssl-context.xml deleted file mode 100644 index 23e527475faf..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-ssl-context.xml +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-ssl.xml b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-ssl.xml deleted file mode 100644 index ffc314cc87b8..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-ssl.xml +++ /dev/null @@ -1,84 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-threadpool.xml b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-threadpool.xml deleted file mode 100644 index b79642525278..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-threadpool.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty.xml b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty.xml deleted file mode 100644 index a5abe13e9d83..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty.xml +++ /dev/null @@ -1,119 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/sessions/id-manager.xml b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/sessions/id-manager.xml deleted file mode 100644 index a4841e55da73..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/sessions/id-manager.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - - node - - - 0 - - - - - - - - - - - - - - - - - - true - - diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/webdefault-ee8.xml b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/webdefault-ee8.xml deleted file mode 100644 index 214b9f6a3805..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/webdefault-ee8.xml +++ /dev/null @@ -1,414 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - Default web.xml file. - This file is applied to a Web application before its own WEB_INF/web.xml file - - - - - - - - org.eclipse.jetty.ee8.servlet.listener.IntrospectorCleaner - - - - - - - - - - - - - - - - - default - org.eclipse.jetty.ee8.servlet.DefaultServlet - - acceptRanges - true - - - dirAllowed - true - - - welcomeServlets - false - - - redirectWelcome - false - - - maxCacheSize - 256000000 - - - maxCachedFileSize - 200000000 - - - maxCachedFiles - 2048 - - - etags - false - - - useFileMappedBuffer - true - - 0 - - - - default - / - - - - - - - - 30 - - - - - - - - - - - - - - - index.html - index.htm - - - - - - - - ar - ISO-8859-6 - - - be - ISO-8859-5 - - - bg - ISO-8859-5 - - - ca - ISO-8859-1 - - - cs - ISO-8859-2 - - - da - ISO-8859-1 - - - de - ISO-8859-1 - - - el - ISO-8859-7 - - - en - ISO-8859-1 - - - es - ISO-8859-1 - - - et - ISO-8859-1 - - - fi - ISO-8859-1 - - - fr - ISO-8859-1 - - - hr - ISO-8859-2 - - - hu - ISO-8859-2 - - - is - ISO-8859-1 - - - it - ISO-8859-1 - - - iw - ISO-8859-8 - - - ja - Shift_JIS - - - ko - EUC-KR - - - lt - ISO-8859-2 - - - lv - ISO-8859-2 - - - mk - ISO-8859-5 - - - nl - ISO-8859-1 - - - no - ISO-8859-1 - - - pl - ISO-8859-2 - - - pt - ISO-8859-1 - - - ro - ISO-8859-2 - - - ru - ISO-8859-5 - - - sh - ISO-8859-5 - - - sk - ISO-8859-2 - - - sl - ISO-8859-2 - - - sq - ISO-8859-2 - - - sr - ISO-8859-5 - - - sv - ISO-8859-1 - - - tr - ISO-8859-9 - - - uk - ISO-8859-5 - - - zh - GB2312 - - - zh_TW - Big5 - - - - - - - - - Disable TRACE - / - TRACE - - - - - - Enable everything but TRACE - / - TRACE - - - - - diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-xwiki.xml b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/xwiki.xml similarity index 100% rename from xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/jetty-xwiki.xml rename to xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/etc/xwiki.xml diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/bytebufferpool.mod b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/bytebufferpool.mod deleted file mode 100644 index 10c542541d88..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/bytebufferpool.mod +++ /dev/null @@ -1,58 +0,0 @@ -# --------------------------------------------------------------------------- -# See the NOTICE file distributed with this work for additional -# information regarding copyright ownership. -# -# This is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this software; if not, write to the Free -# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -# 02110-1301 USA, or see the FSF site: http://www.fsf.org. -# --------------------------------------------------------------------------- - -# DO NOT EDIT - See: https://jetty.org/docs/index.html - -[description] -Configures the ByteBufferPool used by ServerConnectors. -The bucket sizes increase linearly. -Use module "bytebufferpool-quadratic" for a pool that holds more coarse sized buffers. - -[depends] -logging - -[xml] -etc/jetty-bytebufferpool.xml - -[ini-template] -## Minimum capacity of a single ByteBuffer. -#jetty.byteBufferPool.minCapacity=0 - -## Maximum capacity of a single ByteBuffer. -## Requests for ByteBuffers larger than this value results -## in the ByteBuffer being allocated but not pooled. -#jetty.byteBufferPool.maxCapacity=65536 - -## Bucket capacity factor. -## ByteBuffers are allocated out of buckets that have -## a capacity that is multiple of this factor. -#jetty.byteBufferPool.factor=4096 - -## Maximum size for each bucket (-1 for unbounded). -#jetty.byteBufferPool.maxBucketSize=-1 - -## Maximum heap memory held idle by the pool (0 for heuristic, -1 for unlimited). -#jetty.byteBufferPool.maxHeapMemory=0 - -## Maximum direct memory held idle by the pool (0 for heuristic, -1 for unlimited). -#jetty.byteBufferPool.maxDirectMemory=0 - -## Whether statistics are enabled. -#jetty.byteBufferPool.statisticsEnabled=false diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/client.mod b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/client.mod deleted file mode 100644 index 86335d3b8819..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/client.mod +++ /dev/null @@ -1,30 +0,0 @@ -# --------------------------------------------------------------------------- -# See the NOTICE file distributed with this work for additional -# information regarding copyright ownership. -# -# This is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this software; if not, write to the Free -# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -# 02110-1301 USA, or see the FSF site: http://www.fsf.org. -# --------------------------------------------------------------------------- - -# DO NOT EDIT - See: https://jetty.org/docs/index.html - -[description] -Adds the Jetty HTTP client dependencies to the server classpath. - -[tags] -client - -[lib] -lib/jetty-client-${jetty.version}.jar diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/console-capture.mod b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/console-capture.mod deleted file mode 100644 index fb78cc48564f..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/console-capture.mod +++ /dev/null @@ -1,51 +0,0 @@ -# --------------------------------------------------------------------------- -# See the NOTICE file distributed with this work for additional -# information regarding copyright ownership. -# -# This is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this software; if not, write to the Free -# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -# 02110-1301 USA, or see the FSF site: http://www.fsf.org. -# --------------------------------------------------------------------------- - -# DO NOT EDIT - See: https://jetty.org/docs/index.html - -[description] -Redirects the JVM console stderr and stdout to a rolling log file. - -[tags] -logging - -[depends] -logging - -[xml] -etc/console-capture.xml - -[files] -logs/ - -[ini-template] -# tag::documentation[] -## Logging directory (relative to $JETTY_BASE). -# jetty.console-capture.dir=./logs - -## Whether to append to existing file. -# jetty.console-capture.append=true - -## How many days to retain old log files. -# jetty.console-capture.retainDays=90 - -## Timezone ID of the log timestamps, as specified by java.time.ZoneId. -# jetty.console-capture.timezone=GMT -# end::documentation[] diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/deploy.mod b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/deploy.mod deleted file mode 100644 index 716e9f0629da..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/deploy.mod +++ /dev/null @@ -1,37 +0,0 @@ -# --------------------------------------------------------------------------- -# See the NOTICE file distributed with this work for additional -# information regarding copyright ownership. -# -# This is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this software; if not, write to the Free -# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -# 02110-1301 USA, or see the FSF site: http://www.fsf.org. -# --------------------------------------------------------------------------- - -# DO NOT EDIT - See: https://jetty.org/docs/index.html - -[description] -This module enables web application deployment from the `$JETTY_BASE/webapps` directory. - -[depend] -server - -[lib] -lib/jetty-deploy-${jetty.version}.jar - -[files] -webapps/ - -[xml] -etc/jetty-deploy.xml - diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee-webapp.mod b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee-webapp.mod deleted file mode 100644 index 0a664334541f..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee-webapp.mod +++ /dev/null @@ -1,51 +0,0 @@ -# --------------------------------------------------------------------------- -# See the NOTICE file distributed with this work for additional -# information regarding copyright ownership. -# -# This is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this software; if not, write to the Free -# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -# 02110-1301 USA, or see the FSF site: http://www.fsf.org. -# --------------------------------------------------------------------------- - -# DO NOT EDIT - See: https://jetty.org/docs/index.html - -[description] -# tag::description[] -This module provide common configuration of Java Servlet web applications over all environments. -# end::description[] - -[xml] -etc/jetty-ee-webapp.xml - -[lib] -lib/jetty-ee-${jetty.version}.jar - -[ini-template] -# tag::ini-template[] -## Add to the server wide default jars and packages protected or hidden from webapps. -## Protected (aka System) classes cannot be overridden by a webapp. -## Hidden (aka Server) classes cannot be seen by a webapp -## Lists of patterns are comma separated and may be either: -## + a qualified classname e.g. 'com.acme.Foo' -## + a package name e.g. 'net.example.' -## + a jar file e.g. '${jetty.base.uri}/lib/dependency.jar' -## + a directory of jars,resource or classes e.g. '${jetty.base.uri}/resources' -## + A pattern preceded with a '-' is an exclusion, all other patterns are inclusions -## -## The +=, operator appends to a CSV list with a comma as needed. -## -#jetty.server.addProtectedClasses+=,org.example. -#jetty.server.addHiddenClasses+=,org.example. -# end::ini-template[] - diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee8-annotations.mod b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee8-annotations.mod deleted file mode 100644 index 868802984fa8..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee8-annotations.mod +++ /dev/null @@ -1,47 +0,0 @@ -# --------------------------------------------------------------------------- -# See the NOTICE file distributed with this work for additional -# information regarding copyright ownership. -# -# This is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this software; if not, write to the Free -# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -# 02110-1301 USA, or see the FSF site: http://www.fsf.org. -# --------------------------------------------------------------------------- - -# DO NOT EDIT - See: https://jetty.org/docs/index.html - -[description] -Enables Annotation scanning for deployed web applications. - -[environment] -ee8 - -[depend] -plus -ee8-plus - -[ini] -ee8.asm.version?=9.7.1 -ee8.jakarta.annotation.api.version?=1.3.5 - -[lib] -lib/jetty-ee8-annotations-${jetty.version}.jar -lib/ee8-annotations/asm-${ee8.asm.version}.jar -lib/ee8-annotations/asm-analysis-${ee8.asm.version}.jar -lib/ee8-annotations/asm-commons-${ee8.asm.version}.jar -lib/ee8-annotations/asm-tree-${ee8.asm.version}.jar -lib/ee8-annotations/jakarta.annotation-api-${ee8.jakarta.annotation.api.version}.jar - -[jpms] -add-modules:org.objectweb.asm - diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee8-apache-jsp.mod b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee8-apache-jsp.mod deleted file mode 100644 index 6f98b4e67bc7..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee8-apache-jsp.mod +++ /dev/null @@ -1,37 +0,0 @@ -# --------------------------------------------------------------------------- -# See the NOTICE file distributed with this work for additional -# information regarding copyright ownership. -# -# This is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this software; if not, write to the Free -# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -# 02110-1301 USA, or see the FSF site: http://www.fsf.org. -# --------------------------------------------------------------------------- - -# DO NOT EDIT - See: https://jetty.org/docs/index.html - -[description] -Enables use of the apache implementation of JSP. - -[environment] -ee8 - -[depend] -ee8-servlet -ee8-annotations - -[ini] -ee8.jsp.impl.version?=9.0.96 - -[lib] -lib/ee8-apache-jsp/apache-el-${ee8.jsp.impl.version}.jar diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee8-deploy.mod b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee8-deploy.mod deleted file mode 100644 index 371d5789183a..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee8-deploy.mod +++ /dev/null @@ -1,69 +0,0 @@ -# --------------------------------------------------------------------------- -# See the NOTICE file distributed with this work for additional -# information regarding copyright ownership. -# -# This is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this software; if not, write to the Free -# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -# 02110-1301 USA, or see the FSF site: http://www.fsf.org. -# --------------------------------------------------------------------------- - -# DO NOT EDIT - See: https://jetty.org/docs/index.html - -[description] -# tag::description[] -This module enables webapp deployment from the `$JETTY_BASE/webapps` directory. -# end::description[] - -[environment] -ee8 - -[depend] -deploy -ee8-webapp - -[xml] -etc/jetty-ee8-deploy.xml - -[ini-template] -# tag::ini-template[] -## Monitored directory name (relative to $jetty.base) -# jetty.deploy.monitoredDir=webapps - -## Defaults Descriptor for all deployed webapps -# jetty.deploy.defaultsDescriptorPath=${jetty.base}/etc/webdefault-ee8.xml - -## Monitored directory scan period (seconds) -# jetty.deploy.scanInterval=0 - -## Whether to extract *.war files -# jetty.deploy.extractWars=true - -## Whether to give the parent classloader priority -# jetty.deploy.parentLoaderPriority=true - -## Comma separated list of configuration classes to set. -# jetty.deploy.configurationClasses= - -## Pattern to select jars from the container classloader to be scanned (or null to scan no jars) -# jetty.deploy.containerScanJarPattern=.*/jetty-servlet-api-[^/]*\.jar$|.*/javax.servlet.jsp.jstl-.*\.jar$ - -## Pattern to select jars from the container classloader to be scanned (or null to scan all jars). -# jetty.deploy.webInfScanJarPattern= - -## Pattern to exclude discovered ServletContainerInitializers -# jetty.deploy.servletContainerInitializerExclusionPattern= - -## Order of discovered ServletContainerInitializers -# jetty.deploy.servletContainerInitializerOrder= -# end::ini-template[] diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee8-jndi.mod b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee8-jndi.mod deleted file mode 100644 index 9135ddf9f42e..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee8-jndi.mod +++ /dev/null @@ -1,33 +0,0 @@ -# --------------------------------------------------------------------------- -# See the NOTICE file distributed with this work for additional -# information regarding copyright ownership. -# -# This is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this software; if not, write to the Free -# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -# 02110-1301 USA, or see the FSF site: http://www.fsf.org. -# --------------------------------------------------------------------------- - -# DO NOT EDIT - See: https://jetty.org/docs/index.html - -[description] -Adds the Jetty EE8 JNDI reference factories - -[environment] -ee8 - -[depend] -jndi - -[lib] -lib/jetty-ee8-jndi-${jetty.version}.jar diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee8-plus.mod b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee8-plus.mod deleted file mode 100644 index 9cc1f0d8fb9e..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee8-plus.mod +++ /dev/null @@ -1,38 +0,0 @@ -# --------------------------------------------------------------------------- -# See the NOTICE file distributed with this work for additional -# information regarding copyright ownership. -# -# This is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this software; if not, write to the Free -# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -# 02110-1301 USA, or see the FSF site: http://www.fsf.org. -# --------------------------------------------------------------------------- - -# DO NOT EDIT - See: https://jetty.org/docs/index.html - -[description] -Enables Servlet 3.1 resource injection. - -[environment] -ee8 - -[depend] -server -jndi -plus -ee8-security -ee8-webapp - -[lib] -lib/jetty-ee8-plus-${jetty.version}.jar -lib/jakarta.transaction-api-1.3.3.jar diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee8-security.mod b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee8-security.mod deleted file mode 100644 index b334fae5a064..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee8-security.mod +++ /dev/null @@ -1,35 +0,0 @@ -# --------------------------------------------------------------------------- -# See the NOTICE file distributed with this work for additional -# information regarding copyright ownership. -# -# This is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this software; if not, write to the Free -# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -# 02110-1301 USA, or see the FSF site: http://www.fsf.org. -# --------------------------------------------------------------------------- - -# DO NOT EDIT - See: https://jetty.org/docs/index.html - -[description] -Adds servlet standard security handling to the classpath. - -[environment] -ee8 - -[depend] -server -security -ee8-servlet - -[lib] -lib/jetty-ee8-security-${jetty.version}.jar diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee8-servlet.mod b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee8-servlet.mod deleted file mode 100644 index 28eaecb54d28..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee8-servlet.mod +++ /dev/null @@ -1,36 +0,0 @@ -# --------------------------------------------------------------------------- -# See the NOTICE file distributed with this work for additional -# information regarding copyright ownership. -# -# This is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this software; if not, write to the Free -# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -# 02110-1301 USA, or see the FSF site: http://www.fsf.org. -# --------------------------------------------------------------------------- - -# DO NOT EDIT - See: https://jetty.org/docs/index.html - -[description] -Enables standard Servlet handling. - -[environment] -ee8 - -[depend] -server -sessions - -[lib] -lib/jetty-servlet-api-4.0.6.jar -lib/jetty-ee8-nested-${jetty.version}.jar -lib/jetty-ee8-servlet-${jetty.version}.jar diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee8-webapp.mod b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee8-webapp.mod deleted file mode 100644 index 5645f4d3822f..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee8-webapp.mod +++ /dev/null @@ -1,61 +0,0 @@ -# --------------------------------------------------------------------------- -# See the NOTICE file distributed with this work for additional -# information regarding copyright ownership. -# -# This is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this software; if not, write to the Free -# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -# 02110-1301 USA, or see the FSF site: http://www.fsf.org. -# --------------------------------------------------------------------------- - -# DO NOT EDIT - See: https://jetty.org/docs/index.html - -[description] -Adds support for servlet specification web applications to the server classpath. -Without this, only Jetty-specific handlers may be deployed. - -[environment] -ee8 - -[depend] -ee-webapp -ee8-servlet -ee8-security - -[xml] -etc/jetty-ee8-webapp.xml - -[lib] -lib/jetty-ee8-webapp-${jetty.version}.jar - -[ini-template] -## Add to the environment wide default jars and packages protected or hidden from webapps. -## System (aka Protected) classes cannot be overridden by a webapp. -## Server (aka Hidden) classes cannot be seen by a webapp -## Lists of patterns are comma separated and may be either: -## + a qualified classname e.g. 'com.acme.Foo' -## + a package name e.g. 'net.example.' -## + a jar file e.g. '${jetty.base.uri}/lib/dependency.jar' -## + a directory of jars,resource or classes e.g. '${jetty.base.uri}/resources' -## + A pattern preceded with a '-' is an exclusion, all other patterns are inclusions -## -## The +=, operator appends to a CSV list with a comma as needed. -## -#jetty.webapp.addProtectedClasses+=,org.example. -#jetty.webapp.addHiddenClasses+=,org.example. - -[ini] -contextHandlerClass=org.eclipse.jetty.ee8.webapp.WebAppContext - -[jpms] -add-modules:java.instrument diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee8-websocket-javax.mod b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee8-websocket-javax.mod deleted file mode 100644 index 8150285456d2..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee8-websocket-javax.mod +++ /dev/null @@ -1,44 +0,0 @@ -# --------------------------------------------------------------------------- -# See the NOTICE file distributed with this work for additional -# information regarding copyright ownership. -# -# This is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this software; if not, write to the Free -# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -# 02110-1301 USA, or see the FSF site: http://www.fsf.org. -# --------------------------------------------------------------------------- - -# DO NOT EDIT - See: https://jetty.org/docs/index.html - -[description] -Enable javax.websocket APIs for deployed web applications. - -[environment] -ee8 - -[tags] -websocket - -[depend] -client -ee8-annotations - -[lib] -lib/jetty-websocket-core-common-${jetty.version}.jar -lib/jetty-websocket-core-client-${jetty.version}.jar -lib/jetty-websocket-core-server-${jetty.version}.jar -lib/ee8-websocket/jetty-ee8-websocket-servlet-${jetty.version}.jar -lib/ee8-websocket/jetty-javax-websocket-api-1.1.2.jar -lib/ee8-websocket/jetty-ee8-websocket-javax-client-${jetty.version}.jar -lib/ee8-websocket/jetty-ee8-websocket-javax-common-${jetty.version}.jar -lib/ee8-websocket/jetty-ee8-websocket-javax-server-${jetty.version}.jar \ No newline at end of file diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee8-websocket-jetty.mod b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee8-websocket-jetty.mod deleted file mode 100644 index 73ac3941e0c7..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ee8-websocket-jetty.mod +++ /dev/null @@ -1,42 +0,0 @@ -# --------------------------------------------------------------------------- -# See the NOTICE file distributed with this work for additional -# information regarding copyright ownership. -# -# This is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this software; if not, write to the Free -# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -# 02110-1301 USA, or see the FSF site: http://www.fsf.org. -# --------------------------------------------------------------------------- - -# DO NOT EDIT - See: https://jetty.org/docs/index.html - -[description] -Enable the Jetty WebSocket API support for deployed web applications. - -[environment] -ee8 - -[tags] -websocket - -[depend] -ee8-annotations - -[lib] -lib/jetty-websocket-core-common-${jetty.version}.jar -lib/jetty-websocket-core-server-${jetty.version}.jar -lib/ee8-websocket/jetty-ee8-websocket-servlet-${jetty.version}.jar -lib/ee8-websocket/jetty-ee8-websocket-jetty-api-${jetty.version}.jar -lib/ee8-websocket/jetty-ee8-websocket-jetty-common-${jetty.version}.jar -lib/ee8-websocket/jetty-ee8-websocket-jetty-server-${jetty.version}.jar - diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ext.mod b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ext.mod deleted file mode 100644 index 17a98d590e5f..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ext.mod +++ /dev/null @@ -1,35 +0,0 @@ -# --------------------------------------------------------------------------- -# See the NOTICE file distributed with this work for additional -# information regarding copyright ownership. -# -# This is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this software; if not, write to the Free -# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -# 02110-1301 USA, or see the FSF site: http://www.fsf.org. -# --------------------------------------------------------------------------- - -# DO NOT EDIT - See: https://jetty.org/docs/index.html - -[description] -Adds the jar file from $JETTY_HOME/lib/ext and $JETTY_BASE/lib/ext to the server classpath. - -[tags] -classpath - -[lib] -lib/ext/**.jar - -[files] -lib/ -lib/ext/ - diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/http-forwarded.mod b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/http-forwarded.mod deleted file mode 100644 index 63eb39e7d8f2..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/http-forwarded.mod +++ /dev/null @@ -1,78 +0,0 @@ -# --------------------------------------------------------------------------- -# See the NOTICE file distributed with this work for additional -# information regarding copyright ownership. -# -# This is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this software; if not, write to the Free -# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -# 02110-1301 USA, or see the FSF site: http://www.fsf.org. -# --------------------------------------------------------------------------- - -# DO NOT EDIT - See: https://jetty.org/docs/index.html - -[description] -Enables processing of the "Forwarded" HTTP header (and its predecessors "X-Forwarded-*" HTTP headers). -The "Forwarded" HTTP header is added by intermediaries to provide information about the clients. - -[tags] -connector - -[depend] -http - -[xml] -etc/jetty-http-forwarded.xml - -[ini-template] -# tag::documentation[] -### ForwardedRequestCustomizer Configuration - -## Whether to process only the RFC7239 "Forwarded" header. -## "X-Forwarded-*" headers are not processed. -# jetty.httpConfig.forwardedOnly=false - -## Whether the address obtained from "Forwarded: by=" or -## "X-Forwarded-Server" is used in the request authority. -# jetty.httpConfig.forwardedProxyAsAuthority=false - -## Whether the "X-Forwarded-Port" header is used in the request authority, -## or else it is the remote client port. -# jetty.httpConfig.forwardedPortAsAuthority=true - -## The name of the RFC 7239 HTTP header. -# jetty.httpConfig.forwardedHeader=Forwarded - -## The name of the obsolete forwarded host HTTP header. -# jetty.httpConfig.forwardedHostHeader=X-Forwarded-Host - -## The name of the obsolete forwarded server HTTP header. -# jetty.httpConfig.forwardedServerHeader=X-Forwarded-Server - -## The name of the obsolete forwarded scheme HTTP header. -# jetty.httpConfig.forwardedProtoHeader=X-Forwarded-Proto - -## The name of the obsolete forwarded for HTTP header. -# jetty.httpConfig.forwardedForHeader=X-Forwarded-For - -## The name of the obsolete forwarded port HTTP header. -# jetty.httpConfig.forwardedPortHeader=X-Forwarded-Port - -## The name of the obsolete forwarded https HTTP header. -# jetty.httpConfig.forwardedHttpsHeader=X-Proxied-Https - -## The name of the obsolete forwarded SSL session ID HTTP header. -# jetty.httpConfig.forwardedSslSessionIdHeader=Proxy-ssl-id - -## The name of the obsolete forwarded SSL cipher HTTP header. -# jetty.httpConfig.forwardedCipherSuiteHeader=Proxy-auth-cert -# end::documentation[] diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/http.mod b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/http.mod deleted file mode 100644 index b135a62ab5aa..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/http.mod +++ /dev/null @@ -1,78 +0,0 @@ -# --------------------------------------------------------------------------- -# See the NOTICE file distributed with this work for additional -# information regarding copyright ownership. -# -# This is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this software; if not, write to the Free -# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -# 02110-1301 USA, or see the FSF site: http://www.fsf.org. -# --------------------------------------------------------------------------- - -# DO NOT EDIT - See: https://jetty.org/docs/index.html - -[description] -Enables a clear-text HTTP connector. -By default clear-text HTTP/1.1 is enabled, and clear-text HTTP/2 may be added by enabling the "http2c" module. - -[tags] -connector -http - -[depend] -server - -[xml] -etc/jetty-http.xml - -[ini-template] -# tag::documentation[] -### Clear-Text HTTP Connector Configuration - -## The host/address to bind the connector to. -# jetty.http.host=0.0.0.0 - -## The port the connector listens on. -# jetty.http.port=8080 - -## The connector idle timeout, in milliseconds. -# jetty.http.idleTimeout=30000 - -## The number of acceptors (-1 picks a default value based on number of cores). -# jetty.http.acceptors=1 - -## The number of selectors (-1 picks a default value based on number of cores). -# jetty.http.selectors=-1 - -## The ServerSocketChannel accept queue backlog (0 picks the platform default). -# jetty.http.acceptQueueSize=0 - -## The thread priority delta to give to acceptor threads. -# jetty.http.acceptorPriorityDelta=0 - -## Whether to enable the SO_REUSEADDR socket option. -# jetty.http.reuseAddress=true - -## Whether to enable the SO_REUSEPORT socket option. -# jetty.http.reusePort=false - -## Whether to enable the TCP_NODELAY socket option on accepted sockets. -# jetty.http.acceptedTcpNoDelay=true - -## The SO_RCVBUF socket option to set on accepted sockets. -## A value of -1 indicates that the platform default is used. -# jetty.http.acceptedReceiveBufferSize=-1 - -## The SO_SNDBUF socket option to set on accepted sockets. -## A value of -1 indicates that the platform default is used. -# jetty.http.acceptedSendBufferSize=-1 -# end::documentation[] diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/https.mod b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/https.mod deleted file mode 100644 index 6a09c385c745..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/https.mod +++ /dev/null @@ -1,40 +0,0 @@ -# --------------------------------------------------------------------------- -# See the NOTICE file distributed with this work for additional -# information regarding copyright ownership. -# -# This is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this software; if not, write to the Free -# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -# 02110-1301 USA, or see the FSF site: http://www.fsf.org. -# --------------------------------------------------------------------------- - -# DO NOT EDIT - See: https://jetty.org/docs/index.html - -[description] -Adds HTTPS protocol support to the TLS(SSL) Connector. - -[tags] -connector -https -http -ssl - -[depend] -ssl - -[after] -http-forwarded - -[xml] -etc/jetty-https.xml - diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/jmx.mod b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/jmx.mod deleted file mode 100644 index aee601f9d41e..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/jmx.mod +++ /dev/null @@ -1,35 +0,0 @@ -# --------------------------------------------------------------------------- -# See the NOTICE file distributed with this work for additional -# information regarding copyright ownership. -# -# This is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this software; if not, write to the Free -# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -# 02110-1301 USA, or see the FSF site: http://www.fsf.org. -# --------------------------------------------------------------------------- - -# DO NOT EDIT - See: https://jetty.org/docs/index.html - -[description] -# tag::description[] -This module enables local Java Management Extension (JMX) support for Jetty components. -# end::description[] - -[depend] -server - -[lib] -lib/jetty-jmx-${jetty.version}.jar - -[xml] -etc/jetty-jmx.xml diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/jndi.mod b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/jndi.mod deleted file mode 100644 index 8870763db9c0..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/jndi.mod +++ /dev/null @@ -1,31 +0,0 @@ -# --------------------------------------------------------------------------- -# See the NOTICE file distributed with this work for additional -# information regarding copyright ownership. -# -# This is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this software; if not, write to the Free -# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -# 02110-1301 USA, or see the FSF site: http://www.fsf.org. -# --------------------------------------------------------------------------- - -# DO NOT EDIT - See: https://jetty.org/docs/index.html - -[description] -Adds the Jetty JNDI implementation to the classpath. - -[depend] -plus -server - -[lib] -lib/jetty-jndi-${jetty.version}.jar diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/jvm.mod b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/jvm.mod deleted file mode 100644 index 03096bf12007..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/jvm.mod +++ /dev/null @@ -1,47 +0,0 @@ -# --------------------------------------------------------------------------- -# See the NOTICE file distributed with this work for additional -# information regarding copyright ownership. -# -# This is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this software; if not, write to the Free -# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -# 02110-1301 USA, or see the FSF site: http://www.fsf.org. -# --------------------------------------------------------------------------- - -# DO NOT EDIT - See: https://jetty.org/docs/index.html - -[description] -Creates an ini template for setting JVM arguments (eg -Xmx ). - -[ini-template] -## JVM Configuration -## If JVM args are include in an ini file then --exec is needed -## to start a new JVM from start.jar with the extra args. -## -## If you wish to avoid an extra JVM running, place JVM args -## on the normal command line and do not use --exec -# --exec -# -Xmx2000m -# -Xmn512m -# -XX:+UseConcMarkSweepGC -# -XX:ParallelCMSThreads=2 -# -XX:+CMSClassUnloadingEnabled -# -XX:+UseCMSCompactAtFullCollection -# -XX:CMSInitiatingOccupancyFraction=80 -# -internal:gc -# -XX:+PrintGCDateStamps -# -XX:+PrintGCTimeStamps -# -XX:+PrintGCDetails -# -XX:+PrintTenuringDistribution -# -XX:+PrintCommandLineFlags -# -XX:+DisableExplicitGC diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/logging/jetty/resources/jetty-logging.properties b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/logging/jetty/resources/jetty-logging.properties deleted file mode 100644 index 17e9bdcf9e21..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/logging/jetty/resources/jetty-logging.properties +++ /dev/null @@ -1,30 +0,0 @@ -# --------------------------------------------------------------------------- -# See the NOTICE file distributed with this work for additional -# information regarding copyright ownership. -# -# This is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this software; if not, write to the Free -# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -# 02110-1301 USA, or see the FSF site: http://www.fsf.org. -# --------------------------------------------------------------------------- - -## Set logging levels from: ALL, TRACE, DEBUG, INFO, WARN, ERROR, OFF -org.eclipse.jetty.LEVEL=INFO -## Configure a level for an arbitrary logger tree -#com.example.LEVEL=INFO -## Configure a level for specific logger -#com.example.MyComponent.LEVEL=INFO -## Configure JMX Context Name -# org.eclipse.jetty.logging.jmx.context=JettyServer -## Hide stacks traces in an arbitrary logger tree -#com.example.STACKS=false diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/logging/slf4j.mod b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/logging/slf4j.mod deleted file mode 100644 index afa2dadcb266..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/logging/slf4j.mod +++ /dev/null @@ -1,39 +0,0 @@ -# --------------------------------------------------------------------------- -# See the NOTICE file distributed with this work for additional -# information regarding copyright ownership. -# -# This is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this software; if not, write to the Free -# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -# 02110-1301 USA, or see the FSF site: http://www.fsf.org. -# --------------------------------------------------------------------------- - -# DO NOT EDIT - See: https://jetty.org/docs/index.html - -[description] -Configures logging to use SLF4J. -A specific implementation of SLF4J is not enabled. -If one is not selected then NOP implementation will be used. - -[tags] -logging - -[provides] -slf4j - -[lib] -lib/logging/slf4j-api-${slf4j.version}.jar - -[ini] -slf4j.version?=2.0.16 -jetty.webapp.addHiddenClasses+=,org.slf4j. diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/plus.mod b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/plus.mod deleted file mode 100644 index 45c285e5618b..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/plus.mod +++ /dev/null @@ -1,30 +0,0 @@ -# --------------------------------------------------------------------------- -# See the NOTICE file distributed with this work for additional -# information regarding copyright ownership. -# -# This is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this software; if not, write to the Free -# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -# 02110-1301 USA, or see the FSF site: http://www.fsf.org. -# --------------------------------------------------------------------------- - -# DO NOT EDIT - See: https://jetty.org/docs/index.html - -[description] -Adds the Jetty Plus JNDI support to the classpath. - -[depend] -server - -[lib] -lib/jetty-plus-${jetty.version}.jar diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/requestlog.mod b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/requestlog.mod deleted file mode 100644 index ace6429c03bb..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/requestlog.mod +++ /dev/null @@ -1,64 +0,0 @@ -# --------------------------------------------------------------------------- -# See the NOTICE file distributed with this work for additional -# information regarding copyright ownership. -# -# This is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this software; if not, write to the Free -# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -# 02110-1301 USA, or see the FSF site: http://www.fsf.org. -# --------------------------------------------------------------------------- - -# DO NOT EDIT - See: https://jetty.org/docs/index.html - -[description] -Logs requests using CustomRequestLog and AsyncRequestLogWriter. - -[tags] -requestlog -logging - -[depend] -server - -[xml] -etc/jetty-requestlog.xml - -[files] -logs/ - -[ini] -jetty.requestlog.dir?=logs - -[ini-template] -# tag::documentation[] -## Format string -# jetty.requestlog.formatString=%{client}a - %u %{dd/MMM/yyyy:HH:mm:ss ZZZ|GMT}t "%r" %s %O "%{Referer}i" "%{User-Agent}i" - -## Logging directory (relative to $jetty.base) -# jetty.requestlog.dir=logs - -## File path -# jetty.requestlog.filePath=${jetty.requestlog.dir}/yyyy_mm_dd.request.log - -## Date format for rollovered files (uses SimpleDateFormat syntax) -# jetty.requestlog.filenameDateFormat=yyyy_MM_dd - -## How many days to retain old log files -# jetty.requestlog.retainDays=90 - -## Whether to append to existing file -# jetty.requestlog.append=false - -## Timezone of the log file rollover -# jetty.requestlog.timezone=GMT -# end::documentation[] diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/resources.mod b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/resources.mod deleted file mode 100644 index cf2e9a24ea44..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/resources.mod +++ /dev/null @@ -1,36 +0,0 @@ -# --------------------------------------------------------------------------- -# See the NOTICE file distributed with this work for additional -# information regarding copyright ownership. -# -# This is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this software; if not, write to the Free -# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -# 02110-1301 USA, or see the FSF site: http://www.fsf.org. -# --------------------------------------------------------------------------- - -# DO NOT EDIT - See: https://jetty.org/docs/index.html - -[description] -# tag::description[] -This module adds the `$JETTY_BASE/resources` directory to the server's classpath. -# end::description[] - -[tags] -classpath - -[lib] -resources/ - -[files] -resources/ - diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/security.mod b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/security.mod deleted file mode 100644 index 7a0646e13b8c..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/security.mod +++ /dev/null @@ -1,30 +0,0 @@ -# --------------------------------------------------------------------------- -# See the NOTICE file distributed with this work for additional -# information regarding copyright ownership. -# -# This is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this software; if not, write to the Free -# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -# 02110-1301 USA, or see the FSF site: http://www.fsf.org. -# --------------------------------------------------------------------------- - -# DO NOT EDIT - See: https://jetty.org/docs/index.html - -[description] -Adds core security handling to the classpath. - -[depend] -server - -[lib] -lib/jetty-security-${jetty.version}.jar diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/server.mod b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/server.mod deleted file mode 100644 index 4be55e5f8e95..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/server.mod +++ /dev/null @@ -1,147 +0,0 @@ -# --------------------------------------------------------------------------- -# See the NOTICE file distributed with this work for additional -# information regarding copyright ownership. -# -# This is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this software; if not, write to the Free -# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -# 02110-1301 USA, or see the FSF site: http://www.fsf.org. -# --------------------------------------------------------------------------- - -# DO NOT EDIT - See: https://jetty.org/docs/index.html - -[description] -Enables and configures the Jetty server. -This module does not enable any network protocol support. -To enable a specific network protocol such as HTTP/1.1, you must enable the correspondent Jetty module. - -[after] -jvm -ext -resources - -[depend] -threadpool -bytebufferpool -logging - -[lib] -lib/jetty-http-${jetty.version}.jar -lib/jetty-server-${jetty.version}.jar -lib/jetty-xml-${jetty.version}.jar -lib/jetty-util-${jetty.version}.jar -lib/jetty-io-${jetty.version}.jar - -[xml] -etc/jetty.xml - -[ini-template] -# tag::documentation-http-config[] -### Common HTTP configuration -## Scheme to use to build URIs for secure redirects -# jetty.httpConfig.secureScheme=https - -## Port to use to build URIs for secure redirects -# jetty.httpConfig.securePort=8443 - -## Response content buffer size (in bytes) -# jetty.httpConfig.outputBufferSize=32768 - -## Max response content write length that is buffered (in bytes) -# jetty.httpConfig.outputAggregationSize=8192 - -## If HTTP/1.x persistent connections should be enabled -# jetty.httpConfig.persistentConnectionsEnabled=true - -## Max request headers size (in bytes) -# jetty.httpConfig.requestHeaderSize=8192 - -## Max response headers size (in bytes) -# jetty.httpConfig.responseHeaderSize=8192 - -## Whether to send the Server: header -# jetty.httpConfig.sendServerVersion=true - -## Whether to send the Date: header -# jetty.httpConfig.sendDateHeader=false - -## Max per-connection header cache size (in nodes) -# jetty.httpConfig.headerCacheSize=1024 - -## Whether, for requests with content, delay dispatch until some content has arrived -# jetty.httpConfig.delayDispatchUntilContent=true - -## Maximum number of error dispatches to prevent looping -# jetty.httpConfig.maxErrorDispatches=10 - -## Relative Redirect Locations allowed -# jetty.httpConfig.relativeRedirectAllowed=true - -## Whether to use direct ByteBuffers for reading or writing -# jetty.httpConfig.useInputDirectByteBuffers=true -# jetty.httpConfig.useOutputDirectByteBuffers=true -# end::documentation-http-config[] - -# tag::documentation-server-compliance[] -## HTTP Compliance: RFC7230, RFC7230_LEGACY, RFC2616, RFC2616_LEGACY, LEGACY -# jetty.httpConfig.compliance=RFC7230 - -## URI Compliance: DEFAULT, LEGACY, RFC3986, RFC3986_UNAMBIGUOUS, UNSAFE -# jetty.httpConfig.uriCompliance=DEFAULT - -## Cookie compliance mode for parsing request Cookie headers: RFC6265_STRICT, RFC6265, RFC6265_LEGACY, RFC2965, RFC2965_LEGACY -# jetty.httpConfig.requestCookieCompliance=RFC6265 - -## Cookie compliance mode for generating response Set-Cookie: RFC2965, RFC6265 -# jetty.httpConfig.responseCookieCompliance=RFC6265 -# end::documentation-server-compliance[] - -# tag::documentation-server-config[] -### Server configuration -## Whether ctrl+c on the console gracefully stops the Jetty server -# jetty.server.stopAtShutdown=true - -## Timeout in ms to apply when stopping the server gracefully -# jetty.server.stopTimeout=5000 - -## Dump the state of the Jetty server, components, and webapps after startup -# jetty.server.dumpAfterStart=false - -## The temporary directory used by the Jetty server and as a root for its contexts -# jetty.server.tempDirectory= - -## Dump the state of the Jetty server, components, and webapps before shutdown -# jetty.server.dumpBeforeStop=false -# end::documentation-server-config[] - -# tag::documentation-scheduler-config[] -### Server Scheduler Configuration -## The scheduler thread name, defaults to "Scheduler-{hashCode()}" if blank. -# jetty.scheduler.name= - -## Whether the server scheduler threads are daemon. -# jetty.scheduler.daemon=false - -## The number of server scheduler threads. -# jetty.scheduler.threads=1 -# end::documentation-scheduler-config[] - -## Whether the handlers of the ContextHandlerCollection can be updated once the server is started -## If set to false, then -deploy module jetty.deploy.scanInterval should also be set to 0. -# jetty.server.contexts.dynamic=true - -## Should the DefaultHandler serve the jetty favicon.ico from the root. -# jetty.server.default.serveFavIcon=true - -## Should the DefaultHandler show a list of known contexts in a root 404 response. -# jetty.server.default.showContexts=true diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/sessions.mod b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/sessions.mod deleted file mode 100644 index a4cebd14eb42..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/sessions.mod +++ /dev/null @@ -1,47 +0,0 @@ -# --------------------------------------------------------------------------- -# See the NOTICE file distributed with this work for additional -# information regarding copyright ownership. -# -# This is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this software; if not, write to the Free -# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -# 02110-1301 USA, or see the FSF site: http://www.fsf.org. -# --------------------------------------------------------------------------- - -# DO NOT EDIT - See: https://jetty.org/docs/index.html - -[description] -Enables session management. -By enabling this module, it allows session management to be configured via the ini templates -created or by enabling other session-cache or session-store modules. -Without this module enabled, -the server may still use sessions, but their management cannot be configured. - -[tags] -session - -[depends] -server - -[lib] -lib/jetty-session-${jetty.version}.jar - -[xml] -etc/sessions/id-manager.xml - -[ini-template] -## The name to uniquely identify this server instance -#jetty.sessionIdManager.workerName=node1 - -## Period between runs of the session scavenger (in seconds) -#jetty.sessionScavengeInterval.seconds=600 diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ssl.mod b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ssl.mod deleted file mode 100644 index 9b9595fea47b..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/ssl.mod +++ /dev/null @@ -1,158 +0,0 @@ -# --------------------------------------------------------------------------- -# See the NOTICE file distributed with this work for additional -# information regarding copyright ownership. -# -# This is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this software; if not, write to the Free -# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -# 02110-1301 USA, or see the FSF site: http://www.fsf.org. -# --------------------------------------------------------------------------- - -# DO NOT EDIT - See: https://jetty.org/docs/index.html - -[description] -Enables a TLS (SSL) connector to support secure protocols. -Secure HTTP/1.1 is provided by enabling the "https" module and secure HTTP/2 is provided by enabling the "http2" module. - -[tags] -connector -ssl -internal - -[depend] -server - -[xml] -etc/jetty-ssl.xml -etc/jetty-ssl-context.xml - -[ini-template] -# tag::documentation-connector[] -### TLS (SSL) Connector Configuration - -## The host/address to bind the connector to. -# jetty.ssl.host=0.0.0.0 - -## The port the connector listens on. -# jetty.ssl.port=8443 - -## The connector idle timeout, in milliseconds. -# jetty.ssl.idleTimeout=30000 - -## The number of acceptors (-1 picks a default value based on number of cores). -# jetty.ssl.acceptors=1 - -## The number of selectors (-1 picks a default value based on number of cores). -# jetty.ssl.selectors=-1 - -## The ServerSocketChannel accept queue backlog (0 picks the platform default). -# jetty.ssl.acceptQueueSize=0 - -## The thread priority delta to give to acceptor threads. -# jetty.ssl.acceptorPriorityDelta=0 - -## Whether to enable the SO_REUSEADDR socket option. -# jetty.ssl.reuseAddress=true - -## Whether to enable the SO_REUSEPORT socket option. -# jetty.ssl.reusePort=false - -## Whether to enable the TCP_NODELAY socket option on accepted sockets. -# jetty.ssl.acceptedTcpNoDelay=true - -## The SO_RCVBUF socket option to set on accepted sockets. -## A value of -1 indicates that the platform default is used. -# jetty.ssl.acceptedReceiveBufferSize=-1 - -## The SO_SNDBUF socket option to set on accepted sockets. -## A value of -1 indicates that the platform default is used. -# jetty.ssl.acceptedSendBufferSize=-1 - -## Whether client SNI data is required for all secure connections. -## When SNI is required, clients that do not send SNI data are rejected with an HTTP 400 response. -# jetty.ssl.sniRequired=false - -## Whether client SNI data is checked to match CN and SAN in server certificates. -## When SNI is checked, if the match fails the connection is rejected with an HTTP 400 response. -# jetty.ssl.sniHostCheck=true - -## The max age, in seconds, for the Strict-Transport-Security response header. -# jetty.ssl.stsMaxAgeSeconds=31536000 - -## Whether to include the subdomain property in any Strict-Transport-Security header. -# jetty.ssl.stsIncludeSubdomains=true -# end::documentation-connector[] - -# tag::documentation-ssl-context[] -### SslContextFactory Configuration -## Note that OBF passwords are not secure, just protected from casual observation. - -## Whether client SNI data is required for all secure connections. -## When SNI is required, clients that do not send SNI data are rejected with a TLS handshake error. -# jetty.sslContext.sniRequired=false - -## The Endpoint Identification Algorithm. -## Same as javax.net.ssl.SSLParameters#setEndpointIdentificationAlgorithm(String). -# jetty.sslContext.endpointIdentificationAlgorithm= - -## The JSSE Provider. -# jetty.sslContext.provider= - -## The KeyStore file path, either an absolute path or a relative path to $JETTY_BASE. -# jetty.sslContext.keyStorePath=etc/keystore.p12 - -## The TrustStore file path, either an absolute path or a relative path to $JETTY_BASE. -# jetty.sslContext.trustStorePath=etc/keystore.p12 - -## The KeyStore password. -# jetty.sslContext.keyStorePassword= - -## The Keystore type. -# jetty.sslContext.keyStoreType=PKCS12 - -## The KeyStore provider. -# jetty.sslContext.keyStoreProvider= - -## The KeyManager password. -# jetty.sslContext.keyManagerPassword= - -## The TrustStore password. -# jetty.sslContext.trustStorePassword= - -## The TrustStore type. -# jetty.sslContext.trustStoreType=PKCS12 - -## The TrustStore provider. -# jetty.sslContext.trustStoreProvider= - -## Whether client certificate authentication is required. -# jetty.sslContext.needClientAuth=false - -## Whether client certificate authentication is desired, but not required. -# jetty.sslContext.wantClientAuth=false - -## Whether cipher order is significant. -# jetty.sslContext.useCipherSuitesOrder=true - -## The SSLSession cache size. -# jetty.sslContext.sslSessionCacheSize=-1 - -## The SSLSession cache timeout (in seconds). -# jetty.sslContext.sslSessionTimeout=-1 - -## Whether TLS renegotiation is allowed. -# jetty.sslContext.renegotiationAllowed=true - -## The max number of TLS renegotiations per connection. -# jetty.sslContext.renegotiationLimit=5 -# end::documentation-ssl-context[] diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/threadpool.mod b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/threadpool.mod deleted file mode 100644 index 681e970f7e6b..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/threadpool.mod +++ /dev/null @@ -1,61 +0,0 @@ -# --------------------------------------------------------------------------- -# See the NOTICE file distributed with this work for additional -# information regarding copyright ownership. -# -# This is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this software; if not, write to the Free -# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -# 02110-1301 USA, or see the FSF site: http://www.fsf.org. -# --------------------------------------------------------------------------- - -# DO NOT EDIT - See: https://jetty.org/docs/index.html - -[description] -Enables and configures the Server ThreadPool. - -[depends] -logging - -[provides] -threadpool|default - -[xml] -etc/jetty-threadpool.xml - -[ini-template] -# tag::documentation[] -## Thread name prefix. -#jetty.threadPool.namePrefix=qtp - -## Minimum number of pooled threads. -#jetty.threadPool.minThreads=10 - -## Maximum number of pooled threads. -#jetty.threadPool.maxThreads=200 - -## Number of reserved threads (-1 for heuristic). -#jetty.threadPool.reservedThreads=-1 - -## Whether to use virtual threads, if the runtime supports them. -## Deprecated, use Jetty module 'threadpool-virtual' instead. -#jetty.threadPool.useVirtualThreads=false - -## Thread idle timeout (in milliseconds). -#jetty.threadPool.idleTimeout=60000 - -## The max number of idle threads that are evicted in one idleTimeout period. -#jetty.threadPool.maxEvictCount=1 - -## Whether to output a detailed dump. -#jetty.threadPool.detailedDump=false -# end::documentation[] diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/xwiki-logging.mod b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/xwiki-logging.mod deleted file mode 100644 index 23b00e438f35..000000000000 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/xwiki-logging.mod +++ /dev/null @@ -1,43 +0,0 @@ -# --------------------------------------------------------------------------- -# See the NOTICE file distributed with this work for additional -# information regarding copyright ownership. -# -# This is free software; you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation; either version 2.1 of -# the License, or (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this software; if not, write to the Free -# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -# 02110-1301 USA, or see the FSF site: http://www.fsf.org. -# --------------------------------------------------------------------------- - -[description] -Base configuration for the jetty logging mechanism. -Provides a ${jetty.base}/resources/jetty-logging.properties. - -[tags] -logging - -[depend] -logging/slf4j -resources - -[provides] -logging|default - -[files] -basehome:modules/logging/jetty - -[lib] -lib/logging/jetty-slf4j-impl-${jetty.version}.jar - -[ini] -jetty.webapp.addHiddenClasses+=,org.eclipse.jetty.logging. -jetty.webapp.addHiddenClasses+=,${jetty.home.uri}/lib/logging/ diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/xwiki.mod b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/xwiki.mod index df6f98b11487..feef54c548df 100644 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/xwiki.mod +++ b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/jetty/modules/xwiki.mod @@ -23,18 +23,13 @@ [depend] ext -resources -server -logging +console-capture +ee10-apache-jsp +ee10-deploy +ee10-websocket-jakarta http http-forwarded -ee8-annotations -ee8-deploy -requestlog -ee8-websocket-javax -ee8-websocket-jetty -ee8-apache-jsp -console-capture +work [xml] -etc/jetty-xwiki.xml +etc/xwiki.xml diff --git a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/start.d/xwiki.ini b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/start.d/xwiki.ini index fe3160336fcf..6c906e410927 100644 --- a/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/start.d/xwiki.ini +++ b/xwiki-platform-tools/xwiki-platform-tool-jetty/xwiki-platform-tool-jetty-resources/src/main/resources/start.d/xwiki.ini @@ -24,13 +24,3 @@ ## Disable WAR scanning and hot deployments since we use static expanded WAR to speed up Jetty. jetty.deploy.scanInterval=0 jetty.deploy.extractWars=false - -## Jetty has a protection for URLs that don't respect the Servlet specification and that are considered ambiguous. -## See https://github.com/jetty/jetty.project/issues/12162#issuecomment-2286747043 for an explanation. -## Since XWiki uses them, we need to configure Jetty to allow for it. See also -## https://jetty.org/docs/jetty/10/operations-guide/modules/standard.html#server-compliance -## Thus we need to relax the following rules in addition to using RFC3986: -## Remove AMBIGUOUS_PATH_ENCODING when https://jira.xwiki.org/browse/XWIKI-22422 is fixed. -## Remove AMBIGUOUS_EMPTY_SEGMENT when https://jira.xwiki.org/browse/XWIKI-22428 is fixed. -## Remove AMBIGUOUS_PATH_SEPARATOR when https://jira.xwiki.org/browse/XWIKI-22435 is fixed. -jetty.httpConfig.uriCompliance=RFC3986,AMBIGUOUS_PATH_ENCODING,AMBIGUOUS_EMPTY_SEGMENT,AMBIGUOUS_PATH_SEPARATOR diff --git a/xwiki-platform-tools/xwiki-platform-tool-packager-plugin/pom.xml b/xwiki-platform-tools/xwiki-platform-tool-packager-plugin/pom.xml index 28fb23838294..18c706d701ee 100644 --- a/xwiki-platform-tools/xwiki-platform-tool-packager-plugin/pom.xml +++ b/xwiki-platform-tools/xwiki-platform-tool-packager-plugin/pom.xml @@ -148,8 +148,8 @@ - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api runtime diff --git a/xwiki-platform-tools/xwiki-platform-tool-provision-plugin/pom.xml b/xwiki-platform-tools/xwiki-platform-tool-provision-plugin/pom.xml index d1627181a0f0..90e05ab629a4 100644 --- a/xwiki-platform-tools/xwiki-platform-tool-provision-plugin/pom.xml +++ b/xwiki-platform-tools/xwiki-platform-tool-provision-plugin/pom.xml @@ -85,8 +85,8 @@ commons-httpclient - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api compile diff --git a/xwiki-platform-tools/xwiki-platform-tool-rootwebapp/pom.xml b/xwiki-platform-tools/xwiki-platform-tool-rootwebapp/pom.xml index 093b66139634..36b95ebb4263 100644 --- a/xwiki-platform-tools/xwiki-platform-tool-rootwebapp/pom.xml +++ b/xwiki-platform-tools/xwiki-platform-tool-rootwebapp/pom.xml @@ -36,8 +36,8 @@ - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api diff --git a/xwiki-platform-tools/xwiki-platform-tool-rootwebapp/src/main/java/com/xpn/xwiki/XWikiRootServlet.java b/xwiki-platform-tools/xwiki-platform-tool-rootwebapp/src/main/java/com/xpn/xwiki/XWikiRootServlet.java index 520be6492701..a8f5dc303995 100644 --- a/xwiki-platform-tools/xwiki-platform-tool-rootwebapp/src/main/java/com/xpn/xwiki/XWikiRootServlet.java +++ b/xwiki-platform-tools/xwiki-platform-tool-rootwebapp/src/main/java/com/xpn/xwiki/XWikiRootServlet.java @@ -21,10 +21,10 @@ import java.io.IOException; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; /** * The root servlet for XWiki. The purpose of this servlet is to respond to WebDAV requests correctly and to redirect diff --git a/xwiki-platform-tools/xwiki-platform-tool-standards-validator/pom.xml b/xwiki-platform-tools/xwiki-platform-tool-standards-validator/pom.xml index ba70de77eaef..b64b284a36e7 100644 --- a/xwiki-platform-tools/xwiki-platform-tool-standards-validator/pom.xml +++ b/xwiki-platform-tools/xwiki-platform-tool-standards-validator/pom.xml @@ -76,8 +76,8 @@ jetty-server - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api diff --git a/xwiki-platform-tools/xwiki-platform-tool-xmldoc-update-plugin/pom.xml b/xwiki-platform-tools/xwiki-platform-tool-xmldoc-update-plugin/pom.xml index a1ab2fe5a5ca..0d1ac849b1d6 100644 --- a/xwiki-platform-tools/xwiki-platform-tool-xmldoc-update-plugin/pom.xml +++ b/xwiki-platform-tools/xwiki-platform-tool-xmldoc-update-plugin/pom.xml @@ -53,8 +53,8 @@ ${commons.version} - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api compile @@ -106,6 +106,7 @@ log4j-over-slf4j runtime + org.xwiki.platform