From 280f222afa4eacc502317e41658a125887b207b8 Mon Sep 17 00:00:00 2001 From: Martin Baulig Date: Tue, 9 May 2017 11:22:19 -0400 Subject: [PATCH] [System]: Remove 'SECURITY_DEP' conditional from HttpListener and related classes. (#4810) --- .../System/System.Net/ChunkedInputStream.cs | 3 -- .../System/System.Net/EndPointListener.cs | 10 ------- .../System/System.Net/EndPointManager.cs | 3 -- mcs/class/System/System.Net/HttpConnection.cs | 5 +--- .../System/System.Net/HttpListener.Mono.cs | 28 +++++++++++++------ mcs/class/System/System.Net/HttpListener.cs | 9 ------ .../System/System.Net/HttpListenerContext.cs | 9 ------ .../HttpListenerPrefixCollection.cs | 2 -- .../System/System.Net/HttpListenerRequest.cs | 3 -- .../System/System.Net/HttpListenerResponse.cs | 4 +-- .../System/System.Net/ListenerAsyncResult.cs | 3 -- mcs/class/System/System.Net/ListenerPrefix.cs | 3 -- mcs/class/System/System.Net/ResponseStream.cs | 3 -- .../Net/AuthenticationSchemeSelector.cs | 2 -- 14 files changed, 21 insertions(+), 66 deletions(-) diff --git a/mcs/class/System/System.Net/ChunkedInputStream.cs b/mcs/class/System/System.Net/ChunkedInputStream.cs index b62c92a5cb7..04aa77310a6 100644 --- a/mcs/class/System/System.Net/ChunkedInputStream.cs +++ b/mcs/class/System/System.Net/ChunkedInputStream.cs @@ -25,8 +25,6 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -#if SECURITY_DEP - using System.IO; using System.Net.Sockets; using System.Runtime.InteropServices; @@ -173,4 +171,3 @@ namespace System.Net { } } } -#endif diff --git a/mcs/class/System/System.Net/EndPointListener.cs b/mcs/class/System/System.Net/EndPointListener.cs index b7aae27d7f9..58aa63ea062 100644 --- a/mcs/class/System/System.Net/EndPointListener.cs +++ b/mcs/class/System/System.Net/EndPointListener.cs @@ -27,15 +27,6 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -#if SECURITY_DEP - -#if MONO_SECURITY_ALIAS -extern alias MonoSecurity; -using MonoSecurity::Mono.Security.Authenticode; -#else -using Mono.Security.Authenticode; -#endif - using System.IO; using System.Net.Sockets; using System.Collections; @@ -372,5 +363,4 @@ namespace System.Net { } } } -#endif diff --git a/mcs/class/System/System.Net/EndPointManager.cs b/mcs/class/System/System.Net/EndPointManager.cs index 6db036a7f02..2f1658ab113 100644 --- a/mcs/class/System/System.Net/EndPointManager.cs +++ b/mcs/class/System/System.Net/EndPointManager.cs @@ -26,8 +26,6 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -#if SECURITY_DEP - using System.Collections; using System.Collections.Generic; namespace System.Net { @@ -158,5 +156,4 @@ namespace System.Net { } } } -#endif diff --git a/mcs/class/System/System.Net/HttpConnection.cs b/mcs/class/System/System.Net/HttpConnection.cs index 1a145a0066e..231de98ff94 100644 --- a/mcs/class/System/System.Net/HttpConnection.cs +++ b/mcs/class/System/System.Net/HttpConnection.cs @@ -27,7 +27,6 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -#if SECURITY_DEP using System.IO; using System.Net.Sockets; using System.Text; @@ -38,8 +37,7 @@ using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; namespace System.Net { - sealed class HttpConnection - { + sealed class HttpConnection { static AsyncCallback onread_cb = new AsyncCallback (OnRead); const int BufferSize = 8192; Socket sock; @@ -485,5 +483,4 @@ namespace System.Net { } } } -#endif diff --git a/mcs/class/System/System.Net/HttpListener.Mono.cs b/mcs/class/System/System.Net/HttpListener.Mono.cs index 7be7cafe2e4..f6c88f02286 100644 --- a/mcs/class/System/System.Net/HttpListener.Mono.cs +++ b/mcs/class/System/System.Net/HttpListener.Mono.cs @@ -28,10 +28,12 @@ #if MONO_SECURITY_ALIAS extern alias MonoSecurity; using MonoSecurity::Mono.Security.Authenticode; -using MSI = MonoSecurity::Mono.Security.Interface; +using MonoSecurity::Mono.Security.Interface; #else using Mono.Security.Authenticode; -using MSI = Mono.Security.Interface; +using Mono.Security.Interface; +#endif +using MNS = Mono.Net.Security; #endif using System.IO; @@ -42,24 +44,26 @@ using System.Net.Security; using System.Security.Authentication.ExtendedProtection; using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; -using MNS = Mono.Net.Security; namespace System.Net { partial class HttpListener { - MSI.MonoTlsProvider tlsProvider; - MSI.MonoTlsSettings tlsSettings; +#if SECURITY_DEP + MonoTlsProvider tlsProvider; + MonoTlsSettings tlsSettings; X509Certificate certificate; - internal HttpListener (X509Certificate certificate, MSI.MonoTlsProvider tlsProvider, MSI.MonoTlsSettings tlsSettings) + internal HttpListener (X509Certificate certificate, MonoTlsProvider tlsProvider, MonoTlsSettings tlsSettings) : this () { this.certificate = certificate; this.tlsProvider = tlsProvider; this.tlsSettings = tlsSettings; } +#endif internal X509Certificate LoadCertificateAndKey (IPAddress addr, int port) { +#if SECURITY_DEP lock (_internalLock) { if (certificate != null) return certificate; @@ -85,21 +89,27 @@ namespace System.Net { return null; } } +#else + throw new PlatformNotSupportedException (); +#endif } internal SslStream CreateSslStream (Stream innerStream, bool ownsStream, RemoteCertificateValidationCallback callback) { +#if SECURITY_DEP lock (_internalLock) { if (tlsProvider == null) - tlsProvider = MSI.MonoTlsProviderFactory.GetProvider (); + tlsProvider = MonoTlsProviderFactory.GetProvider (); if (tlsSettings == null) - tlsSettings = MSI.MonoTlsSettings.CopyDefaultSettings (); + tlsSettings = MonoTlsSettings.CopyDefaultSettings (); if (tlsSettings.RemoteCertificateValidationCallback == null) tlsSettings.RemoteCertificateValidationCallback = MNS.Private.CallbackHelpers.PublicToMono (callback); var sslStream = tlsProvider.CreateSslStream (innerStream, ownsStream, tlsSettings); return sslStream.SslStream; } +#else + throw new PlatformNotSupportedException (); +#endif } } } -#endif diff --git a/mcs/class/System/System.Net/HttpListener.cs b/mcs/class/System/System.Net/HttpListener.cs index 663b92a1819..d886219bc6d 100644 --- a/mcs/class/System/System.Net/HttpListener.cs +++ b/mcs/class/System/System.Net/HttpListener.cs @@ -28,7 +28,6 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -#if SECURITY_DEP using System.IO; using System.Collections; using System.Threading; @@ -416,11 +415,3 @@ namespace System.Net { } } } -#else // SECURITY_DEP -namespace System.Net -{ - public sealed class HttpListener - { - } -} -#endif diff --git a/mcs/class/System/System.Net/HttpListenerContext.cs b/mcs/class/System/System.Net/HttpListenerContext.cs index 947662dc070..ffb88651509 100644 --- a/mcs/class/System/System.Net/HttpListenerContext.cs +++ b/mcs/class/System/System.Net/HttpListenerContext.cs @@ -26,8 +26,6 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -#if SECURITY_DEP - using System.Collections.Specialized; using System.IO; using System.Security.Principal; @@ -162,10 +160,3 @@ namespace System.Net { } } } -#else -namespace System.Net { - public sealed class HttpListenerContext { - } -} -#endif - diff --git a/mcs/class/System/System.Net/HttpListenerPrefixCollection.cs b/mcs/class/System/System.Net/HttpListenerPrefixCollection.cs index 5c9416e70b0..c4bdad2c89d 100644 --- a/mcs/class/System/System.Net/HttpListenerPrefixCollection.cs +++ b/mcs/class/System/System.Net/HttpListenerPrefixCollection.cs @@ -25,7 +25,6 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -#if SECURITY_DEP using System.Collections; using System.Collections.Generic; @@ -113,5 +112,4 @@ namespace System.Net { } } } -#endif diff --git a/mcs/class/System/System.Net/HttpListenerRequest.cs b/mcs/class/System/System.Net/HttpListenerRequest.cs index fc0125df25a..2a690b0e3b2 100644 --- a/mcs/class/System/System.Net/HttpListenerRequest.cs +++ b/mcs/class/System/System.Net/HttpListenerRequest.cs @@ -28,8 +28,6 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -#if SECURITY_DEP - using System.Collections; using System.Collections.Specialized; using System.Globalization; @@ -579,5 +577,4 @@ namespace System.Net { } } } -#endif diff --git a/mcs/class/System/System.Net/HttpListenerResponse.cs b/mcs/class/System/System.Net/HttpListenerResponse.cs index 73aa6396b53..367c977c0ed 100644 --- a/mcs/class/System/System.Net/HttpListenerResponse.cs +++ b/mcs/class/System/System.Net/HttpListenerResponse.cs @@ -26,11 +26,10 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -#if SECURITY_DEP - using System.Globalization; using System.IO; using System.Text; + namespace System.Net { public sealed class HttpListenerResponse : IDisposable { @@ -518,5 +517,4 @@ namespace System.Net { } } } -#endif diff --git a/mcs/class/System/System.Net/ListenerAsyncResult.cs b/mcs/class/System/System.Net/ListenerAsyncResult.cs index 88f75e88a99..f73922e032f 100644 --- a/mcs/class/System/System.Net/ListenerAsyncResult.cs +++ b/mcs/class/System/System.Net/ListenerAsyncResult.cs @@ -28,8 +28,6 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -#if SECURITY_DEP - using System.Threading; namespace System.Net { class ListenerAsyncResult : IAsyncResult { @@ -181,5 +179,4 @@ namespace System.Net { } } } -#endif diff --git a/mcs/class/System/System.Net/ListenerPrefix.cs b/mcs/class/System/System.Net/ListenerPrefix.cs index f0b7ef8398e..f7cb7b38145 100644 --- a/mcs/class/System/System.Net/ListenerPrefix.cs +++ b/mcs/class/System/System.Net/ListenerPrefix.cs @@ -27,8 +27,6 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -#if SECURITY_DEP - namespace System.Net { sealed class ListenerPrefix { @@ -160,4 +158,3 @@ namespace System.Net { } } } -#endif diff --git a/mcs/class/System/System.Net/ResponseStream.cs b/mcs/class/System/System.Net/ResponseStream.cs index 81e1d6f67d4..5d33e477d1c 100644 --- a/mcs/class/System/System.Net/ResponseStream.cs +++ b/mcs/class/System/System.Net/ResponseStream.cs @@ -26,8 +26,6 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -#if SECURITY_DEP - using System.IO; using System.Net.Sockets; using System.Text; @@ -248,5 +246,4 @@ namespace System.Net { } } } -#endif diff --git a/mcs/class/referencesource/System/net/System/Net/AuthenticationSchemeSelector.cs b/mcs/class/referencesource/System/net/System/Net/AuthenticationSchemeSelector.cs index d111e81a484..886a2fee29c 100644 --- a/mcs/class/referencesource/System/net/System/Net/AuthenticationSchemeSelector.cs +++ b/mcs/class/referencesource/System/net/System/Net/AuthenticationSchemeSelector.cs @@ -5,8 +5,6 @@ //------------------------------------------------------------------------------ namespace System.Net { -#if SECURITY_DEP public delegate AuthenticationSchemes AuthenticationSchemeSelector(HttpListenerRequest httpRequest); -#endif } -- 2.25.1