@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public User createUser(@NotNull User user, String password) { if (user.getId() != null) { throw new HiveException(Messages.ID_NOT_ALLOWED, BAD_REQUEST.getStatusCode()); } user.setLogin(StringUtils.trim(user.getLogin())); User existing = userDAO.findByLogin(user.getLogin()); if (existing != null) { throw new HiveException(Messages.DUPLICATE_LOGIN, FORBIDDEN.getStatusCode()); } if (StringUtils.isEmpty(password)) { throw new HiveException(Messages.PASSWORD_REQUIRED, BAD_REQUEST.getStatusCode()); } String salt = passwordService.generateSalt(); String hash = passwordService.hashPassword(password, salt); user.setPasswordSalt(salt); user.setPasswordHash(hash); user.setLoginAttempts(Constants.INITIAL_LOGIN_ATTEMPTS); hiveValidator.validate(user); return userDAO.create(user); }