Class PlccomMqttTlsOptions.Builder
- java.lang.Object
-
- com.plccom.mqtt.client.PlccomMqttTlsOptions.Builder
-
- Enclosing class:
- PlccomMqttTlsOptions
public static final class PlccomMqttTlsOptions.Builder extends Object
Builder forPlccomMqttTlsOptions.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PlccomMqttTlsOptionsbuild()Builds immutable TLS options.PlccomMqttTlsOptions.BuilderenabledCipherSuites(String... values)Restricts the enabled TLS cipher suites.PlccomMqttTlsOptions.BuilderenabledProtocols(String... values)Restricts the enabled TLS protocols.PlccomMqttTlsOptions.BuilderhandshakeTimeoutMillis(long value)Sets the TLS handshake timeout.PlccomMqttTlsOptions.BuilderhostnameVerificationEnabled(boolean value)Enables or disables TLS hostname verification.PlccomMqttTlsOptions.BuilderhostnameVerifier(HostnameVerifier value)Sets the hostname verifier.PlccomMqttTlsOptions.BuilderkeyStore(KeyStore value, char[] password)Sets the client certificate KeyStore used for mutual TLS.PlccomMqttTlsOptions.BuilderpkiOptions(PlccomMqttPkiOptions value)Sets the PLCcom file-based PKI options for broker certificate validation.PlccomMqttTlsOptions.BuildersslContext(SSLContext value)Sets the SSL context used for TLS sockets.PlccomMqttTlsOptions.BuildertrustStore(KeyStore value)Sets the TrustStore used to validate the broker certificate.
-
-
-
Method Detail
-
sslContext
public PlccomMqttTlsOptions.Builder sslContext(SSLContext value)
Sets the SSL context used for TLS sockets.A ready SSL context brings its own key and trust material and takes precedence over
keyStore(KeyStore, char[]),trustStore(KeyStore)andpkiOptions(PlccomMqttPkiOptions). A client without an own client certificate may passSSLContext.getDefault()to trust the trust store of the JVM; a client certificate set withkeyStore(KeyStore, char[])would then not be used.- Parameters:
value- custom SSL context, ornullto let these options create the context- Returns:
- this builder
-
keyStore
public PlccomMqttTlsOptions.Builder keyStore(KeyStore value, char[] password)
Sets the client certificate KeyStore used for mutual TLS.This is the convenient Paho-style path for brokers that request or require a client certificate during the TLS handshake. The KeyStore must contain the client's private key and certificate chain. When a ready
sslContext(SSLContext)is supplied, that context takes precedence over this KeyStore setting.- Parameters:
value- KeyStore containing the client private key and certificate chainpassword- private-key password, ornullwhen the key entry has no password- Returns:
- this builder
- Throws:
NullPointerException- ifvalueisnull
-
trustStore
public PlccomMqttTlsOptions.Builder trustStore(KeyStore value)
Sets the TrustStore used to validate the broker certificate.Supplying a TrustStore is the convenient counterpart to
keyStore(KeyStore, char[]). It lets applications trust a private CA or test certificate without creating anSSLContextmanually. The TrustStore is the application's own trust decision: the broker certificate is checked with the standard JDK trust manager, the host name as set withhostnameVerificationEnabled(boolean), and the PLCcom PKI store is not used. ConfiguredpkiOptions(PlccomMqttPkiOptions)take precedence. When neither is configured, the PLCcom PKI store in thepkifolder of the working directory decides, not the trust store of the JVM.- Parameters:
value- TrustStore for broker certificates- Returns:
- this builder
- Throws:
NullPointerException- ifvalueisnull
-
pkiOptions
public PlccomMqttTlsOptions.Builder pkiOptions(PlccomMqttPkiOptions value)
Sets the PLCcom file-based PKI options for broker certificate validation.When PKI options are configured, they provide the TrustManager used during the TLS handshake. A ready
sslContext(SSLContext)still takes precedence for expert callers. Without PKI options, a TrustStore or an SSL context, default options with the PKI store in thepkifolder of the working directory apply.- Parameters:
value- PKI options, ornullto use the TrustStore or the default PKI store- Returns:
- this builder
-
hostnameVerifier
public PlccomMqttTlsOptions.Builder hostnameVerifier(HostnameVerifier value)
Sets the hostname verifier.- Parameters:
value- custom verifier, ornullto use the JDK default verifier- Returns:
- this builder
-
hostnameVerificationEnabled
public PlccomMqttTlsOptions.Builder hostnameVerificationEnabled(boolean value)
Enables or disables TLS hostname verification.- Parameters:
value-trueto verify the broker certificate against the endpoint host- Returns:
- this builder
-
enabledProtocols
public PlccomMqttTlsOptions.Builder enabledProtocols(String... values)
Restricts the enabled TLS protocols.- Parameters:
values- protocol names accepted bySSLSocket, ornullto keep socket defaults- Returns:
- this builder
- Throws:
NullPointerException- ifvaluescontains anullelement duringbuild()IllegalArgumentException- ifvaluesis empty or contains a blank value duringbuild()
-
enabledCipherSuites
public PlccomMqttTlsOptions.Builder enabledCipherSuites(String... values)
Restricts the enabled TLS cipher suites.- Parameters:
values- cipher suite names accepted bySSLSocket, ornullto keep socket defaults- Returns:
- this builder
- Throws:
NullPointerException- ifvaluescontains anullelement duringbuild()IllegalArgumentException- ifvaluesis empty or contains a blank value duringbuild()
-
handshakeTimeoutMillis
public PlccomMqttTlsOptions.Builder handshakeTimeoutMillis(long value)
Sets the TLS handshake timeout.- Parameters:
value- timeout in milliseconds- Returns:
- this builder
- Throws:
IllegalArgumentException- ifvalueis not positive duringbuild()
-
build
public PlccomMqttTlsOptions build()
Builds immutable TLS options.- Returns:
- TLS options
- Throws:
NullPointerException- if a configured protocol or cipher suite name isnullIllegalArgumentException- if the handshake timeout is not positive, or a configured protocol or cipher suite list is empty or contains a blank value
-
-