Beispiel #1
0
    // get the oauth access token for the user from OauthAccessTokenStorage.xml
    public static void GetOauthAccessTokenForUser(string emailID, Page page)
    {
        string      path            = page.Server.MapPath("/") + @"OauthAccessTokenStorage.xml";
        string      searchUserXpath = "//record[@usermailid='" + emailID + "']";
        XmlDocument doc             = new XmlDocument();

        doc.Load(path);
        XmlNode record = doc.SelectSingleNode(searchUserXpath);

        if (record != null)
        {
            page.Session["realm"]      = record.Attributes["realmid"].Value;
            page.Session["dataSource"] = record.Attributes["dataSource"].Value;
            string secuirtyKey = ConfigurationManager.AppSettings["securityKey"];
            page.Session["accessToken"]       = CryptographicHelper.DecryptData(record.Attributes["encryptedaccesskey"].Value, secuirtyKey);
            page.Session["accessTokenSecret"] = CryptographicHelper.DecryptData(record.Attributes["encryptedaccesskeysecret"].Value, secuirtyKey);

            // Add flag to session which tells that accessToken is in session
            page.Session["Flag"] = true;
        }
    }