@@ -283,7 +283,6 @@ public class Security extends Plugin implements SystemIndexPlugin, IngestPlugin,
283
283
private static final Logger logger = LogManager .getLogger (Security .class );
284
284
285
285
private final Settings settings ;
286
- private final Environment env ;
287
286
private final boolean enabled ;
288
287
/* what a PITA that we need an extra indirection to initialize this. Yet, once we got rid of guice we can thing about how
289
288
* to fix this or make it simpler. Today we need several service that are created in createComponents but we need to register
@@ -311,7 +310,6 @@ public Security(Settings settings, final Path configPath) {
311
310
// TODO This is wrong. Settings can change after this. We should use the settings from createComponents
312
311
this .settings = settings ;
313
312
// TODO this is wrong, we should only use the environment that is provided to createComponents
314
- this .env = new Environment (settings , configPath );
315
313
this .enabled = XPackSettings .SECURITY_ENABLED .get (settings );
316
314
if (enabled ) {
317
315
runStartupChecks (settings );
@@ -348,7 +346,7 @@ public Collection<Object> createComponents(Client client, ClusterService cluster
348
346
IndexNameExpressionResolver expressionResolver ) {
349
347
try {
350
348
return createComponents (client , threadPool , clusterService , resourceWatcherService , scriptService , xContentRegistry ,
351
- expressionResolver );
349
+ environment , expressionResolver );
352
350
} catch (final Exception e ) {
353
351
throw new IllegalStateException ("security initialization failed" , e );
354
352
}
@@ -357,7 +355,7 @@ public Collection<Object> createComponents(Client client, ClusterService cluster
357
355
// pkg private for testing - tests want to pass in their set of extensions hence we are not using the extension service directly
358
356
Collection <Object > createComponents (Client client , ThreadPool threadPool , ClusterService clusterService ,
359
357
ResourceWatcherService resourceWatcherService , ScriptService scriptService ,
360
- NamedXContentRegistry xContentRegistry ,
358
+ NamedXContentRegistry xContentRegistry , Environment environment ,
361
359
IndexNameExpressionResolver expressionResolver ) throws Exception {
362
360
if (enabled == false ) {
363
361
return Collections .singletonList (new SecurityUsageServices (null , null , null , null ));
@@ -371,7 +369,7 @@ Collection<Object> createComponents(Client client, ThreadPool threadPool, Cluste
371
369
new TokenSSLBootstrapCheck (),
372
370
new PkiRealmBootstrapCheck (getSslService ()),
373
371
new TLSLicenseBootstrapCheck ()));
374
- checks .addAll (InternalRealms .getBootstrapChecks (settings , env ));
372
+ checks .addAll (InternalRealms .getBootstrapChecks (settings , environment ));
375
373
this .bootstrapChecks .set (Collections .unmodifiableList (checks ));
376
374
377
375
threadContext .set (threadPool .getThreadContext ());
@@ -399,9 +397,9 @@ Collection<Object> createComponents(Client client, ThreadPool threadPool, Cluste
399
397
final NativeRoleMappingStore nativeRoleMappingStore = new NativeRoleMappingStore (settings , client , securityIndex .get (),
400
398
scriptService );
401
399
final AnonymousUser anonymousUser = new AnonymousUser (settings );
402
- final ReservedRealm reservedRealm = new ReservedRealm (env , settings , nativeUsersStore ,
400
+ final ReservedRealm reservedRealm = new ReservedRealm (environment , settings , nativeUsersStore ,
403
401
anonymousUser , securityIndex .get (), threadPool );
404
- final SecurityExtension .SecurityComponents extensionComponents = new ExtensionComponents (env , client , clusterService ,
402
+ final SecurityExtension .SecurityComponents extensionComponents = new ExtensionComponents (environment , client , clusterService ,
405
403
resourceWatcherService , nativeRoleMappingStore );
406
404
Map <String , Realm .Factory > realmFactories = new HashMap <>(InternalRealms .getFactories (threadPool , resourceWatcherService ,
407
405
getSslService (), nativeUsersStore , nativeRoleMappingStore , securityIndex .get ()));
@@ -413,7 +411,8 @@ Collection<Object> createComponents(Client client, ThreadPool threadPool, Cluste
413
411
}
414
412
}
415
413
}
416
- final Realms realms = new Realms (settings , env , realmFactories , getLicenseState (), threadPool .getThreadContext (), reservedRealm );
414
+ final Realms realms =
415
+ new Realms (settings , environment , realmFactories , getLicenseState (), threadPool .getThreadContext (), reservedRealm );
417
416
components .add (nativeUsersStore );
418
417
components .add (nativeRoleMappingStore );
419
418
components .add (realms );
@@ -426,7 +425,7 @@ Collection<Object> createComponents(Client client, ThreadPool threadPool, Cluste
426
425
427
426
dlsBitsetCache .set (new DocumentSubsetBitsetCache (settings , threadPool ));
428
427
final FieldPermissionsCache fieldPermissionsCache = new FieldPermissionsCache (settings );
429
- final FileRolesStore fileRolesStore = new FileRolesStore (settings , env , resourceWatcherService , getLicenseState (),
428
+ final FileRolesStore fileRolesStore = new FileRolesStore (settings , environment , resourceWatcherService , getLicenseState (),
430
429
xContentRegistry );
431
430
final NativeRolesStore nativeRolesStore = new NativeRolesStore (settings , client , getLicenseState (), securityIndex .get ());
432
431
final ReservedRolesStore reservedRolesStore = new ReservedRolesStore ();
0 commit comments