/// <summary> /// Return whether the session is valid or not. Performs a /// remote check to Maestrano if required. /// </summary> /// <param name="client">RestClient to use for Remote validation</param> /// <param name="steps">Validation steps to perform</param> /// <returns>True if the Session should be treated as valid, otherwise false.</returns> public Boolean IsValid(RestClient client, SessionValidationSteps steps) { if (steps == SessionValidationSteps.None) { throw new ArgumentOutOfRangeException("steps", "IsValid should be called if you are not going to do any validation!"); } if ((steps & SessionValidationSteps.ValidIfNoHttpSessionState) != SessionValidationSteps.ValidIfNoHttpSessionState) { throw new ArgumentOutOfRangeException("steps", "ValidIfNoHttpSessionState must be the only step if it is specified."); } // Return true automatically if Single Logout (SLO) is disabled if (!MnoHelper.Sso.SloEnabled) { return(true); } // Return true if maestrano session not set // and only the HttpSessionState step is requested if (steps == SessionValidationSteps.ValidIfNoHttpSessionState && (HttpSession == null || HttpSession["maestrano"] == null)) { return(true); } // Perform local validation if ((steps & (SessionValidationSteps.RequireEventListener | SessionValidationSteps.RequireHttpSessionState)) == steps) { if (HttpSession == null && Saved == null) { return(false); } } else { if (steps.HasFlag(SessionValidationSteps.RequireHttpSessionState) && HttpSession == null) { return(false); } if (steps.HasFlag(SessionValidationSteps.RequireEventListener) && Saved == null) { return(false); } } if (steps.HasFlag(SessionValidationSteps.PerformRemoteCheck) && isRemoteCheckRequired()) { if (client == null) { client = new RestClient(MnoHelper.Sso.Idp); } if (PerformRemoteCheck(client)) { Save(); return(true); } else { return(false); } } return(true); }
/// <summary> /// Return whether the session is valid or not. Performs a /// remote check to Maestrano if required. /// </summary> /// <param name="steps">Validation steps to perform</param> /// <returns>True if the Session should be treated as valid, otherwise false.</returns> public Boolean IsValid(SessionValidationSteps steps) { return(IsValid(null, steps)); }