示例#1
0
 public static void DestroyAuthToken(string apikey, string token)
 {
     LegionService.GetReply(LEGION_URL, apikey, ReplyFormat.XML.ToString(), "__system", "DestroyAuthToken", new Dictionary <string, string>()
     {
         { "token", token }
     });
 }
示例#2
0
        public static bool ReissueAuthToken()
        {
            Dictionary <string, string> packet = SessionItemContainer.Retrieve(SessionItemContainerKey.AuthPacket) as Dictionary <string, string>;

            if (packet != null)
            {
                string apiurl = packet["__apiurl"];
                string apikey = packet["__apikey"];
                Dictionary <string, string> parameters = packet.Where(p => !p.Key.StartsWith("__")).ToDictionary(p => p.Key, p => p.Value);

                XmlNode xToken = LegionService.GetReply(apiurl, apikey, ReplyFormat.XML.ToString(), "__system", "CreateAuthToken", parameters).ToXml().SelectSingleNode("//token");
                if (xToken != null)
                {
                    string token = xToken.InnerText;
                    SessionItemContainer.Store(SessionItemContainerKey.AuthPacket, packet);
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
示例#3
0
        public static bool HeartbeatAuthToken(string apikey, string token)
        {
            string tokenheartbeat = LegionService.GetReply(LEGION_URL, apikey, ReplyFormat.XML.ToString(), "__system", "HeartbeatAuthToken", new Dictionary <string, string>()
            {
                { "token", token }
            }).ToXml().SelectSingleNode("//tokenheartbeat").InnerText;

            return(tokenheartbeat.ToLower() == "Success");
        }
示例#4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="apikey"></param>
        /// <param name="apiurl"></param>
        /// <param name="type"></param>
        /// <param name="identifier"></param>
        /// <param name="email"></param>
        /// <param name="givenname"></param>
        /// <param name="surname"></param>
        /// <returns></returns>
        public static string CreateAuthToken(string apikey, string apiurl, LegionAccountType type, string identifier)
        {
            Dictionary <string, string> packet = new Dictionary <string, string>()
            {
                { "AccountType", type.ToString() },
                { "AccountId", identifier },
                { "__apikey", apikey },
                { "__apiurl", apiurl }
            };

            Dictionary <string, string> parameters = packet.Where(p => !p.Key.StartsWith("__")).ToDictionary(p => p.Key, p => p.Value);

            XmlDocument xReply = LegionService.GetReply(apiurl, apikey, ReplyFormat.XML.ToString(), "__system", "CreateAuthToken", parameters).ToXml();

            XmlNode xToken = xReply.SelectSingleNode("//token");

            if (xToken != null)
            {
                string token = xToken.InnerText;
                SessionItemContainer.Store(SessionItemContainerKey.AuthPacket, packet);
                return(token);
            }
            else
            {
                XmlNode xFriendly = xReply.SelectSingleNode("//error/description[@type='friendly']");
                if (xFriendly != null)
                {
                    throw new LegionServiceException(string.Format("{0} ({1}:{2})", xFriendly.InnerText, type, identifier));
                }
                else
                {
                    XmlNode xError = xReply.SelectSingleNode("//error");
                    if (xError != null)
                    {
                        throw new LegionServiceException(string.Format("{0} ({1}:{2})", xFriendly.InnerText, type, identifier));
                    }
                    else
                    {
                        XmlNode xFault = xReply.SelectSingleNode("//fault");
                        if (xFault != null)
                        {
                            throw new LegionServiceException(string.Format("{0} ({1})", xFault.InnerText, xFault.Attributes["type"].Value));
                        }
                        else
                        {
                            throw new LegionServiceException("Unknown error. Unable to parse CreateAuthToken() response.");
                        }
                    }
                }
            }
        }
示例#5
0
 /// <summary>
 /// Get the sReply from a method in a Legion Service
 /// </summary>
 /// <param name="method">The method to call</param>
 /// <param name="p">The parameters to pass to the method</param>
 /// <returns>the raw reponse from the Service</returns>
 public string GetReply(string method, Dictionary <string, string> p)
 {
     return(LegionService.GetReply(_apiurl, _apikey, _replyformat.ToString(), _service, method, p));
 }