2525import build .base .flow .Publicist ;
2626import build .base .flow .Publisher ;
2727import build .base .flow .SubscriberRegistry ;
28+ import build .base .json .JsonObject ;
2829import build .base .option .Email ;
2930import build .base .option .Password ;
3031import build .base .option .Username ;
5152import build .spawn .docker .option .DockerAPIVersion ;
5253import build .spawn .docker .option .DockerRegistry ;
5354import build .spawn .docker .option .IdentityToken ;
54- import com .fasterxml .jackson .databind .ObjectMapper ;
5555
5656import java .nio .charset .StandardCharsets ;
5757import java .nio .file .Path ;
@@ -142,9 +142,6 @@ protected AbstractSession(final InjectionFramework injectionFramework,
142142 this .eventSubscriber = new CompletingSubscriber <>();
143143 this .publicist .subscribe (this .eventSubscriber );
144144
145- // establish an ObjectMapper for working with JSON
146- final ObjectMapper objectMapper = new ObjectMapper ();
147-
148145 // establish the dependency injection context
149146 this .context = injectionFramework
150147 .newContext ();
@@ -155,7 +152,6 @@ protected AbstractSession(final InjectionFramework injectionFramework,
155152 this .context .bind (Session .class ).to (this );
156153 this .context .bind (AbstractSession .class ).to (this );
157154 this .context .bind ((Class ) getClass ()).to (this );
158- this .context .bind (ObjectMapper .class ).to (objectMapper );
159155 this .context .bind (Configuration .class ).to (this .configuration );
160156 this .context .bind (Publicist .class ).to (this .publicist );
161157 this .context .bind (Publisher .class ).to (this .publicist );
@@ -178,23 +174,23 @@ protected AbstractSession(final InjectionFramework injectionFramework,
178174 .to (identityToken );
179175
180176 // establish the Authentication JSON
181- final var json = objectMapper . createObjectNode ();
177+ final var jsonBuilder = JsonObject . builder ();
182178
183179 if (identityToken .isEmpty ()) {
184180 this .configuration .getOptionalValue (Username .class )
185- .ifPresent (username -> json .put ("username" , username ));
181+ .ifPresent (username -> jsonBuilder .put ("username" , username ));
186182 this .configuration .getOptionalValue (Password .class )
187- .ifPresent (password -> json .put ("password" , password ));
183+ .ifPresent (password -> jsonBuilder .put ("password" , password ));
188184 this .configuration .getOptionalValue (Email .class )
189- .ifPresent (email -> json .put ("email" , email ));
185+ .ifPresent (email -> jsonBuilder .put ("email" , email ));
190186 this .configuration .getOptionalValue (DockerRegistry .class )
191- .ifPresent (url -> json .put ("serveraddress" , url .getHost ()));
187+ .ifPresent (url -> jsonBuilder .put ("serveraddress" , url .getHost ()));
192188 }
193189 else {
194- json .put ("identitytoken" , identityToken .get ());
190+ jsonBuilder .put ("identitytoken" , identityToken .get ());
195191 }
196192
197- xRegistryAuth = Optional .of (json . toString ());
193+ xRegistryAuth = Optional .of (jsonBuilder . build (). toJsonString ());
198194 }
199195 else {
200196 // determine the Configuration-provided IdentityToken
@@ -211,9 +207,11 @@ protected AbstractSession(final InjectionFramework injectionFramework,
211207 xRegistryAuth = Optional .empty ();
212208 }
213209 else {
214- final var json = objectMapper .createObjectNode ();
215- json .put ("identitytoken" , identityToken .get ());
216- xRegistryAuth = Optional .of (json .toString ());
210+ xRegistryAuth = Optional .of (
211+ JsonObject .builder ()
212+ .put ("identitytoken" , identityToken .get ())
213+ .build ()
214+ .toJsonString ());
217215 }
218216 }
219217
0 commit comments