org.opencms.security
Class CmsDefaultPasswordHandler

java.lang.Object
  extended by org.opencms.security.CmsDefaultPasswordHandler
All Implemented Interfaces:
I_CmsConfigurationParameterHandler, I_CmsPasswordHandler

public class CmsDefaultPasswordHandler
extends Object
implements I_CmsPasswordHandler

Default implementation for OpenCms password validation, just checks if a password is at last 4 characters long.

Since:
6.0.0

Field Summary
static int PASSWORD_MIN_LENGTH
          The minimum length of a password.
 
Fields inherited from interface org.opencms.security.I_CmsPasswordHandler
CONVERT_DIGEST_ENCODING, DIGEST_TYPE_MD5, DIGEST_TYPE_PLAIN, DIGEST_TYPE_SHA, DIGEST_TYPE_SSHA
 
Fields inherited from interface org.opencms.configuration.I_CmsConfigurationParameterHandler
ADD_PARAMETER_METHOD, INIT_CONFIGURATION_METHOD
 
Constructor Summary
CmsDefaultPasswordHandler()
          The constructor does not perform any operation.
 
Method Summary
 void addConfigurationParameter(String paramName, String paramValue)
          Adds a configuration parameter to this parameter configurable class instance.
 String digest(String password)
          Creates an OpenCms password digest according to the default setting for method/encodings.
 String digest(String password, String digestType, String inputEncoding)
          Creates an OpenCms password digest.
 CmsParameterConfiguration getConfiguration()
          Returns the parameters of this configurable class instance, or null if the class does not need any parameters.
 String getDigestType()
          Returns the digestType.
 String getInputEncoding()
          Returns the input encoding.
 void initConfiguration()
          Initializes a configuration after all parameters have been added.
 void setDigestType(String digestType)
          Sets the digestType.
 void setInputEncoding(String inputEncoding)
          Sets the 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 class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PASSWORD_MIN_LENGTH

public static final int PASSWORD_MIN_LENGTH
The minimum length of a password.

See Also:
Constant Field Values
Constructor Detail

CmsDefaultPasswordHandler

public CmsDefaultPasswordHandler()
The constructor does not perform any operation.

Method Detail

addConfigurationParameter

public void addConfigurationParameter(String paramName,
                                      String paramValue)
Description copied from interface: I_CmsConfigurationParameterHandler
Adds a configuration parameter to this parameter configurable class instance.

Specified by:
addConfigurationParameter in interface I_CmsConfigurationParameterHandler
Parameters:
paramName - the name of the parameter
paramValue - the value for the parameter
See Also:
I_CmsConfigurationParameterHandler.addConfigurationParameter(java.lang.String, java.lang.String)

digest

public String digest(String password)
              throws CmsPasswordEncryptionException
Description copied from interface: I_CmsPasswordHandler
Creates an OpenCms password digest according to the default setting for method/encodings.

Specified by:
digest in interface I_CmsPasswordHandler
Parameters:
password - the password to encrypt
Returns:
the password digest
Throws:
CmsPasswordEncryptionException - if something goes wrong
See Also:
I_CmsPasswordHandler.digest(java.lang.String)

digest

public String digest(String password,
                     String digestType,
                     String inputEncoding)
              throws CmsPasswordEncryptionException
Description copied from interface: I_CmsPasswordHandler
Creates an OpenCms password digest.

Specified by:
digest in interface I_CmsPasswordHandler
Parameters:
password - the password to encrypt
digestType - 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
See Also:
I_CmsPasswordHandler.digest(java.lang.String, java.lang.String, java.lang.String)

getConfiguration

public CmsParameterConfiguration getConfiguration()
Description copied from interface: I_CmsConfigurationParameterHandler
Returns the parameters of this configurable class instance, or null if the class does not need any parameters.

Specified by:
getConfiguration in interface I_CmsConfigurationParameterHandler
Returns:
the parameters of this configurable class instance, or null if the class does not need any parameters
See Also:
I_CmsConfigurationParameterHandler.getConfiguration()

getDigestType

public String getDigestType()
Returns the digestType.

Specified by:
getDigestType in interface I_CmsPasswordHandler
Returns:
the digestType

getInputEncoding

public String getInputEncoding()
Returns the input encoding.

Specified by:
getInputEncoding in interface I_CmsPasswordHandler
Returns:
the input encoding

initConfiguration

public void initConfiguration()
                       throws CmsConfigurationException
Description copied from interface: I_CmsConfigurationParameterHandler
Initializes a configuration after all parameters have been added.

Specified by:
initConfiguration in interface I_CmsConfigurationParameterHandler
Throws:
CmsConfigurationException - if something goes wrong
See Also:
I_CmsConfigurationParameterHandler.initConfiguration()

setDigestType

public void setDigestType(String digestType)
Sets the digestType.

Specified by:
setDigestType in interface I_CmsPasswordHandler
Parameters:
digestType - the digestType to set

setInputEncoding

public void setInputEncoding(String inputEncoding)
Sets the input encoding.

Specified by:
setInputEncoding in interface I_CmsPasswordHandler
Parameters:
inputEncoding - the input encoding to set

validatePassword

public void validatePassword(String password)
                      throws CmsSecurityException
Description copied from interface: I_CmsPasswordHandler
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.

Specified by:
validatePassword in interface I_CmsPasswordHandler
Parameters:
password - the password to check
Throws:
CmsSecurityException - if validation of the password failed
See Also:
I_CmsPasswordHandler.validatePassword(java.lang.String)