SessionUtils { public static boolean isPasswordChangeRequired(HttpSession session) { Object passwordChangeRequired = session.getAttribute(PASSWORD_CHANGE_REQUIRED); if (passwordChangeRequired == null) { return false; } if (!(passwordChangeRequired instanceof Boolean)) { throw new IllegalArgumentException(String.format("The %s attribute on the session must be a Boolean", PASSWORD_CHANGE_REQUIRED)); } return (Boolean) passwordChangeRequired; } private  SessionUtils(); static boolean isPasswordChangeRequired(HttpSession session); static void setPasswordChangeRequired(HttpSession session, boolean passwordChangeRequired); static void setForcePasswordExpiredUser(HttpSession session, UaaAuthentication uaaAuthentication); static UaaAuthentication getForcePasswordExpiredUser(HttpSession session); static void setStateParam(HttpSession session, String stateParamKey, String state); static Object getStateParam(HttpSession session, String stateParamKey); static void setSecurityContext(HttpSession session, SecurityContext context); static void setSavedRequestSession(HttpSession session, SavedRequest clientRedirectSavedRequest); static SavedRequest getSavedRequestSession(HttpSession session); static AuthenticationException getAuthenticationException(HttpSession session); static String stateParameterAttributeKeyForIdp(String idpOriginKey); static final String PASSWORD_CHANGE_REQUIRED; static final String FORCE_PASSWORD_EXPIRED_USER; static final String SAVED_REQUEST_SESSION_ATTRIBUTE; static final String SPRING_SECURITY_CONTEXT; }
@Test void isPasswordChangeRequiredIfNull() { assertFalse(SessionUtils.isPasswordChangeRequired(mockHttpSession)); }
@Test void isPasswordChangeRequiredIfSetNotBoolean() { mockHttpSession.setAttribute(SessionUtils.PASSWORD_CHANGE_REQUIRED, "true"); assertThrows(IllegalArgumentException.class, () -> SessionUtils.isPasswordChangeRequired(mockHttpSession)); }