Beispiel #1
0
        public static OpenIdService CreateInstance(string name, string configXml, string returnUrl)
        {
            OpenIdService result;

            if (string.IsNullOrEmpty(name))
            {
                result = null;
            }
            else
            {
                object[] args = new object[]
                {
                    returnUrl
                };
                Type plugin = OpenIdPlugins.Instance().GetPlugin("OpenIdService", name);
                if (plugin == null)
                {
                    result = null;
                }
                else
                {
                    OpenIdService openIdService = Activator.CreateInstance(plugin, args) as OpenIdService;
                    if (openIdService != null && !string.IsNullOrEmpty(configXml))
                    {
                        XmlDocument xmlDocument = new XmlDocument();
                        xmlDocument.LoadXml(configXml);
                        openIdService.InitConfig(xmlDocument.FirstChild);
                    }
                    result = openIdService;
                }
            }
            return(result);
        }
Beispiel #2
0
 private void ProcessOpenId(HttpContext context)
 {
     if (context.Request["action"] == "getlist")
     {
         OpenIdPlugins openIdPlugins = OpenIdPlugins.Instance();
         context.Response.ContentType = "application/json";
         context.Response.Write(openIdPlugins.GetPlugins().ToJsonString());
     }
     else
     {
         if (context.Request["action"] == "getmetadata")
         {
             context.Response.ContentType = "text/xml";
             OpenIdService openIdService = OpenIdService.CreateInstance(context.Request["name"]);
             if (openIdService == null)
             {
                 context.Response.Write("<xml></xml>");
             }
             else
             {
                 context.Response.Write(openIdService.GetMetaData().OuterXml);
             }
         }
     }
 }