try {
Cryptor cryptor = (Cryptor) CryptorFactory.getCryptor();
return cryptor.encrypt(str);
} catch (InvalidKeyException e) {
logger.error("Invalid Key Exception in crypting the password", e);
throw new FatalErrorException(new ErrorMessage(
"errors.auth.cryptor.InvalidKey", e.getMessage()));
} catch (NoSuchPaddingException e) {
logger.error("Padding Exception in crypting the password", e);
throw new FatalErrorException(new ErrorMessage(
"errors.auth.cryptor.Padding", e.getMessage()));
} catch (NoSuchAlgorithmException e) {
logger.error("Algorithm Exception in crypting the password", e);
throw new FatalErrorException(new ErrorMessage(
"errors.auth.cryptor.Algorithm", e.getMessage()));
} catch (InvalidAlgorithmParameterException e) {
logger.error("Algorithm parameter Exception in crypting the password",
e);
throw new FatalErrorException(new ErrorMessage(
"errors.auth.cryptor.AlgorithmParam", e.getMessage()));
} catch (IllegalBlockSizeException e) {
logger.error("Block size Exception in crypting the password", e);
throw new FatalErrorException(new ErrorMessage(
"errors.auth.cryptor.BlockSize", e.getMessage()));
} catch (BadPaddingException e) {
logger.error("Bad Padding Exception in crypting the password", e);
throw new FatalErrorException(new ErrorMessage(
"errors.auth.cryptor.BadPadding", e.getMessage()));
}
}