| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | using System; |
| | | 5 | | using System.Threading; |
| | | 6 | | using System.Threading.Tasks; |
| | | 7 | | using CoreWCF.Channels; |
| | | 8 | | using CoreWCF.IdentityModel.Selectors; |
| | | 9 | | |
| | | 10 | | namespace CoreWCF.Security |
| | | 11 | | { |
| | | 12 | | internal class WrapperSecurityCommunicationObject : CommunicationObject |
| | | 13 | | { |
| | | 14 | | private readonly ISecurityCommunicationObject _innerCommunicationObject; |
| | | 15 | | |
| | 134 | 16 | | public WrapperSecurityCommunicationObject(ISecurityCommunicationObject innerCommunicationObject) : base() |
| | | 17 | | { |
| | 134 | 18 | | _innerCommunicationObject = innerCommunicationObject ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelper |
| | 134 | 19 | | } |
| | | 20 | | |
| | | 21 | | protected override Type GetCommunicationObjectType() |
| | | 22 | | { |
| | 0 | 23 | | return _innerCommunicationObject.GetType(); |
| | | 24 | | } |
| | | 25 | | |
| | 20 | 26 | | protected override TimeSpan DefaultCloseTimeout => _innerCommunicationObject.DefaultCloseTimeout; |
| | | 27 | | |
| | 222 | 28 | | protected override TimeSpan DefaultOpenTimeout => _innerCommunicationObject.DefaultOpenTimeout; |
| | | 29 | | |
| | | 30 | | protected override void OnAbort() |
| | | 31 | | { |
| | 0 | 32 | | _innerCommunicationObject.OnAbort(); |
| | 0 | 33 | | } |
| | | 34 | | |
| | | 35 | | protected override void OnFaulted() |
| | | 36 | | { |
| | 0 | 37 | | _innerCommunicationObject.OnFaulted(); |
| | 0 | 38 | | base.OnFaulted(); |
| | 0 | 39 | | } |
| | | 40 | | |
| | | 41 | | internal new void ThrowIfDisposedOrImmutable() |
| | | 42 | | { |
| | 1414 | 43 | | base.ThrowIfDisposedOrImmutable(); |
| | 1414 | 44 | | } |
| | | 45 | | |
| | | 46 | | protected override Task OnCloseAsync(CancellationToken token) |
| | | 47 | | { |
| | 10 | 48 | | return _innerCommunicationObject.OnCloseAsync(DefaultCloseTimeout); |
| | | 49 | | } |
| | | 50 | | |
| | | 51 | | protected override Task OnOpenAsync(CancellationToken token) |
| | | 52 | | { |
| | 111 | 53 | | return _innerCommunicationObject.OnOpenAsync(DefaultOpenTimeout); |
| | | 54 | | } |
| | | 55 | | } |
| | | 56 | | |
| | | 57 | | internal abstract class CommunicationObjectSecurityTokenAuthenticator : SecurityTokenAuthenticator, ICommunicationOb |
| | | 58 | | { |
| | | 59 | | protected CommunicationObjectSecurityTokenAuthenticator() |
| | | 60 | | { |
| | | 61 | | CommunicationObject = new WrapperSecurityCommunicationObject(this); |
| | | 62 | | } |
| | | 63 | | |
| | | 64 | | protected WrapperSecurityCommunicationObject CommunicationObject { get; } |
| | | 65 | | |
| | | 66 | | public event EventHandler Closed |
| | | 67 | | { |
| | | 68 | | add { CommunicationObject.Closed += value; } |
| | | 69 | | remove { CommunicationObject.Closed -= value; } |
| | | 70 | | } |
| | | 71 | | |
| | | 72 | | public event EventHandler Closing |
| | | 73 | | { |
| | | 74 | | add { CommunicationObject.Closing += value; } |
| | | 75 | | remove { CommunicationObject.Closing -= value; } |
| | | 76 | | } |
| | | 77 | | |
| | | 78 | | public event EventHandler Faulted |
| | | 79 | | { |
| | | 80 | | add { CommunicationObject.Faulted += value; } |
| | | 81 | | remove { CommunicationObject.Faulted -= value; } |
| | | 82 | | } |
| | | 83 | | |
| | | 84 | | public event EventHandler Opened |
| | | 85 | | { |
| | | 86 | | add { CommunicationObject.Opened += value; } |
| | | 87 | | remove { CommunicationObject.Opened -= value; } |
| | | 88 | | } |
| | | 89 | | |
| | | 90 | | public event EventHandler Opening |
| | | 91 | | { |
| | | 92 | | add { CommunicationObject.Opening += value; } |
| | | 93 | | remove { CommunicationObject.Opening -= value; } |
| | | 94 | | } |
| | | 95 | | |
| | | 96 | | public CommunicationState State => CommunicationObject.State; |
| | | 97 | | |
| | | 98 | | public virtual TimeSpan DefaultOpenTimeout => ServiceDefaults.OpenTimeout; |
| | | 99 | | |
| | | 100 | | public virtual TimeSpan DefaultCloseTimeout => ServiceDefaults.CloseTimeout; |
| | | 101 | | |
| | | 102 | | // communication object |
| | | 103 | | public void Abort() |
| | | 104 | | { |
| | | 105 | | CommunicationObject.Abort(); |
| | | 106 | | } |
| | | 107 | | |
| | | 108 | | |
| | | 109 | | public virtual void OnClose(TimeSpan timeout) |
| | | 110 | | { |
| | | 111 | | } |
| | | 112 | | |
| | | 113 | | public Task OnCloseAsync(TimeSpan timeout) |
| | | 114 | | { |
| | | 115 | | return Task.CompletedTask; |
| | | 116 | | } |
| | | 117 | | |
| | | 118 | | public virtual void OnFaulted() |
| | | 119 | | { |
| | | 120 | | Abort(); |
| | | 121 | | } |
| | | 122 | | |
| | | 123 | | public virtual void OnOpen(TimeSpan timeout) |
| | | 124 | | { |
| | | 125 | | } |
| | | 126 | | |
| | | 127 | | public Task OnOpenAsync(TimeSpan timeout) |
| | | 128 | | { |
| | | 129 | | return Task.CompletedTask; |
| | | 130 | | } |
| | | 131 | | |
| | | 132 | | public virtual Task CloseAsync() |
| | | 133 | | { |
| | | 134 | | return Task.CompletedTask; |
| | | 135 | | } |
| | | 136 | | |
| | | 137 | | public virtual Task CloseAsync(CancellationToken token) |
| | | 138 | | { |
| | | 139 | | return Task.CompletedTask; |
| | | 140 | | } |
| | | 141 | | |
| | | 142 | | public virtual Task OpenAsync() |
| | | 143 | | { |
| | | 144 | | return Task.CompletedTask; |
| | | 145 | | } |
| | | 146 | | |
| | | 147 | | public virtual Task OpenAsync(CancellationToken token) |
| | | 148 | | { |
| | | 149 | | return Task.CompletedTask; |
| | | 150 | | } |
| | | 151 | | |
| | | 152 | | public virtual void OnAbort() |
| | | 153 | | { |
| | | 154 | | } |
| | | 155 | | |
| | | 156 | | public void OnClosed() |
| | | 157 | | { |
| | | 158 | | throw new NotImplementedException(); |
| | | 159 | | } |
| | | 160 | | |
| | | 161 | | public void OnClosing() |
| | | 162 | | { |
| | | 163 | | throw new NotImplementedException(); |
| | | 164 | | } |
| | | 165 | | |
| | | 166 | | public void OnOpened() |
| | | 167 | | { |
| | | 168 | | throw new NotImplementedException(); |
| | | 169 | | } |
| | | 170 | | |
| | | 171 | | public void OnOpening() |
| | | 172 | | { |
| | | 173 | | throw new NotImplementedException(); |
| | | 174 | | } |
| | | 175 | | } |
| | | 176 | | } |