java.lang.Object
com.erudika.para.core.utils.Config
- Direct Known Subclasses:
ParaConfig
This class loads configuration settings from a file and sets defaults.
- Author:
- Alex Bogdanovski [[email protected]]
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
"appid".static final String
"creatorid".static final String
"email".static final String
"etoken".static final String
"groups".static final String
"id".static final String
"identifier".static final String
"key".static final String
"name".static final String
"parentid".static final String
"password".static final String
"properties".static final String
"token".static final String
"tags".static final String
"timestamp".static final String
"type".static final String
"updated".static final String
"version".static final String
Amazon prefix - defaults to 'az:'.static final int
10000.static final String
Facebook prefix - defaults to 'fb:'.static final String
GitHub prefix - defaults to 'gh:'.static final String
Google prefix - defaults to 'gp:'.static final String
LDAP prefix - defaults to 'ldap:'.static final String
LinkedIn prefix - defaults to 'in:'.static final String
Mattermost prefix - defaults to 'mm:'.static final String
Microsoft prefix - defaults to 'ms:'.static final String
OAuth2 generic prefix - defaults to 'oa2:'.static final String
OAuth2 second generic prefix - defaults to 'oa2second:'.static final String
OAuth2 third generic prefix - defaults to 'oa2third:'.static final String
"para".static final String
Passwordless auth prefix - defaults to 'custom:'.static final String
SAML prefix - defaults to 'saml:'.static final String
Slack prefix - defaults to 'sl:'.static final String
Twitter prefix - defaults to 'tw:'. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncom.typesafe.config.Config
Returns the Config object.The name of the configuration file, usually 'app-application.conf'.abstract String
The root prefix of the configuration property names, e.g.getConfigValue
(String key, String defaultValue) Returns the unwrapped value of a configuration parameter or its default value.Constructs a sorted set of configuration keys.render
(boolean asJson) Renders the current configuration as a String, taking into account system properties and ENV precedence ordering.renderConfigDocumentation
(String format, boolean groupByCategory) Renders all configuration options along with their documentation and default values.void
store()
Stores all available configuration to a file, overwriting the existing one.
-
Field Details
-
PARA
"para".- See Also:
-
_TYPE
"type".- See Also:
-
_APPID
"appid".- See Also:
-
_CREATORID
"creatorid".- See Also:
-
_ID
"id".- See Also:
-
_IDENTIFIER
"identifier".- See Also:
-
_KEY
"key".- See Also:
-
_NAME
"name".- See Also:
-
_PARENTID
"parentid".- See Also:
-
_PASSWORD
"password".- See Also:
-
_RESET_TOKEN
"token".- See Also:
-
_EMAIL_TOKEN
"etoken".- See Also:
-
_TIMESTAMP
"timestamp".- See Also:
-
_UPDATED
"updated".- See Also:
-
_TAGS
"tags".- See Also:
-
_EMAIL
"email".- See Also:
-
_GROUPS
"groups".- See Also:
-
_VERSION
"version".- See Also:
-
_PROPERTIES
"properties".- See Also:
-
DEFAULT_LIMIT
public static final int DEFAULT_LIMIT10000.- See Also:
-
FB_PREFIX
Facebook prefix - defaults to 'fb:'.- See Also:
-
GPLUS_PREFIX
Google prefix - defaults to 'gp:'.- See Also:
-
LINKEDIN_PREFIX
LinkedIn prefix - defaults to 'in:'.- See Also:
-
TWITTER_PREFIX
Twitter prefix - defaults to 'tw:'.- See Also:
-
GITHUB_PREFIX
GitHub prefix - defaults to 'gh:'.- See Also:
-
MICROSOFT_PREFIX
Microsoft prefix - defaults to 'ms:'.- See Also:
-
SLACK_PREFIX
Slack prefix - defaults to 'sl:'.- See Also:
-
MATTERMOST_PREFIX
Mattermost prefix - defaults to 'mm:'.- See Also:
-
AMAZON_PREFIX
Amazon prefix - defaults to 'az:'.- See Also:
-
OAUTH2_PREFIX
OAuth2 generic prefix - defaults to 'oa2:'.- See Also:
-
OAUTH2_SECOND_PREFIX
OAuth2 second generic prefix - defaults to 'oa2second:'.- See Also:
-
OAUTH2_THIRD_PREFIX
OAuth2 third generic prefix - defaults to 'oa2third:'.- See Also:
-
LDAP_PREFIX
LDAP prefix - defaults to 'ldap:'.- See Also:
-
SAML_PREFIX
SAML prefix - defaults to 'saml:'.- See Also:
-
PASSWORDLESS_PREFIX
Passwordless auth prefix - defaults to 'custom:'.- See Also:
-
-
Constructor Details
-
Config
public Config()
-
-
Method Details
-
getConfigFilePath
The name of the configuration file, usually 'app-application.conf'.- Returns:
- prefix-application.conf or the value of @{code config.file} system property.
-
getConfigRootPrefix
The root prefix of the configuration property names, e.g. "para".- Returns:
- the root prefix for all config property keys.
-
getConfigValue
Returns the unwrapped value of a configuration parameter or its default value.- Parameters:
key
- the param keydefaultValue
- the default value- Returns:
- object a raw unwrapped value
-
getConfig
public com.typesafe.config.Config getConfig()Returns the Config object.- Returns:
- the config object
-
getSortedConfigKeys
Constructs a sorted set of configuration keys. Heavily relies on theDocumented
annotation for sort order.- Returns:
- a set of map of config keys, without the root prefix (path), to config categories.
-
store
public void store()Stores all available configuration to a file, overwriting the existing one. In case of HOCON, the commented lines are collected from existing file and appended at the end. -
render
- Parameters:
asJson
- if true, a JSON object will be rendered, otherwise the HOCON format is used- Returns:
- config as string
- See Also:
-
render
Renders the current configuration as a String, taking into account system properties and ENV precedence ordering.- Parameters:
asJson
- if true, a JSON object will be rendered, otherwise the HOCON format is usedhoconHeader
- file headerhoconFooter
- file footer- Returns:
- config as string
-
renderConfigDocumentation
Renders all configuration options along with their documentation and default values.- Parameters:
format
- one of "hocon", "json" or "markdown"groupByCategory
- if true, will group properties by category- Returns:
- a HOCON, JSON or MD string
-
getConfigMap
- Returns:
- returns the configuration as a map of keys and values.
-