|
82 | 82 | * @author Mark Paluch
|
83 | 83 | * @author Ryan Gow
|
84 | 84 | * @author Spencer Gibb
|
| 85 | + * @author Luciano Canales |
85 | 86 | * @since 2.2
|
86 | 87 | */
|
87 | 88 | public class ClientHttpRequestFactoryFactory {
|
@@ -128,7 +129,7 @@ public static ClientHttpRequestFactory create(ClientOptions options, SslConfigur
|
128 | 129 | + "must be applied outside the Vault Client to use the JDK HTTP client");
|
129 | 130 | }
|
130 | 131 |
|
131 |
| - return new SimpleClientHttpRequestFactory(); |
| 132 | + return SimpleClient.usingSimpleClientHttpRequest(options); |
132 | 133 | }
|
133 | 134 |
|
134 | 135 | static SSLContext getSSLContext(SslConfiguration sslConfiguration) throws GeneralSecurityException, IOException {
|
@@ -417,6 +418,32 @@ public static Builder getBuilder(ClientOptions options, SslConfiguration sslConf
|
417 | 418 |
|
418 | 419 | }
|
419 | 420 |
|
| 421 | + /** |
| 422 | + * Utilities to create a {@link ClientHttpRequestFactory} for the |
| 423 | + * {@link SimpleClientHttpRequestFactory}. |
| 424 | + * |
| 425 | + * @author Luciano Canales |
| 426 | + */ |
| 427 | + public static class SimpleClient { |
| 428 | + |
| 429 | + /** |
| 430 | + * Create a {@link ClientHttpRequestFactory} using |
| 431 | + * {@link SimpleClientHttpRequestFactory}. |
| 432 | + * @param options must not be {@literal null} |
| 433 | + * @return a new and configured {@link SimpleClientHttpRequestFactory} instance. |
| 434 | + */ |
| 435 | + public static SimpleClientHttpRequestFactory usingSimpleClientHttpRequest(ClientOptions options) { |
| 436 | + |
| 437 | + SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory(); |
| 438 | + |
| 439 | + factory.setConnectTimeout((int) options.getConnectionTimeout().toMillis()); |
| 440 | + factory.setReadTimeout((int) options.getReadTimeout().toMillis()); |
| 441 | + |
| 442 | + return factory; |
| 443 | + } |
| 444 | + |
| 445 | + } |
| 446 | + |
420 | 447 | static class KeySelectingKeyManagerFactory extends KeyManagerFactory {
|
421 | 448 |
|
422 | 449 | KeySelectingKeyManagerFactory(KeyManagerFactory factory, KeyConfiguration keyConfiguration) {
|
|
0 commit comments