Class Common


  • @Singleton
    public class Common
    extends java.lang.Object
    This class provides configuration properties that are common to all modules of JATOS. It mostly takes parameters from application.conf. It is initialized during JATOS start (triggered in GuiceConfig). Since most fields are initialized by the constructor during the JATOS' start (triggered in GuiceConfig), it's safe to access them via static getter methods.
    • Method Detail

      • getDurationWithDefaultUnit

        public java.time.Duration getDurationWithDefaultUnit​(com.typesafe.config.Config config,
                                                             java.lang.String path)
      • getJatosVersion

        public static java.lang.String getJatosVersion()
        JATOS version (full version e.g. v3.5.5-alpha)
      • getJatosApiVersion

        public static java.lang.String getJatosApiVersion()
        JATOS API version (different from JATOS version)
      • getBasepath

        public static java.lang.String getBasepath()
        JATOS' absolute base path without trailing '/.'
      • getStudyAssetsRootPath

        public static java.lang.String getStudyAssetsRootPath()
        Path in the file system to the study assets root directory. If the property is defined in the configuration file then use it as the base path. If property isn't defined, try in default study path instead.
      • isStudyLogsEnabled

        public static boolean isStudyLogsEnabled()
        Is study logging enabled
      • getStudyLogsPath

        public static java.lang.String getStudyLogsPath()
        Path in the file system where JATOS stores its logs for each study
      • isResultUploadsEnabled

        public static boolean isResultUploadsEnabled()
        Are file uploads via jatos.js allowed?
      • getResultUploadsPath

        public static java.lang.String getResultUploadsPath()
        Path in the file system where JATOS stores uploaded result files
      • getResultUploadsMaxFileSize

        public static long getResultUploadsMaxFileSize()
        Max file size in bytes for a single uploaded file
      • getResultUploadsLimitPerStudyRun

        public static long getResultUploadsLimitPerStudyRun()
        Max size of all files uploaded during a single study run in bytes
      • getResultDataMaxSize

        public static long getResultDataMaxSize()
        Maximal size of result data of one component result in Byte
      • getMaxResultsDbQuerySize

        public static int getMaxResultsDbQuerySize()
        Maximal number of results to be fetched from the DB at once
      • getUserSessionTimeout

        public static int getUserSessionTimeout()
        Time in minutes when the Play session will timeout (defined in application.conf)
      • getUserSessionInactivity

        public static int getUserSessionInactivity()
        Time in minutes a user can be inactive before they will be signed out (defined in application.conf)
      • getUserSessionAllowKeepSignedin

        public static boolean getUserSessionAllowKeepSignedin()
        If true, the user has the possibility (a checkbox on the GUI's signin page) to keep the user session and to not get signed out automatically due to user a session timeout (neither through normal timeout nor inactivity). If set to true and the user chooses to keep being signed in, the user session is kept until the user signs out manually or the session cookie is deleted.
      • getDbUrl

        public static java.lang.String getDbUrl()
        Database URL as defined in application.conf
      • usesMysql

        public static boolean usesMysql()
        Does JATOS use an MySQL database?
      • getDbDriver

        public static java.lang.String getDbDriver()
        Database driver as defined in application.conf
      • getDbConnectionPoolSize

        public static java.lang.String getDbConnectionPoolSize()
        Database connection pool size
      • getMac

        public static java.lang.String getMac()
        MAC address of the network interface
      • getUserPasswordMinLength

        public static int getUserPasswordMinLength()
        Message that will be displayed during user creation that describes password requirements
      • getUserPasswordStrengthRegex

        public static org.apache.commons.lang3.tuple.Pair<java.lang.String,​java.lang.String> getUserPasswordStrengthRegex()
        Regex that will be used to check the password during user creation
      • getJatosUrlBasePath

        public static java.lang.String getJatosUrlBasePath()
        HTTP URL base path: will be the prefix for each URL, e.g. /jatos/test -> /myBasePath/jatos/test
      • getJatosUpdateMsg

        public static java.lang.String getJatosUpdateMsg()
        If in update happened during last startup a message might be stored here
      • getJatosHttpAddress

        public static java.lang.String getJatosHttpAddress()
        JATOS HTTP host address without protocol or port (e.g. 192.168.0.1)
      • getJatosHttpPort

        public static int getJatosHttpPort()
        Port JATOS is running on
      • getLdapUrl

        public static java.lang.String getLdapUrl()
        LDAP URL (with port)
      • getLdapUserAttribute

        public static java.lang.String getLdapUserAttribute()
        LDAP User attribute, e.g. 'uid' or 'cn'
      • getLdapBaseDn

        public static java.util.List<java.lang.String> getLdapBaseDn()
        LDAP base DNs (Distinguished Name)
      • getLdapAdminDn

        public static java.lang.String getLdapAdminDn()
        LDAP admin DN (Distinguished Name) - the admin user is used to search for the actual user that wants to log in
      • getLdapAdminPassword

        public static java.lang.String getLdapAdminPassword()
        LDAP admin password
      • isLdapAllowed

        public static boolean isLdapAllowed()
      • getLdapTimeout

        public static int getLdapTimeout()
        Read timeout for the LDAP server
      • isOauthGoogleAllowed

        public static boolean isOauthGoogleAllowed()
      • getOauthGoogleClientId

        public static java.lang.String getOauthGoogleClientId()
        Google Sign-in Client ID for OAuth / OpenId Connect (OIDC)
      • isOidcAllowed

        public static boolean isOidcAllowed()
        OpenId Connect (OIDC) allowed
      • getOidcDiscoveryUrl

        public static java.lang.String getOidcDiscoveryUrl()
        OpenId Connect (OIDC) provider discovery URL (ends with ".well-known/openid-configuration")
      • getOidcClientId

        public static java.lang.String getOidcClientId()
        OpenId Connect (OIDC) client ID
      • getOidcClientSecret

        public static java.lang.String getOidcClientSecret()
        OpenId Connect (OIDC) client secret. Can be null if not used.
      • getOidcScope

        public static java.util.List<java.lang.String> getOidcScope()
        OpenId Connect (OIDC) scope (e.g. "openid", "profile", "email")
      • getOidcUsernameFrom

        public static java.lang.String getOidcUsernameFrom()
        OpenId Connect (OIDC) - Where should JATOS' username be taken from?
      • getOidcIdTokenSigningAlgorithm

        public static java.lang.String getOidcIdTokenSigningAlgorithm()
        OpenId Connect (OIDC) token signing algorithm (e.g. RS256)
      • getOidcSigninButtonText

        public static java.lang.String getOidcSigninButtonText()
        Text of OIDC button in sign-in page
      • getOidcSigninButtonLogoUrl

        public static java.lang.String getOidcSigninButtonLogoUrl()
        Logo URL of OIDC button in sign-in page
      • getOidcSuccessFeedback

        public static java.lang.String getOidcSuccessFeedback()
        Success feedback text shown to the user if OIDC sign-in was successful
      • isOrcidAllowed

        public static boolean isOrcidAllowed()
      • getOrcidDiscoveryUrl

        public static java.lang.String getOrcidDiscoveryUrl()
        ORCID's OpenId Connect (OIDC) provider discovery URL (ends with ".well-known/openid-configuration")
      • getOrcidClientId

        public static java.lang.String getOrcidClientId()
        ORCID'S OpenId Connect (OIDC) client ID
      • getOrcidClientSecret

        public static java.lang.String getOrcidClientSecret()
        ORCID's OpenId Connect (OIDC) client secret.
      • getOrcidScope

        public static java.util.List<java.lang.String> getOrcidScope()
        ORCID's OpenId Connect (OIDC) scope (e.g. "openid", "profile", "email")
      • getOrcidUsernameFrom

        public static java.lang.String getOrcidUsernameFrom()
        ORCID's OpenId Connect (OIDC) - Where should JATOS' username be taken from?
      • getOrcidIdTokenSigningAlgorithm

        public static java.lang.String getOrcidIdTokenSigningAlgorithm()
        ORCID's OpenId Connect (OIDC) token signing algorithm (e.g. RS256)
      • getOrcidSigninButtonText

        public static java.lang.String getOrcidSigninButtonText()
        Text of ORCID button on the sign-in page
      • getOrcidSigninButtonLogoUrl

        public static java.lang.String getOrcidSigninButtonLogoUrl()
        Logo URL of ORCID button on the sign-in page
      • getOrcidSuccessFeedback

        public static java.lang.String getOrcidSuccessFeedback()
        Success feedback text shown to the user if ORCID sign-in was successful.
      • isSramAllowed

        public static boolean isSramAllowed()
        SRAM's OpenId Connect (OIDC) allowed
      • getSramDiscoveryUrl

        public static java.lang.String getSramDiscoveryUrl()
        SRAM's OpenId Connect (OIDC) provider discovery URL (ends with ".well-known/openid-configuration")
      • getSramClientId

        public static java.lang.String getSramClientId()
        SRAM'S OpenId Connect (OIDC) client ID
      • getSramClientSecret

        public static java.lang.String getSramClientSecret()
        SRAM's OpenId Connect (OIDC) client secret.
      • getSramScope

        public static java.util.List<java.lang.String> getSramScope()
        SRAM's OpenId Connect (OIDC) scope (e.g. "openid", "profile", "email")
      • getSramUsernameFrom

        public static java.lang.String getSramUsernameFrom()
        SRAM's OpenId Connect (OIDC) - Where should JATOS' username be taken from?
      • getSramIdTokenSigningAlgorithm

        public static java.lang.String getSramIdTokenSigningAlgorithm()
        SRAM's OpenId Connect (OIDC) token signing algorithm (e.g. RS256)
      • getSramSigninButtonText

        public static java.lang.String getSramSigninButtonText()
        Text of SRAM button on the sign-in page
      • getSramSigninButtonLogoUrl

        public static java.lang.String getSramSigninButtonLogoUrl()
        Logo URL of SRAM button on the sign-in page
      • getSramSuccessFeedback

        public static java.lang.String getSramSuccessFeedback()
        Success feedback text shown to the user if SRAM sign-in was successful.
      • isConextAllowed

        public static boolean isConextAllowed()
        SURFconext OpenId Connect (OIDC) allowed
      • getConextDiscoveryUrl

        public static java.lang.String getConextDiscoveryUrl()
        SURFconext OpenId Connect (OIDC) provider discovery URL (ends with ".well-known/openid-configuration")
      • getConextClientId

        public static java.lang.String getConextClientId()
        SURFconext OpenId Connect (OIDC) client ID
      • getConextClientSecret

        public static java.lang.String getConextClientSecret()
        SURFconext OpenId Connect (OIDC) client secret.
      • getConextScope

        public static java.util.List<java.lang.String> getConextScope()
        SURFconext OpenId Connect (OIDC) scope (e.g. "openid", "profile", "email"). SURFconext ignores scopes other than "openid" (see: https://servicedesk.surf.nl/wiki/spaces/IAM/pages/128909987/OpenID+Connect+features#OpenIDConnectfeatures-Scopes)
      • getConextUsernameFrom

        public static java.lang.String getConextUsernameFrom()
        SURFconext OpenId Connect (OIDC) - Where should JATOS' username be taken from?
      • getConextIdTokenSigningAlgorithm

        public static java.lang.String getConextIdTokenSigningAlgorithm()
        SURFconext OpenId Connect (OIDC) token signing algorithm (e.g. RS256)
      • getConextSigninButtonText

        public static java.lang.String getConextSigninButtonText()
        Text of SURFconext button on the sign-in page
      • getConextSigninButtonLogoUrl

        public static java.lang.String getConextSigninButtonLogoUrl()
        Logo URL of SURFconext button on the sign-in page
      • getConextSuccessFeedback

        public static java.lang.String getConextSuccessFeedback()
        Success feedback text shown to the user if SRAM sign-in was successful.
      • isDonationAllowed

        public static boolean isDonationAllowed()
        Should the GUI show a donations button
      • getTermsOfUseUrl

        public static java.lang.String getTermsOfUseUrl()
        URL to the terms of use that will be shown in a link on the home page
      • getBrandingUrl

        public static java.lang.String getBrandingUrl()
        URL where some static HTML can be found that can be shown instead of the default welcome message on the home page
      • hasBranding

        public static boolean hasBranding()
      • getLocale

        public static java.lang.String getLocale()
        Locale used in the GUI. If not set, the browser's 'navigator.language' is used.
      • isStudyMembersAllowedToAddAllUsers

        public static boolean isStudyMembersAllowedToAddAllUsers()
        If true, it's allowed to add all users that exist on this JATOS server to be added at once as members of a study
      • isIdCookiesSecure

        public static boolean isIdCookiesSecure()
        If true, the ID cookies' secure attribute will be set
      • getIdCookiesSameSite

        public static play.mvc.Http.Cookie.SameSite getIdCookiesSameSite()
        Which SameSite attribute the ID cookies should set
      • getIdCookiesLimit

        public static int getIdCookiesLimit()
        Max number of ID cookies
      • showStudyAssetsSizeInStudyManager

        public static boolean showStudyAssetsSizeInStudyManager()
        If false, the study assets folder size won't be calculated for the study manager page. Sometimes the filesystem is too slow to allow this.
      • showResultDataSizeInStudyManager

        public static boolean showResultDataSizeInStudyManager()
        If false, the result data size won't be calculated for the study manager page. Sometime the database is too slow to allow this.
      • showResultFileSizeInStudyManager

        public static boolean showResultFileSizeInStudyManager()
        If false, the study result file size won't be calculated for the study manager page. Sometimes the filesystem is too slow to allow this.
      • isUserRoleAllowSuperuser

        public static boolean isUserRoleAllowSuperuser()
        If true, it is allowed to grant users the Superuser role
      • isJatosApiAllowed

        public static boolean isJatosApiAllowed()
        If true, it is allowed to use JATOS' API
      • isJatosApiTokensApiGenerationAllowed

        public static boolean isJatosApiTokensApiGenerationAllowed()
        Is it allowed to generate new tokens via the API?
      • getJatosApiTokensApiGenerationExpiresAfter

        public static java.time.Duration getJatosApiTokensApiGenerationExpiresAfter()
        The duration for which a token generated via the API remains valid after its creation. This setting does not apply to tokens created via the GUI.
      • getLogsPath

        public static java.lang.String getLogsPath()
        Path where the application logs are located
      • getLogsFilename

        public static java.lang.String getLogsFilename()
        Base name of JATOS log files without the suffix ('.log' or '.gz'). Default is 'application'.
      • getLogsAppender

        public static java.lang.String getLogsAppender()
        Log appender: can be 'ASYNCFILE' (default) or 'ASYNCSTDOUT'
      • isLogsAppenderStdOut

        public static boolean isLogsAppenderStdOut()
        Returns true if the Logger logs to STDOUT and false otherwise.
      • getTmpPath

        public static java.lang.String getTmpPath()
        Path to the JATOS tmp directory. If not set, it is System.getProperty("java.io.tmpdir").
      • isMultiNode

        public static boolean isMultiNode()
        True indicates that this JATOS runs with others in a cluster
      • getThreadPoolSize

        public static java.lang.String getThreadPoolSize()
        JATOS' thread pool size
      • getStudyArchiveSuffix

        public static java.lang.String getStudyArchiveSuffix()
        File extension of study archive files
      • getResultsArchiveSuffix

        public static java.lang.String getResultsArchiveSuffix()
        File extension of results archive files
      • isGroupsCleaningAllowed

        public static boolean isGroupsCleaningAllowed()
        True if the group cleaning is allowed
      • getGroupsCleaningInterval

        public static int getGroupsCleaningInterval()
        Interval in seconds the group cleaner is started.
      • getGroupsCleaningMemberIdleAfter

        public static int getGroupsCleaningMemberIdleAfter()
        After how many seconds a group member is regarded as idle.
      • getLastSeenDateUpdateThreshold

        public static java.time.Duration getLastSeenDateUpdateThreshold()
        StudyResult's lastSeenDate is updated only if its current value is older than this threshold (in seconds).
      • isOpenAiAllowed

        public static boolean isOpenAiAllowed()
      • getOpenAiApiKey

        public static java.lang.String getOpenAiApiKey()
        OpenAI API key
      • getOpenAiUrlBasePath

        public static java.lang.String getOpenAiUrlBasePath()
        Returns the URL base path used for accessing the OpenAI API.
      • getOpenAiCallLimit

        public static int getOpenAiCallLimit()
        Returns the maximum number of calls allowed to the OpenAI API.
      • getOpenAiTimeout

        public static int getOpenAiTimeout()
        Returns the maximum number of seconds to wait for OpenAI API response.