//校验用户名密码(对Session匹配,或数据库数据匹配) /// <summary> /// /// </summary> /// <param name="encryptToken"></param> /// <param name="accountID"></param> /// <returns></returns> public static bool ValidateTicket(string encryptToken) { ////解密Ticket //var strTicket = FormsAuthentication.Decrypt(encryptToken).UserData; ////从Ticket里面获取用户名和密码 //var index = strTicket.IndexOf("&"); //string userName = strTicket.Substring(0, index); //string password = strTicket.Substring(index + 1); var token = CacheMgr.Get <User>(encryptToken); if (token != null) { return(true); } #region 只使用于网站身份验证 //取得session,不通过说明用户退出,或者session已经过期 //var token = HttpContext.Current.Session[userName]; //accountID = ""; //if (token == null) //{ // return false; //} #endregion //对比session中的令牌 return(false); }
/// <summary> /// Loads the access control rules for the given user's access control group /// </summary> /// <returns>Access control rules for the given user's access control group</returns> AccessControlGroupStructure LoadAccessControl() { if (!_accessControlCache.Exists(_userSignon.DefaultAccessGroupCode.ToString())) { AccessControlGroupStructure accessControlGroup = new AccessControlGroupStructure(); accessControlGroup.AccessGroupCode = _userSignon.DefaultAccessGroupCode; CacheMgr <bool> accessControlRules = new CacheMgr <bool>(); DbCommand dbCmd = _daMgr.DbCmdCacheGetOrAdd(Constants.AccessControlGroupRules, BuildCmdGetAccessControlRulesList); dbCmd.Parameters[_daMgr.BuildParamName(Constants.AccessControlGroupCode)].Value = _userSignon.DefaultAccessGroupCode; DataTable accessRules = _daMgr.ExecuteDataSet(dbCmd, null, null).Tables[0]; foreach (DataRow accessRule in accessRules.Rows) { accessControlGroup.DefaultAccessDenied = Convert.ToBoolean( accessRule[Constants.DefaultAccessDenied]); accessControlGroup.AccessGroupName = accessRule[Constants.AccessControlGroupName].ToString(); if (accessRule[Constants.UIControlCode] != DBNull.Value) { Int32 uiControlCode = Convert.ToInt32(accessRule[Constants.UIControlCode]); bool accessDenied = Convert.ToBoolean(accessRule[Constants.AccessDenied]); accessControlRules.Set(uiControlCode.ToString(), accessDenied); } accessControlGroup.AccessControlRules = accessControlRules; } _accessControlCache.Set(_userSignon.DefaultAccessGroupCode.ToString(), accessControlGroup); } return(_accessControlCache.Get(_userSignon.DefaultAccessGroupCode.ToString())); }
public static void RunTest() { CacheMgr <int> cacheMgr = new CacheMgr <int>(); cacheMgr.Add("Testing", getTestingValue, 18); while (Console.Read() != 'x') { Console.WriteLine(cacheMgr.Get("Testing")); } }
public DCUser2 GetCache(string sessionid) { return(CacheMgr.Get <DCUser2>(CacheMgr.Get <string>(CryptoUtils.DecryptTripleDES(sessionid)))); }