Class AbstractPasswordRule
- java.lang.Object
-
- org.silverpeas.core.security.authentication.password.rule.AbstractPasswordRule
-
- All Implemented Interfaces:
PasswordRule
- Direct Known Subclasses:
AtLeastXDigitPasswordRule
,AtLeastXLowercasePasswordRule
,AtLeastXSpecialCharPasswordRule
,AtLeastXUppercasePasswordRule
,BlankForbiddenPasswordRule
,MaxLengthPasswordRule
,MinLengthPasswordRule
,SequentialForbiddenPasswordRule
public abstract class AbstractPasswordRule extends Object implements PasswordRule
User: Yohann Chastagnier Date: 07/01/13
-
-
Field Summary
Fields Modifier and Type Field Description protected static int
DEFAULT_LENGTH
protected static org.silverpeas.kernel.bundle.SettingBundle
settings
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractPasswordRule(PasswordRuleType passwordRuleType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
countRegexOccur(String text, String regex)
Counting the number of occurrences matching the specified regexp in the given text.String
getDescription(String language)
Gets the description of the rule according to a language.protected Integer
getIntegerFromSettings(String key, Integer defaultValue)
Gets an integer from settingsprotected String
getString(String key, String language, String... params)
Gets a string message according to the given language.PasswordRuleType
getType()
Gets the type password rule.boolean
isCombined()
Indicates if the rule is combined one.boolean
isRequired()
Indicates if the rule is required.protected int
random(int maxValue)
Returns a random integer value included between 0 and (given maxValue - 1).-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.silverpeas.core.security.authentication.password.rule.PasswordRule
check, getValue, random
-
-
-
-
Field Detail
-
DEFAULT_LENGTH
protected static final int DEFAULT_LENGTH
- See Also:
- Constant Field Values
-
settings
protected static org.silverpeas.kernel.bundle.SettingBundle settings
-
-
Constructor Detail
-
AbstractPasswordRule
protected AbstractPasswordRule(PasswordRuleType passwordRuleType)
-
-
Method Detail
-
getType
public PasswordRuleType getType()
Description copied from interface:PasswordRule
Gets the type password rule.- Specified by:
getType
in interfacePasswordRule
- Returns:
-
getDescription
public String getDescription(String language)
Description copied from interface:PasswordRule
Gets the description of the rule according to a language.- Specified by:
getDescription
in interfacePasswordRule
- Returns:
-
isRequired
public boolean isRequired()
Description copied from interface:PasswordRule
Indicates if the rule is required.- Specified by:
isRequired
in interfacePasswordRule
- Returns:
-
isCombined
public boolean isCombined()
Description copied from interface:PasswordRule
Indicates if the rule is combined one.- Specified by:
isCombined
in interfacePasswordRule
- Returns:
-
random
protected int random(int maxValue)
Returns a random integer value included between 0 and (given maxValue - 1).- Returns:
- a random integer value.
-
getString
protected String getString(String key, String language, String... params)
Gets a string message according to the given language.- Parameters:
key
- the key of the message template to get.language
- the language in which the message has to be written.params
- parameters to pass to the message.- Returns:
- the message generated from a template and the parameters.
-
getIntegerFromSettings
protected Integer getIntegerFromSettings(String key, Integer defaultValue)
Gets an integer from settings- Parameters:
key
- the key of the property.defaultValue
- the default value if the property isn't defined.- Returns:
- the property value or 0 if the value got from the settings is negative.
-
-