[System*] Throw a PlatformNotSupported exception when using the managed networking...
[mono.git] / mcs / class / System / System.Net.Security / SslStream.platformnotsupported.cs
1 //
2 // SslStream.cs
3 //
4 // Author:
5 //       Rolf Bjarne Kvinge <rolf@xamarin.com>
6 //
7 // Copyright (c) 2016 Xamarin, Inc.
8 //
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:
15 //
16 // The above copyright notice and this permission notice shall be included in
17 // all copies or substantial portions of the Software.
18 //
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
25 // THE SOFTWARE.
26
27 using System.IO;
28 using System.Security.Authentication;
29 using System.Security.Cryptography.X509Certificates;
30 using System.Threading.Tasks;
31
32 namespace System.Net.Security
33 {
34         public class SslStream : AuthenticatedStream
35         {
36                 const string EXCEPTION_MESSAGE = "System.Net.Security.SslStream is not supported on the current platform.";
37
38                 public SslStream (Stream innerStream)
39                         : this (innerStream, false, null, null)
40                 {
41                 }
42
43                 public SslStream (Stream innerStream, bool leaveInnerStreamOpen)
44                         : this (innerStream, leaveInnerStreamOpen, null, null)
45                 {
46                 }
47
48                 public SslStream (Stream innerStream, bool leaveInnerStreamOpen, RemoteCertificateValidationCallback userCertificateValidationCallback)
49                         : this (innerStream, leaveInnerStreamOpen, userCertificateValidationCallback, null)
50                 {
51                 }
52
53                 public SslStream (Stream innerStream, bool leaveInnerStreamOpen, RemoteCertificateValidationCallback userCertificateValidationCallback, LocalCertificateSelectionCallback userCertificateSelectionCallback)
54                         : base (innerStream, leaveInnerStreamOpen)
55                 {
56                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
57                 }
58
59                 public SslStream (Stream innerStream, bool leaveInnerStreamOpen, RemoteCertificateValidationCallback userCertificateValidationCallback, LocalCertificateSelectionCallback userCertificateSelectionCallback, EncryptionPolicy encryptionPolicy)
60                         : this (innerStream, leaveInnerStreamOpen, userCertificateValidationCallback, userCertificateSelectionCallback)
61                 {
62                 }
63
64                 public virtual void AuthenticateAsClient (string targetHost)
65                 {
66                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
67                 }
68
69                 public virtual void AuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
70                 {
71                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
72                 }
73
74                 public virtual IAsyncResult BeginAuthenticateAsClient (string targetHost, AsyncCallback asyncCallback, object asyncState)
75                 {
76                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
77                 }
78
79                 public virtual IAsyncResult BeginAuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
80                 {
81                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
82                 }
83
84                 public virtual void EndAuthenticateAsClient (IAsyncResult asyncResult)
85                 {
86                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
87                 }
88
89                 public virtual void AuthenticateAsServer (X509Certificate serverCertificate)
90                 {
91                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
92                 }
93
94                 public virtual void AuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
95                 {
96                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
97                 }
98
99                 public virtual IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, AsyncCallback asyncCallback, object asyncState)
100                 {
101                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
102                 }
103
104                 public virtual IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
105                 {
106                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
107                 }
108
109                 public virtual void EndAuthenticateAsServer (IAsyncResult asyncResult)
110                 {
111                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
112                 }
113
114                 public TransportContext TransportContext {
115                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
116                 }
117
118                 public virtual Task AuthenticateAsClientAsync (string targetHost)
119                 {
120                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
121                 }
122
123                 public virtual Task AuthenticateAsClientAsync (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
124                 {
125                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
126                 }
127
128                 public virtual Task AuthenticateAsServerAsync (X509Certificate serverCertificate)
129                 {
130                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
131                 }
132
133                 public virtual Task AuthenticateAsServerAsync (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
134                 {
135                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
136                 }
137
138                 public override bool IsAuthenticated {
139                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
140                 }
141
142                 public override bool IsMutuallyAuthenticated {
143                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
144                 }
145
146                 public override bool IsEncrypted {
147                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
148                 }
149
150                 public override bool IsSigned {
151                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
152                 }
153
154                 public override bool IsServer {
155                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
156                 }
157
158                 public virtual SslProtocols SslProtocol {
159                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
160                 }
161
162                 public virtual bool CheckCertRevocationStatus {
163                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
164                 }
165
166                 public virtual X509Certificate LocalCertificate {
167                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
168                 }
169
170                 public virtual X509Certificate RemoteCertificate {
171                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
172                 }
173
174                 public virtual CipherAlgorithmType CipherAlgorithm {
175                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
176                 }
177
178                 public virtual int CipherStrength {
179                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
180                 }
181
182                 public virtual HashAlgorithmType HashAlgorithm {
183                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
184                 }
185
186                 public virtual int HashStrength {
187                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
188                 }
189
190                 public virtual ExchangeAlgorithmType KeyExchangeAlgorithm {
191                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
192                 }
193
194                 public virtual int KeyExchangeStrength {
195                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
196                 }
197
198                 public override bool CanSeek {
199                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
200                 }
201
202                 public override bool CanRead {
203                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
204                 }
205
206                 public override bool CanTimeout {
207                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
208                 }
209
210                 public override bool CanWrite {
211                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
212                 }
213
214                 public override int ReadTimeout {
215                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
216                         set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
217                 }
218
219                 public override int WriteTimeout {
220                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
221                         set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
222                 }
223
224                 public override long Length {
225                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
226                 }
227
228                 public override long Position {
229                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
230                         set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
231                 }
232
233                 public override void SetLength (long value)
234                 {
235                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
236                 }
237
238                 public override long Seek (long offset, SeekOrigin origin)
239                 {
240                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
241                 }
242
243                 public override void Flush ()
244                 {
245                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
246                 }
247
248                 protected override void Dispose (bool disposing)
249                 {
250                 }
251
252                 public override int Read (byte[] buffer, int offset, int count)
253                 {
254                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
255                 }
256
257                 public void Write (byte[] buffer)
258                 {
259                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
260                 }
261
262                 public override void Write (byte[] buffer, int offset, int count)
263                 {
264                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
265                 }
266
267                 public override IAsyncResult BeginRead (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState)
268                 {
269                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
270                 }
271
272                 public override int EndRead (IAsyncResult asyncResult)
273                 {
274                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
275                 }
276
277                 public override IAsyncResult BeginWrite (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState)
278                 {
279                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
280                 }
281
282                 public override void EndWrite (IAsyncResult asyncResult)
283                 {
284                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
285                 }
286         }
287 }