Example #1
0
        internal JiraUser GetUser(string name)
        {
            JiraUser user;

            if (String.IsNullOrEmpty(name))
            {
                return(JiraUser.Unknown);
            }

            if (!_knownUsers.TryGetValue(name, out user))
            {
                if (_lookupUsers)
                {
                    //	_knownUsers.Add(name, user = new JiraUser(_service.getUser(_token, name)));
                    Task <Atlassian.Jira.JiraUser> j = jira.GetUserAsync(name);
                    string h = j.Result.DisplayName;
                    _knownUsers.Add(name, user = new JiraUser(name, h));
                }
                else
                {
                    _knownUsers.Add(name, user = new JiraUser(name, name));
                }

                _store.Write(this.GetType().FullName, user.Id, user.Name);
                _store.Write(this.GetType().FullName, ALL_USERS_KEY,
                             String.Join(";", new List <String>(_knownUsers.Keys).ToArray()));
            }
            return(user);
        }
Example #2
0
        public void TestStorage()
        {
            string value;

            Store.Write(null, "<?a", "b");

            Assert.IsTrue(Store.Read(null, "<?a", out value));
            Assert.AreEqual("b", value);

            Assert.IsTrue(Store.Read(String.Empty, "<?a", out value));
            Assert.AreEqual("b", value);

            Store.Write(null, "<?a", "b");

            Assert.IsTrue(Store.Read(null, "<?a", out value));
            Assert.AreEqual("b", value);

            Assert.IsTrue(Store.Read(String.Empty, "<?a", out value));
            Assert.AreEqual("b", value);

            Store.Write(">?1/\\", "<?a", "c");

            Assert.IsTrue(Store.Read(String.Empty, "<?a", out value));
            Assert.AreEqual("b", value);

            Assert.IsTrue(Store.Read(">?1/\\", "<?a", out value));
            Assert.AreEqual("c", value);

            Store.Delete(">?1/\\", "<?a");
            Assert.IsFalse(Store.Read(">?1/\\", "<?a", out value));

            Store.Delete(null, "<?a");
            Assert.IsFalse(Store.Read(null, "<?a", out value));
            Assert.IsFalse(Store.Read(String.Empty, "<?a", out value));
        }
Example #3
0
        internal JiraUser GetUser(string name)
        {
            JiraUser user;

            if (String.IsNullOrEmpty(name))
            {
                return(JiraUser.Unknown);
            }

            if (!_knownUsers.TryGetValue(name, out user))
            {
                if (_lookupUsers)
                {
                    _knownUsers.Add(name, user = new JiraUser(_service.getUser(_token, name)));
                }
                else
                {
                    _knownUsers.Add(name, user = new JiraUser(name, name));
                }

                _store.Write(GetType().FullName, user.Id, user.Name);
                _store.Write(GetType().FullName, ALL_USERS_KEY,
                             String.Join(";", new List <String>(_knownUsers.Keys).ToArray()));
            }

            return(user);
        }
Example #4
0
 /// <summary> Writes/Replaces the named value in the storage </summary>
 public void SetValue(string name, Type type, object value)
 {
     try
     {
         if (value == null)
         {
             _store.Delete(ContextPath, name);
         }
         else
         {
             _store.Write(ContextPath, name, StringUtils.ToString(value));
         }
     }
     catch { }
 }
Example #5
0
        private static bool RemoteCertificateValidationCallback(object sender, X509Certificate certificate, X509Chain chain,
                                                                SslPolicyErrors sslPolicyErrors)
        {
            if (sslPolicyErrors == SslPolicyErrors.None)
            {
                return(true);
            }

            var request = sender as WebRequest;

            if (request == null || certificate == null)
            {
                return(false);
            }

            bool   isAllowed;
            string allowed, urn = String.Format("{0}:{1}", request.RequestUri.Host, request.RequestUri.Port);

            if (Storage.Read(urn, certificate.GetCertHashString(), out allowed) && bool.TryParse(allowed, out isAllowed))
            {
                return(isAllowed);
            }

            string sslErrorDesc = String.Empty;

            if ((sslPolicyErrors & SslPolicyErrors.RemoteCertificateChainErrors) == SslPolicyErrors.RemoteCertificateChainErrors)
            {
                sslErrorDesc += Resources.RemoteCertificateChainErrors;
            }
            else if ((sslPolicyErrors & SslPolicyErrors.RemoteCertificateNameMismatch) ==
                     SslPolicyErrors.RemoteCertificateNameMismatch)
            {
                sslErrorDesc += Resources.RemoteCertificateNameMismatch;
            }
            else if ((sslPolicyErrors & SslPolicyErrors.RemoteCertificateNotAvailable) ==
                     SslPolicyErrors.RemoteCertificateNotAvailable)
            {
                sslErrorDesc += Resources.RemoteCertificateNotAvailable;
            }

            sslErrorDesc = String.Format(Resources.SslErrorDescPromptFormat,
                                         urn, sslErrorDesc, certificate.Subject, certificate.GetCertHashString());

            DialogResult dr = MessageBox.Show(sslErrorDesc, "SSL Error", MessageBoxButtons.YesNo, MessageBoxIcon.Error,
                                              MessageBoxDefaultButton.Button2);

            if (dr != DialogResult.Yes)
            {
                return(false);
            }

            Storage.Write(urn, certificate.GetCertHashString(), true.ToString());
            return(true);
        }
 /// <summary> stores the value identified </summary>
 protected virtual void WriteState(Guid transferId, string name, string value)
 {
     _storage.Write(transferId.ToString("N"), name, value);
 }