Exemple #1
0
        public static OpenIdNotify CreateInstance(string name, NameValueCollection parameters)
        {
            OpenIdNotify result;

            if (string.IsNullOrEmpty(name))
            {
                result = null;
            }
            else
            {
                object[] args = new object[]
                {
                    parameters
                };
                OpenIdPlugins openIdPlugins = OpenIdPlugins.Instance();
                Type          plugin        = openIdPlugins.GetPlugin("OpenIdService", name);
                if (plugin == null)
                {
                    result = null;
                }
                else
                {
                    Type pluginWithNamespace = openIdPlugins.GetPluginWithNamespace("OpenIdNotify", plugin.Namespace);
                    if (pluginWithNamespace == null)
                    {
                        result = null;
                    }
                    else
                    {
                        result = (Activator.CreateInstance(pluginWithNamespace, args) as OpenIdNotify);
                    }
                }
            }
            return(result);
        }
Exemple #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);
             }
         }
     }
 }
Exemple #3
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);
        }
Exemple #4
0
 public static OpenIdPlugins Instance()
 {
     if (OpenIdPlugins.instance == null)
     {
         object lockHelper;
         Monitor.Enter(lockHelper = OpenIdPlugins.LockHelper);
         try
         {
             if (OpenIdPlugins.instance == null)
             {
                 OpenIdPlugins.instance = new OpenIdPlugins();
             }
         }
         finally
         {
             Monitor.Exit(lockHelper);
         }
     }
     OpenIdPlugins.instance.VerifyIndex();
     return(OpenIdPlugins.instance);
 }
Exemple #5
0
        public static OpenIdService CreateInstance(string name)
        {
            OpenIdService result;

            if (string.IsNullOrEmpty(name))
            {
                result = null;
            }
            else
            {
                Type plugin = OpenIdPlugins.Instance().GetPlugin("OpenIdService", name);
                if (plugin == null)
                {
                    result = null;
                }
                else
                {
                    result = (Activator.CreateInstance(plugin) as OpenIdService);
                }
            }
            return(result);
        }