Package com.xpn.xwiki.objects.classes
Class PasswordClass
- java.lang.Object
-
- com.xpn.xwiki.objects.BaseElement<R>
-
- com.xpn.xwiki.objects.BaseCollection<ClassPropertyReference>
-
- com.xpn.xwiki.objects.classes.PropertyClass
-
- com.xpn.xwiki.objects.classes.StringClass
-
- com.xpn.xwiki.objects.classes.PasswordClass
-
- All Implemented Interfaces:
PropertyClassInterface,ElementInterface,ObjectInterface,PropertyInterface,Serializable,Cloneable,Comparable<PropertyClass>
public class PasswordClass extends StringClass
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringCRYPT_IDENTIFIERprotected static StringDEFAULT_CRYPT_ALGORITHMprotected static StringDEFAULT_HASH_ALGORITHMprotected static StringDEFAULT_STORAGEprotected static StringFORM_PASSWORD_PLACEHODLERprotected static StringHASH_IDENTIFIERprotected static org.slf4j.LoggerLOGGERprotected static StringSEPARATOR-
Fields inherited from class com.xpn.xwiki.objects.classes.PropertyClass
cachedCustomDisplayer
-
Fields inherited from class com.xpn.xwiki.objects.BaseCollection
currentReferenceDocumentReferenceResolver, fields, fieldsToRemove, number, relativeEntityReferenceResolver
-
Fields inherited from class com.xpn.xwiki.objects.BaseElement
documentReference, ownerDocument, referenceCache
-
-
Constructor Summary
Constructors Constructor Description PasswordClass()PasswordClass(PropertyMetaClass wclass)
-
Method Summary
-
Methods inherited from class com.xpn.xwiki.objects.classes.StringClass
getSize, isPicker, newProperty, setPicker, setSize
-
Methods inherited from class com.xpn.xwiki.objects.classes.PropertyClass
clone, compareTo, createReference, displayCustom, displayEdit, displayEdit, displayHidden, displayHidden, displayView, displayView, flushCache, fromStringArray, fromValue, fromXML, getCachedDefaultCustomDisplayer, getClassName, getClassType, getCustomDisplay, getDefaultCustomDisplayer, getFieldFullName, getFullQueryPropertyName, getHint, getId, getName, getNumber, getObject, getPrettyName, getPrettyName, getTooltip, getTooltip, getTranslatedPrettyName, getValidationMessage, getValidationRegExp, getXClass, getxWikiClass, initLazyCollections, isCustomDisplayed, isDisabled, isUnmodifiable, isValidColumnTypes, mergeProperty, newPropertyfromXML, renderContentInContext, renderContentInContext, setClassType, setCustomDisplay, setDisabled, setHint, setId, setName, setNumber, setObject, setPrettyName, setTooltip, setUnmodifiable, setValidationMessage, setValidationRegExp, setxWikiClass, toFormString, toString, toXML, toXML, validateProperty
-
Methods inherited from class com.xpn.xwiki.objects.BaseCollection
addField, addPropertyForRemoval, apply, equals, get, getCurrentReferenceDocumentReferenceResolver, getCustomMappingMap, getDateValue, getDiff, getDoubleValue, getField, getFieldList, getFieldsToRemove, getFloatValue, getIntValue, getIntValue, getLargeStringValue, getListValue, getLongValue, getProperties, getPropertyList, getPropertyNames, getRelativeEntityReferenceResolver, getRelativeXClassReference, getSetValue, getSortedIterator, getStringValue, getXClassReference, merge, merge, mergeField, put, removeField, safeget, safeput, setClassName, setDateValue, setDBStringListValue, setDocumentReference, setDoubleValue, setFields, setFieldsToRemove, setFloatValue, setIntValue, setLargeStringValue, setLongValue, setOwnerDocument, setSetValue, setStringListValue, setStringValue, setXClassReference, toXMLString
-
Methods inherited from class com.xpn.xwiki.objects.BaseElement
fromXML, getDocumentReference, getLocalEntityReferenceSerializer, getLocalization, getLocalKey, getLocalUidStringEntityReferenceSerializer, getMergeManager, getOwnerDocument, getReference, getXWikiContext, hashCode, localizePlain, localizePlainOrKey, merge, toString, toXMLString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.xpn.xwiki.objects.ElementInterface
apply, getDocumentReference, getReference, merge, merge, setDocumentReference, toString
-
Methods inherited from interface com.xpn.xwiki.objects.ObjectInterface
get, put, safeget, safeput
-
Methods inherited from interface com.xpn.xwiki.objects.classes.PropertyClassInterface
displayView
-
-
-
-
Field Detail
-
LOGGER
protected static org.slf4j.Logger LOGGER
-
DEFAULT_STORAGE
protected static final String DEFAULT_STORAGE
- See Also:
- Constant Field Values
-
DEFAULT_HASH_ALGORITHM
protected static final String DEFAULT_HASH_ALGORITHM
- See Also:
- Constant Field Values
-
DEFAULT_CRYPT_ALGORITHM
protected static final String DEFAULT_CRYPT_ALGORITHM
- See Also:
- Constant Field Values
-
HASH_IDENTIFIER
protected static final String HASH_IDENTIFIER
- See Also:
- Constant Field Values
-
CRYPT_IDENTIFIER
protected static final String CRYPT_IDENTIFIER
- See Also:
- Constant Field Values
-
SEPARATOR
protected static final String SEPARATOR
- See Also:
- Constant Field Values
-
FORM_PASSWORD_PLACEHODLER
protected static final String FORM_PASSWORD_PLACEHODLER
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PasswordClass
public PasswordClass(PropertyMetaClass wclass)
-
PasswordClass
public PasswordClass()
-
-
Method Detail
-
fromString
public BaseProperty fromString(String value)
- Specified by:
fromStringin interfacePropertyClassInterface- Overrides:
fromStringin classStringClass
-
displayHidden
public void displayHidden(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context)
- Specified by:
displayHiddenin interfacePropertyClassInterface- Overrides:
displayHiddenin classPropertyClass
-
displayView
public void displayView(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context)
- Specified by:
displayViewin interfacePropertyClassInterface- Overrides:
displayViewin classStringClass
-
displayEdit
public void displayEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context)
- Specified by:
displayEditin interfacePropertyClassInterface- Overrides:
displayEditin classStringClass
-
getStorageType
public String getStorageType()
- Returns:
- One of 'Clear', 'Hash' or 'Encrypt'.
-
setStorageType
public void setStorageType(String storageType)
- Parameters:
storageType- One of 'Clear', 'Hash' or 'Encrypt'- Since:
- 10.7RC1
-
getHashAlgorithm
public String getHashAlgorithm()
- Returns:
- The hash algorithm configured for this XProperty.
-
getCryptAlgorithm
public String getCryptAlgorithm()
- Returns:
- The encryption algorithm configured for this XProperty.
-
getAlgorithmFromPassword
public String getAlgorithmFromPassword(String password)
- Parameters:
password-- Returns:
- The algorithm used for the given password.
-
getSaltFromPassword
public String getSaltFromPassword(String password)
- Parameters:
password-- Returns:
- The salt used for the given password. If this is an unsalted password, let it be known by returning "".
-
getEquivalentPassword
public String getEquivalentPassword(String storedPassword, String plainPassword)
Transforms a plain text password so that it has the same encryption as a password stored in the database. The current configuration for this password XProperty cannot be used, as the user might have a different encryption mechanism (for example, if the user was imported, or the password was not yet upgraded).- Parameters:
storedPassword- The stored password, which gives the storage type and algorithm.plainPassword- The plain text password to be encrypted.- Returns:
- The input password, encrypted with the same mechanism as the stored password.
-
getPasswordHash
public String getPasswordHash(String password)
- Parameters:
password- the password to hash.- Returns:
- a string of the form
hash:<algorithmName>:<salt>:<hexStrignHash>, where<algorithmName>is the default hashing algorithm (seeDEFAULT_HASH_ALGORITHM),<salt>is a random 64 character salt and<hexStrignHash>is the salted hash of the given password, using the given hashing algorithm.
-
getPasswordHash
public String getPasswordHash(String password, String algorithmName)
- Parameters:
password- the password to hash.algorithmName- the name of the hashing algorithm to use. SeeMessageDigest.getInstance(String).- Returns:
- a string of the form
hash:<algorithmName>:<salt>:<hexStrignHash>, where<salt>is a random 64 character salt and<hexStrignHash>is the salted hash of the given password, using the given hashing algorithm.
-
getPasswordHash
public String getPasswordHash(String password, String algorithmName, String salt)
- Parameters:
password- the password to hash.algorithmName- the name of the hashing algorithm to use. SeeMessageDigest.getInstance(String).salt- the string to pad the password with before hashing. Ifnull, a random 64 character salt will be used. To disable salting, use an empty ("") salt string.- Returns:
- a string of the form
hash:<algorithmName>:<salt>:<hexStrignHash>, where<hexStrignHash>is the salted hash of the given password, using the given hashing algorithm. - Since:
- 6.3M2
-
randomSalt
public static String randomSalt()
-
-