Package org.apache.shiro.crypto.hash
Interface HashRequest
- All Known Implementing Classes:
SimpleHashRequest
public interface HashRequest
A
HashRequest is composed of data that will be used by a HashService to compute a hash (aka
'digest'). While you can instantiate a concrete HashRequest class directly, most will find using the
HashRequest.Builder more convenient.- Since:
- 1.2
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classA Builder class representing the Builder design pattern for constructingHashRequestinstances. -
Method Summary
Modifier and TypeMethodDescriptionReturns the name of the hash algorithm theHashServiceshould use when computing theHash, ornullif the default algorithm configuration of theHashServiceshould be used.Returns various parameters for the requested hash.Optional<org.apache.shiro.lang.util.ByteSource>getSalt()Returns a salt to be used by theHashServiceduring hash computation, ornullif no salt is provided as part of the request.org.apache.shiro.lang.util.ByteSourceReturns the source data that will be hashed by aHashService.
-
Method Details
-
getSource
org.apache.shiro.lang.util.ByteSource getSource()Returns the source data that will be hashed by aHashService. For example, this might be aByteSourcerepresentation of a password, or file, etc.- Returns:
- the source data that will be hashed by a
HashService.
-
getSalt
Optional<org.apache.shiro.lang.util.ByteSource> getSalt()Returns a salt to be used by theHashServiceduring hash computation, ornullif no salt is provided as part of the request. Note that anullvalue does not necessarily mean a salt won't be used at all - it just means that the request didn't include one. The servicingHashServiceis free to provide a salting strategy for a request, even if the request did not specify one.- Returns:
- a salt to be used by the
HashServiceduring hash computation, ornullif no salt is provided as part of the request.
-
getAlgorithmName
Returns the name of the hash algorithm theHashServiceshould use when computing theHash, ornullif the default algorithm configuration of theHashServiceshould be used. A non-null value overrides theHashService's configuration for a single request. Note that aHashServiceis free to ignore this value if it determines that the algorithm is not sufficient to meet a desired level of security.- Returns:
- the name of the hash algorithm the
HashServiceshould use when computing theHash, ornullif the default algorithm configuration of theHashServiceshould be used.
-
getParameters
Returns various parameters for the requested hash.If the map is empty for a specific parameter, the implementation must select the default.
Implementations should provide a nested
.Parametersclass withpublic static final Strings for convenience.Example parameters the number of requested hash iterations (does not apply to bcrypt), memory and cpu constrains, etc. Please find their specific names in the implementation’s nested
.Parametersclass.- Returns:
- the parameters for the requested hash to be used when computing the final
Hashresult. - Throws:
NullPointerException- if any of the values isnull.
-