From 429b521cb9f8407b20ef8b0ba41306f94288a7b2 Mon Sep 17 00:00:00 2001 From: exceptionfactory Date: Wed, 29 Nov 2023 14:23:53 -0600 Subject: [PATCH] NIFI-12434 Upgraded Registry to Spring Framework 6.1.1 - Upgraded Spring Framework from 6.0.13 to 6.1.1 - Upgraded Spring Boot from 3.1.5 to 3.2.0 - Upgraded Spring Security from 6.1.5 to 6.2.0 - Upgraded Jetty from 11.0.18 to 12.0.3 - Upgraded Servlet API from 5.0.0 to 6.0.0 - Adjusted Registry Database Tests to streamline DataSource configuration Signed-off-by: Pierre Villard This closes #8087. --- .../nifi/registry/db/DataSourceFactory.java | 2 + .../nifi/registry/db/DatabaseBaseTest.java | 3 - .../registry/db/DatabaseTestApplication.java | 8 - .../nifi-registry-jetty/pom.xml | 28 +-- .../nifi/registry/jetty/JettyServer.java | 15 -- .../jetty/handler/HeaderWriterHandler.java | 29 +-- .../handler/StandardHandlerProvider.java | 22 +-- .../apache/nifi-registry/web/webdefault.xml | 42 +---- .../handler/HeaderWriterHandlerTest.java | 76 -------- .../db/MariaDB10DataSourceFactory.java | 37 ---- .../db/MariaDB10_2DataSourceFactory.java | 37 ---- .../nifi-registry-web-api/pom.xml | 10 - .../NiFiRegistryPropertiesFactory.java | 2 + .../ResourceAuthorizationFilter.java | 2 +- .../NiFiRegistryTestApiApplication.java | 7 - .../SecureLdapTestApiApplication.java | 7 - .../apache/nifi/registry/web/TestRestAPI.java | 173 ------------------ nifi-registry/nifi-registry-core/pom.xml | 38 ++-- .../nifi-registry-ranger-plugin/pom.xml | 17 ++ .../nifi-registry-ranger/pom.xml | 16 -- nifi-registry/pom.xml | 41 +---- 21 files changed, 85 insertions(+), 527 deletions(-) delete mode 100644 nifi-registry/nifi-registry-core/nifi-registry-jetty/src/test/java/org/apache/nifi/registry/jetty/handler/HeaderWriterHandlerTest.java delete mode 100644 nifi-registry/nifi-registry-core/nifi-registry-test/src/main/java/org/apache/nifi/registry/db/MariaDB10DataSourceFactory.java delete mode 100644 nifi-registry/nifi-registry-core/nifi-registry-test/src/main/java/org/apache/nifi/registry/db/MariaDB10_2DataSourceFactory.java delete mode 100644 nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/TestRestAPI.java diff --git a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/main/java/org/apache/nifi/registry/db/DataSourceFactory.java b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/main/java/org/apache/nifi/registry/db/DataSourceFactory.java index 10b0ce9832..a25a33e73d 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/main/java/org/apache/nifi/registry/db/DataSourceFactory.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/main/java/org/apache/nifi/registry/db/DataSourceFactory.java @@ -22,6 +22,7 @@ import org.apache.nifi.registry.properties.NiFiRegistryProperties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.jdbc.DataSourceBuilder; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -33,6 +34,7 @@ import javax.sql.DataSource; * Overriding Spring Boot's normal automatic creation of a DataSource in order to use the properties * from NiFiRegistryProperties rather than the standard application.properties/yaml. */ +@ConditionalOnProperty("nifi.registry.db.url") @Configuration public class DataSourceFactory { diff --git a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/db/DatabaseBaseTest.java b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/db/DatabaseBaseTest.java index 9023b8d157..b303920331 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/db/DatabaseBaseTest.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/db/DatabaseBaseTest.java @@ -16,16 +16,13 @@ */ package org.apache.nifi.registry.db; -import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.TestExecutionListeners; -import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; import org.springframework.test.context.transaction.TransactionalTestExecutionListener; import org.springframework.transaction.annotation.Transactional; @Transactional -@ExtendWith(SpringExtension.class) @SpringBootTest(classes = DatabaseTestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.NONE) @TestExecutionListeners({DependencyInjectionTestExecutionListener.class, TransactionalTestExecutionListener.class}) public abstract class DatabaseBaseTest { diff --git a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/db/DatabaseTestApplication.java b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/db/DatabaseTestApplication.java index dde331e97e..4d94bd47d0 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/db/DatabaseTestApplication.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-framework/src/test/java/org/apache/nifi/registry/db/DatabaseTestApplication.java @@ -21,8 +21,6 @@ import org.mockito.Mockito; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.FilterType; /** * Sets up the application context for database repository tests. @@ -33,12 +31,6 @@ import org.springframework.context.annotation.FilterType; * The DataSourceFactory is excluded so that Spring Boot will load an in-memory H2 database. */ @SpringBootApplication -@ComponentScan( - excludeFilters = { - @ComponentScan.Filter( - type = FilterType.ASSIGNABLE_TYPE, - value = DataSourceFactory.class) - }) public class DatabaseTestApplication { public static void main(String[] args) { diff --git a/nifi-registry/nifi-registry-core/nifi-registry-jetty/pom.xml b/nifi-registry/nifi-registry-core/nifi-registry-jetty/pom.xml index 718dcaa541..b2be9759e4 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-jetty/pom.xml +++ b/nifi-registry/nifi-registry-core/nifi-registry-jetty/pom.xml @@ -32,6 +32,12 @@ org.apache.nifi nifi-jetty-configuration 2.0.0-SNAPSHOT + + + org.eclipse.jetty.http2 + http2-server + + org.apache.nifi @@ -45,7 +51,7 @@ org.eclipse.jetty.http2 - http2-server + jetty-http2-server org.eclipse.jetty @@ -56,28 +62,28 @@ jetty-server - org.eclipse.jetty - jetty-servlet + org.eclipse.jetty.ee10 + jetty-ee10-servlet - org.eclipse.jetty - jetty-webapp + org.eclipse.jetty.ee10 + jetty-ee10-webapp - org.eclipse.jetty - jetty-servlets + org.eclipse.jetty.ee10 + jetty-ee10-servlets - org.eclipse.jetty - jetty-annotations + org.eclipse.jetty.ee10 + jetty-ee10-annotations org.apache.commons commons-lang3 - org.eclipse.jetty - apache-jsp + org.eclipse.jetty.ee10 + jetty-ee10-apache-jsp compile diff --git a/nifi-registry/nifi-registry-core/nifi-registry-jetty/src/main/java/org/apache/nifi/registry/jetty/JettyServer.java b/nifi-registry/nifi-registry-core/nifi-registry-jetty/src/main/java/org/apache/nifi/registry/jetty/JettyServer.java index c625dddbfb..852c1802c5 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-jetty/src/main/java/org/apache/nifi/registry/jetty/JettyServer.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-jetty/src/main/java/org/apache/nifi/registry/jetty/JettyServer.java @@ -26,7 +26,6 @@ import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.server.SslConnectionFactory; import org.eclipse.jetty.util.thread.QueuedThreadPool; -import org.eclipse.jetty.webapp.WebAppContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -39,7 +38,6 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Objects; -import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; @@ -114,19 +112,6 @@ public class JettyServer { public void start() { try { server.start(); - - final Optional unavailableExceptionFound = Arrays.stream(server.getChildHandlers()) - .filter(handler -> handler instanceof WebAppContext) - .map(handler -> (WebAppContext) handler) - .map(WebAppContext::getUnavailableException) - .filter(Objects::nonNull) - .findFirst(); - - if (unavailableExceptionFound.isPresent()) { - final Throwable unavailableException = unavailableExceptionFound.get(); - shutdown(unavailableException); - } - final List applicationUrls = getApplicationUrls(); if (applicationUrls.isEmpty()) { logger.warn("Started Server without connectors"); diff --git a/nifi-registry/nifi-registry-core/nifi-registry-jetty/src/main/java/org/apache/nifi/registry/jetty/handler/HeaderWriterHandler.java b/nifi-registry/nifi-registry-core/nifi-registry-jetty/src/main/java/org/apache/nifi/registry/jetty/handler/HeaderWriterHandler.java index bb2cf74890..85ed6b6692 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-jetty/src/main/java/org/apache/nifi/registry/jetty/handler/HeaderWriterHandler.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-jetty/src/main/java/org/apache/nifi/registry/jetty/handler/HeaderWriterHandler.java @@ -17,15 +17,15 @@ package org.apache.nifi.registry.jetty.handler; import org.eclipse.jetty.server.Request; -import org.eclipse.jetty.server.handler.ScopedHandler; +import org.eclipse.jetty.server.Handler; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.server.Response; +import org.eclipse.jetty.util.Callback; /** * HTTP Response Header Writer Handler applies standard headers to HTTP responses */ -public class HeaderWriterHandler extends ScopedHandler { +public class HeaderWriterHandler extends Handler.Wrapper { protected static final String CONTENT_SECURITY_POLICY_HEADER = "Content-Security-Policy"; protected static final String CONTENT_SECURITY_POLICY = "frame-ancestors 'self'"; @@ -41,19 +41,22 @@ public class HeaderWriterHandler extends ScopedHandler { /** * Handle requests and set HTTP response headers * - * @param target Target URI * @param request Jetty Request - * @param httpServletRequest HTTP Servlet Request - * @param httpServletResponse HTTP Servlet Response + * @param response Jetty Response + * @param callback Jetty Callback + * @return Handled status + * @throws Exception Thrown on failures from subsequent handlers */ @Override - public void doHandle(final String target, final Request request, final HttpServletRequest httpServletRequest, final HttpServletResponse httpServletResponse) { - httpServletResponse.setHeader(CONTENT_SECURITY_POLICY_HEADER, CONTENT_SECURITY_POLICY); - httpServletResponse.setHeader(FRAME_OPTIONS_HEADER, FRAME_OPTIONS); - httpServletResponse.setHeader(XSS_PROTECTION_HEADER, XSS_PROTECTION); + public boolean handle(final Request request, final Response response, final Callback callback) throws Exception { + response.getHeaders().add(CONTENT_SECURITY_POLICY_HEADER, CONTENT_SECURITY_POLICY); + response.getHeaders().add(FRAME_OPTIONS_HEADER, FRAME_OPTIONS); + response.getHeaders().add(XSS_PROTECTION_HEADER, XSS_PROTECTION); - if (httpServletRequest.isSecure()) { - httpServletResponse.setHeader(STRICT_TRANSPORT_SECURITY_HEADER, STRICT_TRANSPORT_SECURITY); + if (request.isSecure()) { + response.getHeaders().add(STRICT_TRANSPORT_SECURITY_HEADER, STRICT_TRANSPORT_SECURITY); } + + return super.handle(request, response, callback); } } diff --git a/nifi-registry/nifi-registry-core/nifi-registry-jetty/src/main/java/org/apache/nifi/registry/jetty/handler/StandardHandlerProvider.java b/nifi-registry/nifi-registry-core/nifi-registry-jetty/src/main/java/org/apache/nifi/registry/jetty/handler/StandardHandlerProvider.java index d72d9a7802..44a239ddc4 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-jetty/src/main/java/org/apache/nifi/registry/jetty/handler/StandardHandlerProvider.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-jetty/src/main/java/org/apache/nifi/registry/jetty/handler/StandardHandlerProvider.java @@ -20,12 +20,12 @@ import org.apache.commons.lang3.StringUtils; import org.apache.nifi.registry.properties.NiFiRegistryProperties; import org.apache.nifi.registry.security.crypto.CryptoKeyProvider; import org.eclipse.jetty.server.Handler; -import org.eclipse.jetty.server.handler.HandlerCollection; -import org.eclipse.jetty.servlet.DefaultServlet; -import org.eclipse.jetty.servlet.ErrorPageErrorHandler; -import org.eclipse.jetty.servlet.ServletHolder; -import org.eclipse.jetty.webapp.WebAppClassLoader; -import org.eclipse.jetty.webapp.WebAppContext; +import org.eclipse.jetty.server.handler.ContextHandlerCollection; +import org.eclipse.jetty.ee10.servlet.DefaultServlet; +import org.eclipse.jetty.ee10.servlet.ErrorPageErrorHandler; +import org.eclipse.jetty.ee10.servlet.ServletHolder; +import org.eclipse.jetty.ee10.webapp.WebAppClassLoader; +import org.eclipse.jetty.ee10.webapp.WebAppContext; import java.io.File; import java.io.IOException; @@ -101,7 +101,7 @@ public class StandardHandlerProvider implements HandlerProvider { final File libDirectory = properties.getWarLibDirectory(); final File workDirectory = properties.getWebWorkingDirectory(); - final HandlerCollection handlers = new HandlerCollection(); + final Handler.Collection handlers = new ContextHandlerCollection(); // Add Header Writer Handler before others handlers.addHandler(new HeaderWriterHandler()); @@ -158,12 +158,8 @@ public class StandardHandlerProvider implements HandlerProvider { final File tempDirectory = getTempDirectory(workDirectory, applicationFile.getName()); webAppContext.setTempDirectory(tempDirectory); - try { - final WebAppClassLoader webAppClassLoader = new WebAppClassLoader(parentClassLoader, webAppContext); - webAppContext.setClassLoader(webAppClassLoader); - } catch (final IOException e) { - throw new IllegalStateException(String.format("Application Context Path [%s] ClassLoader creation failed", contextPath), e); - } + final WebAppClassLoader webAppClassLoader = new WebAppClassLoader(parentClassLoader, webAppContext); + webAppContext.setClassLoader(webAppClassLoader); return webAppContext; } diff --git a/nifi-registry/nifi-registry-core/nifi-registry-jetty/src/main/resources/org/apache/nifi-registry/web/webdefault.xml b/nifi-registry/nifi-registry-core/nifi-registry-jetty/src/main/resources/org/apache/nifi-registry/web/webdefault.xml index eddd34ed7c..b6445ba826 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-jetty/src/main/resources/org/apache/nifi-registry/web/webdefault.xml +++ b/nifi-registry/nifi-registry-core/nifi-registry-jetty/src/main/resources/org/apache/nifi-registry/web/webdefault.xml @@ -42,34 +42,6 @@ Default web.xml file. This file is applied to a Web application before it's own WEB_INF/web.xml file - - - - - - - org.eclipse.jetty.servlet.listener.IntrospectorCleaner - - - - - - - @@ -139,7 +111,7 @@ default - org.eclipse.jetty.servlet.DefaultServlet + org.eclipse.jetty.ee10.servlet.DefaultServlet aliases false @@ -184,18 +156,6 @@ useFileMappedBuffer true - - 0 diff --git a/nifi-registry/nifi-registry-core/nifi-registry-jetty/src/test/java/org/apache/nifi/registry/jetty/handler/HeaderWriterHandlerTest.java b/nifi-registry/nifi-registry-core/nifi-registry-jetty/src/test/java/org/apache/nifi/registry/jetty/handler/HeaderWriterHandlerTest.java deleted file mode 100644 index 08420fa7d9..0000000000 --- a/nifi-registry/nifi-registry-core/nifi-registry-jetty/src/test/java/org/apache/nifi/registry/jetty/handler/HeaderWriterHandlerTest.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.registry.jetty.handler; - -import org.eclipse.jetty.server.Request; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; - -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -@ExtendWith(MockitoExtension.class) -class HeaderWriterHandlerTest { - private static final String TARGET = HeaderWriterHandler.class.getSimpleName(); - - @Mock - private Request request; - - @Mock - private HttpServletRequest httpServletRequest; - - @Mock - private HttpServletResponse httpServletResponse; - - private HeaderWriterHandler handler; - - @BeforeEach - void setHandler() { - handler = new HeaderWriterHandler(); - } - - @Test - void testDoHandle() { - handler.doHandle(TARGET, request, httpServletRequest, httpServletResponse); - - verifyStandardHeaders(); - } - - @Test - void testDoHandleSecure() { - when(httpServletRequest.isSecure()).thenReturn(true); - - handler.doHandle(TARGET, request, httpServletRequest, httpServletResponse); - - verifyStandardHeaders(); - verify(httpServletResponse).setHeader(eq(HeaderWriterHandler.STRICT_TRANSPORT_SECURITY_HEADER), any()); - } - - private void verifyStandardHeaders() { - verify(httpServletResponse).setHeader(eq(HeaderWriterHandler.CONTENT_SECURITY_POLICY_HEADER), any()); - verify(httpServletResponse).setHeader(eq(HeaderWriterHandler.FRAME_OPTIONS_HEADER), any()); - verify(httpServletResponse).setHeader(eq(HeaderWriterHandler.XSS_PROTECTION_HEADER), any()); - } -} diff --git a/nifi-registry/nifi-registry-core/nifi-registry-test/src/main/java/org/apache/nifi/registry/db/MariaDB10DataSourceFactory.java b/nifi-registry/nifi-registry-core/nifi-registry-test/src/main/java/org/apache/nifi/registry/db/MariaDB10DataSourceFactory.java deleted file mode 100644 index 140af67843..0000000000 --- a/nifi-registry/nifi-registry-core/nifi-registry-test/src/main/java/org/apache/nifi/registry/db/MariaDB10DataSourceFactory.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.registry.db; - -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; -import org.testcontainers.containers.MariaDBContainer; - -@Configuration -@Profile("mariadb-10") -public class MariaDB10DataSourceFactory extends MariaDBDataSourceFactory { - - private static final MariaDBContainer MARIA_DB_CONTAINER = new MariaDBCustomContainer("mariadb:10.0"); - - static { - MARIA_DB_CONTAINER.start(); - } - - @Override - protected MariaDBContainer mariaDBContainer() { - return MARIA_DB_CONTAINER; - } -} diff --git a/nifi-registry/nifi-registry-core/nifi-registry-test/src/main/java/org/apache/nifi/registry/db/MariaDB10_2DataSourceFactory.java b/nifi-registry/nifi-registry-core/nifi-registry-test/src/main/java/org/apache/nifi/registry/db/MariaDB10_2DataSourceFactory.java deleted file mode 100644 index 34a5bc2690..0000000000 --- a/nifi-registry/nifi-registry-core/nifi-registry-test/src/main/java/org/apache/nifi/registry/db/MariaDB10_2DataSourceFactory.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.registry.db; - -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; -import org.testcontainers.containers.MariaDBContainer; - -@Configuration -@Profile("mariadb-10-2") -public class MariaDB10_2DataSourceFactory extends MariaDBDataSourceFactory { - - private static final MariaDBContainer MARIA_DB_CONTAINER = new MariaDBCustomContainer("mariadb:10.2"); - - static { - MARIA_DB_CONTAINER.start(); - } - - @Override - protected MariaDBContainer mariaDBContainer() { - return MARIA_DB_CONTAINER; - } -} diff --git a/nifi-registry/nifi-registry-core/nifi-registry-web-api/pom.xml b/nifi-registry/nifi-registry-core/nifi-registry-web-api/pom.xml index 8edfd3392c..5fd8df6b68 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-web-api/pom.xml +++ b/nifi-registry/nifi-registry-core/nifi-registry-web-api/pom.xml @@ -400,16 +400,6 @@ spring-boot-starter-jetty ${spring.boot.version} test - - - org.eclipse.jetty.websocket - websocket-server - - - org.eclipse.jetty.websocket - javax-websocket-server-impl - - com.unboundid diff --git a/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/NiFiRegistryPropertiesFactory.java b/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/NiFiRegistryPropertiesFactory.java index 514048c4ec..cc16d401f0 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/NiFiRegistryPropertiesFactory.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/NiFiRegistryPropertiesFactory.java @@ -19,6 +19,7 @@ package org.apache.nifi.registry; import org.apache.nifi.registry.properties.NiFiRegistryProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; import org.springframework.web.context.ServletContextAware; import jakarta.servlet.ServletContext; @@ -28,6 +29,7 @@ import jakarta.servlet.ServletContext; * obtains that instance and makes it available to inject to all other places. * */ +@Profile("default") @Configuration public class NiFiRegistryPropertiesFactory implements ServletContextAware { diff --git a/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/security/authorization/ResourceAuthorizationFilter.java b/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/security/authorization/ResourceAuthorizationFilter.java index ce68fe3632..2bdf358d6f 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/security/authorization/ResourceAuthorizationFilter.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/security/authorization/ResourceAuthorizationFilter.java @@ -98,7 +98,7 @@ public class ResourceAuthorizationFilter extends GenericFilterBean { final HttpMethodAuthorizationRules authorizationRules = resourceTypeAuthorizationRules.get(resourceType); if (authorizationRules != null) { final String httpMethodStr = httpServletRequest.getMethod().toUpperCase(); - HttpMethod httpMethod = HttpMethod.resolve(httpMethodStr); + HttpMethod httpMethod = HttpMethod.valueOf(httpMethodStr); // Only require authorization for HTTP methods included in this resource type's rule set if (httpMethod != null && authorizationRules.requiresAuthorization(httpMethod)) { diff --git a/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/NiFiRegistryTestApiApplication.java b/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/NiFiRegistryTestApiApplication.java index ac56d1bf7d..ff65bb2348 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/NiFiRegistryTestApiApplication.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/NiFiRegistryTestApiApplication.java @@ -16,7 +16,6 @@ */ package org.apache.nifi.registry; -import org.apache.nifi.registry.db.DataSourceFactory; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.context.annotation.ComponentScan; @@ -30,12 +29,6 @@ import java.util.TimeZone; @ComponentScan.Filter( type = FilterType.ASSIGNABLE_TYPE, value = SpringBootServletInitializer.class), // Avoid loading NiFiRegistryApiApplication - @ComponentScan.Filter( - type = FilterType.ASSIGNABLE_TYPE, - value = DataSourceFactory.class), // Avoid loading DataSourceFactory - @ComponentScan.Filter( - type = FilterType.REGEX, - pattern = "org\\.apache\\.nifi\\.registry\\.NiFiRegistryPropertiesFactory"), // Avoid loading NiFiRegistryPropertiesFactory }) public class NiFiRegistryTestApiApplication extends SpringBootServletInitializer { diff --git a/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/SecureLdapTestApiApplication.java b/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/SecureLdapTestApiApplication.java index 74d0730ff4..4f75592b69 100644 --- a/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/SecureLdapTestApiApplication.java +++ b/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/SecureLdapTestApiApplication.java @@ -16,7 +16,6 @@ */ package org.apache.nifi.registry; -import org.apache.nifi.registry.db.DataSourceFactory; import org.apache.nifi.registry.security.authorization.AuthorizerFactory; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; @@ -30,15 +29,9 @@ import org.springframework.context.annotation.FilterType; @ComponentScan.Filter( type = FilterType.ASSIGNABLE_TYPE, value = SpringBootServletInitializer.class), // Avoid loading NiFiRegistryApiApplication - @ComponentScan.Filter( - type = FilterType.ASSIGNABLE_TYPE, - value = DataSourceFactory.class), // Avoid loading DataSourceFactory @ComponentScan.Filter( type = FilterType.ASSIGNABLE_TYPE, value = AuthorizerFactory.class), // Avoid loading AuthorizerFactory.getAuthorizer(), as we need to add it again with test-specific @DependsOn annotation - @ComponentScan.Filter( - type = FilterType.REGEX, - pattern = "org\\.apache\\.nifi\\.registry\\.NiFiRegistryPropertiesFactory"), // Avoid loading NiFiRegistryPropertiesFactory }) public class SecureLdapTestApiApplication extends SpringBootServletInitializer { diff --git a/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/TestRestAPI.java b/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/TestRestAPI.java deleted file mode 100644 index 97455b3178..0000000000 --- a/nifi-registry/nifi-registry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/TestRestAPI.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.nifi.registry.web; - -import org.apache.nifi.registry.bucket.Bucket; -import org.apache.nifi.registry.flow.VersionedFlow; -import org.apache.nifi.registry.flow.VersionedFlowSnapshot; -import org.apache.nifi.registry.flow.VersionedFlowSnapshotMetadata; -import org.apache.nifi.flow.VersionedProcessGroup; -import org.apache.nifi.registry.revision.entity.RevisionInfo; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import jakarta.ws.rs.WebApplicationException; -import jakarta.ws.rs.client.Client; -import jakarta.ws.rs.client.ClientBuilder; -import jakarta.ws.rs.client.Entity; -import jakarta.ws.rs.core.MediaType; -import jakarta.ws.rs.core.Response; -import java.util.ArrayList; -import java.util.List; - -public class TestRestAPI { - - public static final Logger LOGGER = LoggerFactory.getLogger(TestRestAPI.class); - - public static final String REGISTRY_API_URL = "http://localhost:18080/nifi-registry-api"; - public static final String REGISTRY_API_BUCKETS_URL = REGISTRY_API_URL + "/buckets"; - public static final String REGISTRY_API_FLOWS_URL = REGISTRY_API_URL + "/flows"; - - public static void main(String[] args) { - try { - final Client client = ClientBuilder.newClient(); - - // create some buckets - final int numBuckets = 20; - final List createdBuckets = new ArrayList<>(); - - for (int i=0; i < numBuckets; i++) { - final Bucket createdBucket = createBucket(client, i); - System.out.println("Created bucket # " + i + " with id " + createdBucket.getIdentifier()); - createdBuckets.add(createdBucket); - } - - // create some flows - final int numFlowsPerBucket = 10; - final List allFlows = new ArrayList<>(); - - for (final Bucket bucket : createdBuckets) { - final List createdFlows = createFlows(client, bucket, numFlowsPerBucket); - allFlows.addAll(createdFlows); - } - - // create some snapshots - final int numSnapshotsPerFlow = 10; - for (final VersionedFlow flow : allFlows) { - createSnapshots(client, flow, numSnapshotsPerFlow); - } - - // Retrieve the flow by id -// final Response flowResponse = client.target(REGISTRY_API_FLOWS_URL) -// .path("/{flowId}") -// .resolveTemplate("flowId", createdFlow.getIdentifier()) -// .request() -// .get(); -// -// final String flowJson = flowResponse.readEntity(String.class); -// System.out.println("Flow: " + flowJson); - - } catch (WebApplicationException e) { - LOGGER.error(e.getMessage(), e); - - final Response response = e.getResponse(); - LOGGER.error(response.readEntity(String.class)); - } - } - - private static Bucket createBucket(Client client, int num) { - final Bucket bucket = new Bucket(); - bucket.setName("Bucket #" + num); - bucket.setDescription("This is bucket #" + num); - bucket.setRevision(new RevisionInfo("clientId", 0L)); - - final Bucket createdBucket = client.target(REGISTRY_API_BUCKETS_URL) - .request() - .post( - Entity.entity(bucket, MediaType.APPLICATION_JSON), - Bucket.class - ); - - return createdBucket; - } - - private static VersionedFlow createFlow(Client client, Bucket bucket, int num) { - final VersionedFlow versionedFlow = new VersionedFlow(); - versionedFlow.setName(bucket.getName() + " Flow #" + num); - versionedFlow.setDescription("This is " + bucket.getName() + " flow #" + num); - versionedFlow.setRevision(new RevisionInfo("clientId", 0L)); - - final VersionedFlow createdFlow = client.target(REGISTRY_API_BUCKETS_URL) - .path("/{bucketId}/flows") - .resolveTemplate("bucketId", bucket.getIdentifier()) - .request() - .post( - Entity.entity(versionedFlow, MediaType.APPLICATION_JSON), - VersionedFlow.class - ); - - return createdFlow; - } - - private static List createFlows(Client client, Bucket bucket, int numFlows) { - final List createdFlows = new ArrayList<>(); - - for (int i=0; i < numFlows; i++) { - final VersionedFlow createdFlow = createFlow(client, bucket, i); - System.out.println("Created flow # " + i + " with id " + createdFlow.getIdentifier()); - createdFlows.add(createdFlow); - } - - return createdFlows; - } - - private static VersionedFlowSnapshot createSnapshot(Client client, VersionedFlow flow, int num) { - final VersionedFlowSnapshotMetadata snapshotMetadata1 = new VersionedFlowSnapshotMetadata(); - snapshotMetadata1.setBucketIdentifier(flow.getBucketIdentifier()); - snapshotMetadata1.setFlowIdentifier(flow.getIdentifier()); - snapshotMetadata1.setVersion(num); - snapshotMetadata1.setComments("This is snapshot #" + num); - - final VersionedProcessGroup snapshotContents1 = new VersionedProcessGroup(); - snapshotContents1.setIdentifier("pg1"); - snapshotContents1.setName("Process Group 1"); - - final VersionedFlowSnapshot snapshot1 = new VersionedFlowSnapshot(); - snapshot1.setSnapshotMetadata(snapshotMetadata1); - snapshot1.setFlowContents(snapshotContents1); - - final VersionedFlowSnapshot createdSnapshot = client.target(REGISTRY_API_BUCKETS_URL) - .path("{bucketId}/flows/{flowId}/versions") - .resolveTemplate("bucketId", flow.getBucketIdentifier()) - .resolveTemplate("flowId", flow.getIdentifier()) - .request() - .post( - Entity.entity(snapshot1, MediaType.APPLICATION_JSON_TYPE), - VersionedFlowSnapshot.class - ); - - return createdSnapshot; - } - - private static void createSnapshots(Client client, VersionedFlow flow, int numSnapshots) { - for (int i=1; i <= numSnapshots; i++) { - createSnapshot(client, flow, i); - System.out.println("Created snapshot # " + i + " for flow with id " + flow.getIdentifier()); - } - } - -} diff --git a/nifi-registry/nifi-registry-core/pom.xml b/nifi-registry/nifi-registry-core/pom.xml index 9801f393a1..f6d4af1a8b 100644 --- a/nifi-registry/nifi-registry-core/pom.xml +++ b/nifi-registry/nifi-registry-core/pom.xml @@ -57,28 +57,33 @@ ${jetty.version} - org.eclipse.jetty - jetty-servlet + org.eclipse.jetty.http2 + jetty-http2-server ${jetty.version} - org.eclipse.jetty - jetty-webapp + org.eclipse.jetty.ee10 + jetty-ee10-servlet ${jetty.version} - org.eclipse.jetty - jetty-servlets + org.eclipse.jetty.ee10 + jetty-ee10-webapp ${jetty.version} - org.eclipse.jetty - jetty-annotations + org.eclipse.jetty.ee10 + jetty-ee10-servlets ${jetty.version} - org.eclipse.jetty - apache-jsp + org.eclipse.jetty.ee10 + jetty-ee10-annotations + ${jetty.version} + + + org.eclipse.jetty.ee10 + jetty-ee10-apache-jsp ${jetty.version} @@ -137,19 +142,6 @@ - - mariadb-10_2-test - verify - - integration-test - verify - - - - mariadb-10-2 - - - mariadb-10_3-test verify diff --git a/nifi-registry/nifi-registry-extensions/nifi-registry-ranger/nifi-registry-ranger-plugin/pom.xml b/nifi-registry/nifi-registry-extensions/nifi-registry-ranger/nifi-registry-ranger-plugin/pom.xml index 01db3d30d2..a7e802c836 100644 --- a/nifi-registry/nifi-registry-extensions/nifi-registry-ranger/nifi-registry-ranger-plugin/pom.xml +++ b/nifi-registry/nifi-registry-extensions/nifi-registry-ranger/nifi-registry-ranger-plugin/pom.xml @@ -247,6 +247,23 @@ ch.qos.logback logback-classic + + + org.eclipse.jetty + jetty-server + + + org.eclipse.jetty + jetty-servlet + + + org.eclipse.jetty + jetty-webapp + + + org.eclipse.jetty + jetty-util + diff --git a/nifi-registry/nifi-registry-extensions/nifi-registry-ranger/pom.xml b/nifi-registry/nifi-registry-extensions/nifi-registry-ranger/pom.xml index 8f5b872243..9073a99c45 100644 --- a/nifi-registry/nifi-registry-extensions/nifi-registry-ranger/pom.xml +++ b/nifi-registry/nifi-registry-extensions/nifi-registry-ranger/pom.xml @@ -32,22 +32,6 @@ - - - org.eclipse.jetty - jetty-server - ${jetty.version} - - - org.eclipse.jetty - jetty-servlet - ${jetty.version} - - - org.eclipse.jetty - jetty-webapp - ${jetty.version} - org.apache.solr diff --git a/nifi-registry/pom.xml b/nifi-registry/pom.xml index 44ed0ea09f..1f1d44779a 100644 --- a/nifi-registry/pom.xml +++ b/nifi-registry/pom.xml @@ -37,11 +37,11 @@ 3.1.0 3.1.3 - 3.1.5 - 6.0.13 - 6.1.5 - 5.0.0 - 11.0.18 + 3.2.0 + 6.1.1 + 6.2.0 + 6.0.0 + 12.0.3 9.22.3 9.5.0 3.12.0 @@ -68,37 +68,6 @@ jetty-server compile - - org.eclipse.jetty - jetty-servlet - compile - - - org.eclipse.jetty - jetty-webapp - compile - - - org.eclipse.jetty - jetty-servlets - compile - - - org.eclipse.jetty - jetty-annotations - compile - - - org.eclipse.jetty - apache-jsp - compile - - - org.eclipse.jetty.http2 - http2-server - ${jetty.version} - compile - org.eclipse.jetty jetty-alpn-server