public static boolean SaveAccount(Account account)
{
logger.executionTrace();
final Session session = DatabaseUtil.getSessionFactory().getCurrentSession();
final Account existingAccount = getAccount(session, account.getUsername());
if (existingAccount == null)
{
final RandomNumberGenerator random = new SecureRandomNumberGenerator();
account.setSalt(random.nextBytes().toBase64());
account.setPassword(new Sha256Hash(account.getPassword(), account.getSalt(), 1024).toBase64());
}
else
{
// Don't allow password changes during an account update.
account.setPassword(existingAccount.getPassword());
}
if (!session.getTransaction().isActive())
session.getTransaction().begin();