gulecroc commented on code in PR #24944:
URL: https://github.com/apache/pulsar/pull/24944#discussion_r2512122032
##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/auth/oauth2/FlowBase.java:
##########
@@ -18,31 +18,80 @@
*/
package org.apache.pulsar.client.impl.auth.oauth2;
+import io.netty.handler.ssl.SslContextBuilder;
+import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Map;
+import javax.net.ssl.SSLException;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
+import org.apache.pulsar.PulsarVersion;
import org.apache.pulsar.client.api.PulsarClientException;
import
org.apache.pulsar.client.impl.auth.oauth2.protocol.DefaultMetadataResolver;
import org.apache.pulsar.client.impl.auth.oauth2.protocol.Metadata;
import org.apache.pulsar.client.impl.auth.oauth2.protocol.MetadataResolver;
+import org.asynchttpclient.AsyncHttpClient;
+import org.asynchttpclient.DefaultAsyncHttpClient;
+import org.asynchttpclient.DefaultAsyncHttpClientConfig;
/**
* An abstract OAuth 2.0 authorization flow.
*/
@Slf4j
abstract class FlowBase implements Flow {
+ public static final String CONFIG_PARAM_CONNECT_TIMEOUT = "connectTimeout";
+ public static final String CONFIG_PARAM_READ_TIMEOUT = "readTimeout";
+ public static final String CONFIG_PARAM_TRUST_CERTS_FILE_PATH =
"trustCertsFilePath";
+
+ protected static final int DEFAULT_CONNECT_TIMEOUT_IN_SECONDS = 10;
+ protected static final int DEFAULT_READ_TIMEOUT_IN_SECONDS = 30;
+
private static final long serialVersionUID = 1L;
protected final URL issuerUrl;
+ protected final AsyncHttpClient httpClient;
protected transient Metadata metadata;
- protected FlowBase(URL issuerUrl) {
+ protected FlowBase(URL issuerUrl, Integer connectTimeout, Integer
readTimeout, String trustCertsFilePath) {
this.issuerUrl = issuerUrl;
+ this.httpClient = defaultHttpClient(readTimeout, connectTimeout,
trustCertsFilePath);
+ }
+
+ private AsyncHttpClient defaultHttpClient(Integer readTimeout, Integer
connectTimeout, String trustCertsFilePath) {
+ DefaultAsyncHttpClientConfig.Builder confBuilder = new
DefaultAsyncHttpClientConfig.Builder();
+ confBuilder.setCookieStore(null);
+ confBuilder.setUseProxyProperties(true);
+ confBuilder.setFollowRedirect(true);
+ confBuilder.setConnectTimeout(
Review Comment:
java doc added and timeouts moved to Duration
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]