Introduce factory methods in SslInfo and remove MockSslInfo

After further consideration, we have decided to remove the recently
introduced MockSslInfo in favor of introducing the following static
factory methods directly in the SslInfo interface.

- SslInfo.from(String sessionId)

- SslInfo from(String sessionId, X509Certificate... peerCertificates)

See gh-35042
See gh-35078
This commit is contained in:
Sam Brannen
2025-06-19 13:39:31 +02:00
parent 1fb04cb83a
commit f478f5cdc8
3 changed files with 22 additions and 98 deletions
@@ -24,12 +24,14 @@ import org.jspecify.annotations.Nullable;
* A holder for SSL session information.
*
* @author Rossen Stoyanchev
* @author Sam Brannen
* @since 5.0.2
* @see javax.net.ssl.SSLSession
*/
public interface SslInfo {
/**
* Return the SSL session id, if any.
* Return the SSL session ID, if any.
*/
@Nullable String getSessionId();
@@ -38,4 +40,21 @@ public interface SslInfo {
*/
X509Certificate @Nullable [] getPeerCertificates();
/**
* Create {@link SslInfo} configured with the supplied session ID.
* @since 7.0
*/
static SslInfo from(String sessionId) {
return new DefaultSslInfo(sessionId, new X509Certificate[0]);
}
/**
* Create {@link SslInfo} configured with the supplied session ID and certificates.
* @since 7.0
*/
static SslInfo from(String sessionId, X509Certificate... peerCertificates) {
return new DefaultSslInfo(sessionId, peerCertificates);
}
}