| | | 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 CoreWCF.Channels; |
| | | 6 | | |
| | | 7 | | namespace CoreWCF |
| | | 8 | | { |
| | | 9 | | public class WSHttpBinding : WSHttpBindingBase |
| | | 10 | | { |
| | 2 | 11 | | private static readonly MessageSecurityVersion s_WSMessageSecurityVersion = MessageSecurityVersion.WSSecurity11W |
| | | 12 | | |
| | 39 | 13 | | private WSHTTPSecurity _security = new WSHTTPSecurity(); |
| | | 14 | | |
| | 12 | 15 | | public WSHttpBinding() : base() { } |
| | | 16 | | |
| | 46 | 17 | | public WSHttpBinding(SecurityMode securityMode) : this(securityMode, false) { } |
| | | 18 | | |
| | 33 | 19 | | public WSHttpBinding(SecurityMode securityMode, bool reliableSessionEnabled) : base(reliableSessionEnabled) |
| | | 20 | | { |
| | 33 | 21 | | _security.Mode = securityMode; |
| | 33 | 22 | | } |
| | | 23 | | |
| | 0 | 24 | | internal WSHttpBinding(WSHTTPSecurity security, bool reliableSessionEnabled) : base(reliableSessionEnabled) |
| | | 25 | | { |
| | 0 | 26 | | _security = security ?? new WSHTTPSecurity(); |
| | 0 | 27 | | } |
| | | 28 | | |
| | | 29 | | public WSHTTPSecurity Security |
| | | 30 | | { |
| | 177 | 31 | | get { return _security; } |
| | | 32 | | set |
| | | 33 | | { |
| | 6 | 34 | | _security = value ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException |
| | 6 | 35 | | } |
| | | 36 | | } |
| | | 37 | | |
| | | 38 | | public override BindingElementCollection CreateBindingElements() |
| | | 39 | | { |
| | 293 | 40 | | return base.CreateBindingElements(); |
| | | 41 | | } |
| | | 42 | | |
| | | 43 | | protected override TransportBindingElement GetTransport() |
| | | 44 | | { |
| | 384 | 45 | | if (_security.Mode == SecurityMode.None || _security.Mode == SecurityMode.Message) |
| | | 46 | | { |
| | 160 | 47 | | HttpTransport.ExtendedProtectionPolicy = _security.Transport.ExtendedProtectionPolicy; |
| | 160 | 48 | | return HttpTransport; |
| | | 49 | | } |
| | | 50 | | else |
| | | 51 | | { |
| | 224 | 52 | | _security.ApplyTransportSecurity(HttpsTransport); |
| | 224 | 53 | | _security.ApplyAuthorizationPolicySupport(HttpsTransport); |
| | 224 | 54 | | return HttpsTransport; |
| | | 55 | | } |
| | | 56 | | } |
| | | 57 | | |
| | | 58 | | protected override SecurityBindingElement CreateMessageSecurity() |
| | | 59 | | { |
| | 152 | 60 | | return _security.CreateMessageSecurity(false, s_WSMessageSecurityVersion); |
| | | 61 | | } |
| | | 62 | | } |
| | | 63 | | } |