From 5408fef02b8332609059beea2bd7f71c58d132d7 Mon Sep 17 00:00:00 2001
From: David Li
Date: Mon, 25 Sep 2023 08:45:08 -0400
Subject: [PATCH] GH-37722: [Java][FlightRPC] Deprecate stateful login methods
(#37833)
### Rationale for this change
The existence of these interfaces confuses users and leads them to antipatterns.
### What changes are included in this PR?
Deprecate (but not for removal) the old interfaces.
### Are these changes tested?
N/A
### Are there any user-facing changes?
Yes.
* Closes: #37722
Authored-by: David Li
Signed-off-by: David Li
---
.../org/apache/arrow/flight/auth/ClientAuthHandler.java | 7 +++++++
.../org/apache/arrow/flight/auth/ServerAuthHandler.java | 9 +++++++++
2 files changed, 16 insertions(+)
diff --git a/java/flight/flight-core/src/main/java/org/apache/arrow/flight/auth/ClientAuthHandler.java b/java/flight/flight-core/src/main/java/org/apache/arrow/flight/auth/ClientAuthHandler.java
index 985e10aa4dd4b..af7da86e009e6 100644
--- a/java/flight/flight-core/src/main/java/org/apache/arrow/flight/auth/ClientAuthHandler.java
+++ b/java/flight/flight-core/src/main/java/org/apache/arrow/flight/auth/ClientAuthHandler.java
@@ -19,9 +19,16 @@
import java.util.Iterator;
+import org.apache.arrow.flight.FlightClient;
+
/**
* Implement authentication for Flight on the client side.
+ *
+ * @deprecated As of 14.0.0. This implements a stateful "login" flow that does not play well with
+ * distributed or stateless systems. It will not be removed, but should not be used. Instead
+ * see {@link FlightClient#authenticateBasicToken(String, String)}.
*/
+@Deprecated
public interface ClientAuthHandler {
/**
* Handle the initial handshake with the server.
diff --git a/java/flight/flight-core/src/main/java/org/apache/arrow/flight/auth/ServerAuthHandler.java b/java/flight/flight-core/src/main/java/org/apache/arrow/flight/auth/ServerAuthHandler.java
index 3a978b131f26c..378027c9287fe 100644
--- a/java/flight/flight-core/src/main/java/org/apache/arrow/flight/auth/ServerAuthHandler.java
+++ b/java/flight/flight-core/src/main/java/org/apache/arrow/flight/auth/ServerAuthHandler.java
@@ -20,9 +20,18 @@
import java.util.Iterator;
import java.util.Optional;
+import org.apache.arrow.flight.FlightServer;
+import org.apache.arrow.flight.auth2.CallHeaderAuthenticator;
+
/**
* Interface for Server side authentication handlers.
+ *
+ * @deprecated As of 14.0.0. This implements a stateful "login" flow that does not play well with
+ * distributed or stateless systems. It will not be removed, but should not be used. Instead,
+ * see {@link FlightServer.Builder#headerAuthenticator(CallHeaderAuthenticator)}
+ * and {@link CallHeaderAuthenticator}.
*/
+@Deprecated
public interface ServerAuthHandler {
/**