示例#1
0
        public bool RetrieveAPIKey(Framework.Data.APIKey keyType)
        {
            bool result = false;

            //code to generate key pair

            /*
             * RSA rsa = new RSACryptoServiceProvider(2048); // Generate a new 2048 bit RSA key
             * string publicPrivateKeyXML = rsa.ToXmlString(true);
             * string publicOnlyKeyXML = rsa.ToXmlString(false);
             * System.IO.File.WriteAllText("privateKey.xml", publicPrivateKeyXML);
             * System.IO.File.WriteAllText("publicKey.xml", publicOnlyKeyXML);
             */

            using (KeyRequestForm dlg = new KeyRequestForm(keyType))
            {
                dlg.ShowDialog();
                if (!string.IsNullOrEmpty(dlg.Token))
                {
                    if (keyType == Framework.Data.APIKey.GeocachingLive)
                    {
                        _geocachingComAccount.APIToken = dlg.Token;
                    }
                    else if (keyType == Framework.Data.APIKey.GeocachingLiveTest)
                    {
                        _geocachingComAccount.APITokenStaging = dlg.Token;
                    }
                    result = true;
                }
            }
            return(result);
        }
示例#2
0
文件: Engine.cs 项目: gahadzikwa/GAPP
        public bool RetrieveAPIKey(Framework.Data.APIKey keyType)
        {
            bool result = false;

            //code to generate key pair
            /*
            RSA rsa = new RSACryptoServiceProvider(2048); // Generate a new 2048 bit RSA key
            string publicPrivateKeyXML = rsa.ToXmlString(true);
            string publicOnlyKeyXML = rsa.ToXmlString(false);
            System.IO.File.WriteAllText("privateKey.xml", publicPrivateKeyXML);
            System.IO.File.WriteAllText("publicKey.xml", publicOnlyKeyXML);
            */

            using (KeyRequestForm dlg = new KeyRequestForm(keyType))
            {
                dlg.ShowDialog();
                if (!string.IsNullOrEmpty(dlg.Token))
                {
                    if (keyType == Framework.Data.APIKey.GeocachingLive)
                    {
                        _geocachingComAccount.APIToken = dlg.Token;
                    }
                    else if (keyType == Framework.Data.APIKey.GeocachingLiveTest)
                    {
                        _geocachingComAccount.APITokenStaging = dlg.Token;
                    }
                    result = true;
                }
            }
            return result;
        }