Skip to content

Commit b45e719

Browse files
retatandonks
authored andcommitted
Introduce SecureHttpTransportParameters experimental API (to complement SecureTransportParameters counterpart) (opensearch-project#18572)
Signed-off-by: Andriy Redko <[email protected]>
1 parent 25c068e commit b45e719

File tree

4 files changed

+134
-0
lines changed

4 files changed

+134
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
77
### Added
88
- Add support for Warm Indices Write Block on Flood Watermark breach ([#18375](https://github.com/opensearch-project/OpenSearch/pull/18375))
99
- Ability to run Code Coverage with Gradle and produce the jacoco reports locally ([#18509](https://github.com/opensearch-project/OpenSearch/issues/18509))
10+
- Introduce SecureHttpTransportParameters experimental API (to complement SecureTransportParameters counterpart) ([#18572](https://github.com/opensearch-project/OpenSearch/issues/18572))
1011

1112
### Changed
1213

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* The OpenSearch Contributors require contributions made to
5+
* this file be licensed under the Apache-2.0 license or a
6+
* compatible open source license.
7+
*/
8+
9+
package org.opensearch.plugins;
10+
11+
import javax.net.ssl.KeyManagerFactory;
12+
import javax.net.ssl.TrustManagerFactory;
13+
14+
import java.util.Collection;
15+
import java.util.List;
16+
import java.util.Optional;
17+
18+
/**
19+
* Default implementation of {@link SecureHttpTransportSettingsProvider.SecureHttpTransportParameters}.
20+
*/
21+
class DefaultSecureHttpTransportParameters implements SecureHttpTransportSettingsProvider.SecureHttpTransportParameters {
22+
@Override
23+
public Optional<KeyManagerFactory> keyManagerFactory() {
24+
return Optional.empty();
25+
}
26+
27+
@Override
28+
public Optional<String> sslProvider() {
29+
return Optional.empty();
30+
}
31+
32+
@Override
33+
public Optional<String> clientAuth() {
34+
return Optional.empty();
35+
}
36+
37+
@Override
38+
public Collection<String> protocols() {
39+
return List.of();
40+
}
41+
42+
@Override
43+
public Collection<String> cipherSuites() {
44+
return List.of();
45+
}
46+
47+
@Override
48+
public Optional<TrustManagerFactory> trustManagerFactory() {
49+
return Optional.empty();
50+
}
51+
}

server/src/main/java/org/opensearch/plugins/SecureHttpTransportSettingsProvider.java

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
import org.opensearch.http.HttpServerTransport;
1414
import org.opensearch.transport.TransportAdapterProvider;
1515

16+
import javax.net.ssl.KeyManagerFactory;
1617
import javax.net.ssl.SSLEngine;
1718
import javax.net.ssl.SSLException;
19+
import javax.net.ssl.TrustManagerFactory;
1820

1921
import java.util.Collection;
2022
import java.util.Collections;
@@ -37,6 +39,48 @@ public interface SecureHttpTransportSettingsProvider {
3739
*/
3840
final String REQUEST_DECOMPRESSOR = "RequestDecompressor";
3941

42+
/**
43+
* Dynamic parameters that can be provided by the {@link SecureHttpTransportParameters}
44+
*/
45+
@ExperimentalApi
46+
interface SecureHttpTransportParameters {
47+
/**
48+
* Provides the instance of {@link KeyManagerFactory}
49+
* @return instance of {@link KeyManagerFactory}
50+
*/
51+
Optional<KeyManagerFactory> keyManagerFactory();
52+
53+
/**
54+
* Provides the SSL provider (JDK, OpenSsl, ...) if supported by transport
55+
* @return SSL provider
56+
*/
57+
Optional<String> sslProvider();
58+
59+
/**
60+
* Provides desired client authentication level
61+
* @return client authentication level
62+
*/
63+
Optional<String> clientAuth();
64+
65+
/**
66+
* Provides the list of supported protocols
67+
* @return list of supported protocols
68+
*/
69+
Collection<String> protocols();
70+
71+
/**
72+
* Provides the list of supported cipher suites
73+
* @return list of supported cipher suites
74+
*/
75+
Collection<String> cipherSuites();
76+
77+
/**
78+
* Provides the instance of {@link TrustManagerFactory}
79+
* @return instance of {@link TrustManagerFactory}
80+
*/
81+
Optional<TrustManagerFactory> trustManagerFactory();
82+
}
83+
4084
/**
4185
* Collection of additional {@link TransportAdapterProvider}s that are specific to particular HTTP transport
4286
* @param settings settings
@@ -46,6 +90,16 @@ default Collection<TransportAdapterProvider<HttpServerTransport>> getHttpTranspo
4690
return Collections.emptyList();
4791
}
4892

93+
/**
94+
* Returns parameters that can be dynamically provided by a plugin providing a {@link SecureHttpTransportParameters}
95+
* implementation
96+
* @param settings settings
97+
* @return an instance of {@link SecureHttpTransportParameters}
98+
*/
99+
default Optional<SecureHttpTransportParameters> parameters(Settings settings) {
100+
return Optional.of(new DefaultSecureHttpTransportParameters());
101+
}
102+
49103
/**
50104
* If supported, builds the {@link TransportExceptionHandler} instance for {@link HttpServerTransport} instance
51105
* @param settings settings

server/src/main/java/org/opensearch/plugins/SecureTransportSettingsProvider.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,46 @@ default Optional<SecureTransportParameters> parameters(Settings settings) {
5353
*/
5454
@ExperimentalApi
5555
interface SecureTransportParameters {
56+
/**
57+
* Enable / Disable dual model (if supported by transport)
58+
* @return dual model enabled or not
59+
*/
5660
boolean dualModeEnabled();
5761

62+
/**
63+
* Provides the instance of {@link KeyManagerFactory}
64+
* @return instance of {@link KeyManagerFactory}
65+
*/
5866
Optional<KeyManagerFactory> keyManagerFactory();
5967

68+
/**
69+
* Provides the SSL provider (JDK, OpenSsl, ...) if supported by transport
70+
* @return SSL provider
71+
*/
6072
Optional<String> sslProvider();
6173

74+
/**
75+
* Provides desired client authentication level
76+
* @return client authentication level
77+
*/
6278
Optional<String> clientAuth();
6379

80+
/**
81+
* Provides the list of supported protocols
82+
* @return list of supported protocols
83+
*/
6484
Collection<String> protocols();
6585

86+
/**
87+
* Provides the list of supported cipher suites
88+
* @return list of supported cipher suites
89+
*/
6690
Collection<String> cipherSuites();
6791

92+
/**
93+
* Provides the instance of {@link TrustManagerFactory}
94+
* @return instance of {@link TrustManagerFactory}
95+
*/
6896
Optional<TrustManagerFactory> trustManagerFactory();
6997
}
7098

0 commit comments

Comments
 (0)