Esempio n. 1
0
        internal static bool GetSecurityModeFromTransport(HttpTransportBindingElement http, HttpTransportSecurity transportSecurity, out UnifiedSecurityMode mode)
        {
            mode = UnifiedSecurityMode.None;
            if (http == null)
            {
                return(false);
            }

            Fx.Assert(http.AuthenticationScheme.IsSingleton(), "authenticationScheme used in an Http(s)ChannelFactory must be a singleton value.");

            if (http is HttpsTransportBindingElement)
            {
                mode = UnifiedSecurityMode.Transport | UnifiedSecurityMode.TransportWithMessageCredential;
                BasicHttpSecurity.EnableTransportSecurity((HttpsTransportBindingElement)http, transportSecurity);
            }
            else if (HttpTransportSecurity.IsDisabledTransportAuthentication(http))
            {
                mode = UnifiedSecurityMode.Message | UnifiedSecurityMode.None;
            }
            else if (!BasicHttpSecurity.IsEnabledTransportAuthentication(http, transportSecurity))
            {
                return(false);
            }
            else
            {
                mode = UnifiedSecurityMode.TransportCredentialOnly;
            }

            return(true);
        }
Esempio n. 2
0
 private static bool GetSecurityModeFromTransport(HttpTransportBindingElement http, HttpTransportSecurity transportSecurity, out UnifiedSecurityMode mode)
 {
     mode = UnifiedSecurityMode.None;
     if (http == null)
     {
         return(false);
     }
     if (http is HttpsTransportBindingElement)
     {
         mode = UnifiedSecurityMode.TransportWithMessageCredential | UnifiedSecurityMode.Transport;
         BasicHttpSecurity.EnableTransportSecurity((HttpsTransportBindingElement)http, transportSecurity);
     }
     else if (HttpTransportSecurity.IsDisabledTransportAuthentication(http))
     {
         mode = UnifiedSecurityMode.Message | UnifiedSecurityMode.None;
     }
     else
     {
         if (!BasicHttpSecurity.IsEnabledTransportAuthentication(http, transportSecurity))
         {
             return(false);
         }
         mode = UnifiedSecurityMode.TransportCredentialOnly;
     }
     return(true);
 }
Esempio n. 3
0
        internal TransportBindingElement GetTransport()
        {
            Fx.Assert(this.BasicHttpSecurity != null, "this.BasicHttpSecurity should not return null from a derived class.");

            BasicHttpSecurity basicHttpSecurity = this.BasicHttpSecurity;

            if (basicHttpSecurity.Mode == BasicHttpSecurityMode.Transport || basicHttpSecurity.Mode == BasicHttpSecurityMode.TransportWithMessageCredential)
            {
                basicHttpSecurity.EnableTransportSecurity(_httpsTransport);
                return(_httpsTransport);
            }
            else if (basicHttpSecurity.Mode == BasicHttpSecurityMode.TransportCredentialOnly)
            {
                basicHttpSecurity.EnableTransportAuthentication(_httpTransport);
                return(_httpTransport);
            }
            else
            {
                // ensure that there is no transport security
                basicHttpSecurity.DisableTransportAuthentication(_httpTransport);
                return(_httpTransport);
            }
        }
Esempio n. 4
0
 internal void EnableTransportSecurity(HttpsTransportBindingElement https)
 {
     _basicHttpSecurity.EnableTransportSecurity(https);
 }