HashRequest.Builder

A Builder class representing the Builder design pattern for constructing {@link HashRequest} instances.

@see SimpleHashRequest

Constructors

this
this()

Default no-arg constructor.

Members

Functions

build
HashRequest build()

Builds a {@link HashRequest} instance reflecting the specified configuration.

setAlgorithmName
Builder setAlgorithmName(string algorithmName)

Sets the name of the hash algorithm the {@code HashService} should use when computing the {@link Hash}. Not calling this method or setting it to {@code null} indicates the the default algorithm configuration of the {@code HashService} should be used. A non-null value overrides the {@code HashService}'s configuration for a single request. <p/> Note that a {@code HashService} is free to ignore this value if it determines that the algorithm is not sufficient to meet a desired level of security. You can always check the result {@code Hash} {@link Hash#getAlgorithmName() getAlgorithmName()} method to see what the actual algorithm was, which may or may not match this request salt.

setIterations
Builder setIterations(int iterations)

Sets the number of requested hash iterations to be performed when computing the final {@code Hash} result. Not calling this method or setting a non-positive value (0 or less) indicates that the {@code HashService}'s default iteration configuration should be used. A positive value overrides the {@code HashService}'s configuration for a single request. <p/> Note that a {@code HashService} is free to ignore this number if it determines the number is not sufficient to meet a desired level of security. You can always check the result {@code Hash} {@link Hash#getIterations() getIterations()} method to see what the actual number of iterations was, which may or may not match this request salt.

setSalt
Builder setSalt(ByteSource salt)

Sets a salt to be used by the {@link HashService} during hash computation. <p/> <b>NOTE</b>: not calling this method does not necessarily mean a salt won't be used at all - it just means that the request didn't include a salt. The servicing {@link HashService} is free to provide a salting strategy for a request, even if the request did not specify one. You can always check the result {@code Hash} {@link Hash#getSalt() getSalt()} method to see what the actual salt was (if any), which may or may not match this request salt.

setSalt
Builder setSalt(Object salt)

Sets a salt to be used by the {@link HashService} during hash computation. <p/> This is a convenience alternative to {@link #setSalt(ByteSource)}: it will attempt to convert the argument into a {@link ByteSource} instance using Shiro's default conversion heuristics (as defined by {@link ByteSourceUtil#isCompatible(Object) ByteSourceUtil.isCompatible}. If the object cannot be heuristically converted to a {@code ByteSource}, an {@code IllegalArgumentException} will be thrown.

setSource
Builder setSource(ByteSource source)

Sets the source data that will be hashed by a {@link HashService}. For example, this might be a {@code ByteSource} representation of a password, or file, etc.

setSource
Builder setSource(Object source)

Sets the source data that will be hashed by a {@link HashService}. <p/> This is a convenience alternative to {@link #setSource(ByteSource)}: it will attempt to convert the argument into a {@link ByteSource} instance using Shiro's default conversion heuristics (as defined by {@link ByteSourceUtil#isCompatible(Object) ByteSourceUtil.isCompatible}. If the object cannot be heuristically converted to a {@code ByteSource}, an {@code IllegalArgumentException} will be thrown.

Meta