Improve toString of SslBundle implementations

See gh-39137
This commit is contained in:
amparab 2024-01-15 01:38:38 +05:30 committed by Andy Wilkinson
parent f66fd0e9e2
commit b49ccbb0c2
2 changed files with 31 additions and 0 deletions

View File

@ -16,6 +16,8 @@
package org.springframework.boot.autoconfigure.ssl;
import java.util.Arrays;
import org.springframework.boot.autoconfigure.ssl.SslBundleProperties.Key;
import org.springframework.boot.ssl.SslBundle;
import org.springframework.boot.ssl.SslBundleKey;
@ -26,6 +28,7 @@ import org.springframework.boot.ssl.jks.JksSslStoreBundle;
import org.springframework.boot.ssl.jks.JksSslStoreDetails;
import org.springframework.boot.ssl.pem.PemSslStoreBundle;
import org.springframework.boot.ssl.pem.PemSslStoreDetails;
import org.springframework.core.style.ToStringCreator;
/**
* {@link SslBundle} backed by {@link JksSslBundleProperties} or
@ -128,4 +131,17 @@ public final class PropertiesSslBundle implements SslBundle {
properties.getPassword());
}
@Override
public String toString() {
ToStringCreator creator = new ToStringCreator(this);
creator.append("key-alias", this.key.getAlias());
creator.append("protocol", this.protocol);
creator.append("keystore-type", this.stores.getKeyStore().getType());
creator.append("truststore-type",
(this.stores.getTrustStore() != null) ? this.stores.getTrustStore().getType() : "");
creator.append("ciphers", Arrays.toString(this.options.getCiphers()));
creator.append("enabled-protocols", Arrays.toString(this.options.getEnabledProtocols()));
return creator.toString();
}
}

View File

@ -17,6 +17,7 @@
package org.springframework.boot.web.server;
import java.security.KeyStore;
import java.util.Arrays;
import org.springframework.boot.ssl.NoSuchSslBundleException;
import org.springframework.boot.ssl.SslBundle;
@ -29,6 +30,7 @@ import org.springframework.boot.ssl.jks.JksSslStoreBundle;
import org.springframework.boot.ssl.jks.JksSslStoreDetails;
import org.springframework.boot.ssl.pem.PemSslStoreBundle;
import org.springframework.boot.ssl.pem.PemSslStoreDetails;
import org.springframework.core.style.ToStringCreator;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.util.function.ThrowingSupplier;
@ -284,4 +286,17 @@ public final class WebServerSslBundle implements SslBundle {
}
@Override
public String toString() {
ToStringCreator creator = new ToStringCreator(this);
creator.append("key-alias", this.key.getAlias());
creator.append("protocol", this.protocol);
creator.append("keystore-type", this.stores.getKeyStore().getType());
creator.append("truststore-type",
(this.stores.getTrustStore() != null) ? this.stores.getTrustStore().getType() : "");
creator.append("ciphers", Arrays.toString(this.options.getCiphers()));
creator.append("enabled-protocols", Arrays.toString(this.options.getEnabledProtocols()));
return creator.toString();
}
}