Merge pull request #5714 from alexischr/update_bockbuild
[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         /*
35          * These two are defined by the referencesource; add them here to make
36          * it easy to switch between the two implementations.
37          */
38
39         internal delegate bool RemoteCertValidationCallback (
40                 string host,
41                 X509Certificate certificate,
42                 X509Chain chain,
43                 SslPolicyErrors sslPolicyErrors);
44
45         internal delegate X509Certificate LocalCertSelectionCallback (
46                 string targetHost,
47                 X509CertificateCollection localCertificates,
48                 X509Certificate remoteCertificate,
49                 string[] acceptableIssuers);
50
51         public class SslStream : AuthenticatedStream
52         {
53                 const string EXCEPTION_MESSAGE = "System.Net.Security.SslStream is not supported on the current platform.";
54
55                 public SslStream (Stream innerStream)
56                         : this (innerStream, false)
57                 {
58                 }
59
60                 public SslStream (Stream innerStream, bool leaveInnerStreamOpen)
61                         : base (innerStream, leaveInnerStreamOpen)
62                 {
63                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
64                 }
65
66                 public SslStream (Stream innerStream, bool leaveInnerStreamOpen, RemoteCertificateValidationCallback userCertificateValidationCallback)
67                         : this (innerStream, leaveInnerStreamOpen)
68                 {
69                 }
70
71                 public SslStream (Stream innerStream, bool leaveInnerStreamOpen, RemoteCertificateValidationCallback userCertificateValidationCallback, LocalCertificateSelectionCallback userCertificateSelectionCallback)
72                         : this (innerStream, leaveInnerStreamOpen)
73                 {
74                 }
75
76                 public SslStream (Stream innerStream, bool leaveInnerStreamOpen, RemoteCertificateValidationCallback userCertificateValidationCallback, LocalCertificateSelectionCallback userCertificateSelectionCallback, EncryptionPolicy encryptionPolicy)
77                         : this (innerStream, leaveInnerStreamOpen)
78                 {
79                 }
80
81                 public virtual void AuthenticateAsClient (string targetHost)
82                 {
83                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
84                 }
85
86                 public virtual void AuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
87                 {
88                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
89                 }
90
91                 public virtual IAsyncResult BeginAuthenticateAsClient (string targetHost, AsyncCallback asyncCallback, object asyncState)
92                 {
93                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
94                 }
95
96                 public virtual IAsyncResult BeginAuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
97                 {
98                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
99                 }
100
101                 public virtual void EndAuthenticateAsClient (IAsyncResult asyncResult)
102                 {
103                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
104                 }
105
106                 public virtual void AuthenticateAsServer (X509Certificate serverCertificate)
107                 {
108                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
109                 }
110
111                 public virtual void AuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
112                 {
113                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
114                 }
115
116                 public virtual IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, AsyncCallback asyncCallback, object asyncState)
117                 {
118                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
119                 }
120
121                 public virtual IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
122                 {
123                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
124                 }
125
126                 public virtual void EndAuthenticateAsServer (IAsyncResult asyncResult)
127                 {
128                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
129                 }
130
131                 public TransportContext TransportContext {
132                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
133                 }
134
135                 public virtual Task AuthenticateAsClientAsync (string targetHost)
136                 {
137                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
138                 }
139
140                 public virtual Task AuthenticateAsClientAsync (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
141                 {
142                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
143                 }
144
145                 public virtual Task AuthenticateAsServerAsync (X509Certificate serverCertificate)
146                 {
147                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
148                 }
149
150                 public virtual Task AuthenticateAsServerAsync (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
151                 {
152                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
153                 }
154
155                 public virtual Task ShutdownAsync ()
156                 {
157                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
158                 }
159
160                 public override bool IsAuthenticated {
161                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
162                 }
163
164                 public override bool IsMutuallyAuthenticated {
165                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
166                 }
167
168                 public override bool IsEncrypted {
169                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
170                 }
171
172                 public override bool IsSigned {
173                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
174                 }
175
176                 public override bool IsServer {
177                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
178                 }
179
180                 public virtual SslProtocols SslProtocol {
181                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
182                 }
183
184                 public virtual bool CheckCertRevocationStatus {
185                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
186                 }
187
188                 public virtual X509Certificate LocalCertificate {
189                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
190                 }
191
192                 public virtual X509Certificate RemoteCertificate {
193                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
194                 }
195
196                 public virtual CipherAlgorithmType CipherAlgorithm {
197                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
198                 }
199
200                 public virtual int CipherStrength {
201                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
202                 }
203
204                 public virtual HashAlgorithmType HashAlgorithm {
205                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
206                 }
207
208                 public virtual int HashStrength {
209                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
210                 }
211
212                 public virtual ExchangeAlgorithmType KeyExchangeAlgorithm {
213                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
214                 }
215
216                 public virtual int KeyExchangeStrength {
217                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
218                 }
219
220                 public override bool CanSeek {
221                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
222                 }
223
224                 public override bool CanRead {
225                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
226                 }
227
228                 public override bool CanTimeout {
229                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
230                 }
231
232                 public override bool CanWrite {
233                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
234                 }
235
236                 public override int ReadTimeout {
237                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
238                         set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
239                 }
240
241                 public override int WriteTimeout {
242                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
243                         set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
244                 }
245
246                 public override long Length {
247                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
248                 }
249
250                 public override long Position {
251                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
252                         set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
253                 }
254
255                 public override void SetLength (long value)
256                 {
257                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
258                 }
259
260                 public override long Seek (long offset, SeekOrigin origin)
261                 {
262                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
263                 }
264
265                 public override void Flush ()
266                 {
267                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
268                 }
269
270                 protected override void Dispose (bool disposing)
271                 {
272                 }
273
274                 public override int Read (byte[] buffer, int offset, int count)
275                 {
276                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
277                 }
278
279                 public void Write (byte[] buffer)
280                 {
281                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
282                 }
283
284                 public override void Write (byte[] buffer, int offset, int count)
285                 {
286                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
287                 }
288
289                 public override IAsyncResult BeginRead (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState)
290                 {
291                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
292                 }
293
294                 public override int EndRead (IAsyncResult asyncResult)
295                 {
296                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
297                 }
298
299                 public override IAsyncResult BeginWrite (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState)
300                 {
301                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
302                 }
303
304                 public override void EndWrite (IAsyncResult asyncResult)
305                 {
306                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
307                 }
308         }
309 }