| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | using System; |
| | | 5 | | using CoreWCF.Runtime; |
| | | 6 | | |
| | | 7 | | namespace CoreWCF.Channels |
| | | 8 | | { |
| | | 9 | | internal class HttpAnonymousUriPrefixMatcher : IAnonymousUriPrefixMatcher |
| | | 10 | | { |
| | | 11 | | private UriPrefixTable<Uri> _anonymousUriPrefixes; |
| | | 12 | | |
| | 423 | 13 | | internal HttpAnonymousUriPrefixMatcher() |
| | | 14 | | { |
| | 423 | 15 | | } |
| | | 16 | | |
| | | 17 | | internal HttpAnonymousUriPrefixMatcher(HttpAnonymousUriPrefixMatcher objectToClone) |
| | 0 | 18 | | : this() |
| | | 19 | | { |
| | 0 | 20 | | if (objectToClone._anonymousUriPrefixes != null) |
| | | 21 | | { |
| | 0 | 22 | | _anonymousUriPrefixes = new UriPrefixTable<Uri>(objectToClone._anonymousUriPrefixes); |
| | | 23 | | } |
| | 0 | 24 | | } |
| | | 25 | | |
| | | 26 | | public void Register(Uri anonymousUriPrefix) |
| | | 27 | | { |
| | 0 | 28 | | if (anonymousUriPrefix == null) |
| | | 29 | | { |
| | 0 | 30 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(anonymousUriPrefix)); |
| | | 31 | | } |
| | | 32 | | |
| | 0 | 33 | | if (!anonymousUriPrefix.IsAbsoluteUri) |
| | | 34 | | { |
| | 0 | 35 | | throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(nameof(anonymousUriPrefix), SR.UriMustBeAbs |
| | | 36 | | } |
| | | 37 | | |
| | 0 | 38 | | if (_anonymousUriPrefixes == null) |
| | | 39 | | { |
| | 0 | 40 | | _anonymousUriPrefixes = new UriPrefixTable<Uri>(true); |
| | | 41 | | } |
| | | 42 | | |
| | 0 | 43 | | if (!_anonymousUriPrefixes.IsRegistered(new BaseUriWithWildcard(anonymousUriPrefix, HostNameComparisonMode.E |
| | | 44 | | { |
| | 0 | 45 | | _anonymousUriPrefixes.RegisterUri(anonymousUriPrefix, HostNameComparisonMode.Exact, anonymousUriPrefix); |
| | | 46 | | } |
| | 0 | 47 | | } |
| | | 48 | | |
| | | 49 | | internal bool IsAnonymousUri(Uri to) |
| | | 50 | | { |
| | | 51 | | Fx.Assert(to == null || to.IsAbsoluteUri, SR.UriMustBeAbsolute); |
| | | 52 | | |
| | 0 | 53 | | if (_anonymousUriPrefixes == null) |
| | | 54 | | { |
| | 0 | 55 | | return false; |
| | | 56 | | } |
| | | 57 | | |
| | 0 | 58 | | return _anonymousUriPrefixes.TryLookupUri(to, HostNameComparisonMode.Exact, out Uri returnValue); |
| | | 59 | | } |
| | | 60 | | } |
| | | 61 | | } |