org.jboss.serial.exception.SerializationException
tony.herstell1 Aug 15, 2007 9:14 PMGetting this...
13:09:13,674 WARN [Component] Exception calling stateful session bean default @Remove method: encryptionController java.lang.RuntimeException: java.lang.RuntimeException: org.jboss.serial.exception.SerializationException: Could not create instance of javax.crypto.Cipher - javax.crypto.Cipher
@Stateful // A component stays in existance for the duration of the Scope (session in this instance).
@Name("encryptionController") // Name used within SEAM for an instance of this class.
@Scope(ScopeType.SESSION) // Scope that this class exists in.
public class EncryptionControllerImpl implements EncryptionController {
/**
* Inject and leverage the Seam Logger.
*/
@Logger
private Log log;
public static final String ENCRYPTION_PROPERTIES = "encryption.properties";
public static final String PASS_PHRASE = "encryption.pass_phrase";
/*
* The properties for the encryption
*/
private Properties encryptionProperties;
private Cipher ecipher;
private Cipher dcipher;
/*
* Methods
*/
@Create // Is run whenever this bean is created.
public void initEncryptionSystem() {
/*
* This will pupm out a key each time the system is run so that we can find
* a valid key when we need one. ;)
*/
log.info("> initEncryptionSystem");
encryptionProperties = getEncryptionProperties();
String passPhrase = (String) encryptionProperties.get(PASS_PHRASE);
log.info("System Pass Phrase: " + passPhrase); // <- Remove this for sanity!
initDesEncrypter(passPhrase);
log.info("< initEncryptionSystem");
}
...
/**
* Sets up the Encrpytion engine based on the DES Algorithm
* using the key retreive from the .properties file.
*/
private void initDesEncrypter(String passPhrase) {
/*
* Ciphers used for encryption/decryption.
*/
byte[] salt = {
xxxxxx};
int iterationCount = 19;
log.info("> initDesEncrypter");
try {
// Create the key
KeySpec keySpec = new PBEKeySpec(passPhrase.toCharArray(), salt, iterationCount);
SecretKey key = SecretKeyFactory.getInstance(
"PBEWithMD5AndDES").generateSecret(keySpec);
ecipher = Cipher.getInstance(key.getAlgorithm());
dcipher = Cipher.getInstance(key.getAlgorithm());
// Prepare the parameter to the ciphers
AlgorithmParameterSpec paramSpec = new PBEParameterSpec(salt, iterationCount);
// Create the ciphers
ecipher.init(Cipher.ENCRYPT_MODE, key, paramSpec);
dcipher.init(Cipher.DECRYPT_MODE, key, paramSpec);
} catch (java.security.InvalidAlgorithmParameterException e) {
} catch (java.security.spec.InvalidKeySpecException e) {
} catch (javax.crypto.NoSuchPaddingException e) {
} catch (java.security.NoSuchAlgorithmException e) {
} catch (java.security.InvalidKeyException e) {
}
log.info("< initDesEncrypter");
}
Just wondering if I can get rid of the exception somehow... it doesn't seem to cause a problem... just fills up the logs and worries me...