internal SecurityBindingElement CreateMessageSecurity(bool isSecureTransportMode)
        {
            SecurityBindingElement algorithmSuite;

            if (!isSecureTransportMode)
            {
                if (this.clientCredentialType != BasicHttpMessageCredentialType.Certificate)
                {
                    throw Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(Microsoft.ServiceBus.SR.GetString(Resources.BasicHttpMessageSecurityRequiresCertificate, new object[0])));
                }
                algorithmSuite = SecurityBindingElement.CreateMutualCertificateBindingElement(MessageSecurityVersion.WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10, true);
            }
            else
            {
                MessageSecurityVersion wSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10 = MessageSecurityVersion.WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10;
                switch (this.clientCredentialType)
                {
                case BasicHttpMessageCredentialType.UserName:
                {
                    algorithmSuite = SecurityBindingElement.CreateUserNameOverTransportBindingElement();
                    algorithmSuite.MessageSecurityVersion = wSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10;
                    algorithmSuite.DefaultAlgorithmSuite  = this.AlgorithmSuite;
                    algorithmSuite.SecurityHeaderLayout   = SecurityHeaderLayout.Lax;
                    algorithmSuite.SetKeyDerivation(false);
                    InvokeHelper.InvokeInstanceSet(algorithmSuite.GetType(), algorithmSuite, "DoNotEmitTrust", true);
                    return(algorithmSuite);
                }

                case BasicHttpMessageCredentialType.Certificate:
                {
                    algorithmSuite = SecurityBindingElement.CreateCertificateOverTransportBindingElement(wSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10);
                    algorithmSuite.DefaultAlgorithmSuite = this.AlgorithmSuite;
                    algorithmSuite.SecurityHeaderLayout  = SecurityHeaderLayout.Lax;
                    algorithmSuite.SetKeyDerivation(false);
                    InvokeHelper.InvokeInstanceSet(algorithmSuite.GetType(), algorithmSuite, "DoNotEmitTrust", true);
                    return(algorithmSuite);
                }
                }
                Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.DebugAssert("Unsupported basic http message credential type");
                throw Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException());
            }
            algorithmSuite.DefaultAlgorithmSuite = this.AlgorithmSuite;
            algorithmSuite.SecurityHeaderLayout  = SecurityHeaderLayout.Lax;
            algorithmSuite.SetKeyDerivation(false);
            InvokeHelper.InvokeInstanceSet(algorithmSuite.GetType(), algorithmSuite, "DoNotEmitTrust", true);
            return(algorithmSuite);
        }