Skip to content

Commit b49ccbb

Browse files
amparabwilkinsona
authored andcommitted
Improve toString of SslBundle implementations
See gh-39137
1 parent f66fd0e commit b49ccbb

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ssl/PropertiesSslBundle.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.boot.autoconfigure.ssl;
1818

19+
import java.util.Arrays;
20+
1921
import org.springframework.boot.autoconfigure.ssl.SslBundleProperties.Key;
2022
import org.springframework.boot.ssl.SslBundle;
2123
import org.springframework.boot.ssl.SslBundleKey;
@@ -26,6 +28,7 @@
2628
import org.springframework.boot.ssl.jks.JksSslStoreDetails;
2729
import org.springframework.boot.ssl.pem.PemSslStoreBundle;
2830
import org.springframework.boot.ssl.pem.PemSslStoreDetails;
31+
import org.springframework.core.style.ToStringCreator;
2932

3033
/**
3134
* {@link SslBundle} backed by {@link JksSslBundleProperties} or
@@ -128,4 +131,17 @@ private static JksSslStoreDetails asStoreDetails(JksSslBundleProperties.Store pr
128131
properties.getPassword());
129132
}
130133

134+
@Override
135+
public String toString() {
136+
ToStringCreator creator = new ToStringCreator(this);
137+
creator.append("key-alias", this.key.getAlias());
138+
creator.append("protocol", this.protocol);
139+
creator.append("keystore-type", this.stores.getKeyStore().getType());
140+
creator.append("truststore-type",
141+
(this.stores.getTrustStore() != null) ? this.stores.getTrustStore().getType() : "");
142+
creator.append("ciphers", Arrays.toString(this.options.getCiphers()));
143+
creator.append("enabled-protocols", Arrays.toString(this.options.getEnabledProtocols()));
144+
return creator.toString();
145+
}
146+
131147
}

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/WebServerSslBundle.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.springframework.boot.web.server;
1818

1919
import java.security.KeyStore;
20+
import java.util.Arrays;
2021

2122
import org.springframework.boot.ssl.NoSuchSslBundleException;
2223
import org.springframework.boot.ssl.SslBundle;
@@ -29,6 +30,7 @@
2930
import org.springframework.boot.ssl.jks.JksSslStoreDetails;
3031
import org.springframework.boot.ssl.pem.PemSslStoreBundle;
3132
import org.springframework.boot.ssl.pem.PemSslStoreDetails;
33+
import org.springframework.core.style.ToStringCreator;
3234
import org.springframework.util.Assert;
3335
import org.springframework.util.StringUtils;
3436
import org.springframework.util.function.ThrowingSupplier;
@@ -284,4 +286,17 @@ public String getKeyStorePassword() {
284286

285287
}
286288

289+
@Override
290+
public String toString() {
291+
ToStringCreator creator = new ToStringCreator(this);
292+
creator.append("key-alias", this.key.getAlias());
293+
creator.append("protocol", this.protocol);
294+
creator.append("keystore-type", this.stores.getKeyStore().getType());
295+
creator.append("truststore-type",
296+
(this.stores.getTrustStore() != null) ? this.stores.getTrustStore().getType() : "");
297+
creator.append("ciphers", Arrays.toString(this.options.getCiphers()));
298+
creator.append("enabled-protocols", Arrays.toString(this.options.getEnabledProtocols()));
299+
return creator.toString();
300+
}
301+
287302
}

0 commit comments

Comments
 (0)