Class TlsConfig.Builder
java.lang.Object
com.loomcache.common.config.TlsConfig.Builder
- Enclosing class:
TlsConfig
Builder for TlsConfig with validation.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionacceptTimeoutMs(int timeoutMs) Set the accept timeout (SO_TIMEOUT) applied to the TLS server socket.build()Build the TlsConfig with validation.Build without file existence validation (for testing or deferred setup).certExpirationCriticalDays(int days) Set the number of days before expiration to trigger critical alert.certExpirationWarningDays(int days) Set the number of days before expiration to warn.cipherSuites(String... suites) Set the cipher suites to enable.cipherSuites(List<String> suites) Set the cipher suites to enable.enabled(boolean enabled) Enable or disable TLS.keyStorePassword(String password) Set the keystore password.keyStorePath(String path) Set the keystore path.keyStorePath(@Nullable Path path) Set the keystore path.keyStoreType(String type) Set the keystore type (PKCS12 or JKS).Set the TLS protocols to enable.Set the TLS protocols to enable.provider(TlsProvider provider) Set the TLS provider.Set the TLS provider from configuration text.requireClientAuth(boolean require) Require client authentication (mTLS).revocationCheckingEnabled(boolean enabled) Enable or disable certificate revocation checking (CRL/OCSP).revocationSoftFail(boolean softFail) Set revocation checking mode.trustStorePassword(String password) Set the truststore password.trustStorePath(String path) Set the truststore path.trustStorePath(@Nullable Path path) Set the truststore path.trustStoreType(String type) Set the truststore type (PKCS12 or JKS).
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
enabled
Enable or disable TLS.- Parameters:
enabled- true to enable TLS- Returns:
- this builder
-
keyStorePath
Set the keystore path.- Parameters:
path- the path to the keystore file- Returns:
- this builder
-
keyStorePath
Set the keystore path.- Parameters:
path- the path string to the keystore file- Returns:
- this builder
-
keyStorePassword
Set the keystore password.- Parameters:
password- the keystore password (must not be null)- Returns:
- this builder
-
keyStoreType
Set the keystore type (PKCS12 or JKS).- Parameters:
type- the keystore type (must not be null)- Returns:
- this builder
-
trustStorePath
Set the truststore path.- Parameters:
path- the path to the truststore file- Returns:
- this builder
-
trustStorePath
Set the truststore path.- Parameters:
path- the path string to the truststore file- Returns:
- this builder
-
trustStorePassword
Set the truststore password.- Parameters:
password- the truststore password (must not be null)- Returns:
- this builder
-
trustStoreType
Set the truststore type (PKCS12 or JKS).- Parameters:
type- the truststore type (must not be null)- Returns:
- this builder
-
requireClientAuth
Require client authentication (mTLS).- Parameters:
require- true to require client authentication- Returns:
- this builder
-
protocols
Set the TLS protocols to enable.- Parameters:
protocols- the list of protocol names (must not be null)- Returns:
- this builder
-
protocols
Set the TLS protocols to enable.- Parameters:
protocols- the protocol names (must not be empty)- Returns:
- this builder
-
cipherSuites
Set the cipher suites to enable.- Parameters:
suites- the list of cipher suite names (must not be null)- Returns:
- this builder
-
cipherSuites
Set the cipher suites to enable.- Parameters:
suites- the cipher suite names- Returns:
- this builder
-
provider
Set the TLS provider.- Parameters:
provider- the provider to use- Returns:
- this builder
-
provider
Set the TLS provider from configuration text.- Parameters:
provider- provider value (JDK, JSSE, OPENSSL, BORINGSSL, OPENSSL_REFCNT)- Returns:
- this builder
-
certExpirationWarningDays
Set the number of days before expiration to warn.- Parameters:
days- the warning threshold in days- Returns:
- this builder
-
certExpirationCriticalDays
Set the number of days before expiration to trigger critical alert.- Parameters:
days- the critical threshold in days- Returns:
- this builder
-
revocationCheckingEnabled
Enable or disable certificate revocation checking (CRL/OCSP). When enabled, certificates are checked against CRL distribution points and OCSP responders embedded in the certificate chain.- Parameters:
enabled- true to enable revocation checking- Returns:
- this builder
-
revocationSoftFail
Set revocation checking mode. When true (default), CRL/OCSP fetch failures are tolerated (soft-fail). When false, any fetch failure rejects the certificate (hard-fail — stricter security, but requires reachable CRL/OCSP infrastructure).- Parameters:
softFail- true for soft-fail, false for hard-fail- Returns:
- this builder
-
acceptTimeoutMs
Set the accept timeout (SO_TIMEOUT) applied to the TLS server socket. The accept loop wakes on each timeout to honor shutdown signals.- Parameters:
timeoutMs- timeout in milliseconds (must be > 0)- Returns:
- this builder
-
build
Build the TlsConfig with validation.- Returns:
- a new TlsConfig
- Throws:
IllegalArgumentException- if validation fails
-
buildUnchecked
Build without file existence validation (for testing or deferred setup).- Returns:
- a new TlsConfig
-