Package com.jalios.jcms.wysiwyg.safety
Class Cleaner
java.lang.Object
com.jalios.jcms.wysiwyg.safety.Cleaner
- Direct Known Subclasses:
AttributeCleaner
Provides common settings for any sanitizer.
- enabled
- whitelisted set
- whitelist regular expression
- blacklisted set
- blacklist regular expression
- default behavior when value is not found in whitelist/blacklist
Whitelist and whitelist regex have precedence over blacklist and blacklist regex.
The setDefaultBehavior(boolean) authorization is applied to values which are neither
whitelisted nor blacklisted (through list or regex).
Default is to consider unknown values are unauthorized.
- Since:
- jcms-10.0.0 / JCMS-6170
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBlacklistedValue(String... values) Add the specified value to the blacklisted values.voidaddWhitelistedValue(String... values) Add the specified value to the whitelisted values.voidConfigure the current cleaner with the specified properties.Retrieve the blacklisted valuesRetrieve the blacklist regular expressionbooleanGet default behavior applied for values not part of whitelist or blacklist and which do not match any whitelist or blacklist pattern.Retrieve the whitelited valuesRetrieve the whitelist regular expressionbooleanisAuthorized(String value) Check if the specified value is authorized or not.booleanCheck if this cleaner is enabled.voidremoveBlacklistedValue(String... values) Remove the specified value from blacklisted values.voidremoveWhitelistedValue(String... values) Remove the specified value from authorized values.voidsetBlacklistRegex(String blacklistRegex) Set the regular expresion to consider value as blacklistedvoidsetDefaultBehavior(boolean authorize) Set the default behavior applied for values not part of whitelist or blacklist and which do not match any whitelist or blacklist pattern.voidsetEnabled(boolean enabled) Set the enabled status of this cleanervoidsetWhitelistRegex(String whitelistRegex) Set the regular expresion to consider value as whitelistedtoString()
-
Constructor Details
-
Cleaner
public Cleaner()
-
-
Method Details
-
configureFromProperties
Configure the current cleaner with the specified properties.- Parameters:
prop- a instance of JProperties, must not be null
-
setEnabled
public void setEnabled(boolean enabled) Set the enabled status of this cleaner- Parameters:
enabled- true to enable, false to disable
-
isEnabled
public boolean isEnabled()Check if this cleaner is enabled.- Returns:
- the enabled
-
addWhitelistedValue
Add the specified value to the whitelisted values.- Parameters:
values- any value
-
removeWhitelistedValue
Remove the specified value from authorized values.- Parameters:
values- any value
-
getWhitelist
Retrieve the whitelited values- Returns:
- a set of whitelisted values, never return null
-
setWhitelistRegex
Set the regular expresion to consider value as whitelisted- Parameters:
whitelistRegex- a regular expression
-
getWhitelistRegex
Retrieve the whitelist regular expression- Returns:
- a regex or null if none is defined
-
addBlacklistedValue
Add the specified value to the blacklisted values.- Parameters:
values- any attribute values (egalert-danger)
-
removeBlacklistedValue
Remove the specified value from blacklisted values.- Parameters:
values- any attribute values (egmodal)
-
getBlacklist
Retrieve the blacklisted values- Returns:
- a set of blacklisted values, never return null
-
setBlacklistRegex
Set the regular expresion to consider value as blacklisted- Parameters:
blacklistRegex- a regular expression
-
getBlacklistRegex
Retrieve the blacklist regular expression- Returns:
- a regex or null if none is defined
-
setDefaultBehavior
public void setDefaultBehavior(boolean authorize) Set the default behavior applied for values not part of whitelist or blacklist and which do not match any whitelist or blacklist pattern.Default is
false: unknown values are considered as unauthorized.- Parameters:
authorize- true to authorize unknown values, false to blacklist
-
getDefaultBehavior
public boolean getDefaultBehavior()Get default behavior applied for values not part of whitelist or blacklist and which do not match any whitelist or blacklist pattern.Default is
false: unknown values are considered as unauthorized.- Returns:
- true if authorized, false if unauthorized
-
toString
-
isAuthorized
Check if the specified value is authorized or not.- Parameters:
value- the value to verify- Returns:
- true if value is authorized, false otherwise
-