Пример #1
0
        public override void CopyFrom(ServiceModelExtensionElement from)
        {
            base.CopyFrom(from);
            ServiceCredentialsElement element = (ServiceCredentialsElement)from;

            this.ClientCertificate.Copy(element.ClientCertificate);
            this.ServiceCertificate.Copy(element.ServiceCertificate);
            this.UserNameAuthentication.Copy(element.UserNameAuthentication);
            this.WindowsAuthentication.Copy(element.WindowsAuthentication);
            this.Peer.Copy(element.Peer);
            this.IssuedTokenAuthentication.Copy(element.IssuedTokenAuthentication);
            this.SecureConversationAuthentication.Copy(element.SecureConversationAuthentication);
            this.Type = element.Type;
        }
Пример #2
0
        public override void CopyFrom(ServiceModelExtensionElement from)
        {
            base.CopyFrom(from);

            ServiceCredentialsElement source = (ServiceCredentialsElement)from;

#pragma warning suppress 56506 //Microsoft; base.CopyFrom() checks for 'from' being null
            this.ClientCertificate.Copy(source.ClientCertificate);
            this.ServiceCertificate.Copy(source.ServiceCertificate);
            this.UserNameAuthentication.Copy(source.UserNameAuthentication);
            this.WindowsAuthentication.Copy(source.WindowsAuthentication);
            this.Peer.Copy(source.Peer);
            this.IssuedTokenAuthentication.Copy(source.IssuedTokenAuthentication);
            this.SecureConversationAuthentication.Copy(source.SecureConversationAuthentication);
            this.Type = source.Type;
            this.UseIdentityConfiguration = source.UseIdentityConfiguration;
            this.IdentityConfiguration    = source.IdentityConfiguration;
        }
Пример #3
0
		public void ServiceCredentialsElement_defaults () {
			ServiceCredentialsElement element = new ServiceCredentialsElement ();

			Assert.AreEqual (typeof (ServiceCredentials), element.BehaviorType, "BehaviorType");
			Assert.AreEqual ("serviceCredentials", element.ConfigurationElementName, "ConfigurationElementName");

			Assert.AreEqual (String.Empty, element.Type, "Type");

			Assert.AreEqual (String.Empty, element.ClientCertificate.Certificate.FindValue, "ClientCertificate.Certificate.FindValue");
			Assert.AreEqual (StoreLocation.LocalMachine, element.ClientCertificate.Certificate.StoreLocation, "ClientCertificate.Certificate.StoreLocation");
			Assert.AreEqual (StoreName.My, element.ClientCertificate.Certificate.StoreName, "ClientCertificate.Certificate.StoreName");
			Assert.AreEqual (X509FindType.FindBySubjectDistinguishedName, element.ClientCertificate.Certificate.X509FindType, "ClientCertificate.Certificate.X509FindType");

			Assert.AreEqual (String.Empty, element.ClientCertificate.Authentication.CustomCertificateValidatorType, "ClientCertificate.Authentication.CustomCertificateValidatorType");
			Assert.AreEqual (X509CertificateValidationMode.ChainTrust, element.ClientCertificate.Authentication.CertificateValidationMode, "ClientCertificate.Authentication.CustomCertificateValidatorType");
			Assert.AreEqual (X509RevocationMode.Online, element.ClientCertificate.Authentication.RevocationMode, "ClientCertificate.Authentication.RevocationMode");
			Assert.AreEqual (StoreLocation.LocalMachine, element.ClientCertificate.Authentication.TrustedStoreLocation, "ClientCertificate.Authentication.TrustedStoreLocation");
			Assert.AreEqual (true, element.ClientCertificate.Authentication.IncludeWindowsGroups, "ClientCertificate.Authentication.IncludeWindowsGroups");
			Assert.AreEqual (false, element.ClientCertificate.Authentication.MapClientCertificateToWindowsAccount, "ClientCertificate.Authentication.MapClientCertificateToWindowsAccount");

			Assert.AreEqual (String.Empty, element.ServiceCertificate.FindValue, "ServiceCertificate.FindValue");
			Assert.AreEqual (StoreLocation.LocalMachine, element.ServiceCertificate.StoreLocation, "ServiceCertificate.StoreLocation");
			Assert.AreEqual (StoreName.My, element.ServiceCertificate.StoreName, "ServiceCertificate.StoreName");
			Assert.AreEqual (X509FindType.FindBySubjectDistinguishedName, element.ServiceCertificate.X509FindType, "ServiceCertificate.X509FindType");

			Assert.AreEqual (UserNamePasswordValidationMode.Windows, element.UserNameAuthentication.UserNamePasswordValidationMode, "UserNameAuthentication.UserNamePasswordValidationMode");
			Assert.AreEqual (true, element.UserNameAuthentication.IncludeWindowsGroups, "UserNameAuthentication.IncludeWindowsGroups");
			Assert.AreEqual (String.Empty, element.UserNameAuthentication.MembershipProviderName, "UserNameAuthentication.MembershipProviderName");
			Assert.AreEqual (String.Empty, element.UserNameAuthentication.CustomUserNamePasswordValidatorType, "UserNameAuthentication.customUserNamePasswordValidatorType");
			Assert.AreEqual (false, element.UserNameAuthentication.CacheLogonTokens, "UserNameAuthentication.CacheLogonTokens");
			Assert.AreEqual (128, element.UserNameAuthentication.MaxCachedLogonTokens, "UserNameAuthentication.MaxCachedLogonTokens");
			Assert.AreEqual (new TimeSpan (0, 15, 0), element.UserNameAuthentication.CachedLogonTokenLifetime, "UserNameAuthentication.CachedLogonTokenLifetime");

			Assert.AreEqual (String.Empty, element.Peer.Certificate.FindValue, "Peer.Certificate.FindValue");
			Assert.AreEqual (StoreLocation.CurrentUser, element.Peer.Certificate.StoreLocation, "Peer.Certificate.StoreLocation");
			Assert.AreEqual (StoreName.My, element.Peer.Certificate.StoreName, "Peer.Certificate.StoreName");
			Assert.AreEqual (X509FindType.FindBySubjectDistinguishedName, element.Peer.Certificate.X509FindType, "Peer.Certificate.X509FindType");

			Assert.AreEqual (String.Empty, element.Peer.PeerAuthentication.CustomCertificateValidatorType, "Peer.Authentication.CustomCertificateValidatorType");
			Assert.AreEqual (X509CertificateValidationMode.PeerOrChainTrust, element.Peer.PeerAuthentication.CertificateValidationMode, "Peer.Authentication.CustomCertificateValidatorType");
			Assert.AreEqual (X509RevocationMode.Online, element.Peer.PeerAuthentication.RevocationMode, "Peer.Authentication.RevocationMode");
			Assert.AreEqual (StoreLocation.CurrentUser, element.Peer.PeerAuthentication.TrustedStoreLocation, "Peer.Authentication.TrustedStoreLocation");

			Assert.AreEqual (String.Empty, element.Peer.MessageSenderAuthentication.CustomCertificateValidatorType, "Peer.MessageSenderAuthentication.CustomCertificateValidatorType");
			Assert.AreEqual (X509CertificateValidationMode.PeerOrChainTrust, element.Peer.MessageSenderAuthentication.CertificateValidationMode, "Peer.MessageSenderAuthentication.CustomCertificateValidatorType");
			Assert.AreEqual (X509RevocationMode.Online, element.Peer.MessageSenderAuthentication.RevocationMode, "Peer.MessageSenderAuthentication.RevocationMode");
			Assert.AreEqual (StoreLocation.CurrentUser, element.Peer.MessageSenderAuthentication.TrustedStoreLocation, "Peer.MessageSenderAuthentication.TrustedStoreLocation");

			Assert.AreEqual (String.Empty, element.IssuedTokenAuthentication.CustomCertificateValidatorType, "IssuedTokenAuthentication.CustomCertificateValidatorType");
			Assert.AreEqual (X509CertificateValidationMode.ChainTrust, element.IssuedTokenAuthentication.CertificateValidationMode, "IssuedTokenAuthentication.CustomCertificateValidatorType");
			Assert.AreEqual (X509RevocationMode.Online, element.IssuedTokenAuthentication.RevocationMode, "IssuedTokenAuthentication.RevocationMode");
			Assert.AreEqual (StoreLocation.LocalMachine, element.IssuedTokenAuthentication.TrustedStoreLocation, "IssuedTokenAuthentication.TrustedStoreLocation");
			Assert.AreEqual (String.Empty, element.IssuedTokenAuthentication.SamlSerializerType, "IssuedTokenAuthentication.SamlSerializerType");
			Assert.AreEqual (false, element.IssuedTokenAuthentication.AllowUntrustedRsaIssuers, "IssuedTokenAuthentication.AllowUntrustedRsaIssuers");

			Assert.AreEqual (0, element.IssuedTokenAuthentication.KnownCertificates.Count, "IssuedTokenAuthentication.KnownCertificates.Count");

			Assert.AreEqual (String.Empty, element.SecureConversationAuthentication.SecurityStateEncoderType, "SecureConversationAuthentication.SecurityStateEncoderType");
		}
        public void UpdateBehaviorExtensionTest()
        {
            NamedServiceModelExtensionCollectionElement<BehaviorExtensionElement> element = LoadManager().GetBehavior(Constants.ServiceBehaviorName);
            ServiceCredentialsElement extension = new ServiceCredentialsElement();
            extension.UserNameAuthentication.MembershipProviderName = Constants.MembershipProviderName;
            ServiceCredentialsElement updatedExtension = ServiceModelConfigurationManager.GetBehaviorExtensionElement<ServiceCredentialsElement>(element);

            Assert.IsNotNull(updatedExtension);
            Assert.AreEqual(updatedExtension.BehaviorType, extension.BehaviorType);
            Assert.AreEqual(Constants.MembershipProviderName, updatedExtension.UserNameAuthentication.MembershipProviderName);
        }