示例#1
0
 public HttpTransportSecurity()
 {
     _clientCredentialType = DefaultClientCredentialType;
     _proxyCredentialType  = DefaultProxyCredentialType;
     Realm = DefaultRealm;
     _extendedProtectionPolicy = ChannelBindingUtility.DefaultPolicy;
 }
示例#2
0
        internal static AuthenticationSchemes MapToAuthenticationScheme(
            HttpProxyCredentialType proxyCredentialType
            )
        {
            switch (proxyCredentialType)
            {
            case HttpProxyCredentialType.None:
                return(AuthenticationSchemes.Anonymous);

            case HttpProxyCredentialType.Basic:
                return(AuthenticationSchemes.Basic);

            case HttpProxyCredentialType.Digest:
                return(AuthenticationSchemes.Digest);

            case HttpProxyCredentialType.Ntlm:
                return(AuthenticationSchemes.Ntlm);

            case HttpProxyCredentialType.Windows:
                return(AuthenticationSchemes.Negotiate);
            }

            Contract.Assert(false, "Invalid proxyCredentialType " + proxyCredentialType);
            return(AuthenticationSchemes.Anonymous);
        }
 internal static AuthenticationSchemes MapToAuthenticationScheme(HttpProxyCredentialType proxyCredentialType)
 {
     AuthenticationSchemes result;
     switch (proxyCredentialType)
     {
         case HttpProxyCredentialType.None:
             result = AuthenticationSchemes.Anonymous;
             break;
         case HttpProxyCredentialType.Basic:
             result = AuthenticationSchemes.Basic;
             break;
         case HttpProxyCredentialType.Digest:
             result = AuthenticationSchemes.Digest;
             break;
         case HttpProxyCredentialType.Ntlm:
             result = AuthenticationSchemes.Ntlm;
             break;
         case HttpProxyCredentialType.Windows:
             result = AuthenticationSchemes.Negotiate;
             break;
         default:
             Fx.Assert("unsupported proxy credential type");
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException());
     }
     return result;
 }
        internal static AuthenticationSchemes MapToAuthenticationScheme(HttpProxyCredentialType proxyCredentialType)
        {
            AuthenticationSchemes result;

            switch (proxyCredentialType)
            {
            case HttpProxyCredentialType.None:
                result = AuthenticationSchemes.Anonymous;
                break;

            case HttpProxyCredentialType.Basic:
                result = AuthenticationSchemes.Basic;
                break;

            case HttpProxyCredentialType.Digest:
                result = AuthenticationSchemes.Digest;
                break;

            case HttpProxyCredentialType.Ntlm:
                result = AuthenticationSchemes.Ntlm;
                break;

            case HttpProxyCredentialType.Windows:
                result = AuthenticationSchemes.Negotiate;
                break;

            default:
                Debug.Assert(false, "unsupported proxy credential type");
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException());
            }
            return(result);
        }
 public HttpTransportSecurity()
 {
     this.clientCredentialType = DefaultClientCredentialType;
     this.proxyCredentialType = DefaultProxyCredentialType;
     this.realm = DefaultRealm;
     this.extendedProtectionPolicy = ChannelBindingUtility.DefaultPolicy;
 }
示例#6
0
 internal static bool IsDefined(HttpProxyCredentialType value)
 {
     if (((value != HttpProxyCredentialType.None) && (value != HttpProxyCredentialType.Basic)) && ((value != HttpProxyCredentialType.Digest) && (value != HttpProxyCredentialType.Ntlm)))
     {
         return(value == HttpProxyCredentialType.Windows);
     }
     return(true);
 }
示例#7
0
 internal void InitializeFrom(HttpRelayTransportSecurity security)
 {
     if (security == null)
     {
         throw Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("security");
     }
     this.ProxyCredentialType = security.ProxyCredentialType;
 }
 internal static bool IsDefined(HttpProxyCredentialType value)
 {
     return (value == HttpProxyCredentialType.None ||
         value == HttpProxyCredentialType.Basic ||
         value == HttpProxyCredentialType.Digest ||
         value == HttpProxyCredentialType.Ntlm ||
         value == HttpProxyCredentialType.Windows);
 }
 internal static bool IsDefined(HttpProxyCredentialType value)
 {
     if (((value != HttpProxyCredentialType.None) && (value != HttpProxyCredentialType.Basic)) && ((value != HttpProxyCredentialType.Digest) && (value != HttpProxyCredentialType.Ntlm)))
     {
         return (value == HttpProxyCredentialType.Windows);
     }
     return true;
 }
示例#10
0
 internal static bool IsDefined(HttpProxyCredentialType value)
 {
     return(value == HttpProxyCredentialType.None ||
            value == HttpProxyCredentialType.Basic ||
            value == HttpProxyCredentialType.Digest ||
            value == HttpProxyCredentialType.Ntlm ||
            value == HttpProxyCredentialType.Windows);
 }
    public static void ProxyCredentialType_Propagates_To_TransportBindingElement(HttpProxyCredentialType credentialType, AuthenticationSchemes mappedAuthScheme)
    {
        var binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);

        binding.Security.Transport.ProxyCredentialType = credentialType;
        var be   = binding.CreateBindingElements();
        var htbe = be.Find <HttpTransportBindingElement>();

        Assert.Equal(mappedAuthScheme, htbe.ProxyAuthenticationScheme);
    }
示例#12
0
        internal static AuthenticationSchemes MapToAuthenticationScheme(HttpProxyCredentialType proxyCredentialType)
        {
            AuthenticationSchemes authenticationScheme;

            switch (proxyCredentialType)
            {
            case HttpProxyCredentialType.None:
            {
                authenticationScheme = AuthenticationSchemes.Anonymous;
                break;
            }

            case HttpProxyCredentialType.Basic:
            {
                authenticationScheme = AuthenticationSchemes.Basic;
                break;
            }

            case HttpProxyCredentialType.Digest:
            {
                authenticationScheme = AuthenticationSchemes.Digest;
                break;
            }

            case HttpProxyCredentialType.Ntlm:
            {
                authenticationScheme = AuthenticationSchemes.Ntlm;
                break;
            }

            case HttpProxyCredentialType.Windows:
            {
                authenticationScheme = AuthenticationSchemes.Negotiate;
                break;
            }

            default:
            {
                Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.DebugAssert("unsupported proxy credential type");
                throw Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException());
            }
            }
            return(authenticationScheme);
        }
示例#13
0
        internal static AuthenticationSchemes MapToAuthenticationScheme(HttpProxyCredentialType proxyCredentialType)
        {
            switch (proxyCredentialType)
            {
            case HttpProxyCredentialType.None:
                return(AuthenticationSchemes.Anonymous);

            case HttpProxyCredentialType.Basic:
                return(AuthenticationSchemes.Basic);

            case HttpProxyCredentialType.Digest:
                return(AuthenticationSchemes.Digest);

            case HttpProxyCredentialType.Ntlm:
                return(AuthenticationSchemes.Ntlm);

            case HttpProxyCredentialType.Windows:
                return(AuthenticationSchemes.Negotiate);
            }
            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException());
        }
        internal static AuthenticationSchemes MapToAuthenticationScheme(HttpProxyCredentialType proxyCredentialType)
        {
            switch (proxyCredentialType)
            {
                case HttpProxyCredentialType.None:
                    return AuthenticationSchemes.Anonymous;

                case HttpProxyCredentialType.Basic:
                    return AuthenticationSchemes.Basic;

                case HttpProxyCredentialType.Digest:
                    return AuthenticationSchemes.Digest;

                case HttpProxyCredentialType.Ntlm:
                    return AuthenticationSchemes.Ntlm;

                case HttpProxyCredentialType.Windows:
                    return AuthenticationSchemes.Negotiate;
            }
            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException());
        }
        internal static AuthenticationSchemes MapToAuthenticationScheme(HttpProxyCredentialType proxyCredentialType)
        {
            switch (proxyCredentialType)
            {
                case HttpProxyCredentialType.None:
                    return AuthenticationSchemes.Anonymous;

                case HttpProxyCredentialType.Basic:
                    return AuthenticationSchemes.Basic;

                case HttpProxyCredentialType.Digest:
                    return AuthenticationSchemes.Digest;

                case HttpProxyCredentialType.Ntlm:
                    return AuthenticationSchemes.Ntlm;

                case HttpProxyCredentialType.Windows:
                    return AuthenticationSchemes.Negotiate;
            }

            Debug.Assert(false, "Invalid proxyCredentialType " + proxyCredentialType);
            return AuthenticationSchemes.Anonymous;
        }
示例#16
0
 public HttpTransportSecurity()
 {
     _clientCredentialType = DefaultClientCredentialType;
     _proxyCredentialType  = DefaultProxyCredentialType;
     _realm = DefaultRealm;
 }
示例#17
0
    public T GetService()
    {
        ServiceBaseConfig config = this.GetOptionBlock();

        EndpointAddress endpointAddress = new EndpointAddress(config.ServiceUrl);

        Binding binding;
        HttpClientCredentialType clientType = HttpClientCredentialType.Basic;
        HttpProxyCredentialType  proxyType  = HttpProxyCredentialType.Basic;

        if (config.Transport != null)
        {
            Enum.TryParse <HttpClientCredentialType>(config.Transport?.ClientCredentialsType, out clientType);
            Enum.TryParse <HttpProxyCredentialType>(config.Transport?.ProxyCredentialsType, out proxyType);
        }



        switch (config.Binding)
        {
        case BindingMode.BasicHttp:
            BasicHttpSecurityMode basicHttpSecurityMode;
            if (!Enum.TryParse <BasicHttpSecurityMode>(config.BasicHttpSecurityMode.ToString(), out basicHttpSecurityMode))
            {
                throw new Exception("SecurityMode not found");
            }
            var httpbinding = new BasicHttpBinding(basicHttpSecurityMode);

            if (config.Transport != null)
            {
                httpbinding.Security.Transport.ClientCredentialType = clientType;
                httpbinding.Security.Transport.ProxyCredentialType  = proxyType;
            }

            httpbinding.MaxBufferPoolSize      = 655369999;
            httpbinding.MaxBufferSize          = 655369999;
            httpbinding.MaxReceivedMessageSize = 655369999;

            binding = httpbinding;
            break;

        case BindingMode.BasicHttps:
            BasicHttpsSecurityMode basicHttpsSecurityMode;
            if (!Enum.TryParse <BasicHttpsSecurityMode>(config.BasicHttpSecurityMode.ToString(), out basicHttpsSecurityMode))
            {
                throw new Exception("SecurityMode not found");
            }
            var httpsbinding = new BasicHttpsBinding(basicHttpsSecurityMode);
            if (config.Transport != null)
            {
                httpsbinding.Security.Transport.ClientCredentialType = clientType;
                httpsbinding.Security.Transport.ProxyCredentialType  = proxyType;
            }

            httpsbinding.MaxBufferPoolSize      = 655369999;
            httpsbinding.MaxBufferSize          = 655369999;
            httpsbinding.MaxReceivedMessageSize = 655369999;

            binding = httpsbinding;
            break;

        default:
            throw new Exception("Binding mode not set");
        }

        var factory      = new ChannelFactory <T>(binding, endpointAddress);
        var serviceProxy = factory.CreateChannel();

        return(serviceProxy);
    }
示例#18
0
 internal HttpRelayTransportSecurity()
 {
     this.proxyCredentialType = HttpProxyCredentialType.None;
 }
示例#19
0
 private XmlRpcHttpSecurity(XmlRpcHttpSecurityMode mode, HttpClientCredentialType clientCredentialType, HttpProxyCredentialType proxyCredentialType, string realm)
 {
     this.Mode = mode;
     this.ClientCredentialType = clientCredentialType;
     this.ProxyCredentialType  = proxyCredentialType;
     this.Realm = realm;
 }