Package org.opencms.security
Interface I_CmsPasswordHandler
- All Superinterfaces:
I_CmsConfigurationParameterHandler
- All Known Implementing Classes:
CmsAdvancedPasswordHandler
,CmsDefaultPasswordHandler
Defines methods for OpenCms password validation.
- Since:
- 6.0.0
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Flag for conversion of the password encoding.static final String
String to identify the key value for md5 password hashes.static final String
String to identify the key value for unhashed passwords.static final String
String to identify the key value for SCrypt password hashes.static final String
String to identify the key value for sha password hashes.static final String
String to identify the key value for sha password hashes with 4 byte salt.Fields inherited from interface org.opencms.configuration.I_CmsConfigurationParameterHandler
ADD_PARAMETER_METHOD, INIT_CONFIGURATION_METHOD
-
Method Summary
Modifier and TypeMethodDescriptionboolean
checkPassword
(String plainPassword, String digestedPassword, boolean useFallback) This method checks if the given plain text password is equal to the given digested password.Creates an OpenCms password digest according to the default setting for method/encodings.Creates an OpenCms password digest.Returns the default digest type.Returns the default password encoding.void
setDigestType
(String digestType) Sets the default digest type.void
setInputEncoding
(String inputEncoding) Sets the default input encoding.void
validatePassword
(String password) This method checks if a new password follows the rules for new passwords, which are defined by a Class configured in the opencms.properties file.Methods inherited from interface org.opencms.configuration.I_CmsConfigurationParameterHandler
addConfigurationParameter, getConfiguration, initConfiguration
-
Field Details
-
CONVERT_DIGEST_ENCODING
Flag for conversion of the password encoding.- See Also:
-
DIGEST_TYPE_MD5
String to identify the key value for md5 password hashes.- See Also:
-
DIGEST_TYPE_PLAIN
String to identify the key value for unhashed passwords.- See Also:
-
DIGEST_TYPE_SHA
String to identify the key value for sha password hashes.- See Also:
-
DIGEST_TYPE_SSHA
String to identify the key value for sha password hashes with 4 byte salt.- See Also:
-
DIGEST_TYPE_SCRYPT
String to identify the key value for SCrypt password hashes.- See Also:
-
-
Method Details
-
checkPassword
This method checks if the given plain text password is equal to the given digested password.Use this to check salted passwords. If the password is salted, it needs to be checked with the salt (and possible other parameters) stored in the digested password. Just digesting the password again and comparing the result to a previous digest won't work because the salt will usually be different.
- Parameters:
plainPassword
- the plain text password to checkdigestedPassword
- the digested password to compare with the plain passworduseFallback
- iftrue
, then use a fall back hashing algorithm in case first validation fails- Returns:
false
if the validation of the password failed
-
digest
Creates an OpenCms password digest according to the default setting for method/encodings.- Parameters:
password
- the password to encrypt- Returns:
- the password digest
- Throws:
CmsPasswordEncryptionException
- if something goes wrong
-
digest
String digest(String password, String digestType, String inputEncoding) throws CmsPasswordEncryptionException Creates an OpenCms password digest.- Parameters:
password
- the password to encryptdigestType
- the algorithm used for encryption (i.e. MD5, SHA ...)inputEncoding
- the encoding used when converting the password to bytes (i.e. UTF-8)- Returns:
- the password digest
- Throws:
CmsPasswordEncryptionException
- if something goes wrong
-
getDigestType
Returns the default digest type.- Returns:
- the default digest type
-
getInputEncoding
Returns the default password encoding.- Returns:
- the default password encoding
-
setDigestType
Sets the default digest type.- Parameters:
digestType
- the digest type used
-
setInputEncoding
Sets the default input encoding.- Parameters:
inputEncoding
- the encoding used for translation the password string to bytes
-
validatePassword
This method checks if a new password follows the rules for new passwords, which are defined by a Class configured in the opencms.properties file.If this method throws no exception the password is valid.
- Parameters:
password
- the password to check- Throws:
CmsSecurityException
- if validation of the password failed
-