Class AuthenticatingClientConfigProperties
- java.lang.Object
-
- org.eclipse.hono.config.AbstractConfig
-
- org.eclipse.hono.config.AuthenticatingClientConfigProperties
-
- Direct Known Subclasses:
ClientConfigProperties
public class AuthenticatingClientConfigProperties extends AbstractConfig
Common configuration properties required for accessing and authenticating to a remote server.
-
-
Field Summary
-
Fields inherited from class org.eclipse.hono.config.AbstractConfig
LOG
-
-
Constructor Summary
Constructors Constructor Description AuthenticatingClientConfigProperties()
Creates new properties with default values.AuthenticatingClientConfigProperties(AuthenticatingClientConfigProperties otherProperties)
Creates properties based on other properties.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getCredentialsPath()
Gets the file system path to a properties file containing the credentials for authenticating to the server.String
getHost()
Gets the name or literal IP address of the host that the client is configured to connect to.String
getPassword()
Gets the password that is used when authenticating to the Hono server.int
getPort()
Gets the TCP port of the server that this client is configured to connect to.String
getServerRole()
Gets the name of the role that the server plays from the client's perspective.String
getUsername()
Gets the user name that is used when authenticating to the Hono server.boolean
isHostnameVerificationRequired()
Checks if the host property must match the distinguished or any of the alternative names asserted by the server's certificate when connecting using TLS.boolean
isTlsEnabled()
Checks if the client should use TLS to verify the server's identity and encrypt the connection.void
setCredentialsPath(String path)
Sets the file system path to a properties file containing the credentials for authenticating to the server.void
setHost(String host)
Sets the name or literal IP address of the host that the client should connect to.void
setHostnameVerificationRequired(boolean hostnameVerificationRequired)
Sets whether the host property must match the distinguished or any of the alternative names asserted by the server's certificate when connecting using TLS.void
setPassword(String password)
Sets the password to use in conjunction with the user name when authenticating to the Hono server.void
setPort(int port)
Sets the TCP port of the server that this client should connect to.void
setServerRole(String roleName)
Sets the name of the role that the server plays from the client's perspective.void
setTlsEnabled(boolean enabled)
Sets whether the client should use TLS to verify the server's identity and encrypt the connection.void
setUsername(String username)
Sets the user name to use when authenticating to the Hono server.-
Methods inherited from class org.eclipse.hono.config.AbstractConfig
getCertPath, getKeyCertOptions, getKeyFormat, getKeyPath, getKeyStorePassword, getKeyStorePath, getPathSeparator, getSecureProtocols, getTrustOptions, getTrustStoreFormat, getTrustStorePassword, getTrustStorePath, isValidPort, setCertPath, setKeyFormat, setKeyPath, setKeyStorePassword, setKeyStorePath, setPathSeparator, setSecureProtocols, setTrustStoreFormat, setTrustStorePassword, setTrustStorePath
-
-
-
-
Constructor Detail
-
AuthenticatingClientConfigProperties
public AuthenticatingClientConfigProperties()
Creates new properties with default values.
-
AuthenticatingClientConfigProperties
public AuthenticatingClientConfigProperties(AuthenticatingClientConfigProperties otherProperties)
Creates properties based on other properties.- Parameters:
otherProperties
- The properties to copy.
-
-
Method Detail
-
getHost
public final String getHost()
Gets the name or literal IP address of the host that the client is configured to connect to.The default value of this property is localhost.
- Returns:
- The host name.
-
setHost
public final void setHost(String host)
Sets the name or literal IP address of the host that the client should connect to.The default value of this property is localhost.
- Parameters:
host
- The host name or IP address.- Throws:
NullPointerException
- if host isnull
.
-
getPort
public final int getPort()
Gets the TCP port of the server that this client is configured to connect to.The default value of this property is
Constants.PORT_AMQPS
.- Returns:
- The port number.
-
setPort
public final void setPort(int port)
Sets the TCP port of the server that this client should connect to.The default value of this property is
Constants.PORT_AMQPS
.- Parameters:
port
- The port number.- Throws:
IllegalArgumentException
- if port < 1000 or port > 65535.
-
getUsername
public final String getUsername()
Gets the user name that is used when authenticating to the Hono server.This method returns the value set using the setUsername method if the value is not
null
. Otherwise, the user name is read from the properties file indicated by the credentialsPath property (if notnull
).- Returns:
- The user name or
null
if not set.
-
setUsername
public final void setUsername(String username)
Sets the user name to use when authenticating to the Hono server.If not set then this client will not try to authenticate to the server.
- Parameters:
username
- The user name.
-
getPassword
public final String getPassword()
Gets the password that is used when authenticating to the Hono server.This method returns the value set using the setPassword method if the value is not
null
. Otherwise, the password is read from the properties file indicated by the credentialsPath property (if notnull
).- Returns:
- The password or
null
if not set.
-
setPassword
public final void setPassword(String password)
Sets the password to use in conjunction with the user name when authenticating to the Hono server.If not set then this client will not try to authenticate to the server.
- Parameters:
password
- The password.
-
getCredentialsPath
public final String getCredentialsPath()
Gets the file system path to a properties file containing the credentials for authenticating to the server.The file is expected to contain a username and a password property, e.g.
username=foo password=bar
- Returns:
- The path or
null
if not set.
-
setCredentialsPath
public final void setCredentialsPath(String path)
Sets the file system path to a properties file containing the credentials for authenticating to the server.The file is expected to contain a username and a password property, e.g.
username=foo password=bar
- Parameters:
path
- The path to the properties file.
-
isHostnameVerificationRequired
public final boolean isHostnameVerificationRequired()
Checks if the host property must match the distinguished or any of the alternative names asserted by the server's certificate when connecting using TLS.- Returns:
true
if the host name will be matched against the asserted names.
-
setHostnameVerificationRequired
public final void setHostnameVerificationRequired(boolean hostnameVerificationRequired)
Sets whether the host property must match the distinguished or any of the alternative names asserted by the server's certificate when connecting using TLS.Verification is enabled by default, i.e. the connection will be established only if the server presents a certificate that has been signed by one of the client's trusted CAs and one of the asserted names matches the host name that the client used to connect to the server.
- Parameters:
hostnameVerificationRequired
-true
if the host name should be matched.
-
isTlsEnabled
public final boolean isTlsEnabled()
Checks if the client should use TLS to verify the server's identity and encrypt the connection.Verification is disabled by default. Setting the trustStorePath property enables verification of the server identity implicitly and the value of this property is ignored.
- Returns:
true
if TLS should be used.
-
setTlsEnabled
public final void setTlsEnabled(boolean enabled)
Sets whether the client should use TLS to verify the server's identity and encrypt the connection.Verification is disabled by default. Setting the trustStorePath property enables verification of the server identity implicitly and the value of this property is ignored.
This property should be set to
true
if the server uses a certificate that has been signed by a CA that is contained in the standard trust store that the JVM is configured to use. In this case the trustStorePath does not need to be set.- Parameters:
enabled
-true
if the server identity should be verified.
-
setServerRole
public final void setServerRole(String roleName)
Sets the name of the role that the server plays from the client's perspective.The default value of this property is unknown.
- Parameters:
roleName
- The name.- Throws:
NullPointerException
- if name isnull
.
-
getServerRole
public final String getServerRole()
Gets the name of the role that the server plays from the client's perspective.The default value of this property is unknown.
- Returns:
- The name.
-
-