Class SecureRandomFactoryBean
- java.lang.Object
-
- org.springframework.security.core.token.SecureRandomFactoryBean
-
- All Implemented Interfaces:
org.springframework.beans.factory.FactoryBean<java.security.SecureRandom>
public class SecureRandomFactoryBean extends java.lang.Object implements org.springframework.beans.factory.FactoryBean<java.security.SecureRandom>
Creates aSecureRandom
instance.- Since:
- 2.0.1
-
-
Constructor Summary
Constructors Constructor Description SecureRandomFactoryBean()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.security.SecureRandom
getObject()
java.lang.Class<java.security.SecureRandom>
getObjectType()
boolean
isSingleton()
void
setAlgorithm(java.lang.String algorithm)
Allows the Pseudo Random Number Generator (PRNG) algorithm to be nominated.void
setSeed(org.springframework.core.io.Resource seed)
Allows the user to specify a resource which will act as a seed for theSecureRandom
instance.
-
-
-
Method Detail
-
getObject
public java.security.SecureRandom getObject() throws java.lang.Exception
- Specified by:
getObject
in interfaceorg.springframework.beans.factory.FactoryBean<java.security.SecureRandom>
- Throws:
java.lang.Exception
-
getObjectType
public java.lang.Class<java.security.SecureRandom> getObjectType()
- Specified by:
getObjectType
in interfaceorg.springframework.beans.factory.FactoryBean<java.security.SecureRandom>
-
isSingleton
public boolean isSingleton()
- Specified by:
isSingleton
in interfaceorg.springframework.beans.factory.FactoryBean<java.security.SecureRandom>
-
setAlgorithm
public void setAlgorithm(java.lang.String algorithm)
Allows the Pseudo Random Number Generator (PRNG) algorithm to be nominated. Defaults to "SHA1PRNG".- Parameters:
algorithm
- to use (mandatory)
-
setSeed
public void setSeed(org.springframework.core.io.Resource seed)
Allows the user to specify a resource which will act as a seed for theSecureRandom
instance. Specifically, the resource will be read into anInputStream
and those bytes presented to theSecureRandom.setSeed(byte[])
method. Note that this will simply supplement, rather than replace, the existing seed. As such, it is always safe to set a seed using this method (it never reduces randomness).- Parameters:
seed
- to use, ornull
if no additional seeding is needed
-
-