Class FileServer

    • Method Detail

      • getNew

        public static FileServer getNew​(DbControl dc)
                                 throws BaseException
        Create a new FileServer item.
        Parameters:
        dc - The DbControl which will be used for permission checking and database access
        Returns:
        The new FileServer item
        Throws:
        BaseException - If there is an error
      • getType

        public Item getType()
        Description copied from interface: Identifiable
        Get the type of item represented by the object. The returned value is one of the values defined in the Item enumeration.
        Returns:
        A value indicating the type of item
      • getConnectionManagerFactoryId

        public String getConnectionManagerFactoryId()
        Get the ID of the connection manager factory that should be used to access file contents and metadata. A null value mean that auto-detection based on the file URI should be used.
        Returns:
        An ID or null if using auto-detection
      • getHost

        public String getHost()
        Get the name:port of the host that should override the host:port in the file url for files using this file server.
        Returns:
        A string or null if no override should be done.
        Since:
        3.0
      • getUsername

        public String getUsername()
        Get the username that is required to authenticate with the file server.
        Returns:
        A username or null if authentication is not required
      • getPassword

        public String getPassword()
        Get the password that is used when authenticating with the file server. NOTE! Write permission is required to read the password.
        Returns:
        The password (which may be null)
        See Also:
        hasPassword()
      • hasPassword

        public boolean hasPassword()
        Is a password set or not?
      • 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 to access servers using https that has a self-signed certificate. Servers which has a valid certificate signed by a trusted certification authority should be automatically trusted by BASE without setting this property. The certificate must be 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:
        getServerX509Certificate()
      • setServerCertificate

        public void setServerCertificate​(byte[] certificate)
        Set the public server certificate so that BASE can trust https connections to the server. See getServerCertificate() for more information. The certificate must be a X.509 certificate in either binary or base64-encoded DER format.
        Parameters:
        certificate - The server certificate or null if no certificate is required
      • getServerX509Certificate

        public X509Certificate getServerX509Certificate()
        Get the X.509 certificate for the server.
        Returns:
        The server certificate or null if no certificate has been specified
      • getClientCertificate

        public byte[] getClientCertificate()
        Get the client certificate that BASE should use to authenticate with the server when connecting with https. 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. NOTE! WRITE permission is required to read this property since it may contain sensitive data, use getClientX509Certificate() to get the public information from the certificate.
        Returns:
        A byte array with the certificate or null if no certificate has been set
        See Also:
        getClientX509Certificate()
      • setClientCertificate

        public void setClientCertificate​(byte[] certificate)
        Set the client certificate that BASE should use to authenticate with the server when connecting with https. The certificate must be a PKCS #12 certificate in binary format, and it should contain only one certificate.
        Parameters:
        certificate - The client certificate or null if no certificate is required
      • getClientX509Certificate

        public X509Certificate getClientX509Certificate()
        Get the X.509 certificate for the client.
        Returns:
        The client certificate or null if no certificate has been specified
      • getClientCertificatePassword

        public String getClientCertificatePassword()
        Get the password that is needed to unlock the client certificate. NOTE! WRITE permission is required to read this property.
        Returns:
        The password (which may be null)
      • hasSshPrivateKey

        public boolean hasSshPrivateKey()
        Check if a SSH private key has been set on this file server.
        Since:
        3.13
      • getSshPrivateKey

        public byte[] getSshPrivateKey()
        Get the private key that BASE should use to authenticate with the server when connecting with SSH. This can be used as an alternate to password authentication. Note that BASE has no built-in support for SSH connections. See http://baseplugins.thep.lu.se/wiki/net.sf.basedb.xfiles for an extension which includes support for SSH.

        NOTE! WRITE permission is required to read this property since it may contain sensitive data.

        Returns:
        A byte array with the private key or null if no private key has been set
        Since:
        3.13
      • setSshPrivateKey

        public void setSshPrivateKey​(byte[] privateKey)
        Set the private that BASE should use to authenticate with the server when connecting with SSH.
        Parameters:
        privateKey - The private key data or null if no private key is required
        Since:
        3.13
      • getSshPrivateKeyPassword

        public String getSshPrivateKeyPassword()
        Get the password that is needed to unlock the SSH private key. NOTE! WRITE permission is required to read this property.
        Returns:
        The password (which may be null)
        Since:
        3.13
      • getSshPrivateKeyFormat

        public String getSshPrivateKeyFormat()
        Get the format of the SSH private key.
        Returns:
        The format (which may be null to use auto-detection)
        Since:
        3.13
      • setRootPath

        public void setRootPath​(String rootPath)
        Set the root path that should be added to all URI:s when used with this file server. Eg. if URI specify http://myhost.com/path/to/file it is converted to http://myhost.com/rootPath/path/to/file
        Parameters:
        rootPath - The root path or null to not use any root path
        Since:
        3.3
      • setSshFingerprint

        public void setSshFingerprint​(String fingerprint)
        Set the SSH fingerprint for the server. Connections made to the server with SSH should be verified against this fingerprint to protect against man-in-the-middle attacks. If no fingerprint is present, the implementation may choose to reject or accept all connections.
        Parameters:
        fingerprint - The fingerprint or null to not use fingerprint
        Since:
        3.3
      • getFingerprintType

        public String getFingerprintType()
        Get the type of the SSH fingerprint.
        Returns:
        The fingerprint type or null if not known
        Since:
        3.11
      • getSSLSocketFactory2

        public org.apache.http.conn.ssl.SSLConnectionSocketFactory getSSLSocketFactory2()
        Get a socket factory that can be used to create SSL connections to the given server. If a server and/or client certificate has been specified for this file server the socket factory will be created with those certificates. Otherwise, the default (as configured in base.config) certificates are used.
        Returns:
        A SSL socket factory
      • getFiles

        public ItemQuery<File> getFiles()
        Get a query returning all files that has been registered with this server.