Expresso 5-6

com.jcorporate.expresso.core.security
Class CryptoManager

java.lang.Object
  extended bycom.jcorporate.expresso.kernel.ComponentBase
      extended bycom.jcorporate.expresso.core.security.CryptoManager
All Implemented Interfaces:
ComponentLifecycle, Describable, ExpressoComponent, Serializable

public class CryptoManager
extends ComponentBase
implements ComponentLifecycle

CryptoManager.java

Singleton Class that acts as a facade for managing if strong or weak crypto is desired.

Copyright 2000-2002 Jcorporate Ltd.

Since:
Expresso 3.0
Author:
Michael Rimov
See Also:
Serialized Form

Field Summary
protected static ByteArrayCounter ivCounter
           
protected  AbstractRandomNumber randomGenerator
           
protected  AbstractStringEncryption stringEncryptor
           
protected  StringHash stringHash
           
 
Constructor Summary
CryptoManager()
          Do not call this constructor directly.
 
Method Summary
 void configure(Configuration newConfig)
          Configure the Cryptographic manager
 void destroy()
          Method removes all static entries.
 String getCryptoKey()
           
 String getEncryptMode()
           
static CryptoManager getInstance()
          Singleton Generator.
 AbstractRandomNumber getRandomGenerator()
          Returns an instantiated subclass of AbstractRandomNumber depending if strong or weak crypto is desired.
 String getRandomSeed()
           
 AbstractStringEncryption getStringEncryption()
          Factory method that returns an instantiated subclass of AbstractStringEncryption depending of strong or weak crypto is desired.
 StringHash getStringHash()
          Factory method that returns an instantiated subclass of AbstractStringHash depending of strong or weak crypto is desired.
 void initialize()
          Initialize the component, this is called before the component receives any configuration information.
 boolean isInitialized()
           
 boolean isStrongCrypto()
           
 boolean isUsingStrongCrypto()
          Returns whether the crypto manager is using strong cryptography or not.
 void loadClasses(boolean useStrongCrypto)
          Loads the appropriate crypto classes.
 void reconfigure(Configuration newConfig)
          Reconfigure lifecycle event.
 void setCryptoKey(String cryptoKey)
           
 void setEncryptMode(String encryptMode)
           
 void setRandomSeed(String randomSeed)
           
 void setStrongCrypto(boolean strongCrypto)
           
 
Methods inherited from class com.jcorporate.expresso.kernel.ComponentBase
getMetaData, getMetadataLocation, getParent, setMetaData, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ivCounter

protected static ByteArrayCounter ivCounter

randomGenerator

protected AbstractRandomNumber randomGenerator

stringEncryptor

protected AbstractStringEncryption stringEncryptor

stringHash

protected StringHash stringHash
Constructor Detail

CryptoManager

public CryptoManager()
Do not call this constructor directly. Use getInstance() instead. This is public ONLY so that it can be instantiated by the test program.

Method Detail

getInstance

public static CryptoManager getInstance()
                                 throws ChainedException
Singleton Generator. Call to get an instance of the Crypto Manager

Please Note If strong encryption is used, this class may take quite some time in initializing due to the nature of generating a default seed for the crypto-strength random number generator.

Returns:
the ony and only instance of the Crypto Manager;
Throws:
ChainedException - If there is a problem instantiating the crypto classes

destroy

public void destroy()
Method removes all static entries.

Specified by:
destroy in interface ComponentLifecycle

isUsingStrongCrypto

public boolean isUsingStrongCrypto()
Returns whether the crypto manager is using strong cryptography or not.

Returns:
true if a strong cryptographic provider is included

getRandomGenerator

public AbstractRandomNumber getRandomGenerator()
Returns an instantiated subclass of AbstractRandomNumber depending if strong or weak crypto is desired.

Returns:
a random number generator
See Also:
AbstractRandomNumber, RandomNumber, RandomNumber

getStringEncryption

public AbstractStringEncryption getStringEncryption()
Factory method that returns an instantiated subclass of AbstractStringEncryption depending of strong or weak crypto is desired.

Returns:
A string encryption concrete class.
See Also:
AbstractStringEncryption, StringEncryption, StringEncryption

getStringHash

public StringHash getStringHash()
Factory method that returns an instantiated subclass of AbstractStringHash depending of strong or weak crypto is desired.

Returns:
An instantiated String Hashing class
See Also:
StringHash

loadClasses

public void loadClasses(boolean useStrongCrypto)
                 throws ChainedException
Loads the appropriate crypto classes. Also is split off from the constructor for testing purposes.

Parameters:
useStrongCrypto - Set to true if we desire to load the strong cryptographic classes.
Throws:
ChainedException - upon error loading the classes.

initialize

public void initialize()
Description copied from interface: ComponentLifecycle
Initialize the component, this is called before the component receives any configuration information.

Specified by:
initialize in interface ComponentLifecycle

configure

public void configure(Configuration newConfig)
               throws ConfigurationException
Configure the Cryptographic manager

Specified by:
configure in interface ComponentLifecycle
Parameters:
newConfig - the new configuration bean to configure with
Throws:
ConfigurationException - upon configuration error

reconfigure

public void reconfigure(Configuration newConfig)
                 throws ConfigurationException
Reconfigure lifecycle event. Destroys itself and reconstructs with the new configuration

Specified by:
reconfigure in interface ComponentLifecycle
Parameters:
newConfig - the configuration data to reconfigure with.
Throws:
ConfigurationException - if for some reason the Component cannot cope with the configuration sent to it. If this exception is thrown then ZERO reconfiguration takes place. Configure() must be an all or nothing 'transaction'

isStrongCrypto

public boolean isStrongCrypto()

setStrongCrypto

public void setStrongCrypto(boolean strongCrypto)

getEncryptMode

public String getEncryptMode()

setEncryptMode

public void setEncryptMode(String encryptMode)

isInitialized

public boolean isInitialized()

setCryptoKey

public void setCryptoKey(String cryptoKey)

getCryptoKey

public String getCryptoKey()

setRandomSeed

public void setRandomSeed(String randomSeed)

getRandomSeed

public String getRandomSeed()

Expresso 5-6

Please see www.jcorporate.com for information about new Expresso releases.