Class Config

java.lang.Object
io.mangoo.core.Config

public class Config extends Object
Main configuration class for all properties configured in 'config.props'
Author:
svenkubiak, williamdunne
  • Constructor Details

    • Config

      public Config()
    • Config

      public Config(String mode)
  • Method Details

    • toProperties

      public Properties toProperties()
      Converts config values to standard java properties
      Returns:
      Properties instance with config values
    • isDecrypted

      public boolean isDecrypted()
      Returns:
      True if decryption of config values was successful, false otherwise
    • getString

      public String getString(String key)
      Retrieves a configuration value with the given key
      Parameters:
      key - The key of the configuration value (e.g. application.name)
      Returns:
      The configured value as String or null if the key is not configured
    • getString

      public String getString(String key, String defaultValue)
      Retrieves a configuration value with the given key
      Parameters:
      key - The key of the configuration value (e.g. application.name)
      defaultValue - The default value to return of no key is found
      Returns:
      The configured value as String or the passed defautlValue if the key is not configured
    • getInt

      public int getInt(String key)
      Retrieves a configuration value with the given key
      Parameters:
      key - The key of the configuration value (e.g. application.name)
      Returns:
      The configured value as int or 0 if the key is not configured
    • getLong

      public long getLong(String key)
      Retrieves a configuration value with the given key
      Parameters:
      key - The key of the configuration value (e.g. application.name)
      Returns:
      The configured value as long or 0 if the key is not configured
    • getLong

      public long getLong(String key, long defaultValue)
      Retrieves a configuration value with the given key
      Parameters:
      key - The key of the configuration value (e.g. application.name)
      defaultValue - The default value to return of no key is found
      Returns:
      The configured value as int or the passed defautlValue if the key is not configured
    • getInt

      public int getInt(String key, int defaultValue)
      Retrieves a configuration value with the given key
      Parameters:
      key - The key of the configuration value (e.g. application.name)
      defaultValue - The default value to return of no key is found
      Returns:
      The configured value as int or the passed defautlValue if the key is not configured
    • getBoolean

      public boolean getBoolean(String key)
      Retrieves a configuration value with the given key
      Parameters:
      key - The key of the configuration value (e.g. application.name)
      Returns:
      The configured value as boolean or false if the key is not configured
    • getBoolean

      public boolean getBoolean(String key, boolean defaultValue)
      Retrieves a configuration value with the given key
      Parameters:
      key - The key of the configuration value (e.g. application.name)
      defaultValue - The default value to return of no key is found
      Returns:
      The configured value as boolean or the passed defautlValue if the key is not configured
    • getString

      public String getString(Key key)
      Retrieves a configuration value with the given key constant (e.g. Key.APPLICATION_NAME)
      Parameters:
      key - The key of the configuration value (e.g. application.name)
      Returns:
      The configured value as String or null if the key is not configured
    • getString

      public String getString(Key key, String defaultValue)
      Retrieves a configuration value with the given key constant (e.g. Key.APPLICATION_NAME)
      Parameters:
      key - The key of the configuration value (e.g. application.name)
      defaultValue - The default value to return of no key is found
      Returns:
      The configured value as String or the passed defautlValue if the key is not configured
    • getLong

      public long getLong(Key key)
      Retrieves a configuration value with the given key constant (e.g. Key.APPLICATION_NAME)
      Parameters:
      key - The key of the configuration value (e.g. application.name)
      Returns:
      The configured value as long or null if the key is not configured
    • getLong

      public long getLong(Key key, long defaultValue)
      Retrieves a configuration value with the given key constant (e.g. Key.APPLICATION_NAME)
      Parameters:
      key - The key of the configuration value (e.g. application.name)
      defaultValue - The default value to return of no key is found
      Returns:
      The configured value as long or the passed defautlValue if the key is not configured
    • getInt

      public int getInt(Key key)
      Retrieves a configuration value with the given key constant (e.g. Key.APPLICATION_NAME)
      Parameters:
      key - The key of the configuration value (e.g. application.name)
      Returns:
      The configured value as int or 0 if the key is not configured
    • getInt

      public int getInt(Key key, int defaultValue)
      Retrieves a configuration value with the given key constant (e.g. Key.APPLICATION_NAME)
      Parameters:
      key - The key of the configuration value (e.g. application.name)
      defaultValue - The default value to return of no key is found
      Returns:
      The configured value as int or the passed defautlValue if the key is not configured
    • getBoolean

      public boolean getBoolean(Key key)
      Retrieves a configuration value with the given key constant (e.g. Key.APPLICATION_NAME)
      Parameters:
      key - The key of the configuration value (e.g. application.name)
      Returns:
      The configured value as boolean or false if the key is not configured
    • getBoolean

      public boolean getBoolean(Key key, boolean defaultValue)
      Retrieves a configuration value with the given key constant (e.g. Key.APPLICATION_NAME)
      Parameters:
      key - The key of the configuration value (e.g. application.name)
      defaultValue - The default value to return of no key is found
      Returns:
      The configured value as boolean or the passed defautlValue if the key is not configured
    • getAllConfigurations

      public Map<String,String> getAllConfigurations()
      Returns:
      All configuration options of the current environment
    • getApplicationName

      public String getApplicationName()
      Returns:
      application.name from config.props
    • getFlashCookieName

      public String getFlashCookieName()
      Returns:
      flash.cookie.name or default value if undefined
    • getSessionCookieName

      public String getSessionCookieName()
      Returns:
      session.cookie.name from config.props or default value if undefined
    • getApplicationSecret

      public String getApplicationSecret()
      Returns:
      application.secret from config.props
    • getApplicationPublicKey

      public String getApplicationPublicKey()
      Returns:
      application.publickey from config.props
    • getAuthenticationCookieName

      public String getAuthenticationCookieName()
      Returns:
      authentication.cookie.name from config.props or default value if undefined
    • getSessionCookieTokenExpires

      public long getSessionCookieTokenExpires()
      Returns:
      session.cookie.token.expires from config.props or default value if undefined
    • isSessionCookieSecure

      public boolean isSessionCookieSecure()
      Returns:
      session.cookie.secure from config.props or default value if undefined
    • isAuthenticationCookieSecure

      public boolean isAuthenticationCookieSecure()
      Returns:
      authentication.cookie.secure from config.props or default value if undefined
    • getI18nCookieName

      public String getI18nCookieName()
      Returns:
      i18n.cookie.name from config.props or default value if undefined
    • isFlashCookieSecure

      public boolean isFlashCookieSecure()
      Returns:
      calls isSessionCookieSecure()
    • getApplicationLanguage

      public String getApplicationLanguage()
      Returns:
      application.language from config.props or default value if undefined
    • getApplicationAdminUsername

      public String getApplicationAdminUsername()
      Returns:
      application.admin.username from config.props or null if undefined
    • getApplicationAdminPassword

      public String getApplicationAdminPassword()
      Returns:
      application.admin.password from config.props or null if undefined
    • getSchedulerPoolsize

      public int getSchedulerPoolsize()
      Returns:
      scheduler.poolsize from config.props or default value if undefined
    • getAuthenticationCookieRememberExpires

      public long getAuthenticationCookieRememberExpires()
      Returns:
      authentication.cookie.remember.expires from config.props or default value if undefined
    • getApplicationController

      public String getApplicationController()
      Returns:
      application.controller from config.props or default value if undefined
    • getApplicationTemplateEngine

      public String getApplicationTemplateEngine()
      Returns:
      application.templateengine from config.props or default value if undefined
    • isApplicationAdminEnable

      public boolean isApplicationAdminEnable()
      Returns:
      application.admin.enable or default value if undefined
    • getSmtpHost

      public String getSmtpHost()
      Returns:
      smtp.host or default value if undefined
    • getSmtpPort

      public int getSmtpPort()
      Returns:
      smtp.port or default value if undefined
    • getSmtpUsername

      public String getSmtpUsername()
      Returns:
      smtp.username or null value if undefined
    • getSmtpPassword

      public String getSmtpPassword()
      Returns:
      smtp.username or null value if undefined
    • getSmtpFrom

      public String getSmtpFrom()
      Returns:
      smtp.from or default value if undefined
    • getConnectorHttpHost

      public String getConnectorHttpHost()
      Returns:
      jvm property http.host or connector.http.host or null if undefined
    • getConnectorHttpPort

      public int getConnectorHttpPort()
      Returns:
      jvm property http.port or connector.http.port or 0 if undefined
    • getConnectorAjpHost

      public String getConnectorAjpHost()
      Returns:
      jvm property ajp.host or connector.ajp.host or null if undefined
    • getConnectorAjpPort

      public int getConnectorAjpPort()
      Returns:
      jvm property ajp.port or connector.ajp.port or 0 if undefined
    • isCacheCluserEnable

      public boolean isCacheCluserEnable()
      Returns:
      cache.cluster.enable or default value if undefined
    • isMetricsEnable

      public boolean isMetricsEnable()
      Returns:
      metrics.enable or default value if undefined
    • getAuthenticationLock

      public int getAuthenticationLock()
      Returns:
      authentication.lock or default value if undefined
    • getCacheClusterUrl

      public String getCacheClusterUrl()
      Returns:
      cache.cluster.url or null if undefined
    • getUndertowMaxEntitySize

      public long getUndertowMaxEntitySize()
      Returns:
      undertow.maxentitysize or default value if undefined
    • getSessionCookieSecret

      public String getSessionCookieSecret()
      Returns:
      session.cookie.secret or application secret if undefined
    • getAuthenticationCookieSecret

      public String getAuthenticationCookieSecret()
      Returns:
      authentication.cookie.secret or application secret if undefined
    • getFlashCookieSecret

      public String getFlashCookieSecret()
      Returns:
      flash.cookie.secret or application secret if undefined
    • isSchedulerEnabled

      public boolean isSchedulerEnabled()
      Returns:
      scheduler.enable or default value if undefined
    • getApplicationAdminSecret

      public String getApplicationAdminSecret()
      Returns:
      application.admin.secret or null if undefined
    • isSmtpDebug

      public boolean isSmtpDebug()
      Returns:
      smtp.debug or default value if undefined
    • isCorsEnable

      public boolean isCorsEnable()
      Returns:
      cors.enable or default value if undefined
    • getCorsUrlPattern

      public com.google.re2j.Pattern getCorsUrlPattern()
      Returns:
      cors.urlpattern as compiled pattern or default value if undefined
    • getCorsAllowOrigin

      public com.google.re2j.Pattern getCorsAllowOrigin()
      Returns:
      cors.policyclass as compiled pattern or default value if undefined
    • getCorsHeadersAllowCredentials

      public String getCorsHeadersAllowCredentials()
      Returns:
      cors.headers.allowcredentials or default value if undefined
    • getCorsHeadersAllowHeaders

      public String getCorsHeadersAllowHeaders()
      Returns:
      cors.headers.allowheaders or default value if undefined
    • getCorsHeadersAllowMethods

      public String getCorsHeadersAllowMethods()
      Returns:
      cors.headers.allowheaders or default value if undefined
    • getCorsHeadersExposeHeaders

      public String getCorsHeadersExposeHeaders()
      Returns:
      cors.headers.exposeheaders or default value if undefined
    • getCorsHeadersMaxAge

      public String getCorsHeadersMaxAge()
      Returns:
      cors.headers.maxage or default value if undefined
    • getMongoHost

      public String getMongoHost(String prefix)
      Parameters:
      prefix - The prefix to use
      Returns:
      persistence.mongo.host or default value if undefined
    • getMongoPort

      public int getMongoPort(String prefix)
      Parameters:
      prefix - The prefix to use
      Returns:
      persistence.mongo.port or default value if undefined
    • getMongoUsername

      public String getMongoUsername(String prefix)
      Parameters:
      prefix - The prefix to use
      Returns:
      persistence.mongo.username or null if undefined
    • getMongoPassword

      public String getMongoPassword(String prefix)
      Parameters:
      prefix - The prefix to use
      Returns:
      persistence.mongo.password or null if undefined
    • getMongoAuthDB

      public String getMongoAuthDB(String prefix)
      Parameters:
      prefix - The prefix to use
      Returns:
      persistence.mongo.authdb or null if undefined
    • isMongoAuth

      public boolean isMongoAuth(String prefix)
      Parameters:
      prefix - The prefix to use
      Returns:
      persistence.mongo.auth or default value if undefined
    • getMongoPackage

      public String getMongoPackage(String prefix)
      Parameters:
      prefix - The prefix to use
      Returns:
      persistence.mongo.package or default value if undefined
    • getMongoDbName

      public String getMongoDbName(String prefix)
      Parameters:
      prefix - The prefix to use
      Returns:
      persistence.mongo.dbname or default value if undefined
    • isMongoEmbedded

      public boolean isMongoEmbedded(String prefix)
      Parameters:
      prefix - The prefix to use
      Returns:
      persistence.mongo.embedded or default value if undefined
    • isSessionCookieExpires

      public boolean isSessionCookieExpires()
      Returns:
      session.cookie.expires or default value if undefined
    • isAuthenticationCookieExpires

      public boolean isAuthenticationCookieExpires()
      Returns:
      authentication.cookie.expires or default value if undefined
    • getAuthenticationCookieTokenExpires

      public long getAuthenticationCookieTokenExpires()
      Returns:
      authentication.cookie.expires or default value if undefined
    • isSmtpAuthentication

      public boolean isSmtpAuthentication()
      Returns:
      smtp.authentication or default value if undefined
    • getSmtpProtocol

      public String getSmtpProtocol()
      Returns:
      smtp.protocol or default value if undefined
    • isApplicationAdminHealthEnable

      public boolean isApplicationAdminHealthEnable()
      Returns:
      application.admin.health.enable or default value if undefined
    • getApplicationAdminHealthToken

      public String getApplicationAdminHealthToken()
      Returns:
      application.admin.health.token or null if undefined