Beispiel #1
0
        private token GetDict(string text)
        {
            Dictionary <string, string> d = new Dictionary <string, string>();

            text = text.Replace(" ", "");
            string[]     words        = text.Split('\n');
            token        token        = new token();
            tokencache   tokencache   = new tokencache();
            accesstoken  accesstoken  = new accesstoken();
            requesttoken requesttoken = new requesttoken();

            requesttoken.token    = words[3].Split(':', ',')[1].Substring(1, words[3].Split(':', ',')[1].Length - 2);
            requesttoken.secret   = words[4].Split(':', ',')[1].Substring(1, words[4].Split(':', ',')[1].Length - 2);
            requesttoken.verifier = words[5].Split(':')[1].Substring(1, words[5].Split(':', ',')[1].Length - 3);
            try
            {
                accesstoken.token      = words[8].Split(':', ',')[1].Substring(1, words[8].Split(':', ',')[1].Length - 2);
                accesstoken.secret     = words[9].Split(':', ',')[1].Substring(1, words[9].Split(':', ',')[1].Length - 2);
                accesstoken.endpoint   = words[10].Split(':')[1].Substring(1, words[10].Split(':', ',')[1].Length - 1) + ":" + words[10].Split(':')[2] + ":" + words[10].Split(':')[3].Substring(0, words[10].Split(':', ',')[3].Length - 2);
                accesstoken.revokecode = words[11].Split(':', ',')[1].Substring(1, words[11].Split(':', ',')[1].Length - 3);
                tokencache.accesstoken = accesstoken;
            }
            catch
            {
                tokencache.accesstoken = null;
            }
            tokencache.requesttoken = requesttoken;
            token._ = tokencache;
            return(token);
        }
Beispiel #2
0
 public Microgear()
 {
     this.onDisconnect = do_nothing;
     this.onPresent    = do_nothing;
     this.onAbsent     = do_nothing;
     this.onConnect    = do_nothing;
     this.onMessage    = do_nothing;
     this.onError      = do_nothing;
     this.cache        = new cache();
     this.tokencache   = new tokencache();
     this.accesstoken  = new accesstoken();
     this.requesttoken = new requesttoken();
     this.token        = new token();
 }
Beispiel #3
0
        public tokencache get_item(string key)
        {
            string path    = Directory.GetCurrentDirectory();
            string pathkey = System.IO.Path.Combine(path, key);

            if (!System.IO.File.Exists(pathkey))
            {
                return(null);
            }
            else
            {
                string text = System.IO.File.ReadAllText(pathkey);
                if (text.Length > 0)
                {
                    return(GetDict(text)._);
                }
                tokencache tokencache = new tokencache();
                tokencache.accesstoken  = null;
                tokencache.requesttoken = null;
                return(tokencache);
            }
        }
Beispiel #4
0
        private void get_token()
        {
            var cached = this.cache.get_item("microgear-" + init.gearkey + ".cache");

            if (cached == null)
            {
                this.cache.set_item(null, "microgear-" + init.gearkey + ".cache");
                cached = this.cache.get_item("microgear-" + init.gearkey + ".cache");
            }
            if (cached.accesstoken != null)
            {
                string[] endpoint = cached.accesstoken.endpoint.Split(':');
                init.accesstoken   = cached.accesstoken.token;
                init.accesssecret  = cached.accesstoken.secret;
                init.gearexaddress = endpoint[1].Split('/')[2];
                init.gearexport    = endpoint[2];
            }
            else
            {
                this.tokencache = cached;
                forToken();
            }
        }