CreateKey() public method

public CreateKey ( string email, string usage ) : APIKey
email string
usage string
return APIKey
Esempio n. 1
0
    public static Hashtable RequestKey(string Description)
    {
        System.Collections.Hashtable ht = new System.Collections.Hashtable();
        HttpContext context             = HttpContext.Current;

        if (context.User.Identity.IsAuthenticated)
        {
            try
            {
                vwar.service.host.APIKeyManager keyMan = new vwar.service.host.APIKeyManager();
                vwar.service.host.APIKey        key    = keyMan.CreateKey(context.User.Identity.Name, context.Server.HtmlEncode(Description));
                ht["Key"]     = key.Key;
                ht["Usage"]   = key.Usage;
                ht["Active"]  = (key.State == vwar.service.host.APIKeyState.ACTIVE) ? "Yes" : "No";
                ht["Message"] = System.Configuration.ConfigurationManager.AppSettings["ProfilePage_KeyRequestSuccess"];
            }
            catch
            {
                ht["Message"] = System.Configuration.ConfigurationManager.AppSettings["ProfilePage_KeyRequestError"];
            }
        }
        else
        {
            ht["Message"] = System.Configuration.ConfigurationManager.AppSettings["ProfilePage_KeyRequestError"];
        }

        return(ht);
    }
    public static Hashtable RequestKey(string Description)
    {
        System.Collections.Hashtable ht = new System.Collections.Hashtable();
        HttpContext context = HttpContext.Current;
        if (context.User.Identity.IsAuthenticated)
        {
            try
            {
                vwar.service.host.APIKeyManager keyMan = new vwar.service.host.APIKeyManager();
                vwar.service.host.APIKey key = keyMan.CreateKey(context.User.Identity.Name, context.Server.HtmlEncode(Description));
                ht["Key"] = key.Key;
                ht["Usage"] = key.Usage;
                ht["Active"] = (key.State == vwar.service.host.APIKeyState.ACTIVE) ? "Yes" : "No";
                ht["Message"] = System.Configuration.ConfigurationManager.AppSettings["ProfilePage_KeyRequestSuccess"];
            }
            catch
            {
                ht["Message"] = System.Configuration.ConfigurationManager.AppSettings["ProfilePage_KeyRequestError"];
            }
        }
        else
        {
            ht["Message"] = System.Configuration.ConfigurationManager.AppSettings["ProfilePage_KeyRequestError"];
        }

        return ht;
    }