org.springframework.security.token
Class SecureRandomFactoryBean

java.lang.Object
  extended by org.springframework.security.token.SecureRandomFactoryBean
All Implemented Interfaces:
org.springframework.beans.factory.FactoryBean

public class SecureRandomFactoryBean
extends java.lang.Object
implements org.springframework.beans.factory.FactoryBean

Creates a SecureRandom instance.

Since:
2.0.1
Author:
Ben Alex

Constructor Summary
SecureRandomFactoryBean()
           
 
Method Summary
 java.lang.Object getObject()
           
 java.lang.Class 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 the SecureRandom instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SecureRandomFactoryBean

public SecureRandomFactoryBean()
Method Detail

getObject

public java.lang.Object getObject()
                           throws java.lang.Exception
Specified by:
getObject in interface org.springframework.beans.factory.FactoryBean
Throws:
java.lang.Exception

getObjectType

public java.lang.Class getObjectType()
Specified by:
getObjectType in interface org.springframework.beans.factory.FactoryBean

isSingleton

public boolean isSingleton()
Specified by:
isSingleton in interface org.springframework.beans.factory.FactoryBean

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 the SecureRandom instance. Specifically, the resource will be read into an InputStream and those bytes presented to the SecureRandom.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, or null if no additional seeding is needed