Package net.devh.boot.grpc.client.config
Class GrpcChannelProperties.Security
java.lang.Object
net.devh.boot.grpc.client.config.GrpcChannelProperties.Security
- Enclosing class:
- GrpcChannelProperties
A container with options for the channel's transport security.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
void
Copies the defaults from the given configuration.boolean
Gets the authority to check for during server certificate verification.Gets the resource containing the SSL certificate chain.Gets the cipher suite accepted for secure connections (in the order of preference).The resource containing the key store.The format of thekeyStore
.Password for the key store.Gets resource containing the private key.Gets the password for the private key.String[]
Gets the TLS protocols accepted for secure connectionsGets the resource containing the the trusted certificate collection.The resource containing the trust store.The format of thetrustStore
.Password for the trust store.int
hashCode()
boolean
Gets whether client can authenticate using certificates.void
setAuthorityOverride
(String authorityOverride) Sets the authority to check for during server certificate verification.void
setCertificateChain
(Resource certificateChain) Sets the resource containing the SSL certificate chain.void
setCiphers
(String ciphers) Sets the cipher suite accepted for secure connections (in the order of preference).void
setClientAuthEnabled
(Boolean clientAuthEnabled) Set whether client can authenticate using certificates.void
setKeyStore
(Resource keyStore) The resource containing the key store.void
setKeyStoreFormat
(String keyStoreFormat) The format of thekeyStore
.void
setKeyStorePassword
(String keyStorePassword) Password for the key store.void
setPrivateKey
(Resource privateKey) Sets the resource containing the private key.void
setPrivateKeyPassword
(String privateKeyPassword) Sets the password for the private key.void
setProtocols
(String protocols) Sets the TLS protocols accepted for secure connections.void
setTrustCertCollection
(Resource trustCertCollection) Sets the resource containing the trusted certificate collection.void
setTrustStore
(Resource trustStore) The resource containing the trust store.void
setTrustStoreFormat
(String trustStoreFormat) The format of thetrustStore
.void
setTrustStorePassword
(String trustStorePassword) Password for the trust store.toString()
-
Constructor Details
-
Security
public Security()
-
-
Method Details
-
isClientAuthEnabled
public boolean isClientAuthEnabled()Gets whether client can authenticate using certificates.- Returns:
- True, if the client can authenticate itself using certificates.
- See Also:
-
setClientAuthEnabled
Set whether client can authenticate using certificates. Defaults tofalse
.- Parameters:
clientAuthEnabled
- Whether the client can authenticate itself using certificates.
-
getCertificateChain
Gets the resource containing the SSL certificate chain.- Returns:
- The certificate chain resource or null, if security is not enabled.
- See Also:
-
setCertificateChain
Sets the resource containing the SSL certificate chain. Required ifisClientAuthEnabled()
is true. The linked certificate will be used to authenticate the client.- Parameters:
certificateChain
- The certificate chain.- See Also:
-
SslContextBuilder.keyManager(InputStream, InputStream, String)
-
getPrivateKey
Gets resource containing the private key.- Returns:
- The private key resource or null, if security is not enabled.
- See Also:
-
setPrivateKey
Sets the resource containing the private key. Required ifisClientAuthEnabled()
is true.- Parameters:
privateKey
- The private key resource.- See Also:
-
SslContextBuilder.keyManager(InputStream, InputStream, String)
-
getPrivateKeyPassword
Gets the password for the private key.- Returns:
- The password for the private key or null, if the private key is not set or not encrypted.
- See Also:
-
setPrivateKeyPassword
Sets the password for the private key.- Parameters:
privateKeyPassword
- The password for the private key.- See Also:
-
SslContextBuilder.keyManager(File, File, String)
-
getKeyStoreFormat
The format of thekeyStore
.Possible values includes:
AUTODETECT
(default)JKS
(.jks
)PKCS12
(.p12
)- any supported
KeyStore
format - Fallback to
KeyStore#getDefaultType()
- Returns:
- The key store format to use.
-
setKeyStoreFormat
The format of thekeyStore
.Possible values includes:
AUTODETECT
(default)JKS
(.jks
)PKCS12
(.p12
)- any supported
KeyStore
format - Fallback to
KeyStore#getDefaultType()
- Parameters:
keyStoreFormat
- The key store format to use
-
getKeyStore
The resource containing the key store. Cannot be used in conjunction withprivateKey
.- Returns:
- The key store resource or null.
-
setKeyStore
The resource containing the key store. Cannot be used in conjunction withprivateKey
.- Parameters:
keyStore
- The key store resource.
-
getKeyStorePassword
Password for the key store. Use is combination withkeyStore
.- Returns:
- The password for the key store or null.
-
setKeyStorePassword
Password for the key store. Use is combination withkeyStore
.- Parameters:
keyStorePassword
- The password for the key store.
-
getTrustCertCollection
Gets the resource containing the the trusted certificate collection. Ifnull
or empty the use the system's default collection should be used.- Returns:
- The trusted certificate collection resource or null.
- See Also:
-
setTrustCertCollection
Sets the resource containing the trusted certificate collection. If not set (null
) it will use the system's default collection (Default). This collection will be used to verify server certificates.- Parameters:
trustCertCollection
- The path to the trusted certificate collection.- See Also:
-
SslContextBuilder.trustManager(InputStream)
-
getTrustStoreFormat
The format of thetrustStore
.Possible values includes:
AUTODETECT
(default)JKS
(.jks
)PKCS12
(.p12
)- any supported
KeyStore
format - Fallback to
KeyStore#getDefaultType()
- Returns:
- The trust store format to use.
-
setTrustStoreFormat
The format of thetrustStore
.Possible values includes:
AUTODETECT
(default)JKS
(.jks
)PKCS12
(.p12
)- any supported
KeyStore
format - Fallback to
KeyStore#getDefaultType()
- Parameters:
trustStoreFormat
- The trust store format to use.
-
getTrustStore
The resource containing the trust store. Cannot be used in conjunction withtrustCertCollection
. If neither this nortrustCertCollection
is set then the system's trust store will be used.- Returns:
- The trust store resource or null.
-
setTrustStore
The resource containing the trust store. Cannot be used in conjunction withtrustCertCollection
. If neither this nortrustCertCollection
is set then the system's trust store will be used.- Parameters:
trustStore
- The trust store resource.
-
getTrustStorePassword
Password for the trust store. Use is combination withtrustStore
.- Returns:
- The password for the trust store or null.
-
setTrustStorePassword
Password for the trust store. Use is combination withtrustStore
.- Parameters:
trustStorePassword
- The password for the trust store.
-
getAuthorityOverride
Gets the authority to check for during server certificate verification.- Returns:
- The override for the authority to check for or null, there is no override configured.
- See Also:
-
setAuthorityOverride
Sets the authority to check for during server certificate verification. By default the clients will use the name of the client to check the server certificate's common + alternative names.- Parameters:
authorityOverride
- The authority to check for in the certificate, or null to use the default checks.- See Also:
-
getCiphers
Gets the cipher suite accepted for secure connections (in the order of preference).- Returns:
- The cipher suite accepted for secure connections or null.
-
setCiphers
Sets the cipher suite accepted for secure connections (in the order of preference). If not specified (null), then the default suites should be used.- Parameters:
ciphers
- Cipher suite consisting of one or more cipher strings separated by colons, commas or spaces- See Also:
-
SslContextBuilder.ciphers(Iterable)
-
getProtocols
Gets the TLS protocols accepted for secure connections- Returns:
- The protocols accepted for secure connections or null.
-
setProtocols
Sets the TLS protocols accepted for secure connections. If not specified (null), then the default ones will be used.- Parameters:
protocols
- Protocol list consisting of one or more protocols separated by colons, commas or spaces.- See Also:
-
SslContextBuilder.protocols(String...)
-
copyDefaultsFrom
Copies the defaults from the given configuration. Values are considered "default" if they are null. Please note that the getters might return fallback values instead.- Parameters:
config
- The config to copy the defaults from.
-
toString
-
equals
-
canEqual
-
hashCode
public int hashCode()
-