21
21
import java .io .Closeable ;
22
22
import java .io .IOException ;
23
23
import java .net .SocketAddress ;
24
- import java .util .concurrent .CompletableFuture ;
25
24
import javax .naming .AuthenticationException ;
26
25
import javax .net .ssl .SSLSession ;
27
26
import javax .servlet .http .HttpServletRequest ;
28
27
import javax .servlet .http .HttpServletResponse ;
29
28
import org .apache .pulsar .broker .ServiceConfiguration ;
30
29
import org .apache .pulsar .common .api .AuthData ;
31
- import org .apache .pulsar .common .classification .InterfaceStability ;
32
- import org .apache .pulsar .common .util .FutureUtil ;
33
30
34
31
/**
35
32
* Provider of authentication mechanism.
@@ -51,29 +48,6 @@ public interface AuthenticationProvider extends Closeable {
51
48
*/
52
49
String getAuthMethodName ();
53
50
54
- /**
55
- * Validate the authentication for the given credentials with the specified authentication data.
56
- * This method is useful in one stage authentication, if you're not doing one stage or if you're providing
57
- * your own state implementation for one stage authentication, it should return a failed future.
58
- *
59
- * <p>Warning: the calling thread is an IO thread. Any implementation that relies on blocking behavior
60
- * must ensure that the execution is completed using a separate thread pool to ensure IO threads
61
- * are never blocked.</p>
62
- *
63
- * @param authData authentication data generated while initiating a connection. There are several types,
64
- * including, but not strictly limited to, {@link AuthenticationDataHttp},
65
- * {@link AuthenticationDataHttps}, and {@link AuthenticationDataCommand}.
66
- * @return A completed future with the "role" string for the authenticated connection, if authentication is
67
- * successful, or a failed future if the authData is not valid.
68
- */
69
- default CompletableFuture <String > authenticateAsync (AuthenticationDataSource authData ) {
70
- try {
71
- return CompletableFuture .completedFuture (this .authenticate (authData ));
72
- } catch (AuthenticationException e ) {
73
- return FutureUtil .failedFuture (e );
74
- }
75
- }
76
-
77
51
/**
78
52
* Validate the authentication for the given credentials with the specified authentication data.
79
53
* This method is useful in one stage authn, if you're not doing one stage or if you're providing
@@ -84,9 +58,7 @@ default CompletableFuture<String> authenticateAsync(AuthenticationDataSource aut
84
58
* @return the "role" string for the authenticated connection, if the authentication was successful
85
59
* @throws AuthenticationException
86
60
* if the credentials are not valid
87
- * @deprecated use and implement {@link AuthenticationProvider#authenticateAsync(AuthenticationDataSource)} instead.
88
61
*/
89
- @ Deprecated
90
62
default String authenticate (AuthenticationDataSource authData ) throws AuthenticationException {
91
63
throw new AuthenticationException ("Not supported" );
92
64
}
@@ -101,38 +73,10 @@ default AuthenticationState newAuthState(AuthData authData,
101
73
return new OneStageAuthenticationState (authData , remoteAddress , sslSession , this );
102
74
}
103
75
104
- /**
105
- * Validate the authentication for the given credentials with the specified authentication data.
106
- *
107
- * <p>Warning: the calling thread is an IO thread. Any implementations that rely on blocking behavior
108
- * must ensure that the execution is completed on using a separate thread pool to ensure IO threads
109
- * are never blocked.</p>
110
- *
111
- * <p>Note: this method is marked as unstable because the Pulsar code base only calls it for the
112
- * Pulsar Broker Auth SASL plugin. All non SASL HTTP requests are authenticated using the
113
- * {@link AuthenticationProvider#authenticateAsync(AuthenticationDataSource)} method. As such,
114
- * this method might be removed in favor of the SASL provider implementing the
115
- * {@link AuthenticationProvider#authenticateAsync(AuthenticationDataSource)} method.</p>
116
- *
117
- * @return Set response, according to passed in request.
118
- * and return whether we should do following chain.doFilter or not.
119
- */
120
- @ InterfaceStability .Unstable
121
- default CompletableFuture <Boolean > authenticateHttpRequestAsync (HttpServletRequest request ,
122
- HttpServletResponse response ) {
123
- try {
124
- return CompletableFuture .completedFuture (this .authenticateHttpRequest (request , response ));
125
- } catch (Exception e ) {
126
- return FutureUtil .failedFuture (e );
127
- }
128
- }
129
-
130
76
/**
131
77
* Set response, according to passed in request.
132
78
* and return whether we should do following chain.doFilter or not.
133
- * @deprecated use and implement {@link AuthenticationProvider#authenticateHttpRequestAsync} instead.
134
79
*/
135
- @ Deprecated
136
80
default boolean authenticateHttpRequest (HttpServletRequest request , HttpServletResponse response ) throws Exception {
137
81
throw new AuthenticationException ("Not supported" );
138
82
}
0 commit comments