2424import jakarta .enterprise .context .ApplicationScoped ;
2525import jakarta .inject .Inject ;
2626import java .time .Clock ;
27- import java .util .Collections ;
27+ import java .util .List ;
2828import java .util .Map ;
2929import java .util .Set ;
3030import java .util .concurrent .CopyOnWriteArraySet ;
@@ -65,7 +65,7 @@ public InMemoryPolarisMetaStoreManagerFactory(
6565 }
6666
6767 public void onStartup (RealmContextConfiguration realmContextConfiguration ) {
68- bootstrapRealmAndPrintCredentials (realmContextConfiguration .defaultRealm ());
68+ bootstrapRealmsAndPrintCredentials (realmContextConfiguration .realms ());
6969 }
7070
7171 @ Override
@@ -86,7 +86,7 @@ protected PolarisMetaStoreSession createMetaStoreSession(
8686 @ Override
8787 public synchronized PolarisMetaStoreManager getOrCreateMetaStoreManager (RealmId realmId ) {
8888 if (!bootstrappedRealms .contains (realmId .id ())) {
89- bootstrapRealmAndPrintCredentials ( realmId .id ());
89+ bootstrapRealmsAndPrintCredentials ( List . of ( realmId .id () ));
9090 }
9191 return super .getOrCreateMetaStoreManager (realmId );
9292 }
@@ -95,25 +95,28 @@ public synchronized PolarisMetaStoreManager getOrCreateMetaStoreManager(RealmId
9595 public synchronized Supplier <PolarisMetaStoreSession > getOrCreateSessionSupplier (
9696 RealmId realmId ) {
9797 if (!bootstrappedRealms .contains (realmId .id ())) {
98- bootstrapRealmAndPrintCredentials ( realmId .id ());
98+ bootstrapRealmsAndPrintCredentials ( List . of ( realmId .id () ));
9999 }
100100 return super .getOrCreateSessionSupplier (realmId );
101101 }
102102
103- private void bootstrapRealmAndPrintCredentials (String realmId ) {
103+ private void bootstrapRealmsAndPrintCredentials (List <String > realms ) {
104+ PolarisCredentialsBootstrap credentialsBootstrap =
105+ PolarisCredentialsBootstrap .fromEnvironment ();
104106 Map <String , PrincipalSecretsResult > results =
105- this .bootstrapRealms (
106- Collections .singletonList (realmId ), PolarisCredentialsBootstrap .fromEnvironment ());
107- bootstrappedRealms .add (realmId );
107+ this .bootstrapRealms (realms , credentialsBootstrap );
108+ bootstrappedRealms .addAll (realms );
108109
109- PrincipalSecretsResult principalSecrets = results .get (realmId );
110+ for (String realmId : realms ) {
111+ PrincipalSecretsResult principalSecrets = results .get (realmId );
110112
111- String msg =
112- String .format (
113- "realm: %1s root principal credentials: %2s:%3s" ,
114- realmId ,
115- principalSecrets .getPrincipalSecrets ().getPrincipalClientId (),
116- principalSecrets .getPrincipalSecrets ().getMainSecret ());
117- System .out .println (msg );
113+ String msg =
114+ String .format (
115+ "realm: %1s root principal credentials: %2s:%3s" ,
116+ realmId ,
117+ principalSecrets .getPrincipalSecrets ().getPrincipalClientId (),
118+ principalSecrets .getPrincipalSecrets ().getMainSecret ());
119+ System .out .println (msg );
120+ }
118121 }
119122}
0 commit comments