Exemplo n.º 1
0
        public IdentityInfo Authenticate(string refUserCode)
        {
            var up = GetUserPermission(refUserCode);

            if (up.Permissions.Count == 0)
            {
                throw new AuthException("未授权用户");
            }
            var tokenInfo = new TokenInfo {
                AccessTime = DateTime.Now, RefUserCode = refUserCode
            };
            var          token        = TokenHelper.EncryptToken(tokenInfo);
            IdentityInfo identityInfo = CreateIdentityInfo();

            this._identityInfoType   = identityInfo.GetType();
            identityInfo.RefUserCode = refUserCode;
            identityInfo.Token       = token;
            identityInfo.ExpireTime  = DateTime.Now.AddMinutes(_identity_distribute_expire_minutes);
            bool flag = cacheManager.Set(_cache_distribute_token_key, identityInfo, _identity_distribute_expire_minutes, token);

            if (!flag)
            {
                throw new AuthException("令牌缓存失败");
            }
            cacheManager.Set(_cache_distribute_token_touch_key, 1, _identity_distribute_expire_minutes - 5, token);
            return(identityInfo);
        }
Exemplo n.º 2
0
 public void PassesMamcachedManager_Set_Success()
 {
     _client.Set("name", "joe", 1000);
     _client.HasKey("name").TestBeTrue();
     _client.Get <string>("name").TestEqual("joe");
     _client.Remove("name");
     _client.HasKey("name").TestBeFalse();
 }
        public void TestMethod1()
        {
            MemcachedManager m = new MemcachedManager();
            var c = m.Get <string>("api_keyTest");

            if (string.IsNullOrEmpty(c))
            {
                m.Set("api_keyTest", "test");
            }
            c = m.Get <string>("api_keyTest");
        }