Beispiel #1
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (ProxyEnabled != null)
         {
             hashCode = hashCode * 59 + ProxyEnabled.GetHashCode();
         }
         if (ProxyHost != null)
         {
             hashCode = hashCode * 59 + ProxyHost.GetHashCode();
         }
         if (ProxyPort != null)
         {
             hashCode = hashCode * 59 + ProxyPort.GetHashCode();
         }
         if (ProxyUser != null)
         {
             hashCode = hashCode * 59 + ProxyUser.GetHashCode();
         }
         if (ProxyPassword != null)
         {
             hashCode = hashCode * 59 + ProxyPassword.GetHashCode();
         }
         if (ProxyExceptions != null)
         {
             hashCode = hashCode * 59 + ProxyExceptions.GetHashCode();
         }
         return(hashCode);
     }
 }
        private SP.ClientContext GetClientContext(string webUrl)
        {
            SP.ClientContext ctx = new SP.ClientContext(webUrl);
            if (txtUser.Text != "")
            {
                string domain = "";
                string user   = "";
                if (txtUser.Text.Replace('/', '\\').Contains('\\'))
                {
                    string[] tmp = txtUser.Text.Split('\\');
                    domain = tmp[0];
                    user   = tmp[1];
                }
                else
                {
                    user = txtUser.Text;
                }
                string password = txtPwd.Text;

                if (chkLoginOnline.Checked)
                {
                    System.Security.SecureString secpwd = new System.Security.SecureString();
                    for (int i = 0; i < password.Length; i++)
                    {
                        secpwd.AppendChar(password[i]);
                    }
                    //ClientAuthenticationMode = ClientAuthenticationMode.FormsAuthentication;
                    //FormsAuthenticationLoginInfo creds = new FormsAuthenticationLoginInfo(User, Password);
                    SharePointOnlineCredentials creds = new SharePointOnlineCredentials(user, secpwd);
                    ctx.Credentials = creds;
                }
                else
                {
                    ctx.Credentials = new System.Net.NetworkCredential(user, txtPwd.Text, domain);
                }
            }
            if (string.IsNullOrEmpty(ProxyUrl) == false)
            {
                ctx.ExecutingWebRequest += (sen, args) =>
                {
                    System.Net.WebProxy myProxy = new System.Net.WebProxy(ProxyUrl);
                    string domain = "";
                    string user   = "";
                    if (ProxyUser.Replace('/', '\\').Contains('\\'))
                    {
                        string[] tmp = ProxyUser.Split('\\');
                        domain = tmp[0];
                        user   = tmp[1];
                    }
                    // myProxy.Credentials = new System.Net.NetworkCredential(ProxyUser, ProxyPwd, domain);
                    myProxy.Credentials                      = System.Net.CredentialCache.DefaultCredentials;
                    myProxy.UseDefaultCredentials            = true;
                    args.WebRequestExecutor.WebRequest.Proxy = myProxy;
                };
            }

            return(ctx);
        }
Beispiel #3
0
        /// <summary>
        /// Returns true if ComDayCommonsHttpclientProperties instances are equal
        /// </summary>
        /// <param name="other">Instance of ComDayCommonsHttpclientProperties to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(ComDayCommonsHttpclientProperties other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     ProxyEnabled == other.ProxyEnabled ||
                     ProxyEnabled != null &&
                     ProxyEnabled.Equals(other.ProxyEnabled)
                     ) &&
                 (
                     ProxyHost == other.ProxyHost ||
                     ProxyHost != null &&
                     ProxyHost.Equals(other.ProxyHost)
                 ) &&
                 (
                     ProxyUser == other.ProxyUser ||
                     ProxyUser != null &&
                     ProxyUser.Equals(other.ProxyUser)
                 ) &&
                 (
                     ProxyPassword == other.ProxyPassword ||
                     ProxyPassword != null &&
                     ProxyPassword.Equals(other.ProxyPassword)
                 ) &&
                 (
                     ProxyNtlmHost == other.ProxyNtlmHost ||
                     ProxyNtlmHost != null &&
                     ProxyNtlmHost.Equals(other.ProxyNtlmHost)
                 ) &&
                 (
                     ProxyNtlmDomain == other.ProxyNtlmDomain ||
                     ProxyNtlmDomain != null &&
                     ProxyNtlmDomain.Equals(other.ProxyNtlmDomain)
                 ) &&
                 (
                     ProxyExceptions == other.ProxyExceptions ||
                     ProxyExceptions != null &&
                     ProxyExceptions.Equals(other.ProxyExceptions)
                 ));
        }
Beispiel #4
0
        /// <summary>
        /// Returns true if OrgApacheHttpProxyconfiguratorProperties instances are equal
        /// </summary>
        /// <param name="other">Instance of OrgApacheHttpProxyconfiguratorProperties to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(OrgApacheHttpProxyconfiguratorProperties other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     ProxyEnabled == other.ProxyEnabled ||
                     ProxyEnabled != null &&
                     ProxyEnabled.Equals(other.ProxyEnabled)
                     ) &&
                 (
                     ProxyHost == other.ProxyHost ||
                     ProxyHost != null &&
                     ProxyHost.Equals(other.ProxyHost)
                 ) &&
                 (
                     ProxyPort == other.ProxyPort ||
                     ProxyPort != null &&
                     ProxyPort.Equals(other.ProxyPort)
                 ) &&
                 (
                     ProxyUser == other.ProxyUser ||
                     ProxyUser != null &&
                     ProxyUser.Equals(other.ProxyUser)
                 ) &&
                 (
                     ProxyPassword == other.ProxyPassword ||
                     ProxyPassword != null &&
                     ProxyPassword.Equals(other.ProxyPassword)
                 ) &&
                 (
                     ProxyExceptions == other.ProxyExceptions ||
                     ProxyExceptions != null &&
                     ProxyExceptions.Equals(other.ProxyExceptions)
                 ));
        }
    public User FindUserByName(string name)
    {
        DirectorySearcher searcher = new DirectorySearcher();
        // ...
        // set up the filter and properties of the searcher
        // ...
        Result result = searcher.FindOne();
        User   user   = new ProxyUser(this)
        {
            Name       = result.Properties["displayName"][0],
            Email      = result.Properties["email"][0],
            GroupNames = new List <string>()
        };

        foreach (string groupName in result.Properties["memberOf"])
        {
            user.GroupNames.Add(groupName);
        }
        return(user);
    }
Beispiel #6
0
        public ASCommandResponse GetResponse()
        {
            string StatusCode = string.Empty;
            string Meaning    = string.Empty;
            string Cause      = string.Empty;
            string Resolution = string.Empty;

            EASTester.EasHelp oHelp = new EASTester.EasHelp();

            GenerateXMLPayload();

            //if (ProtocolVersion == null)
            //    throw new InvalidDataException("ASCommandRequest not initialized - Protocol version not specified.");

            //if (ProtocolVersion == null)
            //    throw new InvalidDataException("ASCommandRequest not initialized - EAS Protocol version must be set");

            //if (WbxmlBytes == null)
            //    throw new InvalidDataException("ASCommandRequest not initialized - Request is empty.");

            //if (Server == null)
            //    throw new InvalidDataException("ASCommandRequest not initialized - Server must be specified.");

            //if (Credentials == null && useCertificateAuthentication == false)
            //    throw new InvalidDataException("ASCommandRequest not initialized for authentication.");

            //if (useCertificateAuthentication == true && certificateFile.Length == 0)
            //    throw new InvalidDataException("ASCommandRequest not initialized - Certificate file must be specified.");

            string uriString = string.Format("{0}//{1}/Microsoft-Server-ActiveSync?{2}",
                                             useSSL ? "https:" : "http:", server, RequestLine);
            Uri serverUri = new Uri(uriString);

            HttpWebRequest httpReq = (HttpWebRequest)WebRequest.Create(uriString);

            //httpReq.ClientCertificates.
            httpReq.Method      = "POST";
            httpReq.ContentType = "application/vnd.ms-sync.wbxml";

            // Handle any certificate errors on the certificate from the server.
            //ServicePointManager.CertificatePolicy = new CertPolicy();

            //bool bSettingCredsWasOK = false;
            if (useCertificateAuthentication == true)
            {
                // https://support.microsoft.com/en-us/kb/895971
                try
                {
                    httpReq.UseDefaultCredentials = false;
                    X509Certificate oX509Certificate = null;

                    //oX509Certificate = new X509Certificate.CreateFromCertFile(certificateFile);

                    oX509Certificate = new X509Certificate(certificateFile, certificatePassword);
                    httpReq.ClientCertificates.Add(oX509Certificate);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Exception: \r\n" + ex.ToString(), "Error setting certificate authentication.");
                    return(null);
                }
            }
            else
            {
                try
                {
                    CredentialCache creds = new CredentialCache();
                    creds.Add(serverUri, "Basic", credential);  // Using Basic authentication
                    httpReq.Credentials = creds;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Exception: \r\n" + ex.ToString(), "Error setting specified credentials.");
                    return(null);
                }
            }



            if (SpecifyProxySettings == true)
            {
                WebProxy oWebProxy = null;
                oWebProxy = new WebProxy(ProxyServer, ProxyPort);
                //oWebProxy.BypassProxyOnLocal = BypassProxyForLocalAddress;

                if (OverrideProxyCredntials == true)
                {
                    if (ProxyUser.Trim().Length == 0)
                    {
                        oWebProxy.UseDefaultCredentials = true;
                    }
                    else
                    {
                        if (ProxyDomain.Trim().Length == 0)
                        {
                            oWebProxy.Credentials = new NetworkCredential(ProxyUser, ProxyPassword);
                        }
                        else
                        {
                            oWebProxy.Credentials = new NetworkCredential(ProxyUser, ProxyPassword, ProxyDomain);
                        }
                    }
                }
                else
                {
                    oWebProxy.UseDefaultCredentials = true;
                }

                httpReq.Proxy = oWebProxy;
            }

            if (UserAgent.Trim().Length != 0)
            {
                httpReq.UserAgent = UserAgent;
            }

            if (!UseEncodedRequestLine)
            {
                httpReq.Headers.Add("MS-ASProtocolVersion", ProtocolVersion);
                httpReq.Headers.Add("X-MS-PolicyKey", PolicyKey.ToString());
            }

            try
            {
                Stream requestStream = httpReq.GetRequestStream();
                requestStream.Write(WbxmlBytes, 0, WbxmlBytes.Length);
                requestStream.Close();

                HttpWebResponse httpResp = (HttpWebResponse)httpReq.GetResponse();

                //float iisStatusCode = (float)httpResp.StatusCode;


                ASCommandResponse response = WrapHttpResponse(httpResp);

                httpResp.Close();

                //StatusCode = iisStatusCode.ToString();
                //Meaning = string.Empty;
                //Cause = string.Empty;
                //Resolution = string.Empty;
                //oHelp.GetHttpStatusInfo(StatusCode, ref Meaning, ref Cause, ref Resolution);

                //MessageBox.Show("IIS Resposne Code: " + StatusCode + "\r\nDescription: " + Meaning);

                return(response);
            }
            catch (WebException wex)
            {
                MessageBox.Show("Exception: \r\n" + wex.ToString(), "Error");

                return(null);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception: \r\n" + ex.ToString(), "Error");

                return(null);
            }
        }
Beispiel #7
0
        /// <summary>
        /// Call to inform a provider to start a synchronization cycle
        /// </summary>
        /// <returns> True - provider successfully finished a sync cycle,
        /// False - provider failed the sync cycle
        /// </returns>
        public bool Start(Simias.IdentitySynchronization.State State)
        {
            log.Debug("Start called");

            bool status = false;

            abort = false;
            try
            {
                this.state = State;

                try
                {
                    ldapSettings = LdapSettings.Get(Store.StorePath);
                    log.Debug("new LdapConnection");
                    conn = new LdapConnection();

                    log.Debug("Connecting to: " + ldapSettings.Host + " on port: " + ldapSettings.Port.ToString());
                    conn.SecureSocketLayer = ldapSettings.SSL;
                    conn.Connect(ldapSettings.Host, ldapSettings.Port);

                    ProxyUser proxy = new ProxyUser();

                    log.Debug("Binding as: " + proxy.UserDN);
                    conn.Bind(proxy.UserDN, proxy.Password);

                    ProcessSimiasAdmin(conn);
                    ProcessSearchObjects(conn, ldapSettings);
                }
                catch (SimiasShutdownException s)
                {
                    log.Error(s.Message);
                    syncException = s;
                    syncStatus    = Simias.LdapProvider.Status.SyncThreadDown;
                }
                catch (LdapException e)
                {
                    log.Error(e.LdapErrorMessage);
                    log.Error(e.StackTrace);
                    syncException = e;
                    syncStatus    =
                        (conn == null)
                                                ? Simias.LdapProvider.Status.LdapConnectionFailure
                                                : Simias.LdapProvider.Status.LdapAuthenticationFailure;

                    state.ReportError(e.LdapErrorMessage);
                }
                catch (Exception e)
                {
                    log.Error(e.Message);
                    log.Error(e.StackTrace);
                    syncException = e;
                    syncStatus    = Simias.LdapProvider.Status.InternalException;

                    state.ReportError(e.Message);
                }
                finally
                {
                    if (conn != null)
                    {
                        log.Debug("Disconnecting Ldap connection");
                        try{
                            conn.Disconnect();
                        }catch {}
                        conn = null;
                    }
                }
                status = true;
            }
            catch (Exception e)
            {
                log.Error(e.Message);
                log.Error(e.StackTrace);
                State.ReportError(e.Message);
            }

            return(status);
        }
Beispiel #8
0
 internal static System.Security.Claims.ClaimsIdentity CreateIdentity(ProxyUser user, string authenticationType)
 {
     return(DoUserManager(manager => {
         return manager.CreateIdentity(user, authenticationType);
     }));
 }
Beispiel #9
0
        public string PostUser([FromBody] dynamic id)
        {
            //ObservableCollection<Dictionary<string, object>> detailcollection = new ObservableCollection<Dictionary<string, object>>();
            //Dictionary<string, object> InvoiceStatus = new Dictionary<string, object>();
            string InvoiceId = string.Empty;

            try
            {
                ObservableCollection <IDictionary <string, object> > obj = JsonConvert.DeserializeObject <ObservableCollection <IDictionary <string, object> > >(Convert.ToString(id));
                string Status = string.Empty;
                foreach (Dictionary <string, object> header in obj)
                {
                    //Status = header["Status"].ToString();
                    prxyuser = JsonConvert.DeserializeObject <ProxyUser>(Convert.ToString(header["UserHeader"].ToString()));


                    //Invoicedetail = JsonConvert.DeserializeObject<List<ProxyInvoiceDetails>>(Convert.ToString(header["SalesDetail"].ToString()));
                }

                var users = (from rec in _TripstarContext.TblUsers where rec.FirstName == prxyuser.login_firstname.ToString() select rec).FirstOrDefault();
                if (users == null)
                {
                    tbluser                   = new TblUsers();
                    tbluser.Address           = prxyuser.login_address;
                    tbluser.Dob               = prxyuser.login_dob;
                    tbluser.EmailId           = prxyuser.login_EmailID;
                    tbluser.FirstName         = prxyuser.login_firstname;
                    tbluser.LastName          = prxyuser.login_lastname;
                    tbluser.Phone             = Convert.ToInt64(prxyuser.login_phone);
                    tbluser.PreferredCurrency = prxyuser.login_prefercurrency;
                    tbluser.PreferredLanguage = prxyuser.login_preferLanguage;
                    tbluser.Remarks           = prxyuser.login_Remarks;
                    tbluser.Password          = prxyuser.login_password;
                    tbluser.usertype          = prxyuser.UserType;
                    //tbluser.password
                    _TripstarContext.Add(tbluser);
                    _TripstarContext.SaveChanges();
                }
                else
                {
                    tbluser = (from rec in _TripstarContext.TblUsers where rec.FirstName == prxyuser.login_firstname.ToString() select rec).FirstOrDefault();

                    tbluser.Address           = prxyuser.login_address;
                    tbluser.Dob               = prxyuser.login_dob;
                    tbluser.EmailId           = prxyuser.login_EmailID;
                    tbluser.FirstName         = prxyuser.login_firstname;
                    tbluser.LastName          = prxyuser.login_lastname;
                    tbluser.Phone             = Convert.ToInt64(prxyuser.login_phone);
                    tbluser.PreferredCurrency = prxyuser.login_prefercurrency;
                    tbluser.PreferredLanguage = prxyuser.login_preferLanguage;
                    tbluser.Remarks           = prxyuser.login_Remarks;
                    tbluser.Password          = prxyuser.login_password;
                    tbluser.usertype          = prxyuser.UserType;
                    //tbluser.password
                    //_TripstarContext.Add(tbluser);
                    _TripstarContext.SaveChanges();
                }


                //return _repository.PostInvoice(Status, Headerdata, Invoicedetail);
                return("true");
            }
            catch (Exception ex)
            {
                //InvoiceStatus["Status"] = "Fail";
                //InvoiceStatus["Error"] = "please check log file..";
                //detailcollection.Add(InvoiceStatus);
                //File.AppendAllText(AppDomain.CurrentDomain.BaseDirectory + "Log\\Errorlog.txt", ex.ToString());
                return("false");
            }
        }
Beispiel #10
0
        public ASOptionsResponse GetOptions()
        {
            if (server == null)
            {
                throw new InvalidDataException("ASOptionsRequest not initialized because server was not specified.");
            }

            if ((useCertificateAuthentication == false && credential == null) || server == null)
            {
                throw new InvalidDataException("ASOptionsRequest not initialized. User credentials or certificate authentication need to be specified.");
            }

            string         strURI    = string.Format("{0}//{1}/Microsoft-Server-ActiveSync", UseSSL ? "https:" : "http:", Server);
            Uri            serverUri = new Uri(strURI);
            HttpWebRequest httpReq   = (HttpWebRequest)WebRequest.Create(strURI);

            if (useCertificateAuthentication == true)
            {
                try
                {
                    httpReq.UseDefaultCredentials = false;
                    X509Certificate oX509Certificate = null;
                    oX509Certificate = new X509Certificate(certificateFile, certificatePassword);
                    httpReq.ClientCertificates.Add(oX509Certificate);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Exception: \r\n" + ex.ToString(), "Error setting certificate authentication.");
                    return(null);
                }
            }
            else
            {
                try
                {
                    CredentialCache creds = new CredentialCache();
                    creds.Add(serverUri, "Basic", Credentials);  // Using Basic authentication
                    httpReq.Credentials = creds;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Exception: \r\n" + ex.ToString(), "Error setting specified credentials.");
                    return(null);
                }
            }

            httpReq.Method = "OPTIONS";

            if (SpecifyProxySettings == true)
            {
                WebProxy oWebProxy = null;
                oWebProxy = new WebProxy(ProxyServer, ProxyPort);
                //oWebProxy.BypassProxyOnLocal = BypassProxyForLocalAddress;

                if (OverrideProxyCredntials == true)
                {
                    if (ProxyUser.Trim().Length == 0)
                    {
                        oWebProxy.UseDefaultCredentials = true;
                    }
                    else
                    {
                        if (ProxyDomain.Trim().Length == 0)
                        {
                            oWebProxy.Credentials = new NetworkCredential(ProxyUser, ProxyPassword);
                        }
                        else
                        {
                            oWebProxy.Credentials = new NetworkCredential(ProxyUser, ProxyPassword, ProxyDomain);
                        }
                    }
                }
                else
                {
                    oWebProxy.UseDefaultCredentials = true;
                }

                httpReq.Proxy = oWebProxy;
            }

            if (UserAgent.Trim().Length != 0)
            {
                httpReq.UserAgent = UserAgent;
            }

            try
            {
                HttpWebResponse httpResp = (HttpWebResponse)httpReq.GetResponse();

                ASOptionsResponse response = new ASOptionsResponse(httpResp);


                httpResp.Close();

                return(response);
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message, "Error calling GetOptions");
                //VSError.ReportException(ex);
                return(null);
            }
        }
        private void ResetPasswordFailure(ProxyUser user)
        {
            user.FailedPasswordAnswers = 0;
            user.FailedPasswordAnswerStart = DateTime.MaxValue;
            user.FailedPasswordAttempts = 0;
            user.FailedPasswordAttemptStart = DateTime.MaxValue;

            userDao.Save(user);
        }
        private void IncrementPasswordFailure(ProxyUser user)
        {
            if (user.FailedPasswordAttemptStart > DateTime.Now.AddMinutes(this.PasswordAttemptWindow))
            {
                user.FailedPasswordAttemptStart = DateTime.Now;
                user.FailedPasswordAttempts = 1;
            }
            else
            {
                user.FailedPasswordAttempts += 1;
                if (user.FailedPasswordAttempts > this.MaxInvalidPasswordAttempts)
                {
                    user.IsLockedOut = true;
                    user.LastLockoutDate = DateTime.Now;
                }
            }

            userDao.Save(user);
        }
 private MembershipUser GetMembershipUser(ProxyUser user)
 {
     return new MembershipUser(
             this.Name,
             user.Username,
             user.UserKey,
             user.Email,
             user.PasswordQuestion,
             user.Comment,
             user.IsApproved,
             user.IsLockedOut,
             user.CreateDate,
             user.LastLoginDate,
             user.LastActivityDate,
             user.LastPasswordChangedDate,
             user.LastLockoutDate);
 }
        public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
        {
            var args = new ValidatePasswordEventArgs(username, password, true);

            OnValidatingPassword(args);

            if (args.Cancel)
            {
                status = MembershipCreateStatus.InvalidPassword;
                return null;
            }

            // Check Email
            var user = GetUser(GetUserNameByEmail(email), false);
            if (RequiresUniqueEmail && user != null && user.IsApproved)
            {
                status = MembershipCreateStatus.DuplicateEmail;
                return null;
            }

            // Check Username
            user = GetUser(username, false);
            if (user != null && user.IsApproved)
            {
                status = MembershipCreateStatus.DuplicateUserName;
                return null;
            }

            // Check Provider Key
            if (providerUserKey == null)
                providerUserKey = Guid.NewGuid();
            else if (providerUserKey.GetType() != typeof(Guid))
            {
                status = MembershipCreateStatus.InvalidProviderUserKey;
                return null;
            }

            user = GetUser(providerUserKey, false);
            if (GetUser(providerUserKey, false) != null && user.IsApproved)
            {
                status = MembershipCreateStatus.DuplicateProviderUserKey;
                return null;
            }

            var userKey = (Guid)providerUserKey;

            var createDate = DateTime.Now;

            var proxyUserDao = new ProxyUserDao();
            var proxyUser = new ProxyUser(this.ApplicationName, userKey, username, email, EncodePassword(userKey, password), isApproved);
            proxyUser.PasswordQuestion = (passwordQuestion + "").Trim();
            proxyUser.PasswordAnswer = EncodePassword(userKey, (passwordAnswer + "").Trim().ToUpper());

            proxyUserDao.Save(proxyUser);

            status = MembershipCreateStatus.Success;
            return GetUser(userKey, false);
        }
        /// <summary>
        ///     Sends all the messages
        /// </summary>
        /// <param name="message"></param>
        /// <returns>
        ///     <value>true</value>
        ///     if succeeded
        /// </returns>
        private bool SendFast(string message)
        {
            _conversationActiveFlag.Wait(_terminateProcessor.Token);
            try
            {
                var http = (HttpWebRequest)WebRequest.Create(Url);
                http.KeepAlive = false;
                http.Method    = Method;

                http.ContentType = ContentType;
                http.Accept      = Accept;
                http.Timeout     = ConnectTimeout;
                http.Proxy       = String.IsNullOrWhiteSpace(ProxyUrl) ? NoProxy :
                                   new WebProxy(new Uri(ProxyUrl))
                {
                    UseDefaultCredentials = String.IsNullOrWhiteSpace(ProxyUser)
                };
                if (!String.IsNullOrWhiteSpace(ProxyUser))
                {
                    var cred = ProxyUser.Split('\\');
                    http.Proxy.Credentials = cred.Length == 1
                        ? new NetworkCredential {
                        UserName = ProxyUser, Password = ProxyPassword
                    }
                        : new NetworkCredential {
                        Domain = cred[0], UserName = cred[1], Password = ProxyPassword
                    };
                }

                if (IgnoreSslErrors)
                {
                    http.ServerCertificateValidationCallback = (sender, certificate, chain, errors) => true;
                }
                if (!string.IsNullOrWhiteSpace(Authorization))
                {
                    http.Headers.Add("Authorization", Authorization);
                }

                var bytes = Encoding.ASCII.GetBytes(message);
                http.ContentLength = bytes.Length;
                using (var os = http.GetRequestStream())
                {
                    os.Write(bytes, 0, bytes.Length); //Push it out there
                }

                using (var response = http.GetResponseAsync())
                {
                    using (var sr =
                               new StreamReader(response.Result.GetResponseStream() ?? throw new InvalidOperationException()))
                    {
                        //TODO What should we check for>
                        // ReSharper disable once UnusedVariable
                        var content = sr.ReadToEnd();
                    }

                    return(!response.IsFaulted);
                }
            }
            catch (WebException wex)
            {
                InternalLogger.Warn(wex, "Failed to communicate over HTTP");
                return(false);
            }
            catch (Exception ex)
            {
                InternalLogger.Warn(ex, "Unknown exception occured");
                return(false);
            }
            finally
            {
                _conversationActiveFlag.Release();
            }
        }