internal static bool TryCreate(SecurityBindingElement sbe, UnifiedSecurityMode mode, HttpTransportSecurity transportSecurity, out BasicHttpSecurity security)
        {
            security = null;
            BasicHttpMessageSecurity messageSecurity = null;

            if (sbe != null)
            {
                mode &= UnifiedSecurityMode.Message | UnifiedSecurityMode.TransportWithMessageCredential;
                bool isSecureTransportMode;
                if (!BasicHttpMessageSecurity.TryCreate(sbe, out messageSecurity, out isSecureTransportMode))
                {
                    return(false);
                }
            }
            else
            {
                mode &= ~(UnifiedSecurityMode.Message | UnifiedSecurityMode.TransportWithMessageCredential);
            }
            BasicHttpSecurityMode basicHttpSecurityMode = BasicHttpSecurityModeHelper.ToSecurityMode(mode);

            Fx.Assert(BasicHttpSecurityModeHelper.IsDefined(basicHttpSecurityMode), string.Format("Invalid BasicHttpSecurityMode value: {0}.", basicHttpSecurityMode.ToString()));
            security = new BasicHttpSecurity(basicHttpSecurityMode, transportSecurity, messageSecurity);

            return(SecurityElement.AreBindingsMatching(security.CreateMessageSecurity(), sbe));
        }
Exemplo n.º 2
0
        public override BindingElementCollection CreateBindingElements()
        {
            CheckSettings();

            // return collection of BindingElements
            BindingElementCollection bindingElements = new BindingElementCollection();

            // add security (*optional)
            SecurityBindingElement messageSecurity = BasicHttpSecurity.CreateMessageSecurity();

            if (messageSecurity != null)
            {
                bindingElements.Add(messageSecurity);
            }

            // add encoding
            switch (MessageEncoding)
            {
            case NetHttpMessageEncoding.Text:
                bindingElements.Add(TextMessageEncodingBindingElement);
                break;

            case NetHttpMessageEncoding.Mtom:
                throw ExceptionHelper.PlatformNotSupported(SR.Format(SR.UnsupportedBindingProperty, "MessageEncoding", MessageEncoding));

            default:
                bindingElements.Add(_binaryMessageEncodingBindingElement);
                break;
            }

            // add transport (http or https)
            bindingElements.Add(GetTransport());

            return(bindingElements.Clone());
        }
Exemplo n.º 3
0
        public override BindingElementCollection CreateBindingElements()
        {
            CheckSettings();

            // return collection of BindingElements
            BindingElementCollection bindingElements = new BindingElementCollection();

            // order of BindingElements is important
            // add session
            if (_reliableSession.Enabled)
            {
                bindingElements.Add(_session);
            }

            // add security (*optional)
            SecurityBindingElement messageSecurity = BasicHttpSecurity.CreateMessageSecurity();

            if (messageSecurity != null)
            {
                bindingElements.Add(messageSecurity);
            }

            // add encoding
            switch (MessageEncoding)
            {
            case NetHttpMessageEncoding.Text:
                bindingElements.Add(TextMessageEncodingBindingElement);
                break;

            case NetHttpMessageEncoding.Mtom:
                bindingElements.Add(MtomMessageEncodingBindingElement);
                break;

            default:
                bindingElements.Add(_binaryMessageEncodingBindingElement);
                break;
            }

            // add transport (http or https)
            bindingElements.Add(GetTransport());

            return(bindingElements.Clone());
        }
        internal static bool TryCreate(SecurityBindingElement sbe, UnifiedSecurityMode mode, HttpTransportSecurity transportSecurity, out BasicHttpSecurity security)
        {
            security = null;
            BasicHttpMessageSecurity security2 = null;

            if (sbe != null)
            {
                bool flag;
                mode &= UnifiedSecurityMode.TransportWithMessageCredential | UnifiedSecurityMode.Message;
                if (!BasicHttpMessageSecurity.TryCreate(sbe, out security2, out flag))
                {
                    return(false);
                }
            }
            else
            {
                mode &= ~(UnifiedSecurityMode.TransportWithMessageCredential | UnifiedSecurityMode.Message);
            }
            BasicHttpSecurityMode mode2 = BasicHttpSecurityModeHelper.ToSecurityMode(mode);

            security = new BasicHttpSecurity(mode2, transportSecurity, security2);
            return(SecurityElementBase.AreBindingsMatching(security.CreateMessageSecurity(), sbe));
        }
        internal static bool TryCreate(SecurityBindingElement sbe, UnifiedSecurityMode mode, HttpTransportSecurity transportSecurity, out BasicHttpSecurity security)
        {
            security = null;
            BasicHttpMessageSecurity messageSecurity = null;
            if (sbe != null)
            {
                mode &= UnifiedSecurityMode.Message | UnifiedSecurityMode.TransportWithMessageCredential;
                bool isSecureTransportMode;
                if (!BasicHttpMessageSecurity.TryCreate(sbe, out messageSecurity, out isSecureTransportMode))
                {
                    return false;
                }
            }
            else
            {
                mode &= ~(UnifiedSecurityMode.Message | UnifiedSecurityMode.TransportWithMessageCredential);
            }
            BasicHttpSecurityMode basicHttpSecurityMode = BasicHttpSecurityModeHelper.ToSecurityMode(mode);
            Fx.Assert(BasicHttpSecurityModeHelper.IsDefined(basicHttpSecurityMode), string.Format("Invalid BasicHttpSecurityMode value: {0}.", basicHttpSecurityMode.ToString()));
            security = new BasicHttpSecurity(basicHttpSecurityMode, transportSecurity, messageSecurity);

            return SecurityElement.AreBindingsMatching(security.CreateMessageSecurity(), sbe);
        }
 internal static bool TryCreate(SecurityBindingElement sbe, UnifiedSecurityMode mode, HttpTransportSecurity transportSecurity, out BasicHttpSecurity security)
 {
     security = null;
     BasicHttpMessageSecurity security2 = null;
     if (sbe != null)
     {
         bool flag;
         mode &= UnifiedSecurityMode.TransportWithMessageCredential | UnifiedSecurityMode.Message;
         if (!BasicHttpMessageSecurity.TryCreate(sbe, out security2, out flag))
         {
             return false;
         }
     }
     else
     {
         mode &= ~(UnifiedSecurityMode.TransportWithMessageCredential | UnifiedSecurityMode.Message);
     }
     BasicHttpSecurityMode mode2 = BasicHttpSecurityModeHelper.ToSecurityMode(mode);
     security = new BasicHttpSecurity(mode2, transportSecurity, security2);
     return SecurityElementBase.AreBindingsMatching(security.CreateMessageSecurity(), sbe);
 }
Exemplo n.º 7
0
 internal SecurityBindingElement CreateMessageSecurity()
 {
     return(_basicHttpSecurity.CreateMessageSecurity());
 }