/** * Generate a new password of given user and tag it as secured. The password generation is delegated to the first * password plug-in available. When no plug-in is found, the user is not tagged as secured. * * @param user * The user to update. * @param quiet * Flag to turn-off the possible notification such as mail. * @return The new generated password. When <code>null</code> no password could be generated, and the user is not * tagged as secured. */ protected String updatePassword(final UserOrg user, final boolean quiet) { return applicationContext.getBeansOfType(IPasswordGenerator.class).values().stream().findFirst().map(p -> { // Have to generate a new password final String password = p.generate(user.getId(), quiet); // This user is now secured user.setSecured(true); return password; }).orElse(null); }