Class ServerSettings

    • Field Detail

      • CONFIG_FILE_EXT

        public static final java.lang.String CONFIG_FILE_EXT
        The extension of the iiziServer configuration file: ".iiziServer".
        See Also:
        Constant Field Values
      • CONFIG_FILE_DEFAULT_BASE_NAME

        public static final java.lang.String CONFIG_FILE_DEFAULT_BASE_NAME
        Default base name without file extension of the iiziServer configuration file: "config".
        See Also:
        Constant Field Values
      • CONFIG_FILE_DEFAULT_NAME

        public static final java.lang.String CONFIG_FILE_DEFAULT_NAME
        Default name of the iiziServer configuration file: "config.iiziServer".
        See Also:
        Constant Field Values
      • DEFAULT_SERVER_CONFIG_ENV

        public static final java.lang.String DEFAULT_SERVER_CONFIG_ENV
        The default server configuration environment.
        See Also:
        Constant Field Values
      • IDLE_TIMEOUT

        public static final java.lang.String IDLE_TIMEOUT
        Timeout before a client session is disposed when it has not processes any transactions, default 2 hours. Range is 2 minutes to 2 days. The idle timeout includes dormant session timeout.
        See Also:
        Constant Field Values
      • DORMANT_TIMEOUT

        public static final java.lang.String DORMANT_TIMEOUT
        Timeout before an app session is disposed of when no more client sessions are present, default 10 minutes. Range is 30 seconds to 12 hours.
        See Also:
        Constant Field Values
      • HEARTBEAT_INTERVAL

        public static final java.lang.String HEARTBEAT_INTERVAL
        Heartbeat interval in seconds to keep communication link up, default 45 seconds. Range is 30 seconds to 5 minutes.
        See Also:
        Constant Field Values
      • TRANS_CACHE_MIN

        public static final java.lang.String TRANS_CACHE_MIN
        Property name of "minimum string length of a transactional cache".
        See Also:
        Constant Field Values
      • TRANS_CACHE_MAX

        public static final java.lang.String TRANS_CACHE_MAX
        Property name of "maximum string length of a transactional cache".
        See Also:
        Constant Field Values
      • TRANS_CACHE_COUNT

        public static final java.lang.String TRANS_CACHE_COUNT
        Property name of "count of strings in transactional cache".
        See Also:
        Constant Field Values
      • EXTERNAL_SERVER_URL

        public static final java.lang.String EXTERNAL_SERVER_URL
        Property name for external server URL, including protocol and potential port number (if different from protocol port).

        This setting must be set if the retrieval of the local host name e.g. does not include the domain DNS suffix, or that the name is known on external nets differently than on the internal network. This host name is typically used for the OAuth 2.0 authentication callback URL's.

        See Also:
        Constant Field Values
      • DIR_LIST

        public static final java.lang.String DIR_LIST
        Property name for "directory listing allowed".
        See Also:
        Constant Field Values
      • WS_IDLE_TIMEOUT

        public static final java.lang.String WS_IDLE_TIMEOUT
        The web server maximum thread idle time settings.
        See Also:
        Constant Field Values
      • WS_MAX_THREADS

        public static final java.lang.String WS_MAX_THREADS
        The web server maximum number of threads setting.
        See Also:
        Constant Field Values
      • WS_MIN_THREADS

        public static final java.lang.String WS_MIN_THREADS
        The web server minimum number of threads setting.
        See Also:
        Constant Field Values
      • WS_RESERVED_THREADS

        public static final java.lang.String WS_RESERVED_THREADS
        The web server number of reserved threads setting.
        See Also:
        Constant Field Values
      • REALM_PROPERTIES

        public static final java.lang.String REALM_PROPERTIES
        The file name for authentication realm properties, default "authentication-realm-properties.txt" in the current directory of the server.
        See Also:
        Constant Field Values
      • AUTH_BASIC

        public static final java.lang.String AUTH_BASIC
        Authentication required: basic.
        See Also:
        Constant Field Values
      • MAX_SERVER_KEY_AGE

        public static final java.lang.String MAX_SERVER_KEY_AGE
        Maximum server key age in days: "maxServerKeyAge".
        See Also:
        Constant Field Values
      • DEFAULT_MAX_SERVER_KEY_AGE

        public static final int DEFAULT_MAX_SERVER_KEY_AGE
        Default value for maximum server key age: 90 days.
        See Also:
        Constant Field Values
      • FILE_PROVIDER_ROOT

        public static final java.lang.String FILE_PROVIDER_ROOT
        Root directory relative the server's current directory where to place external files provided for remote usage over the web server.
        See Also:
        Constant Field Values
      • DEFAULT_FILE_PROVIDER_ROOT

        public static final java.lang.String DEFAULT_FILE_PROVIDER_ROOT
        The default directory for the file provider root.
        See Also:
        Constant Field Values
      • URLBOX_IO_API_KEY

        public static final java.lang.String URLBOX_IO_API_KEY
        The "urlbox.io" API key. You will find this key on your Dashboard when you login to "urlbox.io".
        See Also:
        Constant Field Values
      • MAX_CONCURRENT_THUMBNAILS_COUNT

        public static final java.lang.String MAX_CONCURRENT_THUMBNAILS_COUNT
        The maximum count of current thumbnail requests to "urlbox.io", default 10.

        Be careful not to exceed your quota, there are different plans available.

        See Also:
        Constant Field Values
      • DEFAULT_MAX_CONCURRENT_THUMBNAILS_COUNT

        public static final int DEFAULT_MAX_CONCURRENT_THUMBNAILS_COUNT
        The default maximum count of current thumbnail requests to "urlbox.io", default 5.
        See Also:
        Constant Field Values
      • MAX_HISTORY_LOCATION

        public static final java.lang.String MAX_HISTORY_LOCATION
        The maximum history size for geolocation entries per user.
        See Also:
        Constant Field Values
      • DEFAULT_MAX_HISTORY_LOCATION

        public static final int DEFAULT_MAX_HISTORY_LOCATION
        The default maximum history size for geolocation entries per user.
        See Also:
        Constant Field Values
      • DB_AUTO_CREATE

        public static final java.lang.String DB_AUTO_CREATE
        Database tables auto-creation flag, default true.
        See Also:
        Constant Field Values
      • DB_DIRECTORY

        public static final java.lang.String DB_DIRECTORY
        Database directory (local embedded Derby), default "db".
        See Also:
        Constant Field Values
      • DB_HOST

        public static final java.lang.String DB_HOST
        Database server host name or address (remote Derby).
        See Also:
        Constant Field Values
      • DB_PORT

        public static final java.lang.String DB_PORT
        Database server port number, default 1527.
        See Also:
        Constant Field Values
      • DB_AUTO_START

        public static final java.lang.String DB_AUTO_START
        Database server auto-start (Derby Database Server running on same machine), default true.
        See Also:
        Constant Field Values
      • DB_MAX_FILE_COUNT

        public static final java.lang.String DB_MAX_FILE_COUNT
        Maximum number of cached database files.
        See Also:
        Constant Field Values
      • DEFAULT_DB_MAX_FILE_COUNT

        public static final int DEFAULT_DB_MAX_FILE_COUNT
        Default maximum number of cached database files: 10_000.
        See Also:
        Constant Field Values
      • DB_MAX_FILE_AGE

        public static final java.lang.String DB_MAX_FILE_AGE
        Maximum age of cached database files: milliseconds.
        See Also:
        Constant Field Values
      • DEFAULT_DB_MAX_FILE_AGE

        public static final long DEFAULT_DB_MAX_FILE_AGE
        Default maximum age of cached database files: 90 days or 7_776_000_000 milliseconds.
        See Also:
        Constant Field Values
      • LOGFILE_NAME

        public static final java.lang.String LOGFILE_NAME
        Log file name.
        See Also:
        Constant Field Values
      • DEFAULT_LOGFILE_NAME

        public static final java.lang.String DEFAULT_LOGFILE_NAME
        Default log file name.
        See Also:
        Constant Field Values
      • MAX_LOGFILE_SIZE

        public static final java.lang.String MAX_LOGFILE_SIZE
        Max size of log file before new file.
        See Also:
        Constant Field Values
      • DEFAULT_MAX_LOGFILE_SIZE

        public static final int DEFAULT_MAX_LOGFILE_SIZE
        Default max log file size in MB = 50 MB, undefined = unlimited (-1).
        See Also:
        Constant Field Values
      • DEFAULT_LOG_LEVEL

        public static final int DEFAULT_LOG_LEVEL
        Default log level = ILog.INFO.
        See Also:
        Constant Field Values
      • LOG_TO_CONSOLE

        public static final java.lang.String LOG_TO_CONSOLE
        Log to console.
        See Also:
        Constant Field Values
      • LOG_HISTORY_SIZE

        public static final java.lang.String LOG_HISTORY_SIZE
        The history size.
        See Also:
        Constant Field Values
      • LOG_COMPRESS

        public static final java.lang.String LOG_COMPRESS
        Old log compression: 0=none, 1=gzip (default), 2=xz.
        See Also:
        Constant Field Values
      • DEFAULT_LOG_HISTORY_SIZE

        public static final int DEFAULT_LOG_HISTORY_SIZE
        Default history size = 500.
        See Also:
        Constant Field Values
      • ALLOW_UPLOAD

        public static final java.lang.String ALLOW_UPLOAD
        Flag to allow file upload, default false.
        See Also:
        Constant Field Values
      • MAX_UPLOAD_SIZE

        public static final java.lang.String MAX_UPLOAD_SIZE
        Maximum upload size in MB.
        See Also:
        Constant Field Values
      • DEFAULT_MAX_UPLOAD_SIZE

        public static final int DEFAULT_MAX_UPLOAD_SIZE
        Default maximum upload size: 50 MB.
        See Also:
        Constant Field Values
      • UPLOAD_DIRECTORY

        public static final java.lang.String UPLOAD_DIRECTORY
        Directory name for file upload.
        See Also:
        Constant Field Values
      • DEFAULT_UPLOAD_DIRECTORY

        public static final java.lang.String DEFAULT_UPLOAD_DIRECTORY
        Default directory name for file upload = "uploads";
        See Also:
        Constant Field Values
    • Constructor Detail

      • ServerSettings

        public ServerSettings()
        Creates the server settings without a name. The name must be set in all cases using the setPropertyAtom call.
      • ServerSettings

        public ServerSettings​(Atom atom)
        Creates the server settings with a name.
        Parameters:
        atom - The name of the property.
    • Method Detail

      • addPredefinedProps

        protected void addPredefinedProps()
                                   throws PropException
        Adds the predefined containers for identifications, fields and actions. This method is overridden fully by the Editor versions of the class.
        Overrides:
        addPredefinedProps in class PropCnr
        Throws:
        PropException - for property exceptions.
      • clone

        public ServerSettings clone()
        Creates a clone out of this property. The cloning is overridden by the subclasses in order to handle cloning of its class variables appropriately.
        Overrides:
        clone in class PropCnr
      • getDescription

        public java.lang.String getDescription()
        Gets the description of the Server.
        Specified by:
        getDescription in interface IServerSettings
        Returns:
        The description, "iizi Server" for default.
      • getLogFileName

        public java.lang.String getLogFileName()
        Gets the log file name.
        Returns:
        The log file name, default "logs/server.log".
      • getMaximumLogFileSize

        public long getMaximumLogFileSize()
        Gets the maximum log file size.
        Returns:
        The maximum log file size, zero for no maximum.
      • getLogLevel

        public int getLogLevel()
        Gets the log level to use.
        Returns:
        The log level as defined in ILog, range is ILog.SEVERE to ILog.FINEST.
      • getLogToConsole

        public boolean getLogToConsole()
        Logging output also to console.
        Returns:
        true to write log to console as well as to log file, default true.
      • getLogHistorySize

        public int getLogHistorySize()
        Gets the history size for events kept in-memory for the server administration program to retrieve.
        Returns:
        The number of events, minimum 100, maximum 5000, default 500.
      • getAdministratorPasswordPolicy

        public PasswordPolicy getAdministratorPasswordPolicy()
        Gets the password policy for administrators.
        Returns:
        The password policy settings for administrators.
      • getUserPasswordPolicy

        public PasswordPolicy getUserPasswordPolicy()
        Gets the password policy for users.
        Returns:
        The password policy settings for normal users.
      • createPolicyProps

        protected PolicyProps createPolicyProps​(Atom atom)
        Creates a policy property with the specified atom name.
        Parameters:
        atom - The atom name.
        Returns:
        The policy property.
      • setExternalHostName

        public boolean setExternalHostName​(java.lang.String extServerURL)
        Sets the external server URL, including protocol and potential port number (if different from protocol port).

        This setting must be set if the retrieval of the local host name e.g. does not include the domain DNS suffix, or that the name is known on external nets differently than on the internal network. This host name is typically used for the OAuth 2.0 authentication callback URL's.

        Parameters:
        extServerURL - The URL to use.
        Returns:
        true when this property container has been changed, false otherwise (or for error).
        Throws:
        java.lang.NullPointerException - If extHostName is null.
        java.lang.IllegalArgumentException - If extHostName is empty or not valid.
      • getExternalHostName

        public java.lang.String getExternalHostName()
        Gets the external server URL, including protocol and potential port number (if different from protocol port).

        This setting must be set if the retrieval of the local host name e.g. does not include the domain DNS suffix, or that the name is known on external nets differently than on the internal network. This host name is typically used for the OAuth 2.0 authentication callback URL's.

        Returns:
        The URL, or null for none.
      • setRootDirectory

        public boolean setRootDirectory​(java.lang.String root)
                                 throws java.io.IOException
        Sets the root directory for external files. This call is done from a server instance when e.g. the command line overrides the default root in the settings.
        Parameters:
        root - The new root.
        Returns:
        true when this property container has been changed, false otherwise (or for error).
        Throws:
        java.io.IOException - If the directory does not exist.
      • getRootDirectory

        public java.lang.String getRootDirectory()
        Gets the root directory for external files. If the directory doesn't exist it will be created.
        Specified by:
        getRootDirectory in interface IServerSettings
        Returns:
        The root directory or "/iiziServer/root" (of the current drive for Windows) if none is specified. The return String is null if the directory cannot be created if not present, or the root is not a readable and writable directory. At the same time, logging will occur.
      • isDirectoryListingAllowed

        public boolean isDirectoryListingAllowed()
        Flag for directory listing allowed.
        Specified by:
        isDirectoryListingAllowed in interface IServerSettings
        Returns:
        The flag allowing directory listing of the web servers root and subdirectories, default false.
      • useGzip

        public boolean useGzip()
        Flag if Gzip compression should be used in the web server.
        Specified by:
        useGzip in interface IServerSettings
        Returns:
        true to enable Gzip (default), false otherwise.
      • getWSMaxThreads

        public int getWSMaxThreads()
        Get the web server maximum number of threads, default is 200. Range is 20 to 1024, always larger or equal to the minimum threads. An out-of-range value will give the default.
        Specified by:
        getWSMaxThreads in interface IServerSettings
        Returns:
        The maximum number of threads.
      • getWSMinThreads

        public int getWSMinThreads()
        Get the web server minimum number of threads, default is 8. Range is 20 to 1024, always smaller or equal to the minimum threads. An out-of-range value will give the default.
        Specified by:
        getWSMinThreads in interface IServerSettings
        Returns:
        Minimum number of threads.
      • getWSReservedThreads

        public int getWSReservedThreads()
        Get the web server number of reserved threads, default to -1. Range is -1, or 8-64. An out-of-range value will give the default -1.
        Specified by:
        getWSReservedThreads in interface IServerSettings
        Returns:
        Number of reserved threads or -1 for heuristically determined.
      • getWSIdleTimeout

        public int getWSIdleTimeout()
        Get the web server maximum thread idle time, default is 60 seconds, 60_000 milliseconds. Range is 5_000 (5 seconds) to 300_000 (5 minutes). An out-of-range value will give the default.
        Specified by:
        getWSIdleTimeout in interface IServerSettings
        Returns:
        Max idle time in ms.
      • getFileProviderRoot

        public java.lang.String getFileProviderRoot()
        Gets the root directory relative the server's current directory where to place external files provided for remote usage over the web server.
        Returns:
        The root directory name, relative (or absolute path), "wsfiles" as default.
      • getRealmPropertiesFileName

        public java.lang.String getRealmPropertiesFileName()
        Gets the file name for the authentication realm properties.
        Specified by:
        getRealmPropertiesFileName in interface IServerSettings
        Returns:
        The file name, or "authentication-realm-properties.txt" if undefined.
      • getAuthenticationRealm

        public java.lang.String getAuthenticationRealm()
        Gets the realm for authentication.
        Specified by:
        getAuthenticationRealm in interface IServerSettings
        Returns:
        The realm string, "iiziServer Authentication" if not defined or empty String.
      • isBasicAuthenticationEnabled

        public boolean isBasicAuthenticationEnabled()
        Checks if basic authentication should be used.
        Specified by:
        isBasicAuthenticationEnabled in interface IServerSettings
        Returns:
        The flag for authentication enabled.
      • getUrlboxIOAPIKey

        public java.lang.String getUrlboxIOAPIKey()
        Gets the "urlbox.io" API key.

        You will find this key on your Dashboard when you login to "urlbox.io".

        Returns:
        The configured API key, empty string for none.
      • getMaxConcurrentThumbnailsRequests

        public int getMaxConcurrentThumbnailsRequests()
        The maximum count of current thumbnail requests to "urlbox.io", default 5.

        Be careful not to exceed your quota, there are different plans available.

      • isFileUploadEnabled

        public boolean isFileUploadEnabled()
        Checks if file upload is enabled or not.
        Returns:
        The upload enablement flag, false by default.
      • getMaximumUploadFileSize

        public int getMaximumUploadFileSize()
        Returns the maximum size of any uploaded file in MB.
        Returns:
        The file size in MB, default 50 MB.
      • getFileUploadStagingDirectory

        public java.lang.String getFileUploadStagingDirectory()
        Gets the upload directory where files are placed in a staging area.
        Returns:
        The directory name, relative the server's current directory.
      • getMaximumGeolocationHistorySizePerUser

        public int getMaximumGeolocationHistorySizePerUser()
        Gets the maximum number of geolocation entries per user in the history.
        Returns:
        The maximum number of locations, default 100, minimum 10, maximum 10000.
      • getClientIdleTimeout

        public long getClientIdleTimeout()
        Gets the timeout before a client session is disposed when it has not processes any transactions, default 2 hours. Range is 2 minutes to 2 days. The idle timeout includes dormant session timeout.
        Returns:
        Value in milliseconds.
      • getClientDormantTimeout

        public long getClientDormantTimeout()
        Timeout before an app session is disposed of when no more client sessions are present, default 10 minutes. Range is 30 seconds to 12 hours.
        Returns:
        Value in milliseconds.
      • getClientHeartBeatInterval

        public long getClientHeartBeatInterval()
        Heartbeat interval in seconds to keep communication link up, default 45 seconds. Range is 30 seconds to 5 minutes.
        Returns:
        Value in milliseconds (between 45_000L and 300_000L).
      • getMaximumServerKeyAge

        public int getMaximumServerKeyAge()
        Gets the maximum server key age in days.
        Returns:
        A value between 7 and 365 in days.
      • setCacheParams

        public void setCacheParams​(int minLength,
                                   int maxLength,
                                   int count)
        Sets the parameters for cache: minLength, maxLength, count.
        Parameters:
        minLength - The minimum length for caching, 7 is the smallest value.
        maxLength - The maximum length for caching, normally 80 or so (maximum 1024).
        count - The count should normally be larger than 200 and smaller than 1000 (maximum 2048).
        Throws:
        java.lang.IllegalArgumentException - If arguments are not valid.
      • getCacheParams

        public int[] getCacheParams()
        Gets the cache parameters as 3 integers in an array, param[0] is minLength, param[1] is maxLength, param[2] is count.

        The default values are minLength=7, maxLength=80, count=700 if nothing is specified.

        Specified by:
        getCacheParams in interface IServerSettings
        Returns:
        Array of 3 integer parameters, param[0] is minLength, param[1] is maxLength, param[2] is count.
      • getLetsEncryptDomains

        public LetsEncryptDomain[] getLetsEncryptDomains()
        Gets the Let's Encrypt domains.
        Returns:
        The array of Let's Encrypt domains.
      • getDefaultServerConfigurationEnvironmentName

        public java.lang.String getDefaultServerConfigurationEnvironmentName()
        Gets the default Server configuration environment name.
        Returns:
        The defined default Server configuration environment name, or "default" if such definition is not done.
      • getServerConfigEnvironment

        public ServerConfigEnvProps getServerConfigEnvironment​(java.lang.String name)
        Gets the configuration environment of a name.
        Parameters:
        name - The name (e.g. "test", "development" or "production"), or null for default configuration environment name.
        Returns:
        The configuration setup, or null if not found.
      • getServerConfigEnvironments

        public ServerConfigEnvProps[] getServerConfigEnvironments()
        Gets the array of configuration environments present.
      • onServerSettingsChanged

        protected void onServerSettingsChanged()
        Called when loaded to update the ServerProps instance.
      • getDBCacheMaxFileCount

        public int getDBCacheMaxFileCount()
        Gets the maximum number of cached database files.
        Returns:
        Maximum number of files, minimum 100, default 10_000.
      • getDBCacheMaxFileAge

        public long getDBCacheMaxFileAge()
        Gets the maximum file age of cached database files.
        Returns:
        Maximum age in milliseconds of files: minimum 1 hour, default 90 days.
      • verify

        public boolean verify​(PropVerification verification)
        Verifies this property container. The check performed is the extension of classes and that no circular reference is present.
        Specified by:
        verify in interface IGProp<GProp<?>[]>
        Overrides:
        verify in class PropCnr
        Parameters:
        verification - The property verification class.
        Returns:
        true if verification should proceed, false if disposed of and verification should not take place.
      • onApplicationUnload

        public void onApplicationUnload​(AppFactory app)
        Called when the application is unloaded.
        Parameters:
        app - The application begin unloaded.
      • onApplicationSessionStarted

        public void onApplicationSessionStarted​(AppSessionGyro appGyro)
        Called when an application is instantiated and started by a user session.
      • onApplicationSessionStopped

        public void onApplicationSessionStopped​(AppSessionGyro appGyro)
        Called when an application is stopped.
      • getMailSender

        public MailSender getMailSender​(java.lang.String name,
                                        java.util.concurrent.ExecutorService executorService,
                                        java.io.File baseDir)
                                 throws NotFoundException,
                                        AddressException,
                                        NoSuchProviderException,
                                        java.io.IOException
        Gets the mail sender with the specified name.
        Parameters:
        name - The mail properties name, null for default.
        executorService - The executor service.
        baseDir - The base directory where the server is (generally current directory).
        Returns:
        The mail sender.
        Throws:
        NotFoundException - If the mail sender is not found.
        java.io.IOException - If the mail queue directory does not exist.
        NoSuchProviderException - If the "smtp" or "smtps" providers do not exist!
        AddressException - If the default sender failed to parse.
      • getRegionLocationGlobalCacheSize

        public int getRegionLocationGlobalCacheSize()
        Gets the global cache size for the region location service providers.
        Returns:
        A value between 100 and 100_000, default is 20_000.
      • getRegionLocationAPIKey

        public java.lang.String getRegionLocationAPIKey​(java.lang.String providerName)
        Gets the API key for a region location service provider.
        Parameters:
        providerName - The provider name, e.g. "IPStack.com".
        Returns:
        The API key, or null if not configured.