Class ConnectionParameters

java.lang.Object
net.sf.basedb.util.uri.ConnectionParameters

public class ConnectionParameters extends Object
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 Details

    • factoryId

      private String factoryId
    • host

      private String host
    • username

      private String username
    • password

      private String password
    • rootPath

      private String rootPath
    • sshFingerprint

      private String sshFingerprint
    • sshPrivateKey

      private byte[] sshPrivateKey
    • sshPrivateKeyPassword

      private String sshPrivateKeyPassword
    • sshPrivateKeyFormat

      private String sshPrivateKeyFormat
    • serverCertificate

      private byte[] serverCertificate
    • clientCertificate

      private byte[] clientCertificate
    • clientCertificatePassword

      private String clientCertificatePassword
  • Constructor Details

    • ConnectionParameters

      public ConnectionParameters()
      Create a new empty parameters object.
  • Method Details

    • create

      public static ConnectionParameters create(FileServerData fileServer)
      Create a parameters object using information from the FileServer object.
    • getConnectionManagerFactoryId

      public String getConnectionManagerFactoryId()
      Get the connection manager factory that we should use to access the file, or null to use auto-detection.
    • setConnectionManagerFactoryId

      public void setConnectionManagerFactoryId(String factoryId)
    • getHost

      public String getHost()
      Get the host:port that should override the host:port specified by the file URI.
    • setHost

      public void setHost(String host)
    • getUsername

      public String getUsername()
      Get the username that should be used to authenticate the user.
    • setUsername

      public void setUsername(String username)
    • getPassword

      public String getPassword()
      Get the password that should be used to authenticate the user.
    • setPassword

      public void setPassword(String password)
    • getRootPath

      public String getRootPath()
      Get the root path that must be added to all URI:s used with these connection parameters.
      Since:
      3.3
    • setRootPath

      public void setRootPath(String rootPath)
    • 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

      public String getClientCertificatePassword()
      Get the password that is needed to unlock the client certificate.
      Returns:
      The password (which may be null)
    • setClientCertificatePassword

      public void setClientCertificatePassword(String password)
    • getSshFingerprint

      public String getSshFingerprint()
      Get the SSH fingerprint of the server. Should be used to verify the connection when connecting via SSH.
      Since:
      3.3
    • setSshFingerprint

      public void setSshFingerprint(String sshFingerprint)
    • 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

      public String getSshPrivateKeyPassword()
      Get the password that is needed to unlock the SSH private key.
      Returns:
      The password (which may be null)
      Since:
      3.13
    • setSshPrivateKeyPassword

      public void setSshPrivateKeyPassword(String password)
    • getSshPrivateKeyFormat

      public String 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

      public void setSshPrivateKeyFormat(String format)
    • changeHost

      public URI changeHost(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. 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