Package net.sf.basedb.util.uri
Class ConnectionParameters
java.lang.Object
net.sf.basedb.util.uri.ConnectionParameters
Connection parameters, such as username/password, that may be needed
to connect to a server.
- Since:
- 3.0
- Author:
- Nicklas
- Last modified
- $Date: 2018-04-09 15:23:53 +0200 (må, 09 apr 2018) $
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionchangeHost
(URI uri) If the connection parameters include a specific host:port or root path a new URI is created were the host:port is replaced and the root path is added to the URI path.static ConnectionParameters
create
(FileServerData fileServer) Create a parameters object using information from theFileServer
object.byte[]
Get the client certificate that BASE should use to authenticate with the server when connecting using SSL.Get the password that is needed to unlock the client certificate.Get the connection manager factory that we should use to access the file, or null to use auto-detection.getHost()
Get the host:port that should override the host:port specified by the file URI.Get the password that should be used to authenticate the user.Get the root path that must be added to all URI:s used with these connection parameters.byte[]
Get the public server certificate that indicates that we should only trust the server if it can present a certificate that matches this.Get the SSH fingerprint of the server.byte[]
Get the private key that should be used to authenticate with the server when connecting using SSH.Get the format of the SSH private key (if known).Get the password that is needed to unlock the SSH private key.Get the username that should be used to authenticate the user.void
setClientCertificate
(byte[] certificate) void
setClientCertificatePassword
(String password) void
setConnectionManagerFactoryId
(String factoryId) void
void
setPassword
(String password) void
setRootPath
(String rootPath) void
setServerCertificate
(byte[] certificate) void
setSshFingerprint
(String sshFingerprint) void
setSshPrivateKey
(byte[] sshPrivateKey) void
setSshPrivateKeyFormat
(String format) void
setSshPrivateKeyPassword
(String password) void
setUsername
(String username)
-
Field Details
-
factoryId
-
host
-
username
-
password
-
rootPath
-
sshFingerprint
-
sshPrivateKey
private byte[] sshPrivateKey -
sshPrivateKeyPassword
-
sshPrivateKeyFormat
-
serverCertificate
private byte[] serverCertificate -
clientCertificate
private byte[] clientCertificate -
clientCertificatePassword
-
-
Constructor Details
-
ConnectionParameters
public ConnectionParameters()Create a new empty parameters object.
-
-
Method Details
-
create
Create a parameters object using information from theFileServer
object. -
getConnectionManagerFactoryId
Get the connection manager factory that we should use to access the file, or null to use auto-detection. -
setConnectionManagerFactoryId
-
getHost
Get the host:port that should override the host:port specified by the file URI. -
setHost
-
getUsername
Get the username that should be used to authenticate the user. -
setUsername
-
getPassword
Get the password that should be used to authenticate the user. -
setPassword
-
getRootPath
Get the root path that must be added to all URI:s used with these connection parameters.- Since:
- 3.3
-
setRootPath
-
getServerCertificate
public byte[] getServerCertificate()Get the public server certificate that indicates that we should only trust the server if it can present a certificate that matches this. This property is typically only needed when using SSL to access servers that has a self-signed certificate. Servers which has a certificate signed by a trusted certification authority should be automatically trusted by BASE without this property. The certificate is a X.509 certificate in either binary or base64-encoded DER format.- Returns:
- A byte array with the certificate or null if no certificate has been set
- See Also:
-
setServerCertificate
public void setServerCertificate(byte[] certificate) -
getClientCertificate
public byte[] getClientCertificate()Get the client certificate that BASE should use to authenticate with the server when connecting using SSL. This property is typically needed when the server requires clients to authenticate themselves using a certificate. The certificate must be a PKCS #12 certificate in binary format, and it should contain only one certificate.- Returns:
- A byte array with the certificate or null if no certificate has been set
- See Also:
-
setClientCertificate
public void setClientCertificate(byte[] certificate) -
getClientCertificatePassword
Get the password that is needed to unlock the client certificate.- Returns:
- The password (which may be null)
-
setClientCertificatePassword
-
getSshFingerprint
Get the SSH fingerprint of the server. Should be used to verify the connection when connecting via SSH.- Since:
- 3.3
-
setSshFingerprint
-
getSshPrivateKey
public byte[] getSshPrivateKey()Get the private key that should be used to authenticate with the server when connecting using SSH.- Since:
- 3.13
-
setSshPrivateKey
public void setSshPrivateKey(byte[] sshPrivateKey) -
getSshPrivateKeyPassword
Get the password that is needed to unlock the SSH private key.- Returns:
- The password (which may be null)
- Since:
- 3.13
-
setSshPrivateKeyPassword
-
getSshPrivateKeyFormat
Get the format of the SSH private key (if known).- Returns:
- The private key format (or null to try auto-detection)
- Since:
- 3.13
-
setSshPrivateKeyFormat
-
changeHost
If the connection parameters include a specific host:port or root path a new URI is created were the host:port is replaced and the root path is added to the URI path. Otherwise the original URI is returned unmodified.- Parameters:
uri
- The URI to change- Returns:
- The new URI
- Throws:
PermissionDeniedException
- If the given URI tries to move outside the root path by including '..' to step up one or more levels
-