/// <summary> /// Adds the specified AuthnRequest 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="authnRequest">AuthnRequest to add to the collection.</param> internal static void AddSentAuthnRequest(HttpContext context, AuthnRequest authnRequest) { Queue authnRequests = AuthnRequestCache.GetSentAuthnRequests(context); if (authnRequests == null) { authnRequests = new Queue(AuthnRequestCache.MaximumRequestsStored); } if (authnRequests.Count == AuthnRequestCache.MaximumRequestsStored) { authnRequests.Dequeue(); } authnRequests.Enqueue(authnRequest); context.Session[AuthnRequestCache.AuthnRequestSessionAttribute] = authnRequests; StringBuilder message = new StringBuilder(); message.Append("AuthnRequestsCache:\r\n"); IEnumerator i = authnRequests.GetEnumerator(); while (i.MoveNext()) { AuthnRequest a = (AuthnRequest)i.Current; message.Append(a.Id + "\r\n"); } FedletLogger.Info(message.ToString()); }
/// <summary> /// Removes the AuthnRequest from the collection of previously /// sent requests based on the provided AuthnRequest.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="authnRequestId"> /// ID of the AuthnRequest to be removed from the cache. /// </param> internal static void RemoveSentAuthnRequest(HttpContext context, string authnRequestId) { Queue originalCache = AuthnRequestCache.GetSentAuthnRequests(context); if (originalCache != null) { Queue revisedCache = new Queue(); while (originalCache.Count > 0) { AuthnRequest temp = (AuthnRequest)originalCache.Dequeue(); if (temp.Id != authnRequestId) { revisedCache.Enqueue(temp); } } context.Session[AuthnRequestCache.AuthnRequestSessionAttribute] = revisedCache; } }