class AcmLoginSuccessOperations {

    protected void setPasswordExpirationSessionAttribute(HttpServletRequest request)
    {
        HttpSession session = request.getSession(false);
        AcmUser acmUser = (AcmUser) session.getAttribute("acm_user");

        LocalDate passwordExpirationDate = acmUser.getPasswordExpirationDate();
        LocalDate today = LocalDate.now();
        if (passwordExpirationDate != null)
        {
            long daysBetween = DAYS.between(today, passwordExpirationDate);
            if (daysBetween <= DAYS_TO_PASSWORD_EXPIRATION)
            {
                String daysToExpiration = daysBetween == 0 ? "today" : String.format("in %d day(s)", daysBetween);
                session.setAttribute("acm_user_message",
                        "Your password expires " + daysToExpiration + ", please change it before expiration date.");
            }
        }
    }

}