Skip to content

Commit

Permalink
Improve toString of SslBundle implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
amparab authored and wilkinsona committed Jan 17, 2024
1 parent f66fd0e commit b49ccbb
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -26,6 +28,7 @@
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
Expand Down Expand Up @@ -128,4 +131,17 @@ private static JksSslStoreDetails asStoreDetails(JksSslBundleProperties.Store pr
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();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -29,6 +30,7 @@
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;
Expand Down Expand Up @@ -284,4 +286,17 @@ public String getKeyStorePassword() {

}

@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();
}

}

0 comments on commit b49ccbb

Please sign in to comment.