@Override public Boolean checkPassword(String userId, String password, PasswordEncoder passwordEncoder, PasswordSalt salt) { User user = null; if (userId != null) { user = findById(userId); } return (user != null) && (password != null) && passwordEncoder.isMatches(password, user.getPassword(), salt); }
@Override public User execute(CommandContext commandContext) { if (!CommandContextUtil.getUserEntityManager(commandContext).isNewUser(user)) { PasswordEncoder passwordEncoder = CommandContextUtil.getIdmEngineConfiguration().getPasswordEncoder(); PasswordSalt passwordSalt = CommandContextUtil.getIdmEngineConfiguration().getPasswordSalt(); user.setPassword(passwordEncoder.encode(user.getPassword(), passwordSalt)); CommandContextUtil.getUserEntityManager(commandContext).updateUser(user); } return user; } }
@Override public Void execute(CommandContext commandContext) { if (user == null) { throw new FlowableIllegalArgumentException("user is null"); } if (CommandContextUtil.getUserEntityManager(commandContext).isNewUser(user)) { if (user.getPassword() != null) { PasswordEncoder passwordEncoder = CommandContextUtil.getIdmEngineConfiguration().getPasswordEncoder(); PasswordSalt passwordSalt = CommandContextUtil.getIdmEngineConfiguration().getPasswordSalt(); user.setPassword(passwordEncoder.encode(user.getPassword(), passwordSalt)); } if (user instanceof UserEntity) { CommandContextUtil.getUserEntityManager(commandContext).insert((UserEntity) user, true); } else { CommandContextUtil.getDbSqlSession(commandContext).insert((Entity) user); } } else { UserEntity dbUser = CommandContextUtil.getUserEntityManager().findById(user.getId()); user.setPassword(dbUser.getPassword()); CommandContextUtil.getUserEntityManager().updateUser(user); } return null; } }