|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.shiro.crypto.hash.HashRequest.Builder
public static class HashRequest.Builder
A Builder class representing the Builder design pattern for constructing HashRequest
instances.
SimpleHashRequest
Constructor Summary | |
---|---|
HashRequest.Builder()
Default no-arg constructor. |
Method Summary | |
---|---|
HashRequest |
build()
Builds a HashRequest instance reflecting the specified configuration. |
HashRequest.Builder |
setAlgorithmName(String algorithmName)
Sets the name of the hash algorithm the HashService should use when computing the Hash . |
HashRequest.Builder |
setIterations(int iterations)
Sets the number of requested hash iterations to be performed when computing the final Hash result. |
HashRequest.Builder |
setSalt(ByteSource salt)
Sets a salt to be used by the HashService during hash computation. |
HashRequest.Builder |
setSalt(Object salt)
Sets a salt to be used by the HashService during hash computation. |
HashRequest.Builder |
setSource(ByteSource source)
Sets the source data that will be hashed by a HashService . |
HashRequest.Builder |
setSource(Object source)
Sets the source data that will be hashed by a HashService . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public HashRequest.Builder()
Method Detail |
---|
public HashRequest.Builder setSource(ByteSource source)
HashService
. For example, this might be a
ByteSource
representation of a password, or file, etc.
source
- the source data that will be hashed by a HashService
.
Builder
instance for method chaining.HashRequest.getSource()
,
setSource(Object)
public HashRequest.Builder setSource(Object source) throws IllegalArgumentException
HashService
.
This is a convenience alternative to setSource(ByteSource)
: it will attempt to convert the
argument into a ByteSource
instance using Shiro's default conversion heuristics
(as defined by ByteSource.Util.isCompatible
. If the object
cannot be heuristically converted to a ByteSource
, an IllegalArgumentException
will be
thrown.
source
- the byte-backed source data that will be hashed by a HashService
.
Builder
instance for method chaining.
IllegalArgumentException
- if the argument cannot be heuristically converted to a ByteSource
instance.HashRequest.getSource()
,
setSource(ByteSource)
public HashRequest.Builder setSalt(ByteSource salt)
HashService
during hash computation.
NOTE: 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 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
Hash
getSalt()
method to see what the actual
salt was (if any), which may or may not match this request salt.
salt
- a salt to be used by the HashService
during hash computation
Builder
instance for method chaining.HashRequest.getSalt()
public HashRequest.Builder setSalt(Object salt) throws IllegalArgumentException
HashService
during hash computation.
This is a convenience alternative to setSalt(ByteSource)
: it will attempt to convert the
argument into a ByteSource
instance using Shiro's default conversion heuristics
(as defined by ByteSource.Util.isCompatible
. If the object
cannot be heuristically converted to a ByteSource
, an IllegalArgumentException
will be
thrown.
salt
- a salt to be used by the HashService
during hash computation.
Builder
instance for method chaining.
IllegalArgumentException
- if the argument cannot be heuristically converted to a ByteSource
instance.setSalt(ByteSource)
,
HashRequest.getSalt()
public HashRequest.Builder setIterations(int iterations)
Hash
result.
Not calling this method or setting a non-positive value (0 or less) indicates that the HashService
's
default iteration configuration should be used. A positive value overrides the HashService
's
configuration for a single request.
Note that a 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
Hash
getIterations()
method to see what the actual
number of iterations was, which may or may not match this request salt.
iterations
- the number of requested hash iterations to be performed when computing the final
Hash
result.
Builder
instance for method chaining.HashRequest.getIterations()
public HashRequest.Builder setAlgorithmName(String algorithmName)
HashService
should use when computing the Hash
.
Not calling this method or setting it to null
indicates the the default algorithm configuration of
the HashService
should be used. A non-null value
overrides the HashService
's configuration for a single request.
Note that a 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
Hash
getAlgorithmName()
method to see what the actual
algorithm was, which may or may not match this request salt.
algorithmName
- the name of the hash algorithm the HashService
should use when computing the
Hash
, or null
if the default algorithm configuration of the
HashService
should be used.
Builder
instance for method chaining.HashRequest.getAlgorithmName()
public HashRequest build()
HashRequest
instance reflecting the specified configuration.
HashRequest
instance reflecting the specified configuration.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |