[runtime] Fix the managed name of the ReRegisterForFinalize () icall.
[mono.git] / mcs / class / Mono.Security.Providers.NewTls / Mono.Security.Providers.NewTls / MonoNewTlsStream.cs
1 //
2 // MonoNewTlsStream.cs
3 //
4 // Author:
5 //       Martin Baulig <martin.baulig@xamarin.com>
6 //
7 // Copyright (c) 2015 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 extern alias NewSystemSource;
28
29 using EncryptionPolicy = NewSystemSource::System.Net.Security.EncryptionPolicy;
30 using LocalCertificateSelectionCallback = NewSystemSource::System.Net.Security.LocalCertificateSelectionCallback;
31 using RemoteCertificateValidationCallback = NewSystemSource::System.Net.Security.RemoteCertificateValidationCallback;
32 using SslStream = NewSystemSource::System.Net.Security.SslStream;
33
34 using System;
35 using System.IO;
36 using System.Threading.Tasks;
37
38 using MSI = Mono.Security.Interface;
39
40 using XAuthenticatedStream = System.Net.Security.AuthenticatedStream;
41 using System.Security.Cryptography.X509Certificates;
42
43 namespace Mono.Security.Providers.NewTls
44 {
45         public class MonoNewTlsStream : SslStream, MSI.IMonoSslStream
46         {
47                 MSI.MonoTlsProvider provider;
48
49                 internal MonoNewTlsStream (Stream innerStream, MSI.MonoTlsProvider provider, MSI.MonoTlsSettings settings)
50                         : this (innerStream, false, provider, settings)
51                 {
52                 }
53
54                 internal MonoNewTlsStream (Stream innerStream, bool leaveOpen, MSI.MonoTlsProvider provider, MSI.MonoTlsSettings settings)
55                         : base (innerStream, leaveOpen, EncryptionPolicy.RequireEncryption, provider, settings)
56                 {
57                         this.provider = provider;
58                 }
59
60                 public MSI.MonoTlsProvider Provider {
61                         get { return provider; }
62                 }
63
64                 new public bool IsClosed {
65                         get { return base.IsClosed; }
66                 }
67
68                 public MSI.MonoTlsConnectionInfo GetConnectionInfo ()
69                 {
70                         return GetMonoConnectionInfo ();
71                 }
72
73                 public Task Shutdown ()
74                 {
75                         return Task.Factory.FromAsync ((state, result) => BeginShutdown (state, result), EndShutdown, null);
76                 }
77
78                 public Task RequestRenegotiation ()
79                 {
80                         return Task.Factory.FromAsync ((state, result) => BeginRenegotiate (state, result), EndRenegotiate, null);
81                 }
82
83                  X509Certificate MSI.IMonoSslStream.InternalLocalCertificate {
84                         get { return InternalLocalCertificate; }
85                 }
86
87                 XAuthenticatedStream MSI.IMonoSslStream.AuthenticatedStream {
88                         get { return this; }
89                 }
90         }
91 }
92
93