From f39b2a88397cd86b4ab0d7c01af99b20afc461c9 Mon Sep 17 00:00:00 2001 From: exceptionfactory Date: Wed, 1 Oct 2025 08:33:47 -0500 Subject: [PATCH] NIFI-15031 Removed historical fallback Remote PG registration requests - Removed RemoteNiFiUtils class from framework components --- .../apache/nifi/remote/RemoteNiFiUtils.java | 72 ------------------- .../remote/StandardRemoteProcessGroup.java | 21 +----- 2 files changed, 2 insertions(+), 91 deletions(-) delete mode 100644 nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/remote/RemoteNiFiUtils.java diff --git a/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/remote/RemoteNiFiUtils.java b/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/remote/RemoteNiFiUtils.java deleted file mode 100644 index 57e00cac48bd..000000000000 --- a/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/remote/RemoteNiFiUtils.java +++ /dev/null @@ -1,72 +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.remote; - -import org.apache.nifi.web.util.WebClientUtils; -import org.glassfish.jersey.client.ClientConfig; -import org.glassfish.jersey.client.ClientProperties; - -import javax.net.ssl.SSLContext; -import jakarta.ws.rs.client.Client; -import jakarta.ws.rs.client.Entity; -import jakarta.ws.rs.core.MultivaluedHashMap; -import jakarta.ws.rs.core.Response; -import java.net.URI; - -public class RemoteNiFiUtils { - - private static final int CONNECT_TIMEOUT = 10000; - private static final int READ_TIMEOUT = 10000; - - private final Client client; - - public RemoteNiFiUtils(final SSLContext sslContext) { - this.client = getClient(sslContext); - } - - private Client getClient(final SSLContext sslContext) { - final ClientConfig clientConfig = new ClientConfig(); - clientConfig.property(ClientProperties.READ_TIMEOUT, READ_TIMEOUT); - clientConfig.property(ClientProperties.CONNECT_TIMEOUT, CONNECT_TIMEOUT); - - final Client client; - if (sslContext == null) { - client = WebClientUtils.createClient(clientConfig); - } else { - client = WebClientUtils.createClient(clientConfig, sslContext); - } - - return client; - } - - /** - * Issues a registration request for this NiFi instance for the instance at the baseApiUri. - * - * @param baseApiUri uri to register with - * @return response - */ - public Response issueRegistrationRequest(String baseApiUri) { - final URI uri = URI.create(String.format("%s/controller/users", baseApiUri)); - - // set up the query params - MultivaluedHashMap entity = new MultivaluedHashMap<>(); - entity.add("justification", "A Remote instance of NiFi has attempted to create a reference to this NiFi. This action must be approved first."); - - // get the resource - return client.target(uri).request().post(Entity.form(entity)); - } -} diff --git a/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/remote/StandardRemoteProcessGroup.java b/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/remote/StandardRemoteProcessGroup.java index f7bab5c7b336..1a744115f5d9 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/remote/StandardRemoteProcessGroup.java +++ b/nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/remote/StandardRemoteProcessGroup.java @@ -1274,25 +1274,8 @@ public void run() { writeLock.unlock(); } } catch (SiteToSiteRestApiClient.HttpGetFailedException e) { - - if (e.getResponseCode() == UNAUTHORIZED_STATUS_CODE) { - try { - // attempt to issue a registration request in case the target instance is a 0.x - final boolean isApiSecure = apiClient.getBaseUrl().toLowerCase().startsWith("https"); - final RemoteNiFiUtils utils = new RemoteNiFiUtils(isApiSecure ? sslContext : null); - final Response requestAccountResponse = utils.issueRegistrationRequest(apiClient.getBaseUrl()); - if (Response.Status.Family.SUCCESSFUL.equals(requestAccountResponse.getStatusInfo().getFamily())) { - logger.info("{} Issued a Request to communicate with remote instance", this); - } else { - logger.error("{} Failed to request account: got unexpected response code of {}:{}", this, - requestAccountResponse.getStatus(), requestAccountResponse.getStatusInfo().getReasonPhrase()); - } - } catch (final Exception re) { - logger.error("{} Failed to request account", this, re); - } - - authorizationIssue = e.getDescription(); - } else if (e.getResponseCode() == FORBIDDEN_STATUS_CODE) { + final int responseCode = e.getResponseCode(); + if (responseCode == UNAUTHORIZED_STATUS_CODE || responseCode == FORBIDDEN_STATUS_CODE) { authorizationIssue = e.getDescription(); } else { final String message = e.getDescription();