internal void ApplyConfiguration(UserNamePasswordServiceCredential userName)
 {
     if (userName == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("userName");
     }
     userName.UserNamePasswordValidationMode = this.UserNamePasswordValidationMode;
     userName.IncludeWindowsGroups = this.IncludeWindowsGroups;
     userName.CacheLogonTokens = this.CacheLogonTokens;
     userName.MaxCachedLogonTokens = this.MaxCachedLogonTokens;
     userName.CachedLogonTokenLifetime = this.CachedLogonTokenLifetime;
     if (base.ElementInformation.Properties["membershipProviderName"].ValueOrigin != PropertyValueOrigin.Default)
     {
         userName.MembershipProvider = SystemWebHelper.GetMembershipProvider(this.MembershipProviderName);
         if (userName.MembershipProvider == null)
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(System.ServiceModel.SR.GetString("InvalidMembershipProviderSpecifiedInConfig", new object[] { this.MembershipProviderName })));
         }
     }
     else if (userName.UserNamePasswordValidationMode == System.ServiceModel.Security.UserNamePasswordValidationMode.MembershipProvider)
     {
         userName.MembershipProvider = SystemWebHelper.GetMembershipProvider();
     }
     if (!string.IsNullOrEmpty(this.CustomUserNamePasswordValidatorType))
     {
         Type c = Type.GetType(this.CustomUserNamePasswordValidatorType, true);
         if (!typeof(UserNamePasswordValidator).IsAssignableFrom(c))
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationErrorsException(System.ServiceModel.SR.GetString("ConfigInvalidUserNamePasswordValidatorType", new object[] { this.CustomUserNamePasswordValidatorType, typeof(UserNamePasswordValidator).ToString() })));
         }
         userName.CustomUserNamePasswordValidator = (UserNamePasswordValidator) Activator.CreateInstance(c);
     }
 }
 public ServiceCredentials()
 {
     this.userName = new UserNamePasswordServiceCredential();
     this.clientCertificate = new X509CertificateInitiatorServiceCredential();
     this.serviceCertificate = new X509CertificateRecipientServiceCredential();
     this.windows = new WindowsServiceCredential();
     this.issuedToken = new IssuedTokenServiceCredential();
     this.peer = new PeerCredential();
     this.secureConversation = new SecureConversationServiceCredential();
 }
 internal UserNamePasswordServiceCredential(UserNamePasswordServiceCredential other)
 {
     this.includeWindowsGroups     = other.includeWindowsGroups;
     this.membershipProvider       = other.membershipProvider;
     this.validationMode           = other.validationMode;
     this.validator                = other.validator;
     this.cacheLogonTokens         = other.cacheLogonTokens;
     this.maxCachedLogonTokens     = other.maxCachedLogonTokens;
     this.cachedLogonTokenLifetime = other.cachedLogonTokenLifetime;
     this.isReadOnly               = other.isReadOnly;
 }
 internal UserNamePasswordServiceCredential(UserNamePasswordServiceCredential other)
 {
     this.includeWindowsGroups = other.includeWindowsGroups;
     this.membershipProvider = other.membershipProvider;
     this.validationMode = other.validationMode;
     this.validator = other.validator;
     this.cacheLogonTokens = other.cacheLogonTokens;
     this.maxCachedLogonTokens = other.maxCachedLogonTokens;
     this.cachedLogonTokenLifetime = other.cachedLogonTokenLifetime;
     this.isReadOnly = other.isReadOnly;
 }
 protected ServiceCredentials(ServiceCredentials other)
 {
     if (other == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("other");
     }
     this.userName = new UserNamePasswordServiceCredential(other.userName);
     this.clientCertificate = new X509CertificateInitiatorServiceCredential(other.clientCertificate);
     this.serviceCertificate = new X509CertificateRecipientServiceCredential(other.serviceCertificate);
     this.windows = new WindowsServiceCredential(other.windows);
     this.issuedToken = new IssuedTokenServiceCredential(other.issuedToken);
     this.peer = new PeerCredential(other.peer);
     this.secureConversation = new SecureConversationServiceCredential(other.secureConversation);
 }
Example #6
0
        UserNameSecurityTokenAuthenticator CreateUserNameAuthenticator(SecurityTokenRequirement requirement)
        {
            UserNamePasswordServiceCredential c = ServiceCredentials.UserNameAuthentication;

            switch (c.UserNamePasswordValidationMode)
            {
            case UserNamePasswordValidationMode.MembershipProvider:
                if (c.MembershipProvider == null)
                {
                    throw new InvalidOperationException("For MembershipProvider validation mode, MembershipProvider is required to create a user name token authenticator.");
                }
                return(new CustomUserNameSecurityTokenAuthenticator(UserNamePasswordValidator.CreateMembershipProviderValidator(c.MembershipProvider)));

            case UserNamePasswordValidationMode.Windows:
                return(new WindowsUserNameSecurityTokenAuthenticator(c.IncludeWindowsGroups));

            default:
                if (c.CustomUserNamePasswordValidator == null)
                {
                    throw new InvalidOperationException("For Custom validation mode, CustomUserNamePasswordValidator is required to create a user name token authenticator.");
                }
                return(new CustomUserNameSecurityTokenAuthenticator(c.CustomUserNamePasswordValidator));
            }
        }