2 // NoReflectionHelper.cs
5 // Martin Baulig <martin.baulig@xamarin.com>
7 // Copyright (c) 2015 Xamarin, Inc.
9 // Permission is hereby granted, free of charge, to any person obtaining a copy
10 // of this software and associated documentation files (the "Software"), to deal
11 // in the Software without restriction, including without limitation the rights
12 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 // copies of the Software, and to permit persons to whom the Software is
14 // furnished to do so, subject to the following conditions:
16 // The above copyright notice and this permission notice shall be included in
17 // all copies or substantial portions of the Software.
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28 #if MONO_SECURITY_ALIAS
29 extern alias MonoSecurity
;
30 using MSI
= MonoSecurity
::Mono
.Security
.Interface
;
31 using MX
= MonoSecurity
::Mono
.Security
.X509
;
33 using MSI
= Mono
.Security
.Interface
;
34 using MX
= Mono
.Security
.X509
;
36 using System
.Security
.Cryptography
.X509Certificates
;
41 using System
.Net
.Security
;
43 namespace Mono
.Net
.Security
46 // Internal APIs which are used by Mono.Security.dll to avoid using reflection.
48 internal static class NoReflectionHelper
50 internal static object GetDefaultValidator (object settings
)
53 return ChainValidationHelper
.GetDefaultValidator ((MSI
.MonoTlsSettings
)settings
);
55 throw new NotSupportedException ();
59 internal static object GetProvider ()
62 return MonoTlsProviderFactory
.GetProvider ();
64 throw new NotSupportedException ();
68 internal static bool IsInitialized
{
71 return MonoTlsProviderFactory
.IsInitialized
;
73 throw new NotSupportedException ();
78 internal static void Initialize ()
81 MonoTlsProviderFactory
.Initialize ();
83 throw new NotSupportedException ();
87 internal static void Initialize (string provider
)
90 MonoTlsProviderFactory
.Initialize (provider
);
92 throw new NotSupportedException ();
96 internal static HttpWebRequest
CreateHttpsRequest (Uri requestUri
, object provider
, object settings
)
99 return new HttpWebRequest (requestUri
, (MobileTlsProvider
)provider
, (MSI
.MonoTlsSettings
)settings
);
101 throw new NotSupportedException ();
105 internal static object CreateHttpListener (object certificate
, object provider
, object settings
)
108 return new HttpListener ((X509Certificate
)certificate
, (MSI
.MonoTlsProvider
)provider
, (MSI
.MonoTlsSettings
)settings
);
110 throw new NotSupportedException ();
114 internal static object GetMonoSslStream (SslStream stream
)
119 throw new NotSupportedException ();
123 internal static object GetMonoSslStream (HttpListenerContext context
)
126 return context
.Connection
.SslStream
?.Impl
;
128 throw new NotSupportedException ();
132 internal static bool IsProviderSupported (string name
)
135 return MonoTlsProviderFactory
.IsProviderSupported (name
);
137 throw new NotSupportedException ();
141 internal static object GetProvider (string name
)
144 return MonoTlsProviderFactory
.GetProvider (name
);
146 throw new NotSupportedException ();