Exemplo n.º 1
0
        /// <summary>
        /// 变量初始化构造函数
        /// </summary>
        public MaSecurityConfig()
        {
            m_loginUrl   = "login.html";                           //登录路径
            m_defaultUrl = "default.html";                         //定义在身份验证之后用于重定向的默认 URL。

            m_cookieName        = "MaRBACName";                    //Cookie 名称
            m_requireSSL        = false;                           //指定是否需要 SSL 连接来传输身份验证 Cookie。
            m_slidingExpiration = true;                            //指定是否启用可调过期时间。可调过期将 Cookie 的当前身份验证时间重置为在单个会话期间收到每个请求时过期。
            m_timeout           = 30;                              //指定 Cookie 过期前逝去的时间(以整数分钟为单位)。
            m_cookiePath        = "/";                             //Cookie路径
            m_cookieMode        = HttpCookieMode.UseDeviceProfile; //定义是否使用 Cookie 以及 Cookie 的行为。
            m_validateIP        = false;

            m_maPrincipalType = "Masir.WebSite.Security.MaPrincipal";

            m_openDoamin        = new List <string>();
            m_authorizationPath = new List <string>();
            m_openPath          = new List <string>();

            m_securityIP = new List <string[]>();
            m_securityIP.Add(new string[] { "127.0.0.1", "255.255.255.255" });

            m_stopInfo = "未授权请求";
            m_stopType = StopBrowseType.Redirect;

            m_cookieUseCurrentRootDomain = true;
        }
Exemplo n.º 2
0
 /// <summary>
 /// 加载安全配置信息
 /// </summary>
 /// <param name="node"></param>
 public override void Load(XmlElement node)
 {
     foreach (XmlNode item in node.ChildNodes)
     {
         if (item.Name == "Cookie")
         {
             #region Cookie信息
             if (item["Key"] != null)
             {
                 m_key = item["Key"].InnerText;
             }
             if (item["Name"] != null)
             {
                 m_cookieName = item["Name"].InnerText;
             }
             if (item["RequireSSL"] != null)
             {
                 m_requireSSL = bool.Parse(item["RequireSSL"].InnerText);
             }
             if (item["SlidingExpiration"] != null)
             {
                 m_slidingExpiration = bool.Parse(item["SlidingExpiration"].InnerText);
             }
             if (item["Timeout"] != null)
             {
                 m_timeout = int.Parse(item["Timeout"].InnerText);
             }
             if (item["CookiePath"] != null)
             {
                 m_cookiePath = item["CookiePath"].InnerText;
             }
             if (item["CookieMode"] != null)
             {
                 //_obj.m_key = item["CookieMode"].InnerText;
             }
             if (item["Domain"] != null)
             {
                 m_cookieDomain = item["Domain"].InnerText;
             }
             if (item["UseCurrentRootDomain"] != null)
             {
                 bool.TryParse(item["UseCurrentRootDomain"].InnerText, out m_cookieUseCurrentRootDomain);
             }
             if (item["ValidateIP"] != null)
             {
                 bool.TryParse(item["ValidateIP"].InnerText, out m_validateIP);
             }
             #endregion
         }
         else if (item.Name == "MaUserType")
         {
             m_maPrincipalType = item.InnerText;
         }
         else if (item.Name == "StopInfo")
         {
             m_stopInfo = item.InnerText;
         }
         else if (item.Name == "StopType")
         {
             if (!Enum.TryParse <StopBrowseType>(item.InnerText, out m_stopType))
             {
                 m_stopType = StopBrowseType.Redirect;
             }
         }
         else if (item.Name == "LoginUrl")
         {
             m_loginUrl = item.InnerText;
         }
         else if (item.Name == "DefaultUrl")
         {
             m_defaultUrl = item.InnerText;
         }
         //需要开放的域名
         else if (item.Name == "OpenDomain")
         {
             List <string> _list = new List <string>();
             foreach (XmlNode item1 in item.SelectNodes("Add"))
             {
                 _list.Add(item1.Attributes["value"].Value.ToLower());
             }
             m_openDoamin = _list;
         }
         //需要授权的目录
         else if (item.Name == "AuthorizationPath")
         {
             List <string> _list = new List <string>();
             foreach (XmlNode item1 in item.SelectNodes("Add"))
             {
                 _list.Add(item1.Attributes["value"].Value.ToLower());
             }
             m_authorizationPath = _list;
         }
         //需要开放的目录
         else if (item.Name == "OpenPath")
         {
             List <string> _list = new List <string>();
             foreach (XmlNode item1 in item.SelectNodes("Add"))
             {
                 _list.Add(item1.Attributes["value"].Value.ToLower());
             }
             m_openPath = _list;
         }
         //安全IP信息
         else if (item.Name == "SecurityIP")
         {
             List <string[]> _list = new List <string[]>();
             foreach (XmlNode item1 in item.SelectNodes("Add"))
             {
                 string[] _ip = new string[] { item1.Attributes["ip"].Value, item1.Attributes["mask"].Value };
                 _list.Add(_ip);
             }
             m_securityIP = _list;
         }
     }
 }