*/
public void save() throws RegistryException {
EntityManager em = null;
try {
em = ResourceUtils.getEntityManager();
Users existingUser = em.find(Users.class, userName);
em.close();
em = ResourceUtils.getEntityManager();
em.getTransaction().begin();
Users user = new Users();
user.setUser_name(userName);
if (password != null && !password.equals("")) {
try {
user.setPassword(SecurityUtil.digestString(password,
RegistrySettings.getSetting("default.registry.password.hash.method")));
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException("Error hashing default admin password. Invalid hash algorithm.", e);
} catch (RegistrySettingsException e) {
throw new RuntimeException("Error reading hash algorithm from configurations", e);