Package com.exedio.cope.pattern
Class Hash
java.lang.Object
com.exedio.cope.Feature
com.exedio.cope.Pattern
com.exedio.cope.pattern.Hash
- All Implemented Interfaces:
HashInterface
,Settable<String>
,Serializable
- Direct Known Subclasses:
MD5Hash
,MessageDigestHash
,SHAHash
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
static final class
A plain text is either too short, too long or doesn't match the format requirementstatic class
Validate plain text for potential limits, to be specified in sub classes -
Constructor Summary
ConstructorsConstructorDescriptionHash
(Hash.Algorithm algorithm) Hash
(Hash.Algorithm algorithm, String encoding) Deprecated.Hash
(Hash.Algorithm algorithm, Charset charset) Hash
(HashAlgorithm algorithm) Hash
(StringField storage, Hash.Algorithm algorithm) Hash
(StringField storage, Hash.Algorithm algorithm, String encoding) Deprecated.UseHash(StringField, Algorithm, Charset)
insteadHash
(StringField storage, Hash.Algorithm algorithm, Charset charset) Hash
(StringField storage, HashAlgorithm algorithm) -
Method Summary
Modifier and TypeMethodDescriptionfinal void
Deprecated.Useblind(String)
instead.final void
Wastes (almost) as much cpu cycles, as a call tocheck(Item, String)
would have needed.final boolean
final void
checkPlainText
(String plainText) final SetValue<?>[]
final Hash.Algorithm
Deprecated.UsegetAlgorithm2()
instead.final HashAlgorithm
final String
final String
Deprecated.UsegetAlgorithmID()
insteadfinal String
Deprecated.Throws exception if not initialized viaHash.Algorithm
.final String
Returns the exceptions possibly thrown, when setting a value for this settable.final Class<?>
final int
final Hash.PlainTextValidator
final StringField
final String
final boolean
isFinal()
Returns true, if a value for the settable can be specified on the creation of an item only, thus cannot be modified later.final boolean
Returns true, if a value for the settable should be specified on the creation of an item.final boolean
final Condition
final Condition
final Condition
isNull()
final boolean
final Condition
final Hash
limit
(int plainTextLimit) Creates a new hash with a new plain text limit.final String
newRandomPassword
(SecureRandom random) final Hash
optional()
final void
final void
final Hash
toFinal()
final Hash
validate
(Hash.PlainTextValidator validator) Methods inherited from class com.exedio.cope.Pattern
addSource, addSource, addSource, addSource, addSourceFeature, addSourceFeature, addSourceFeature, annotationField, equals, getGeneratedTypes, getSourceFeatures, getSourceFeaturesGather, getSourceFields, getSources, getSourceTypes, getType, hashCode, initialize, newSourceType, newSourceType, newSourceType, newSourceType, newSourceType, newSourceType, newType, newType, onMount, registerSource
Methods inherited from class com.exedio.cope.Feature
afterModelCreated, getAbstractType, getAnnotation, getID, getLocalizationKeys, getName, getPattern, isAnnotationPresent, isSourceAlready, mount, readResolve, requireMounted, toString, toString, writeReplace
-
Constructor Details
-
Hash
-
Hash
-
Hash
-
Hash
-
Hash
-
Hash
-
Hash
Deprecated.UseHash(StringField, Algorithm, Charset)
instead -
Hash
Deprecated.UseHash(Algorithm, Charset)
instead
-
-
Method Details
-
getStorage
-
getPlainTextLimit
public final int getPlainTextLimit()- See Also:
-
getAlgorithm2
-
getAlgorithmID
-
getEncoding
Deprecated.Throws exception if not initialized viaHash.Algorithm
. -
getPlainTextValidator
- See Also:
-
isInitial
public final boolean isInitial()Description copied from interface:Settable
Returns true, if a value for the settable should be specified on the creation of an item. -
isFinal
public final boolean isFinal()Description copied from interface:Settable
Returns true, if a value for the settable can be specified on the creation of an item only, thus cannot be modified later. -
isMandatory
public final boolean isMandatory()- Specified by:
isMandatory
in interfaceSettable<String>
-
getInitialType
- Specified by:
getInitialType
in interfaceSettable<String>
-
getInitialExceptions
Description copied from interface:Settable
Returns the exceptions possibly thrown, when setting a value for this settable.- Specified by:
getInitialExceptions
in interfaceSettable<String>
-
toFinal
-
optional
-
limit
Creates a new hash with a new plain text limit. The default is 150. Setting hashes longer than the limit will cause anHash.InvalidPlainTextException
.Checking
for hashes longer than the limit will silently return false. This is a precaution against DOS attacks with very long plain texts.- See Also:
-
validate
- See Also:
-
set
- Specified by:
set
in interfaceHashInterface
-
check
- Specified by:
check
in interfaceHashInterface
-
isNull
- Specified by:
isNull
in interfaceHashInterface
-
blind
Wastes (almost) as much cpu cycles, as a call tocheck(Item, String)
would have needed. Needed to prevent Timing Attacks. See https://en.wikipedia.org/wiki/Timing_attack- Specified by:
blind
in interfaceHashInterface
-
execute
public final SetValue<?>[] execute(String value, Item exceptionItem) throws Hash.InvalidPlainTextException - Specified by:
execute
in interfaceSettable<String>
- Throws:
Hash.InvalidPlainTextException
-
getHash
- Specified by:
getHash
in interfaceHashInterface
-
setHash
-
hash
-
checkPlainText
-
isNull
-
isNull
-
isNotNull
-
isNotNull
-
newRandomPassword
- Specified by:
newRandomPassword
in interfaceHashInterface
-
getAlgorithmName
Deprecated.UsegetAlgorithmID()
instead -
getAlgorithm
Deprecated.UsegetAlgorithm2()
instead. Throws exception if not initialized viaHash.Algorithm
. -
blind
Deprecated.Useblind(String)
instead.
-
Hash(Algorithm, Charset)
instead