Exemplo n.º 1
0
        /// <summary>
        /// Adds the specified LogoutRequest to the collection of previously
        /// sent requests, maintaining the imposed limit as defined by
        /// MaximumRequestsStored.  This collection is represented as a
        /// queue and is attached to the user's session.
        /// </summary>
        /// <param name="context">
        /// HttpContext containing session, request, and response objects.
        /// </param>
        /// <param name="logoutRequest">
        /// LogoutRequest to add to the collection.
        /// </param>
        internal static void AddSentLogoutRequest(HttpContext context, LogoutRequest logoutRequest)
        {
            Queue logoutRequests = LogoutRequestCache.GetSentLogoutRequests(context);

            if (logoutRequests == null)
            {
                logoutRequests = new Queue(LogoutRequestCache.MaximumRequestsStored);
            }

            if (logoutRequests.Count == LogoutRequestCache.MaximumRequestsStored)
            {
                logoutRequests.Dequeue();
            }

            logoutRequests.Enqueue(logoutRequest);
            context.Session[LogoutRequestCache.LogoutRequestSessionAttribute] = logoutRequests;

            StringBuilder message = new StringBuilder();

            message.Append("LogoutRequestCache:\r\n");
            IEnumerator i = logoutRequests.GetEnumerator();

            while (i.MoveNext())
            {
                LogoutRequest l = (LogoutRequest)i.Current;
                message.Append(l.Id + "\r\n");
            }

            FedletLogger.Info(message.ToString());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Removes the LogoutRequest from the collection of previously
        /// sent requests based on the provided LogoutRequest.Id value.
        /// This collection is represented as a queue and is attached to
        /// the user's session.
        /// </summary>
        /// <param name="context">
        /// HttpContext containing session, request, and response objects.
        /// </param>
        /// <param name="logoutRequestId">
        /// ID of the LogoutRequest to be removed from the cache.
        /// </param>
        internal static void RemoveSentLogoutRequest(HttpContext context, string logoutRequestId)
        {
            Queue originalCache = LogoutRequestCache.GetSentLogoutRequests(context);

            if (originalCache != null)
            {
                Queue revisedCache = new Queue();
                while (originalCache.Count > 0)
                {
                    LogoutRequest temp = (LogoutRequest)originalCache.Dequeue();
                    if (temp.Id != logoutRequestId)
                    {
                        revisedCache.Enqueue(temp);
                    }
                }

                context.Session[LogoutRequestCache.LogoutRequestSessionAttribute] = revisedCache;
            }
        }