private bool TryMatchCore(Message message, out KeyValuePair <MessageFilter, FilterData> match)
 {
     match = new KeyValuePair <MessageFilter, FilterData>();
     if (!SecuritySessionFilter.ShouldExcludeMessage(message, this.excludedActions))
     {
         List <UniqueId> list;
         try
         {
             if (!this.TryGetContextIds(message, out list))
             {
                 return(false);
             }
         }
         catch (Exception exception)
         {
             if (!SecuritySessionFilter.CanHandleException(exception))
             {
                 throw;
             }
             return(false);
         }
         for (int i = 0; i < list.Count; i++)
         {
             if (this.contextMappings.TryGetValue(list[i], out match))
             {
                 message.Properties.Remove(SecuritySessionFilter.SessionContextIdsProperty);
                 return(true);
             }
         }
     }
     return(false);
 }
Пример #2
0
            bool TryMatchCore(Message message, out KeyValuePair <MessageFilter, FilterData> match)
            {
                match = default(KeyValuePair <MessageFilter, FilterData>);
                if (ShouldExcludeMessage(message, this.excludedActions))
                {
                    return(false);
                }
                List <UniqueId> contextIds;

                try
                {
                    if (!TryGetContextIds(message, out contextIds))
                    {
                        return(false);
                    }
                }
#pragma warning suppress 56500 // covered by FxCOP
                catch (Exception e)
                {
                    if (!SecuritySessionFilter.CanHandleException(e))
                    {
                        throw;
                    }
                    return(false);
                }
                for (int i = 0; i < contextIds.Count; ++i)
                {
                    if (this.contextMappings.TryGetValue(contextIds[i], out match))
                    {
                        message.Properties.Remove(SessionContextIdsProperty);
                        return(true);
                    }
                }
                return(false);
            }
Пример #3
0
            public void Add(MessageFilter filter, FilterData data)
            {
                SecuritySessionFilter sessionFilter = filter as SecuritySessionFilter;

                if (sessionFilter == null)
                {
                    Fx.Assert(String.Format(CultureInfo.InvariantCulture, "Unknown filter type {0}", filter.GetType()));
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.GetString(SR.UnknownFilterType, filter.GetType())));
                }
                if (sessionFilter.standardsManager != this.standardsManager)
                {
                    Fx.Assert("Standards manager of filter does not match that of filter table");
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.GetString(SR.StandardsManagerDoesNotMatch)));
                }
                if (sessionFilter.isStrictMode != this.isStrictMode)
                {
                    Fx.Assert("Session filter's isStrictMode differs from filter table's isStrictMode");
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.GetString(SR.FilterStrictModeDifferent)));
                }
                if (this.contextMappings.ContainsKey(sessionFilter.SecurityContextTokenId))
                {
                    Fx.Assert(SR.GetString(SR.SecuritySessionIdAlreadyPresentInFilterTable, sessionFilter.SecurityContextTokenId));
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.GetString(SR.SecuritySessionIdAlreadyPresentInFilterTable, sessionFilter.SecurityContextTokenId)));
                }
                this.filterMappings.Add(filter, data);
                this.contextMappings.Add(sessionFilter.SecurityContextTokenId, new KeyValuePair <MessageFilter, FilterData>(filter, data));
            }
            public bool Remove(MessageFilter filter)
            {
                SecuritySessionFilter filter2 = filter as SecuritySessionFilter;

                if (filter2 == null)
                {
                    return(false);
                }
                bool flag = this.filterMappings.Remove(filter);

                if (flag)
                {
                    this.contextMappings.Remove(filter2.SecurityContextTokenId);
                }
                return(flag);
            }
Пример #5
0
            public bool Remove(MessageFilter filter)
            {
                SecuritySessionFilter sessionFilter = filter as SecuritySessionFilter;

                if (sessionFilter == null)
                {
                    return(false);
                }
                bool result = this.filterMappings.Remove(filter);

                if (result)
                {
                    this.contextMappings.Remove(sessionFilter.SecurityContextTokenId);
                }
                return(result);
            }
            public void Add(MessageFilter filter, FilterData data)
            {
                SecuritySessionFilter filter2 = filter as SecuritySessionFilter;

                if (filter2 == null)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(System.ServiceModel.SR.GetString("UnknownFilterType", new object[] { filter.GetType() })));
                }
                if (filter2.standardsManager != this.standardsManager)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(System.ServiceModel.SR.GetString("StandardsManagerDoesNotMatch")));
                }
                if (filter2.isStrictMode != this.isStrictMode)
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(System.ServiceModel.SR.GetString("FilterStrictModeDifferent")));
                }
                if (this.contextMappings.ContainsKey(filter2.SecurityContextTokenId))
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SecuritySessionIdAlreadyPresentInFilterTable", new object[] { filter2.SecurityContextTokenId })));
                }
                this.filterMappings.Add(filter, data);
                this.contextMappings.Add(filter2.SecurityContextTokenId, new KeyValuePair <MessageFilter, FilterData>(filter, data));
            }