This is an automated email from the ASF dual-hosted git repository.

pvillard pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/main by this push:
     new 47fecfac7c NIFI-15031 Removed historical fallback Remote PG 
registration requests
47fecfac7c is described below

commit 47fecfac7cc934ef7845bb04aed3ad964aefb1f2
Author: exceptionfactory <[email protected]>
AuthorDate: Wed Oct 1 08:33:47 2025 -0500

    NIFI-15031 Removed historical fallback Remote PG registration requests
    
    - Removed RemoteNiFiUtils class from framework components
    
    Signed-off-by: Pierre Villard <[email protected]>
    
    This closes #10361.
---
 .../org/apache/nifi/remote/RemoteNiFiUtils.java    | 72 ----------------------
 .../nifi/remote/StandardRemoteProcessGroup.java    | 21 +------
 2 files changed, 2 insertions(+), 91 deletions(-)

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 57e00cac48..0000000000
--- 
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<String, String> 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 f7bab5c7b3..1a744115f5 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 class StandardRemoteProcessGroup implements 
RemoteProcessGroup {
                         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();

Reply via email to