66import java .io .File ;
77import java .io .FileInputStream ;
88import java .io .IOException ;
9+ import java .io .Serializable ;
910import java .net .URI ;
1011import java .util .Map ;
1112import java .util .Properties ;
1213
13- public class DockerClientConfig {
14+ public class DockerClientConfig implements Serializable {
1415 private static final String DOCKER_HOST_PROPERTY = "DOCKER_HOST" ;
1516 private static final String DOCKER_CERT_PATH_PROPERTY = "DOCKER_CERT_PATH" ;
1617 private static final String DOCKER_IO_URL_PROPERTY = "docker.io.url" ;
@@ -41,21 +42,22 @@ public class DockerClientConfig {
4142 .build ();
4243 private static final String DOCKER_IO_PROPERTIES_PROPERTY = "docker.io.properties" ;
4344 private final URI uri ;
44- private final String version , username , password , email , serverAddress , dockerCertPath , dockerCfgPath ;
45+ private final String version , username , password , email , serverAddress , dockerCfgPath ;
4546 private final Integer readTimeout ;
4647 private final boolean loggingFilterEnabled ;
48+ private final SSLConfig sslConfig ;
4749
48- DockerClientConfig (URI uri , String version , String username , String password , String email , String serverAddress , String dockerCertPath , String dockerCfgPath , Integer readTimeout , boolean loggingFilterEnabled ) {
50+ DockerClientConfig (URI uri , String version , String username , String password , String email , String serverAddress , String dockerCfgPath , Integer readTimeout , boolean loggingFilterEnabled , SSLConfig sslConfig ) {
4951 this .uri = uri ;
5052 this .version = version ;
5153 this .username = username ;
5254 this .password = password ;
5355 this .email = email ;
5456 this .serverAddress = serverAddress ;
55- this .dockerCertPath = dockerCertPath ;
5657 this .dockerCfgPath = dockerCfgPath ;
5758 this .readTimeout = readTimeout ;
5859 this .loggingFilterEnabled = loggingFilterEnabled ;
60+ this .sslConfig = sslConfig ;
5961 }
6062
6163 private static Properties loadIncludedDockerProperties (Properties systemProperties ) {
@@ -212,23 +214,23 @@ public boolean isLoggingFilterEnabled() {
212214 return loggingFilterEnabled ;
213215 }
214216
215- public String getDockerCertPath () {
216- return dockerCertPath ;
217+ public SSLConfig getSslConfig () {
218+ return sslConfig ;
217219 }
218220
219221 public String getDockerCfgPath () {
220222 return dockerCfgPath ;
221223 }
222224
223- @ Override
225+ @ Override
224226 public boolean equals (Object o ) {
225227 if (this == o ) return true ;
226228 if (o == null || getClass () != o .getClass ()) return false ;
227229
228230 DockerClientConfig that = (DockerClientConfig ) o ;
229231
230232 if (loggingFilterEnabled != that .loggingFilterEnabled ) return false ;
231- if (dockerCertPath != null ? !dockerCertPath .equals (that .dockerCertPath ) : that .dockerCertPath != null )
233+ if (sslConfig != null ? !sslConfig .equals (that .sslConfig ) : that .sslConfig != null )
232234 return false ;
233235 if (dockerCfgPath != null ? !dockerCfgPath .equals (that .dockerCfgPath ) : that .dockerCfgPath != null )
234236 return false ;
@@ -252,8 +254,8 @@ public int hashCode() {
252254 result = 31 * result + (password != null ? password .hashCode () : 0 );
253255 result = 31 * result + (email != null ? email .hashCode () : 0 );
254256 result = 31 * result + (serverAddress != null ? serverAddress .hashCode () : 0 );
255- result = 31 * result + (dockerCertPath != null ? dockerCertPath .hashCode () : 0 );
256257 result = 31 * result + (dockerCfgPath != null ? dockerCfgPath .hashCode () : 0 );
258+ result = 31 * result + (sslConfig != null ? sslConfig .hashCode () : 0 );
257259 result = 31 * result + (readTimeout != null ? readTimeout .hashCode () : 0 );
258260 result = 31 * result + (loggingFilterEnabled ? 1 : 0 );
259261 return result ;
@@ -268,18 +270,19 @@ public String toString() {
268270 ", password='" + password + '\'' +
269271 ", email='" + email + '\'' +
270272 ", serverAddress='" + serverAddress + '\'' +
271- ", dockerCertPath='" + dockerCertPath + '\'' +
272273 ", dockerCfgPath='" + dockerCfgPath + '\'' +
274+ ", sslConfig='" + sslConfig + '\'' +
273275 ", readTimeout=" + readTimeout +
274276 ", loggingFilterEnabled=" + loggingFilterEnabled +
275277 '}' ;
276278 }
277279
278280 public static class DockerClientConfigBuilder {
279281 private URI uri ;
280- private String version , username , password , email , serverAddress , dockerCertPath , dockerCfgPath ;
282+ private String version , username , password , email , serverAddress , dockerCfgPath ;
281283 private Integer readTimeout ;
282284 private boolean loggingFilterEnabled ;
285+ private SSLConfig sslConfig ;
283286
284287 /**
285288 * This will set all fields in the builder to those contained in the Properties object. The Properties object
@@ -342,7 +345,7 @@ public final DockerClientConfigBuilder withLoggingFilter(boolean loggingFilterEn
342345 }
343346
344347 public final DockerClientConfigBuilder withDockerCertPath (String dockerCertPath ) {
345- this .dockerCertPath = dockerCertPath ;
348+ this .sslConfig = new LocalDirectorySSLConfig ( dockerCertPath ) ;
346349 return this ;
347350 }
348351
@@ -352,6 +355,11 @@ public final DockerClientConfigBuilder withDockerCfgPath(String dockerCfgPath) {
352355 }
353356
354357
358+ public final DockerClientConfigBuilder withSSLConfig (SSLConfig config ) {
359+ this .sslConfig = config ;
360+ return this ;
361+ }
362+
355363 public DockerClientConfig build () {
356364 return new DockerClientConfig (
357365 uri ,
@@ -360,10 +368,10 @@ public DockerClientConfig build() {
360368 password ,
361369 email ,
362370 serverAddress ,
363- dockerCertPath ,
364371 dockerCfgPath ,
365372 readTimeout ,
366- loggingFilterEnabled
373+ loggingFilterEnabled ,
374+ sslConfig
367375 );
368376 }
369377 }
0 commit comments