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 java.lang.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
Version:
$Revision: 1.25 $
Author:
Alexander Kandzior, Carsten Weinholz

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(java.lang.String paramName, java.lang.String paramValue)
          Adds a configuration parameter to this parameter configurable class instance.
 java.lang.String digest(java.lang.String password)
          Creates an OpenCms password digest according to the default setting for method/encodings.
 java.lang.String digest(java.lang.String password, java.lang.String digestType, java.lang.String inputEncoding)
          Creates an OpenCms password digest.
 java.util.Map getConfiguration()
          Returns the configuration of this parameter configurable class instance, or null if the class does not need to be configured.
 java.lang.String getDigestType()
          Returns the digestType.
 java.lang.String getInputEncoding()
          Returns the input encoding.
 void initConfiguration()
          Initializes a configuration after all parameters have been added.
 void setDigestType(java.lang.String digestType)
          Sets the digestType.
 void setInputEncoding(java.lang.String inputEncoding)
          Sets the input encoding.
 void validatePassword(java.lang.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(java.lang.String paramName,
                                      java.lang.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 java.lang.String digest(java.lang.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 java.lang.String digest(java.lang.String password,
                               java.lang.String digestType,
                               java.lang.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 java.util.Map getConfiguration()
Description copied from interface: I_CmsConfigurationParameterHandler
Returns the configuration of this parameter configurable class instance, or null if the class does not need to be configured.

All elements in the configuration are key, value String pairs, set using the I_CmsConfigurationParameterHandler.addConfigurationParameter(String, String) method during initialization of the loader.

Implementations will (should) not to return a direct reference to the internal configuration but just a copy of it, to avoid unwanted external manipulation.

Specified by:
getConfiguration in interface I_CmsConfigurationParameterHandler
Returns:
the configuration of this resource loader, or null
See Also:
I_CmsConfigurationParameterHandler.getConfiguration()

getDigestType

public java.lang.String getDigestType()
Returns the digestType.

Specified by:
getDigestType in interface I_CmsPasswordHandler
Returns:
the digestType

getInputEncoding

public java.lang.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(java.lang.String digestType)
Sets the digestType.

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

setInputEncoding

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

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

validatePassword

public void validatePassword(java.lang.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)