blob: 424a0ab074d2b821a262025f3d44601b7ae8910c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
//------------------------------------------------------------------------------
// <copyright file="TransportContext.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System.Net.Security;
using System.Security.Authentication.ExtendedProtection;
namespace System.Net
{
public abstract class TransportContext
{
public abstract ChannelBinding GetChannelBinding(ChannelBindingKind kind);
}
#if MONO_FEATURE_WEB_STACK
internal class ConnectStreamContext : TransportContext
{
internal ConnectStreamContext(ConnectStream connectStream)
{
GlobalLog.Assert(connectStream != null, "ConnectStreamContext..ctor(): Not expecting a null connectStream!");
this.connectStream = connectStream;
}
public override ChannelBinding GetChannelBinding(ChannelBindingKind kind)
{
return connectStream.GetChannelBinding(kind);
}
private ConnectStream connectStream;
}
#endif
#if MONO_FEATURE_NEW_TLS
internal class SslStreamContext : TransportContext
{
internal SslStreamContext(SslStream sslStream)
{
GlobalLog.Assert(sslStream != null, "SslStreamContext..ctor(): Not expecting a null sslStream!");
this.sslStream = sslStream;
}
public override ChannelBinding GetChannelBinding(ChannelBindingKind kind)
{
return sslStream.GetChannelBinding(kind);
}
private SslStream sslStream;
}
#endif
#if MONO_FEATURE_WEB_STACK
internal class HttpListenerRequestContext : TransportContext
{
internal HttpListenerRequestContext(HttpListenerRequest request)
{
GlobalLog.Assert(request != null, "HttpListenerRequestContext..ctor(): Not expecting a null request!");
this.request = request;
}
public override ChannelBinding GetChannelBinding(ChannelBindingKind kind)
{
if (kind != ChannelBindingKind.Endpoint)
{
throw new NotSupportedException(SR.GetString(
SR.net_listener_invalid_cbt_type, kind.ToString()));
}
return request.GetChannelBinding();
}
private HttpListenerRequest request;
}
#endif
// Holds a cached Endpoint binding to be reused by HttpWebRequest preauthentication
internal class CachedTransportContext : TransportContext
{
internal CachedTransportContext(ChannelBinding binding)
{
this.binding = binding;
}
public override ChannelBinding GetChannelBinding(ChannelBindingKind kind)
{
if (kind != ChannelBindingKind.Endpoint)
return null;
return binding;
}
private ChannelBinding binding;
}
}
|