12
12
import org .elasticsearch .action .support .DestructiveOperations ;
13
13
import org .elasticsearch .cluster .service .ClusterService ;
14
14
import org .elasticsearch .common .CheckedConsumer ;
15
- import org .elasticsearch .common .settings .Setting ;
16
15
import org .elasticsearch .common .settings .Settings ;
17
16
import org .elasticsearch .common .util .concurrent .AbstractRunnable ;
18
17
import org .elasticsearch .common .util .concurrent .ThreadContext ;
45
44
import java .util .HashMap ;
46
45
import java .util .Map ;
47
46
import java .util .concurrent .Executor ;
48
- import java .util .function .Function ;
49
47
50
48
import static org .elasticsearch .xpack .core .security .SecurityField .setting ;
51
49
52
50
public class SecurityServerTransportInterceptor implements TransportInterceptor {
53
51
54
- private static final Function <String , Setting <String >> TRANSPORT_TYPE_SETTING_TEMPLATE = key -> new Setting <>(key , "node" , v -> {
55
- if (v .equals ("node" ) || v .equals ("client" )) {
56
- return v ;
57
- }
58
- throw new IllegalArgumentException ("type must be one of [client, node]" );
59
- }, Setting .Property .NodeScope );
60
- private static final String TRANSPORT_TYPE_SETTING_KEY = "xpack.security.type" ;
61
52
private static final Logger logger = LogManager .getLogger (SecurityServerTransportInterceptor .class );
62
53
63
- public static final Setting .AffixSetting <String > TRANSPORT_TYPE_PROFILE_SETTING = Setting .affixKeySetting ("transport.profiles." ,
64
- TRANSPORT_TYPE_SETTING_KEY , TRANSPORT_TYPE_SETTING_TEMPLATE );
65
-
66
54
private final AuthenticationService authcService ;
67
55
private final AuthorizationService authzService ;
68
56
private final SSLService sslService ;
@@ -71,7 +59,6 @@ public class SecurityServerTransportInterceptor implements TransportInterceptor
71
59
private final ThreadPool threadPool ;
72
60
private final Settings settings ;
73
61
private final SecurityContext securityContext ;
74
- private final boolean reservedRealmEnabled ;
75
62
76
63
private volatile boolean isStateNotRecovered = true ;
77
64
@@ -92,7 +79,6 @@ public SecurityServerTransportInterceptor(Settings settings,
92
79
this .sslService = sslService ;
93
80
this .securityContext = securityContext ;
94
81
this .profileFilters = initializeProfileFilters (destructiveOperations );
95
- this .reservedRealmEnabled = XPackSettings .RESERVED_REALM_ENABLED_SETTING .get (settings );
96
82
clusterService .addListener (e -> isStateNotRecovered = e .state ().blocks ().hasGlobalBlock (GatewayService .STATE_NOT_RECOVERED_BLOCK ));
97
83
}
98
84
@@ -187,21 +173,8 @@ private Map<String, ServerTransportFilter> initializeProfileFilters(DestructiveO
187
173
for (Map .Entry <String , SSLConfiguration > entry : profileConfigurations .entrySet ()) {
188
174
final SSLConfiguration profileConfiguration = entry .getValue ();
189
175
final boolean extractClientCert = transportSSLEnabled && sslService .isSSLClientAuthEnabled (profileConfiguration );
190
- final String type = TRANSPORT_TYPE_PROFILE_SETTING .getConcreteSettingForNamespace (entry .getKey ()).get (settings );
191
- switch (type ) {
192
- case "client" :
193
- profileFilters .put (entry .getKey (), new ServerTransportFilter .ClientProfile (authcService , authzService ,
194
- threadPool .getThreadContext (), extractClientCert , destructiveOperations , reservedRealmEnabled ,
195
- securityContext , licenseState ));
196
- break ;
197
- case "node" :
198
- profileFilters .put (entry .getKey (), new ServerTransportFilter .NodeProfile (authcService , authzService ,
199
- threadPool .getThreadContext (), extractClientCert , destructiveOperations , reservedRealmEnabled ,
200
- securityContext , licenseState ));
201
- break ;
202
- default :
203
- throw new IllegalStateException ("unknown profile type: " + type );
204
- }
176
+ profileFilters .put (entry .getKey (), new ServerTransportFilter (authcService , authzService , threadPool .getThreadContext (),
177
+ extractClientCert , destructiveOperations , securityContext , licenseState ));
205
178
}
206
179
207
180
return Collections .unmodifiableMap (profileFilters );
0 commit comments