org.szegedi.spring.crypto
Class GeneratedKeyPairFactory

java.lang.Object
  extended by org.springframework.beans.factory.config.AbstractFactoryBean
      extended by org.szegedi.spring.crypto.support.ProviderBasedFactory
          extended by org.szegedi.spring.crypto.GeneratedKeyPairFactory
All Implemented Interfaces:
org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.FactoryBean, org.springframework.beans.factory.InitializingBean

public class GeneratedKeyPairFactory
extends ProviderBasedFactory

Generates a new pair of a public and private keys. Note that as keys are not preserved across application context restarts, whatever you might have encrypted or signed using them will become invalid no later than when the JVM is shut down. Use the KeyStoreKeyPairFactory instead to load a persistent keypair from a Java keystore file.

Version:
$Id: GeneratedKeyPairFactory.java 79 2007-09-17 11:24:06Z szegedia $
Author:
Attila Szegedi

Field Summary
 
Fields inherited from class org.szegedi.spring.crypto.support.ProviderBasedFactory
provider
 
Fields inherited from class org.springframework.beans.factory.config.AbstractFactoryBean
logger
 
Constructor Summary
GeneratedKeyPairFactory()
           
 
Method Summary
protected  java.lang.Object createInstance()
           
 java.lang.Class getObjectType()
           
 void setAlgorithm(java.lang.String algorithm)
          Sets the key algorithm to use.
 void setKeySize(int keySize)
          Sets the size of the keys in bits.
 void setSecureRandom(java.security.SecureRandom secureRandom)
          Sets an instance of secure random to use.
 
Methods inherited from class org.szegedi.spring.crypto.support.ProviderBasedFactory
setProvider
 
Methods inherited from class org.springframework.beans.factory.config.AbstractFactoryBean
afterPropertiesSet, destroy, destroyInstance, getBeanFactory, getBeanTypeConverter, getEarlySingletonInterfaces, getObject, isSingleton, setBeanFactory, setSingleton
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GeneratedKeyPairFactory

public GeneratedKeyPairFactory()
Method Detail

setAlgorithm

public void setAlgorithm(java.lang.String algorithm)
Sets the key algorithm to use. Defaults to "RSA".

Parameters:
algorithm - the key algorithm

setKeySize

public void setKeySize(int keySize)
Sets the size of the keys in bits. Defaults to 1024.

Parameters:
keySize - the size of the keys.

setSecureRandom

public void setSecureRandom(java.security.SecureRandom secureRandom)
Sets an instance of secure random to use. If not set, a one-off instance created using a private instance of SecureRandomFactory will be created, with the configured security provider.

Parameters:
secureRandom - the secure random instance to use.

createInstance

protected java.lang.Object createInstance()
                                   throws java.lang.Exception
Specified by:
createInstance in class org.springframework.beans.factory.config.AbstractFactoryBean
Throws:
java.lang.Exception

getObjectType

public java.lang.Class getObjectType()
Specified by:
getObjectType in interface org.springframework.beans.factory.FactoryBean
Specified by:
getObjectType in class org.springframework.beans.factory.config.AbstractFactoryBean
Returns:
KeyPair.class