Package net.sf.basedb.opengrid.config
Class ConnectionInfo
java.lang.Object
net.sf.basedb.opengrid.config.AbstractLockable<ConnectionInfo>
net.sf.basedb.opengrid.config.ConnectionInfo
Informatation such as the address, port, SSH fingerprint and login
information that is needed to connect via SSH to the cluster.
The information becomes readonly when a
OpenGridCluster
instance
has been created.- Since:
- 1.0
- Author:
- nicklas
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCreate a new connection information instance.ConnectionInfo
(FileServer server) Create a new connection information and use the information in the file server for configuration.ConnectionInfo
(ConnectionInfo clone) Create a new connection information instance and clone the connection information from the given instance. -
Method Summary
Modifier and TypeMethodDescriptionorg.json.simple.JSONObject
asJSONObject
(JSONOptions options) Get the configuration information as a JSON object.protected void
checkValid
(boolean forLock) Address, fingerprint and user are required.Get the internet address of the primary node.Get the public key SSH fingerprint of the primary node.Get the fingerprint type.getName()
Get the display name of the cluster.Get the password to use when connecting to the primary node.int
getPort()
Get the port number to use for connecting to the primary node.Get the private key to use when connecting to the primary node.Get the format of the private key (null = auto-detect)Get the password for unlocking the private key.getUser()
Get the username to use when connecting to the primary node.void
setAddress
(String address) Set the internet address to the primary node.void
setFingerPrint
(String fingerprint) Set the public key fingerprint for the host so we can verify that the connection is made to the exepected SSH server.void
Set the display name of the cluster.void
setPassword
(String password) Set the password to use for connecting to the primary node.void
setPort
(int port) Set the port number to use for connecting to the primary node.void
setPrivateKey
(String privateKey) Set the private key to use for connecting to the primary node.void
setPrivateKeyFormat
(String privateKeyFormat) Set the format of the private key (null = auto-detect).void
setPrivateKeyPassword
(String privateKeyPassword) Set the password to use for unlocking the private key.void
Set the username to use for connecting to the primary node.toString()
Methods inherited from class net.sf.basedb.opengrid.config.AbstractLockable
checkLocked, isLocked, isValid, lock
-
Field Details
-
name
-
address
-
port
private int port -
fingerprint
-
fingerPrintType
-
user
-
password
-
privateKey
-
privateKeyFormat
-
privateKeyPassword
-
-
Constructor Details
-
ConnectionInfo
public ConnectionInfo()Create a new connection information instance. The port is set to 22 by default. All other properties need to be set before anOpenGridCluster
instance can be created. After that this instance become locked and it is no longer possible to modify the parameters. -
ConnectionInfo
Create a new connection information instance and clone the connection information from the given instance. The new instance will be unlocked.- Parameters:
clone
- The instance to clone from
-
ConnectionInfo
Create a new connection information and use the information in the file server for configuration. The file server should have all required settings or they need to be provided before a connection can be made.- Parameters:
server
- A FileServer instance to take parameters from
-
-
Method Details
-
getName
Get the display name of the cluster. -
setName
Set the display name of the cluster.- Throws:
IllegalStateException
- If this instance has been locked
-
getAddress
Get the internet address of the primary node. -
setAddress
Set the internet address to the primary node.- Throws:
IllegalStateException
- If this instance has been locked
-
getPort
public int getPort()Get the port number to use for connecting to the primary node. -
setPort
public void setPort(int port) Set the port number to use for connecting to the primary node.- Throws:
IllegalStateException
- If this instance has been locked
-
getFingerPrint
Get the public key SSH fingerprint of the primary node. This is used to verify that we are connecting to the expected host and not to a man-in-the-middle. The fingerprint is a string containing 16 pairs of hexadecimal numbers separated with colon. -
setFingerPrint
Set the public key fingerprint for the host so we can verify that the connection is made to the exepected SSH server. The fingerprint is a string containing 16 pairs of hexadecimal numbers separated with colon.- Throws:
IllegalStateException
- If this instance has been lockedIllegalArgumentException
- If the fingerprint is not 16 pairs of hexadecimal numbers separated with colon
-
getFingerPrintType
Get the fingerprint type. Automatically updated by thesetFingerPrint(String)
method. -
getUser
Get the username to use when connecting to the primary node. -
setUser
Set the username to use for connecting to the primary node.- Throws:
IllegalStateException
- If this instance has been locked
-
getPassword
Get the password to use when connecting to the primary node. -
setPassword
Set the password to use for connecting to the primary node.- Throws:
IllegalStateException
- If this instance has been locked
-
getPrivateKey
Get the private key to use when connecting to the primary node.- Since:
- 1.2
-
setPrivateKey
Set the private key to use for connecting to the primary node.- Throws:
IllegalStateException
- If this instance has been locked- Since:
- 1.2
-
getPrivateKeyFormat
Get the format of the private key (null = auto-detect)- Since:
- 1.2
-
setPrivateKeyFormat
Set the format of the private key (null = auto-detect). Supported values are: - OpenSSH - OpenSSHv1 - PuTTY - PKCS5 - PKCS8- Throws:
IllegalStateException
- If this instance has been locked- Since:
- 1.2
-
getPrivateKeyPassword
Get the password for unlocking the private key.- Since:
- 1.2
-
setPrivateKeyPassword
Set the password to use for unlocking the private key.- Throws:
IllegalStateException
- If this instance has been locked- Since:
- 1.2
-
checkValid
protected void checkValid(boolean forLock) Address, fingerprint and user are required. The fingerprint must be a valid string (seeSshUtil.FINGERPRINT_PATTERN
). The port number must be a positive integer.- Overrides:
checkValid
in classAbstractLockable<ConnectionInfo>
- Parameters:
forLock
- If TRUE, the instance will be locked after validation
-
toString
-
asJSONObject
Get the configuration information as a JSON object. By default the following properties are exposed: - name - address - port - fingerprint - fingerprintType - user If theJSONOption.CONNECTION_PASSWORD
option is enabled the password is also included. If theJSONOption.PRIVATE_KEY
option is enabled the private key (and password) is also included.
-