| | | 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.Configuration; |
| | | 6 | | using System.Security.Authentication; |
| | | 7 | | using CoreWCF.Channels; |
| | | 8 | | |
| | | 9 | | namespace CoreWCF.Configuration |
| | | 10 | | { |
| | | 11 | | public sealed class SslStreamSecurityElement : BindingElementExtensionElement |
| | | 12 | | { |
| | 0 | 13 | | public SslStreamSecurityElement() |
| | | 14 | | { |
| | 0 | 15 | | } |
| | | 16 | | |
| | | 17 | | [ConfigurationProperty( |
| | | 18 | | ConfigurationStrings.RequireClientCertificate, DefaultValue = TransportDefaults.RequireClientCertificate)] |
| | | 19 | | public bool RequireClientCertificate |
| | | 20 | | { |
| | 0 | 21 | | get { return (bool)base[ConfigurationStrings.RequireClientCertificate]; } |
| | 0 | 22 | | set { base[ConfigurationStrings.RequireClientCertificate] = value; } |
| | | 23 | | } |
| | | 24 | | |
| | | 25 | | [ConfigurationProperty(ConfigurationStrings.SslProtocols, DefaultValue = TransportDefaults.OldDefaultSslProtocol |
| | | 26 | | public SslProtocols SslProtocols |
| | | 27 | | { |
| | 0 | 28 | | get { return (SslProtocols)base[ConfigurationStrings.SslProtocols]; } |
| | 0 | 29 | | private set { base[ConfigurationStrings.SslProtocols] = value; } |
| | | 30 | | } |
| | | 31 | | |
| | | 32 | | |
| | | 33 | | public override void ApplyConfiguration(BindingElement bindingElement) |
| | | 34 | | { |
| | 0 | 35 | | base.ApplyConfiguration(bindingElement); |
| | 0 | 36 | | SslStreamSecurityBindingElement sslBindingElement = |
| | 0 | 37 | | (SslStreamSecurityBindingElement)bindingElement; |
| | 0 | 38 | | sslBindingElement.RequireClientCertificate = RequireClientCertificate; |
| | 0 | 39 | | sslBindingElement.SslProtocols = SslProtocols; |
| | 0 | 40 | | } |
| | | 41 | | |
| | | 42 | | protected internal override BindingElement CreateBindingElement() |
| | | 43 | | { |
| | 0 | 44 | | SslStreamSecurityBindingElement sslBindingElement |
| | 0 | 45 | | = new SslStreamSecurityBindingElement(); |
| | | 46 | | |
| | 0 | 47 | | ApplyConfiguration(sslBindingElement); |
| | 0 | 48 | | return sslBindingElement; |
| | | 49 | | } |
| | | 50 | | |
| | | 51 | | public override Type BindingElementType |
| | | 52 | | { |
| | 0 | 53 | | get { return typeof(SslStreamSecurityBindingElement); } |
| | | 54 | | } |
| | | 55 | | |
| | | 56 | | public override void CopyFrom(ServiceModelExtensionElement from) |
| | | 57 | | { |
| | 0 | 58 | | base.CopyFrom(from); |
| | | 59 | | |
| | 0 | 60 | | SslStreamSecurityElement source = (SslStreamSecurityElement)from; |
| | 0 | 61 | | RequireClientCertificate = source.RequireClientCertificate; |
| | 0 | 62 | | SslProtocols = source.SslProtocols; |
| | 0 | 63 | | } |
| | | 64 | | |
| | | 65 | | protected internal override void InitializeFrom(BindingElement bindingElement) |
| | | 66 | | { |
| | 0 | 67 | | base.InitializeFrom(bindingElement); |
| | 0 | 68 | | SslStreamSecurityBindingElement sslBindingElement |
| | 0 | 69 | | = (SslStreamSecurityBindingElement)bindingElement; |
| | 0 | 70 | | SetPropertyValueIfNotDefaultValue(ConfigurationStrings.RequireClientCertificate, sslBindingElement.RequireCl |
| | 0 | 71 | | SetPropertyValueIfNotDefaultValue(ConfigurationStrings.SslProtocols, sslBindingElement.SslProtocols); |
| | 0 | 72 | | } |
| | | 73 | | } |
| | | 74 | | } |