Beispiel #1
0
        private static AuthData GetConfig()
        {
            AuthData conf;

            AuthSection auth = ConfigurationManager.GetSection("authSection") as AuthSection;

            if (auth == null || String.IsNullOrEmpty(auth.UserName) || String.IsNullOrEmpty(auth.Password))
            {
#if DEBUG
                // Try the user auth.config file in the sandbox root (this tool is obviously incorrect if not running near the source code)
                if (File.Exists(ConfigurationManager.AppSettings["AlternativeAuthConf"]))
                {
                    conf = AuthData.Load(ConfigurationManager.AppSettings["AlternativeAuthConf"]);
                }
                else
#endif
                {
                    throw new AuthorizationException("Invalid authSection in configuration file", null);
                }
            }
            else
            {
                conf = new AuthData
                {
                    Username = auth.UserName,
                    Password = auth.Password
                };
            }

            return(conf);
        }
Beispiel #2
0
        public override object Create(object parent, object configContext, System.Xml.XmlNode section)
        {
            IAuthSection model = null;

            if (section != null)
            {
                model = new AuthSection();

                XmlNode node = null;

                #region

                if (GetSingleNodeValue(section, "/AuthSection/QQ", out node))
                {
                    model.QQ.AppId       = GetSingleNodeAttributeValue(node, "item[@key=\"AppId\"]", "value");
                    model.QQ.AppKey      = GetSingleNodeAttributeValue(node, "item[@key=\"AppKey\"]", "value");
                    model.QQ.CallbackUrl = GetSingleNodeAttributeValue(node, "item[@key=\"CallbackUrl\"]", "value");
                }
                if (GetSingleNodeValue(section, "/AuthSection/Weibo", out node))
                {
                    model.Weibo.AppId       = GetSingleNodeAttributeValue(node, "item[@key=\"AppId\"]", "value");
                    model.Weibo.AppKey      = GetSingleNodeAttributeValue(node, "item[@key=\"AppKey\"]", "value");
                    model.Weibo.CallbackUrl = GetSingleNodeAttributeValue(node, "item[@key=\"CallbackUrl\"]", "value");
                }
                if (GetSingleNodeValue(section, "/AuthSection/WeChat", out node))
                {
                    model.WeChat.QrCodeAppId  = GetSingleNodeAttributeValue(node, "item[@key=\"QrCodeAppId\"]", "value");
                    model.WeChat.QrCodeAppKey = GetSingleNodeAttributeValue(node, "item[@key=\"QrCodeAppKey\"]", "value");
                    model.WeChat.AppId        = GetSingleNodeAttributeValue(node, "item[@key=\"AppId\"]", "value");
                    model.WeChat.AppKey       = GetSingleNodeAttributeValue(node, "item[@key=\"AppKey\"]", "value");
                    model.WeChat.CallbackUrl  = GetSingleNodeAttributeValue(node, "item[@key=\"CallbackUrl\"]", "value");
                }

                #endregion
            }

            return(model);
        }
 /// <summary>
 /// Default constructor
 /// </summary>
 private AuthBuilder()
 {
     this.CRMSection = ConfigurationManager.GetSection(SECTION_NAME) as AuthSection;
 }