| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- //------------------------------------------------------------------------------
- // Copyright (c) Microsoft Corporation. All rights reserved.
- //------------------------------------------------------------------------------
- namespace System.ServiceModel.Configuration
- {
- using System.Configuration;
- using System.Diagnostics.CodeAnalysis;
- using System.ServiceModel.Channels;
- using System.Globalization;
- using System.Net;
- using System.Net.Security;
- using System.Runtime;
- using System.Security.Authentication.ExtendedProtection.Configuration;
- using System.ServiceModel;
- using System.ServiceModel.Security;
- using System.ComponentModel;
- public sealed partial class HttpTransportSecurityElement : ServiceModelConfigurationElement
- {
- [ConfigurationProperty(ConfigurationStrings.ClientCredentialType, DefaultValue = HttpTransportSecurity.DefaultClientCredentialType)]
- [ServiceModelEnumValidator(typeof(HttpClientCredentialTypeHelper))]
- public HttpClientCredentialType ClientCredentialType
- {
- get { return (HttpClientCredentialType)base[ConfigurationStrings.ClientCredentialType]; }
- set { base[ConfigurationStrings.ClientCredentialType] = value; }
- }
- [ConfigurationProperty(ConfigurationStrings.ProxyCredentialType, DefaultValue = HttpTransportSecurity.DefaultProxyCredentialType)]
- [ServiceModelEnumValidator(typeof(HttpProxyCredentialTypeHelper))]
- public HttpProxyCredentialType ProxyCredentialType
- {
- get { return (HttpProxyCredentialType)base[ConfigurationStrings.ProxyCredentialType]; }
- set { base[ConfigurationStrings.ProxyCredentialType] = value; }
- }
- [ConfigurationProperty(ConfigurationStrings.ExtendedProtectionPolicy)]
- public ExtendedProtectionPolicyElement ExtendedProtectionPolicy
- {
- get { return (ExtendedProtectionPolicyElement)base[ConfigurationStrings.ExtendedProtectionPolicy]; }
- private set { base[ConfigurationStrings.ExtendedProtectionPolicy] = value; }
- }
- [ConfigurationProperty(ConfigurationStrings.Realm, DefaultValue = HttpTransportSecurity.DefaultRealm)]
- [StringValidator(MinLength = 0)]
- public string Realm
- {
- get { return (string)base[ConfigurationStrings.Realm]; }
- set
- {
- if (String.IsNullOrEmpty(value))
- {
- value = String.Empty;
- }
- base[ConfigurationStrings.Realm] = value;
- }
- }
- internal void ApplyConfiguration(HttpTransportSecurity security)
- {
- if (security == null)
- {
- throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("security");
- }
- security.ClientCredentialType = this.ClientCredentialType;
- security.ProxyCredentialType = this.ProxyCredentialType;
- security.Realm = this.Realm;
- security.ExtendedProtectionPolicy = ChannelBindingUtility.BuildPolicy(this.ExtendedProtectionPolicy);
- }
- internal void InitializeFrom(HttpTransportSecurity security)
- {
- if (security == null)
- {
- throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("security");
- }
- SetPropertyValueIfNotDefaultValue(ConfigurationStrings.ClientCredentialType, security.ClientCredentialType);
- SetPropertyValueIfNotDefaultValue(ConfigurationStrings.ProxyCredentialType, security.ProxyCredentialType);
- SetPropertyValueIfNotDefaultValue(ConfigurationStrings.Realm, security.Realm);
-
- ChannelBindingUtility.InitializeFrom(security.ExtendedProtectionPolicy, this.ExtendedProtectionPolicy);
- }
- }
- }
|